Ejemplo n.º 1
0
/**
 * SOAP request/response logging to a file
 */
function writeToLog($client)
{
    if (!($logfile = fopen(TRANSACTIONS_LOG_FILE, "a"))) {
        error_func("Cannot open " . TRANSACTIONS_LOG_FILE . " file.\n", 0);
        exit(1);
    }
    fwrite($logfile, sprintf("\r%s:- %s", date("D M j G:i:s T Y"), $client->__getLastRequest() . "\n\n" . $client->__getLastResponse()));
}
/**
 * SOAP request/response logging to a file
 */
function writeToLog($client)
{
    /**
     * __DIR__ refers to the directory path of the library file.
     * This location is not relative based on Include/Require.
     */
    if (!($logfile = fopen(__DIR__ . '/fedextransactions.log', "a"))) {
        error_func("Cannot open " . __DIR__ . '/fedextransactions.log' . " file.\n", 0);
        exit(1);
    }
    fwrite($logfile, sprintf("\r%s:- %s", date("D M j G:i:s T Y"), $client->__getLastRequest() . "\r\n" . $client->__getLastResponse() . "\r\n\r\n"));
}
Ejemplo n.º 3
0
 * commands appropriately
 *
 * To use this code for merchant-calculated feedback, this url must be
 * set also as the merchant-calculations-url when the cart is posted
 * Depending on your calculations for shipping, taxes, coupons and gift
 * certificates update parts of the code as required
 *
 */
