Example #1
0
 public function TransferToProvider()
 {
     require_once "lib/pxaccess.php";
     $pxaccess = new PxAccess('https://www.paymentexpress.com/pxpay/pxpay.aspx', $this->GetValue('userid'), $this->GetValue('key'), $this->GetValue('mackey'));
     $request = new PxPayRequest();
     $http_host = getenv("HTTP_HOST");
     $request_uri = getenv("SCRIPT_NAME");
     $server_url = "http://{$http_host}";
     $hash = md5($this->GetGatewayAmount() . $this->GetValue('userid') . $this->GetValue('key') . $this->GetValue('mackey'));
     $session = $_COOKIE['SHOP_ORDER_TOKEN'];
     $currency = GetDefaultCurrency();
     $script_url = $GLOBALS['ShopPath'] . '/finishorder.php';
     $request->setAmountInput($this->GetGatewayAmount());
     $request->setTxnData1($this->GetCombinedOrderId());
     $request->setTxnData2($hash);
     $request->setTxnData3('');
     $request->setTxnType("Purchase");
     $request->setInputCurrency($currency['currencycode']);
     $request->setMerchantReference($this->GetCombinedOrderId());
     $request->setEmailAddress('');
     $request->setUrlFail($script_url);
     $request->setUrlSuccess($script_url);
     $request_string = $pxaccess->makeRequest($request);
     header('Location: ' . $request_string);
 }
