コード例 #1
0
 public static function getTransactionResultFromPaymentFormHandler($szPaymentFormResultHandlerURL, $szMerchantID, $szPassword, $szCrossReference, &$trTransactionResult, &$szOutputMessage)
 {
     $boErrorOccurred = false;
     $szOutputMessage = "";
     $trTransactionResult = null;
     try {
         // use curl to post the cross reference to the
         // payment form to query its status
         $cCURL = curl_init();
         // build up the post string
         $szPostString = "MerchantID=" . urlencode($szMerchantID) . "&Password="******"&CrossReference=" . urlencode($szCrossReference);
         curl_setopt($cCURL, CURLOPT_URL, $szPaymentFormResultHandlerURL);
         curl_setopt($cCURL, CURLOPT_POST, true);
         curl_setopt($cCURL, CURLOPT_POSTFIELDS, $szPostString);
         curl_setopt($cCURL, CURLOPT_SSL_VERIFYPEER, false);
         curl_setopt($cCURL, CURLOPT_RETURNTRANSFER, true);
         // read the response
         $szResponse = curl_exec($cCURL);
         $szErrorNo = curl_errno($cCURL);
         $ezErrorMsg = curl_error($cCURL);
         $szHeaderInfo = curl_getinfo($cCURL);
         curl_close($cCURL);
         if ($szResponse == "") {
             $boErrorOccurred = true;
             $szOutputMessage = "Received empty response from payment form hander";
         } else {
             try {
                 // parse the response into an array
                 $aParsedPostVariables = PaymentFormHelper::parseNameValueStringIntoArray($szResponse, true);
                 if (!isset($aParsedPostVariables["StatusCode"]) or intval($aParsedPostVariables["StatusCode"]) != 0) {
                     $boErrorOccurred = true;
                     // the message field is expected if the status code is non-zero
                     if (!isset($aParsedPostVariables["Message"])) {
                         $szOutputMessage = "Received invalid response from payment form hander [" . $szResponse . "]";
                     } else {
                         $szOutputMessage = $aParsedPostVariables["Message"];
                     }
                 } else {
                     // status code is 0, so	get the transaction result
                     if (!isset($aParsedPostVariables["TransactionResult"])) {
                         $boErrorOccurred = true;
                         $szOutputMessage = "No transaction result in response from payment form hander [" . $szResponse . "]";
                     } else {
                         // parse the URL decoded transaction result field into a name value array
                         $aTransactionResultArray = PaymentFormHelper::parseNameValueStringIntoArray(urldecode($aParsedPostVariables["TransactionResult"]), false);
                         // parse this array into a transaction result object
                         if (!PaymentFormHelper::getTransactionResultFromPostVariables($aTransactionResultArray, $trTransactionResult, $szHashDigest, $szErrorMessage)) {
                             $boErrorOccurred = true;
                             $szOutputMessage = "Error [" . $szErrorMessage . "] parsing transaction result [" . urldecode($aParsedPostVariables["TransactionResult"]) . "] in response from payment form hander [" . $szResponse . "]";
                         } else {
                             $boErrorOccurred = false;
                         }
                     }
                 }
             } catch (Exception $e) {
                 $boErrorOccurred = true;
                 $szOutputMessage = "Exception [" . $e->getMessage() . "] when processing response from payment form handler [" . $szResponse . "]";
             }
         }
     } catch (Exception $e) {
         $boErrorOccurred = true;
         $szOutputMessage = $e->getMessage();
     }
     return !$boErrorOccurred;
 }
コード例 #2
0
ファイル: cardSave.php プロジェクト: penkoh/TradingEye-V7.1.1
 function m_CardSave_Hosted_Callback($who)
 {
     require_once SITE_PATH . "modules/ecom/classes/main/PaymentFormHelper.php";
     if ($who == "1") {
         //cutomer
         $orderId = $_GET['OrderID'];
         $retUrl = $this->libFunc->m_safeUrl(SITE_SAFEURL . "ecom/index.php?action=checkout.process&mode=" . $orderId);
         $this->libFunc->m_mosRedirect($retUrl);
     } elseif ($who == "0") {
         //notification
         $nOutputStatusCode = 30;
         $szOutputMessage = "";
         $szUpdateOrderMessage = "";
         $boErrorOccurred = false;
         try {
             // read in the transaction result variables
             if (!PaymentFormHelper::getTransactionResultFromPostVariables($_POST, $trTransactionResult, $szHashDigest, $szOutputMessage)) {
                 $nOutputStatusCode = 30;
             } else {
                 if (!PaymentFormHelper::reportTransactionResults($trTransactionResult, $szUpdateOrderMessage)) {
                     $nOutputStatusCode = 30;
                     $szOutputMessage = $szOutputMessage . $szUpdateOrderMessage;
                 } else {
                     $nOutputStatusCode = 0;
                 }
             }
         } catch (Exception $e) {
             $nOutputStatusCode = 30;
             $szOutputMessage = $szOutputMessage . $e->getMessage();
         }
         if ($nOutputStatusCode != 0 && $szOutputMessage == "") {
             $szOutputMessage = "Unknown error";
         }
         // output the status code and message letting the payment form
         // know whether the transaction result was processed successfully
         echo "StatusCode=" . $nOutputStatusCode . "&Message=" . $szOutputMessage;
         if ($nOutputStatusCode == 0) {
         }
     } else {
     }
 }