chdir("..");
require_once 'library/googleresponse.php';
require_once 'library/googlemerchantcalculations.php';
require_once 'library/googleresult.php';
define('RESPONSE_HANDLER_LOG_FILE', 'googlemessage.log');
//Setup the log file
if (!($message_log = fopen(RESPONSE_HANDLER_LOG_FILE, "a"))) {
    error_func("Cannot open " . RESPONSE_HANDLER_LOG_FILE . " file.\n", 0);
    exit(1);
}
// Retrieve the XML sent in the HTTP POST request to the ResponseHandler
$xml_response = $HTTP_RAW_POST_DATA;
if (get_magic_quotes_gpc()) {
    $xml_response = stripslashes($xml_response);
}
$headers = getallheaders();
fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), $xml_response));
// Create new response object
$merchant_id = "";
//Your Merchant ID
$merchant_key = "";
//Your Merchant Key
$server_type = "sandbox";
Ejemplo n.º 4
0
 /**
  * This method is handles the response that will be invoked by the
  * notification or request sent by the payment processor.
  * hex string from paymentexpress is passed to this function as hex string. Code based on googleIPN
  * mac_key is only passed if the processor is pxaccess as it is used for decryption
  * $dps_method is either pxaccess or pxpay
  */
 public static function main($dps_method, $rawPostData, $dps_url, $dps_user, $dps_key, $mac_key)
 {
     $config = CRM_Core_Config::singleton();
     define('RESPONSE_HANDLER_LOG_FILE', $config->uploadDir . 'CiviCRM.PaymentExpress.log');
     //Setup the log file
     if (!($message_log = fopen(RESPONSE_HANDLER_LOG_FILE, "a"))) {
         error_func("Cannot open " . RESPONSE_HANDLER_LOG_FILE . " file.\n", 0);
         exit(1);
     }
     if ($dps_method == "pxpay") {
         $processResponse = CRM_Core_Payment_PaymentExpressUtils::_valueXml(array('PxPayUserId' => $dps_user, 'PxPayKey' => $dps_key, 'Response' => $_GET['result']));
         $processResponse = CRM_Core_Payment_PaymentExpressUtils::_valueXml('ProcessResponse', $processResponse);
         fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), $processResponse));
         // Send the XML-formatted validation request to DPS so that we can receive a decrypted XML response which contains the transaction results
         $curl = CRM_Core_Payment_PaymentExpressUtils::_initCURL($processResponse, $dps_url);
         fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), $curl));
         $success = FALSE;
         if ($response = curl_exec($curl)) {
             fwrite($message_log, sprintf("\n\r%s:- %s\n", date("D M j G:i:s T Y"), $response));
             curl_close($curl);
             // Assign the returned XML values to variables
             $valid = CRM_Core_Payment_PaymentExpressUtils::_xmlAttribute($response, 'valid');
             $success = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'Success');
             $txnId = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'TxnId');
             $responseText = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'ResponseText');
             $authCode = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'AuthCode');
             $DPStxnRef = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, 'DpsTxnRef');
             $qfKey = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData1");
             $privateData = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData2");
             list($component, $paymentProcessorID, ) = explode(',', CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "TxnData3"));
             $amount = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "AmountSettlement");
             $merchantReference = CRM_Core_Payment_PaymentExpressUtils::_xmlElement($response, "MerchantReference");
         } else {
             // calling DPS failed
             CRM_Core_Error::fatal(ts('Unable to establish connection to the payment gateway to verify transaction response.'));
             exit;
         }
     } elseif ($dps_method == "pxaccess") {
         require_once 'PaymentExpress/pxaccess.inc.php';
         global $pxaccess;
         $pxaccess = new PxAccess($dps_url, $dps_user, $dps_key, $mac_key);
         #getResponse method in PxAccess object returns PxPayResponse object
         #which encapsulates all the response data
         $rsp = $pxaccess->getResponse($rawPostData);
         $qfKey = $rsp->getTxnData1();
         $privateData = $rsp->getTxnData2();
         list($component, $paymentProcessorID) = explode(',', $rsp->getTxnData3());
         $success = $rsp->getSuccess();
         $authCode = $rsp->getAuthCode();
         $DPStxnRef = $rsp->getDpsTxnRef();
         $amount = $rsp->getAmountSettlement();
         $MerchantReference = $rsp->getMerchantReference();
     }
     $privateData = $privateData ? self::stringToArray($privateData) : '';
     // Record the current count in array, before we start adding things (for later checks)
     $countPrivateData = count($privateData);
     // Private Data consists of : a=contactID, b=contributionID,c=contributionTypeID,d=invoiceID,e=membershipID,f=participantID,g=eventID
     $privateData['contactID'] = $privateData['a'];
     $privateData['contributionID'] = $privateData['b'];
     $privateData['contributionTypeID'] = $privateData['c'];
     $privateData['invoiceID'] = $privateData['d'];
     if ($component == "event") {
         $privateData['participantID'] = $privateData['f'];
         $privateData['eventID'] = $privateData['g'];
     } elseif ($component == "contribute") {
         if ($countPrivateData == 5) {
             $privateData["membershipID"] = $privateData['e'];
         }
     }
     $transactionReference = $authCode . "-" . $DPStxnRef;
     list($mode, $component, $duplicateTransaction) = self::getContext($privateData, $transactionReference);
     $mode = $mode ? 'test' : 'live';
     $paymentProcessor = CRM_Financial_BAO_PaymentProcessor::getPayment($paymentProcessorID, $mode);
     $ipn = self::singleton($mode, $component, $paymentProcessor);
     //Check status and take appropriate action
     if ($success == 1) {
         if ($duplicateTransaction == 0) {
             $ipn->newOrderNotify($success, $privateData, $component, $amount, $transactionReference);
         }
         if ($component == "event") {
             $finalURL = CRM_Utils_System::url('civicrm/event/register', "_qf_ThankYou_display=1&qfKey={$qfKey}", FALSE, NULL, FALSE);
         } elseif ($component == "contribute") {
             $finalURL = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_ThankYou_display=1&qfKey={$qfKey}", FALSE, NULL, FALSE);
         }
         CRM_Utils_System::redirect($finalURL);
     } else {
         if ($component == "event") {
             $finalURL = CRM_Utils_System::url('civicrm/event/confirm', "reset=1&cc=fail&participantId={$privateData['participantID']}", FALSE, NULL, FALSE);
         } elseif ($component == "contribute") {
             $finalURL = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Main_display=1&cancel=1&qfKey={$qfKey}", FALSE, NULL, FALSE);
         }
         CRM_Utils_System::redirect($finalURL);
     }
 }