示例#1
0
 function mpgHttpsPost($storeid, $apitoken, $mpgRequestOBJ, $production = false)
 {
     $this->store_id = $storeid;
     $this->api_token = $apitoken;
     $this->mpgRequest = $mpgRequestOBJ;
     $dataToSend = $this->toXML();
     //do post
     $g = new mpgGlobals();
     $g->setProduction($production);
     $gArray = $g->getGlobals();
     $url = $gArray[MONERIS_PROTOCOL] . "://" . $gArray[MONERIS_HOST] . ":" . $gArray[MONERIS_PORT] . $gArray[MONERIS_FILE];
     $ch = curl_init();
     curl_setopt($ch, CURLOPT_URL, $url);
     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
     curl_setopt($ch, CURLOPT_HEADER, 0);
     curl_setopt($ch, CURLOPT_POST, 1);
     curl_setopt($ch, CURLOPT_POSTFIELDS, $dataToSend);
     curl_setopt($ch, CURLOPT_TIMEOUT, $gArray[CLIENT_TIMEOUT]);
     curl_setopt($ch, CURLOPT_USERAGENT, $gArray[API_VERSION]);
     curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
     $response = curl_exec($ch);
     curl_close($ch);
     if (!$response) {
         $response = "<?xml version=\"1.0\"?><response><receipt>" . "<ReceiptId>Global Error Receipt</ReceiptId>" . "<ReferenceNum>null</ReferenceNum><ResponseCode>null</ResponseCode>" . "<ISO>null</ISO> <AuthCode>null</AuthCode><TransTime>null</TransTime>" . "<TransDate>null</TransDate><TransType>null</TransType><Complete>false</Complete>" . "<Message>null</Message><TransAmount>null</TransAmount>" . "<CardType>null</CardType>" . "<TransID>null</TransID><TimedOut>null</TimedOut>" . "</receipt></response>";
     }
     $this->mpgResponse = new mpgResponse($response);
 }