public function process($data)
 {
     //Construct the request
     $request = new PxPayRequest();
     $request->setAmountInput($data['Amount']);
     $request->setCurrencyInput($data['Currency']);
     //Set PxPay properties
     if (isset($data['Reference'])) {
         $request->setMerchantReference($data['Reference']);
     }
     if (isset($data['EmailAddress'])) {
         $request->setEmailAddress($data['EmailAddress']);
     }
     $request->setUrlFail($this->cancelURL);
     $request->setUrlSuccess($this->returnURL);
     //Generate a unique identifier for the transaction
     $request->setTxnId(uniqid('ID'));
     $request->setTxnType('Purchase');
     //Get encrypted URL from DPS to redirect the user to
     $request_string = $this->makeProcessRequest($request, $data);
     //Obtain output XML
     $response = new MifMessage($request_string);
     //Parse output XML
     $url = $response->get_element_text('URI');
     $valid = $response->get_attribute('valid');
     //If this is a fail or incomplete (cannot reach gateway) then mark payment accordingly and redirect to payment
     if ($valid && is_numeric($valid) && $valid == 1) {
         //Redirect to payment page
         Controller::curr()->redirect($url);
     } else {
         if (is_numeric($valid) && $valid == 0) {
             return new PaymentGateway_Failure();
         } else {
             return new PaymentGateway_Incomplete();
         }
     }
 }
 /**
  * Generate a {@link PxPayRequest} object and populate it with the submitted
  * data from a instance.
  * 
  * @see http://www.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html#GenerateRequest
  * 
  * @param array $data
  * @return PxPayRequest
  */
 protected function prepareRequest($data)
 {
     $request = new PxPayRequest();
     // Set in payment_dpshosted/_config.php
     $postProcess_url = Director::absoluteBaseURL() . DPSHostedPayment_Controller::$URLSegment . "/processResponse";
     $request->setUrlFail($postProcess_url);
     $request->setUrlSuccess($postProcess_url);
     // set amount
     $request->setAmountInput($this->Amount->Amount);
     // mandatory free text data
     if (isset($data['FirstName']) && isset($data['Surname'])) {
         $request->setTxnData1($data['FirstName'] . " " . $data['Surname']);
         $request->setTxnData2($this->ID);
         //$request->setTxnData3();
     }
     // Auth, Complete, Purchase, Refund (DPS recomend completeing refunds through other API's)
     $request->setTxnType('Purchase');
     // mandatory
     // randomly generated number from {@link processPayment()}
     $request->setTxnId($this->TxnID);
     // defaults to NZD
     $request->setInputCurrency(self::$px_currency);
     // mandatory
     // use website URL as a reference if none is given
     $ref = Director::absoluteBaseURL();
     if (self::$px_merchantreference) {
         $ref = sprintf(self::$px_merchantreference, $this->PaidForID);
     } elseif ($this->PaidObject() && ($name = $this->PaidObject()->singular_name())) {
         $ref .= $name . $this->PaidForID;
     } else {
         $ref = Director::absoluteBaseURL();
     }
     $request->setMerchantReference($ref);
     // mandatory
     if (isset($data['Email'])) {
         $request->setEmailAddress($data['Email']);
         // optional
     }
     return $request;
 }
