function mpgHttpsPost($storeid, $apitoken, $mpgRequestOBJ, $test = false)
 {
     $this->store_id = $storeid;
     $this->api_token = $apitoken;
     $this->mpgRequest = $mpgRequestOBJ;
     $dataToSend = $this->toXML();
     //print("String to be sent = " . $dataToSend);
     //do post
     $g = new mpgGlobals($test);
     $gArray = $g->getGlobals();
     $transactionType = $mpgRequestOBJ->getTransactionType();
     $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, TRUE);
     curl_setopt($ch, CURLOPT_CAINFO, dirname(__FILE__) . '/curl-ca-bundle.crt');
     $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>" . "<AuthCode>null</AuthCode><TransTime>null</TransTime>" . "<TransDate>null</TransDate><TransType>null</TransType><Complete>false</Complete>" . "<Message>Global Error Receipt</Message><TransAmount>null</TransAmount>" . "<CardType>null</CardType>" . "<TransID>null</TransID><TimedOut>null</TimedOut>" . "<CorporateCard>false</CorporateCard><MessageId>null</MessageId>" . "</receipt></response>";
     }
     $this->mpgResponse = new mpgResponse($response);
 }
示例#2
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);
 }
 function mpgHttpsPostStatus($store_id, $api_token, $status, $mpgRequestOBJ)
 {
     $this->store_id = $store_id;
     $this->api_token = $api_token;
     $this->status = $status;
     $this->mpgRequest = $mpgRequestOBJ;
     $dataToSend = $this->toXML();
     echo "DATA TO SEND = {$dataToSend}\n\n";
     //do post
     $g = new mpgGlobals();
     $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, TRUE);
     $response = curl_exec($ch);
     curl_close($ch);
     //echo "RESPONSE = $response\n\n";
     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);
 }