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); }
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; }
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; }
$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'); }
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); }
/** * 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; }
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; }