コード例 #3
0
ファイル: dps_access.php プロジェクト: ambient-lounge/site
} else {
    if (!defined('BOOTSTRAP')) {
        die('Access denied');
    }
    // This file is a SAMPLE showing redirect to Payments Page from PHP.
    //Inlcude PxAccess Objects
    include Registry::get('config.dir.payments') . 'dps_files/pxaccess.inc';
    $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
コード例 #4
0
function redirect_form()
{
    global $pxpay;
    $request = new PxPayRequest();
    $http_host = getenv("HTTP_HOST");
    $request_uri = getenv("SCRIPT_NAME");
    $server_url = "http://{$http_host}";
    #$script_url  = "$server_url/$request_uri"; //using this code before PHP version 4.3.4
    #$script_url  = "$server_url$request_uri"; //Using this code after PHP version 4.3.4
    $script_url = version_compare(PHP_VERSION, "4.3.4", ">=") ? "{$server_url}{$request_uri}" : "{$server_url}/{$request_uri}";
    # the following variables are read from the form
    $Quantity = $_REQUEST["Quantity"];
    $MerchantReference = $_REQUEST["Reference"];
    $Address1 = $_REQUEST["Address1"];
    $Address2 = $_REQUEST["Address2"];
    $Address3 = $_REQUEST["Address3"];
    #Calculate AmountInput
    $AmountInput = 19.95 * $Quantity;
    #Generate a unique identifier for the transaction
    $TxnId = uniqid("ID");
    #Set PxPay properties
    $request->setMerchantReference($MerchantReference);
    $request->setAmountInput($AmountInput);
    $request->setTxnData1($Address1);
    $request->setTxnData2($Address2);
    $request->setTxnData3($Address3);
    $request->setTxnType("Purchase");
    $request->setCurrencyInput("NZD");
    $request->setEmailAddress("*****@*****.**");
    $request->setUrlFail($script_url);
    # can be a dedicated failure page
    $request->setUrlSuccess($script_url);
    # can be a dedicated success page
    $request->setTxnId($TxnId);
    #The following properties are not used in this case
    # $request->setEnableAddBillCard($EnableAddBillCard);
    # $request->setBillingId($BillingId);
    # $request->setOpt($Opt);
    #Call makeRequest function to obtain input XML
    $request_string = $pxpay->makeRequest($request);
    #Obtain output XML
    $response = new MifMessage($request_string);
    #Parse output XML
    $url = $response->get_element_text("URI");
    $valid = $response->get_attribute("valid");
    #Redirect to payment page
    header("Location: " . $url);
}
コード例 #5
0
ファイル: dps.php プロジェクト: benhuson/Gold-Cart
function gateway_dps($seperator, $sessionid)
{
    $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(wpsc_get_customer_meta('shipping_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;
}
コード例 #6
0
 /**
  * Generate a {@link PxPayRequest} object and populate it with the submitted
  * data from a {@link DPSHostedPaymentForm} instance. You'll likely need to subclass
  * this method to add custom data.
  * 
  * @see http://www.paymentexpress.com/technical_resources/ecommerce_hosted/pxpay.html#GenerateRequest
  * 
  * @param array $data
  * @return PxPayRequest
  */
 protected function prepareRequest($data)
 {
     $request = new PxPayRequest();
     // Set in payment_dpshosted/_config.php
     $postProcess_url = Director::absoluteBaseURL() . "DPSHostedPayment/processResponse";
     $request->setUrlFail($postProcess_url);
     $request->setUrlSuccess($postProcess_url);
     // set amount
     $amount = (double) ltrim($data['Amount'], '$');
     $request->setAmountInput($amount);
     // mandatory free text data
     if (isset($data['FirstName']) && isset($data['SurName'])) {
         $request->setTxnData1($data['FirstName'] . " " . $data['SurName']);
         //$request->setTxnData2();
         //$request->setTxnData3();
     }
     // Auth, Complete, Purchase, Refund (DPS recomend completeing refunds through other API's)
     $request->setTxnType('Purchase');
     // mandatory
     // randomly generated number from {@link processPayment()}
     $request->setTxnId($this->TxnID);
     // defaults to NZD
     $request->setInputCurrency(self::$px_currency);
     // mandatory
     // use website URL as a reference if none is given
     $ref = self::$px_merchantreference ? self::$px_merchantreference : Director::absoluteBaseURL();
     $request->setMerchantReference($ref);
     // mandatory
     if (isset($data['Email'])) {
         $request->setEmailAddress($data['Email']);
         // optional
     }
     return $request;
 }
コード例 #7
0
 /**  
  * 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);
     }
 }
コード例 #8
0
<?php

// Start the session
session_start();
//get the config file
require '../config.php';
require 'app/PxPay_Curl.inc.php';
//create an instance of the library
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', $PxPay_Userid, $PxPay_Key);
//Create a new request object
$request = new PxPayRequest();
//prepare the url to come back to once payment has been complete
$http_host = getenv('HTTP_HOST');
//localhost. if online than domain name
$folders = getenv('SCRIPT_NAME');
$urlToComeBackTo = 'http://' . $http_host . $folders;
//loopthrough cart and calculate the grand total
$grandTotal = 0;
foreach ($_SESSION['cart'] as $cartItem) {
    $grandTotal += $cartItem['quantity'] * $cartItem['price'];
}
//prepare data for PxPay
$request->setAmountInput($grandTotal);
$request->setTxnType('Purchase');
//transaction type
$request->setCurrencyInput('NZD');
$request->setUrlFail(PROJECT_ROOT . 'payment-response.php');
$request->setUrlSuccess(PROJECT_ROOT . 'payment-response.php');
$request->setTxnData1('Nehal Patel');
$request->setTxnData2('20 Kent Terrace, Wellington, NZ');
$request->setTxnData3('Somthing else');
コード例 #9
0
// Get the id of this order
$orderID = $dbc->insert_id;
// Loop over the cart contents and add them to the ordered products table
foreach ($_SESSION['cart'] as $product) {
    $productID = $product['id'];
    $quantity = $product['quantity'];
    $price = $product['price'];
    $sql = "INSERT INTO ordered_products VALUES(NULL, {$productID}, {$orderID}, {$quantity}, {$price})";
    $dbc->query($sql);
}
// Include the pxpay library
require 'PxPay_Curl.inc.php';
// Create instance if the pxpay class
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', PXPAY_USER, PXPAY_KEY);
// Create instancce of request object
$request = new PxPayRequest();
// get the text values of the city and suburb for the transaction
// Populate the request with transaction details
$request->setAmountInput($grandTotal);
$request->setTxnType('Purchase');
$request->setCurrencyInput('NZD');
$request->setUrlSuccess('http://localhost/~jasana.mael/shopping-cart/transaction-success.php');
$request->setUrlFail('http://localhost/~jasana.mael/shopping-cart/transaction-fail.php');
$request->setTxnData1($_POST['full-name']);
$request->setTxnData2($_POST['phone']);
$request->setTxnData3($_POST['email']);
// Convert the request object into XML
$requestString = $pxpay->makeRequest($request);
// Send the request away and wait for a response
$response = new MifMessage($requestString);
// Extract the URl from the response and redirect the user
コード例 #10
0
ファイル: module.pxpay.php プロジェクト: hungnv0789/vhtm
		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);
		}
コード例 #11
0
<?php

// Start the session
session_start();
// Require the config file
require '../assets/config.php';
// Require the PxPay library
require 'app/PxPay_Curl.inc.php';
// Create an instance of the library
// Inside the brackets you enter where you want to redirect the user
$pxpay = new PxPay_Curl('https://sec.paymentexpress.com/pxpay/pxaccess.aspx', $PxPay_Userid, $PxPay_Key);
// Create a new request object
$request = new PxPayRequest();
// Prepare a URL to comeback to once payment has been completed
$http_host = getenv('HTTP_HOST');
// localhost
$folders = getenv('SCRIPT_NAME');
// Where you want to take the user back to
$urlToComeBackTo = 'http://' . $http_host . $folders;
// Loop through the cart and calculate the grand total
$grandTotal = 0;
foreach ($_SESSION['cart'] as $cartItem) {
    // Look at the how many items there are and the price and multiple them
    $grandTotal += $cartItem['quantity'] * $cartItem['price'];
}
// Prepare data for the PxPay
$request->setAmountInput($grandTotal);
$request->setTxnType('Purchase');
// Transaction type
$request->setCurrencyInput('NZD');
$request->setUrlFail(PROJECT_ROOT . 'payment-response.php');
コード例 #12
0
 function startPaymentProcess()
 {
     if (!$this->TxnId) {
         $this->TxnId = uniqid("ID");
     }
     $request = new PxPayRequest();
     #Set PxPay properties
     if ($this->MerchantReference) {
         $request->setMerchantReference($this->MerchantReference);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, MerchantReference not set. ", E_USER_WARNING);
     }
     if ($this->AmountInput) {
         $request->setAmountInput($this->AmountInput);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, AmountInput not set. ", E_USER_WARNING);
     }
     if ($this->TxnData1) {
         $request->setTxnData1($this->TxnData1);
     }
     if ($this->TxnData2) {
         $request->setTxnData2($this->TxnData2);
     }
     if ($this->TxnData3) {
         $request->setTxnData3($this->TxnData3);
     }
     if ($this->TxnType) {
         $request->setTxnType($this->TxnType);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, TxnType not set. ", E_USER_WARNING);
     }
     if ($this->CurrencyInput) {
         $request->setCurrencyInput($this->CurrencyInput);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, CurrencyInput not set. ", E_USER_WARNING);
     }
     if ($this->EmailAddress) {
         $request->setEmailAddress($this->EmailAddress);
     }
     if ($this->UrlFail) {
         $request->setUrlFail($this->UrlFail);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, UrlFail not set. ", E_USER_WARNING);
     }
     if ($this->UrlSuccess) {
         $request->setUrlSuccess($this->UrlSuccess);
     } else {
         user_error("error in DpsPxPayComs::startPaymentProcess, UrlSuccess not set. ", E_USER_WARNING);
     }
     if ($this->TxnId) {
         $request->setTxnId($this->TxnId);
     }
     if ($this->EnableAddBillCard) {
         $request->setEnableAddBillCard($this->EnableAddBillCard);
     }
     if ($this->BillingId) {
         $request->setBillingId($this->BillingId);
     }
     /* TODO:
     		$request->setEnableAddBillCard($EnableAddBillCard);
     		$request->setBillingId($BillingId);
     		$request->setOpt($Opt);
     		*/
     #Call makeRequest function to obtain input XML
     $request_string = $this->PxPayObject->makeRequest($request);
     #Obtain output XML
     $this->response = new MifMessage($request_string);
     #Parse output XML
     $url = $this->response->get_element_text("URI");
     //$valid = $this->response->get_attribute("valid");
     #Redirect to payment page
     return $url;
 }