Example #2
0
function gateway_dps($seperator, $sessionid)
{
    $_SESSION['checkoutdata'] = '';
    //exit();
    //require_once(ABSPATH . 'wp-content/plugins/wp-shopping-cart/gold_cart_files/pxaccess.php');
    $PxAccess_Url = get_option('access_url');
    $PxAccess_Userid = get_option('access_userid');
    $PxAccess_Key = get_option('access_key');
    $Mac_Key = get_option('mac_key');
    $pxaccess = new PxAccess($PxAccess_Url, $PxAccess_Userid, $PxAccess_Key, $Mac_Key);
    $request = new PxPayRequest();
    $http_host = getenv("HTTP_HOST");
    $request_uri = getenv("SCRIPT_NAME");
    $server_url = get_option('siteurl');
    $script_url = get_option('transact_url');
    //Using this code after PHP version 4.3.4  ?page_id=$_GET['page_id']
    //echo $script_url . '<br />';
    //exit(get_option('checkout_url'));
    # the following variables are read from the form
    $Address1 = $_POST['address'];
    $Address2 = "";
    #Set up PxPayRequest Object
    $request->setAmountInput(nzshpcrt_overall_total_price($_SESSION['delivery_country']));
    $request->setTxnData1(get_option('blogname'));
    # whatever you want to appear, original:   $request->setTxnData1("Widget order");
    $request->setTxnData2("n/a");
    # whatever you want to appear
    $request->setTxnData3("n/a");
    # whatever you want to appear
    $request->setTxnType("Purchase");
    if (get_option('dps_curcode') != '') {
        $request->setInputCurrency(get_option('dps_curcode'));
    } else {
        $request->setInputCurrency("USD");
    }
    $request->setMerchantReference($sessionid);
    # fill this with your order number
    $request->setEmailAddress(get_option('purch_log_email'));
    $request->setUrlFail($script_url);
    $request->setUrlSuccess($script_url);
    #Call makeResponse of PxAccess object to obtain the 3-DES encrypted payment request
    $request_string = $pxaccess->makeRequest($request);
    header("Location: {$request_string}");
    exit;
}
Example #3
0
    $PxAccess_Url = "https://sec.paymentexpress.com/pxpay/pxpay.aspx";
    $PxAccess_Userid = $processor_data["processor_params"]["user_id"];
    //Change to your user ID
    $PxAccess_Key = $processor_data["processor_params"]["key"];
    //Your DES Key from DPS
    $Mac_Key = $processor_data["processor_params"]["mac_key"];
    //Your MAC key from DPS
    $pxaccess = new PxAccess($PxAccess_Url, $PxAccess_Userid, $PxAccess_Key, $Mac_Key);
    $request = new PxPayRequest();
    $script_url = fn_payment_url('current', 'dps_access.php');
    $_order_id = $order_info['repaid'] ? $order_id . '_' . $order_info['repaid'] : $order_id;
    Tygh::$app['session']['dps_access']['order_id'] = $order_id;
    //Set up PxPayRequest Object
    $request->setAmountInput($order_info['total']);
    $request->setTxnData1("");
    // whatever you want to appear
    $request->setTxnData2("");
    // whatever you want to appear
    $request->setTxnData3("");
    // whatever you want to appear
    $request->setTxnType("Purchase");
    $request->setInputCurrency($processor_data["processor_params"]["currency"]);
    $request->setMerchantReference($_order_id);
    // fill this with your order number
    $request->setEmailAddress($order_info['email']);
    $request->setUrlFail($script_url);
    $request->setUrlSuccess($script_url);
    //Call makeResponse of PxAccess object to obtain the 3-DES encrypted payment request
    $request_string = $pxaccess->makeRequest($request);
    fn_create_payment_form($request_string, array(), 'DPS server', true, 'get');
}
 /**  
  * Main transaction function
  *  
  * @param array $params  name value pair of contribution data
  *  
  * @return void  
  * @access public 
  *  
  */
 function doTransferCheckout(&$params, $component)
 {
     $component = strtolower($component);
     $config = CRM_Core_Config::singleton();
     if ($component != 'contribute' && $component != 'event') {
         CRM_Core_Error::fatal(ts('Component is invalid'));
     }
     $url = $config->userFrameworkResourceURL . "extern/pxIPN.php";
     if ($component == 'event') {
         $cancelURL = CRM_Utils_System::url('civicrm/event/register', "_qf_Confirm_display=true&qfKey={$params['qfKey']}", false, null, false);
     } else {
         if ($component == 'contribute') {
             $cancelURL = CRM_Utils_System::url('civicrm/contribute/transact', "_qf_Confirm_display=true&qfKey={$params['qfKey']}", false, null, false);
         }
     }
     /*  
      * Build the private data string to pass to DPS, which they will give back to us with the
      *
      * transaction result.  We are building this as a comma-separated list so as to avoid long URLs.
      *
      * Parameters passed: a=contactID, b=contributionID,c=contributionTypeID,d=invoiceID,e=membershipID,f=participantID,g=eventID
      */
     $privateData = "a={$params['contactID']},b={$params['contributionID']},c={$params['contributionTypeID']},d={$params['invoiceID']}";
     if ($component == 'event') {
         $privateData .= ",f={$params['participantID']},g={$params['eventID']}";
         $merchantRef = "event registration";
     } elseif ($component == 'contribute') {
         $merchantRef = "Charitable Contribution";
         $membershipID = CRM_Utils_Array::value('membershipID', $params);
         if ($membershipID) {
             $privateData .= ",e={$membershipID}";
         }
     }
     // Allow further manipulation of params via custom hooks
     CRM_Utils_Hook::alterPaymentProcessorParams($this, $params, $privateData);
     /*  
      *  determine whether method is pxaccess or pxpay by whether signature (mac key) is defined
      */
     if (empty($this->_paymentProcessor['signature'])) {
         /*
          * Processor is pxpay 
          *
          * This contains the XML/Curl functions we'll need to generate the XML request
          */
         require_once 'CRM/Core/Payment/PaymentExpressUtils.php';
         // Build a valid XML string to pass to DPS
         $generateRequest = _valueXml(array('PxPayUserId' => $this->_paymentProcessor['user_name'], 'PxPayKey' => $this->_paymentProcessor['password'], 'AmountInput' => str_replace(",", "", number_format($params['amount'], 2)), 'CurrencyInput' => $params['currencyID'], 'MerchantReference' => $merchantRef, 'TxnData1' => $params['qfKey'], 'TxnData2' => $privateData, 'TxnData3' => $component, 'TxnType' => 'Purchase', 'TxnId' => '', 'UrlFail' => $url, 'UrlSuccess' => $url));
         $generateRequest = _valueXml('GenerateRequest', $generateRequest);
         // Get the special validated URL back from DPS by sending them the XML we've generated
         $curl = _initCURL($generateRequest, $this->_paymentProcessor['url_site']);
         $success = false;
         if ($response = curl_exec($curl)) {
             curl_close($curl);
             $valid = _xmlAttribute($response, 'valid');
             if (1 == $valid) {
                 // the request was validated, so we'll get the URL and redirect to it
                 $uri = _xmlElement($response, 'URI');
                 CRM_Utils_System::redirect($uri);
             } else {
                 // redisplay confirmation page
                 CRM_Utils_System::redirect($cancelURL);
             }
         } else {
             // calling DPS failed
             CRM_Core_Error::fatal(ts('Unable to establish connection to the payment gateway.'));
         }
     } else {
         $processortype = "pxaccess";
         require_once 'PaymentExpress/pxaccess.inc.php';
         $PxAccess_Url = $this->_paymentProcessor['url_site'];
         // URL
         $PxAccess_Userid = $this->_paymentProcessor['user_name'];
         // User ID
         $PxAccess_Key = $this->_paymentProcessor['password'];
         // Your DES Key from DPS
         $Mac_Key = $this->_paymentProcessor['signature'];
         // Your MAC key from DPS
         $pxaccess = new PxAccess($PxAccess_Url, $PxAccess_Userid, $PxAccess_Key, $Mac_Key);
         $request = new PxPayRequest();
         $request->setAmountInput(number_format($params['amount'], 2));
         $request->setTxnData1($params['qfKey']);
         $request->setTxnData2($privateData);
         $request->setTxnData3($component);
         $request->setTxnType("Purchase");
         $request->setInputCurrency($params['currencyID']);
         $request->setMerchantReference($merchantRef);
         $request->setUrlFail($url);
         $request->setUrlSuccess($url);
         $request_string = $pxaccess->makeRequest($request);
         CRM_Utils_System::redirect($request_string);
     }
 }