|
I have edited the Payment Express module for DPS payment. Here is how I did it in case anyone else is wondering.
Inside app>code>core>Mage>Admin>Model>Paypal>Model>Api>Nvp.php
there is a function called callSetExpressCheckout()
Make sure that the include for pxpay is inside the Api folder.
replace it with this. There are a few variables you will have to change but shoud be obvious…
public function callSetExpressCheckout()
{
require_once("pxpay.php");
//------------------------------------------------------------------------------------------------------------------------------------
// Construct the parameter string that describes the SetExpressCheckout API call
$nvpArr = array(
‘PAYMENTACTION’ => $this->getPaymentType(),
‘AMT’ => $this->getAmount(),
‘CURRENCYCODE’ => $this->getCurrencyCode(),
‘RETURNURL’ => $this->getReturnUrl(),
‘CANCELURL’ => $this->getCancelUrl(),
);
$this->setUserAction(self::USER_ACTION_CONTINUE);
// for mark SetExpressCheckout API call
if ($a = $this->getShippingAddress()) {
$nvpArr = array_merge($nvpArr, array(
‘ADDROVERRIDE’ => 1,
‘SHIPTONAME’ => $a->getName(),
‘SHIPTOSTREET’ => $a->getStreet(1),
‘SHIPTOSTREET2’ => $a->getStreet(2),
‘SHIPTOCITY’ => $a->getCity(),
‘SHIPTOSTATE’ => $a->getRegionCode(),
‘SHIPTOCOUNTRYCODE’ => $a->getCountry(),
‘SHIPTOZIP’ => $a->getPostcode(),
‘PHONENUM’ => $a->getTelephone(),
));
$this->setUserAction(self::USER_ACTION_COMMIT);
}
//’---------------------------------------------------------------------------------------------------------------
//’ Make the API call to PayPal
//’ If the API call succeded, then redirect the buyer to PayPal to begin to authorize payment.
//’ If an error occured, show the resulting errors
//’---------------------------------------------------------------------------------------------------------------
$resArr = $this->call(’SetExpressCheckout’, $nvpArr);
if (false===$resArr) {
return false;
}
$this->setToken($resArr[’TOKEN’]);
// dps login details
$dpsAccount = ‘ACCOUNT NAME HERE’;
$dpsKey = ‘DPS KEY HERE’;
$pxpay = new PxPay( ‘https://www.paymentexpress.com/pxpay/pxaccess.aspx’, $dpsAccount, $dpsKey );
$request = new PxPayRequest();
//$http_host = getenv("HTTP_HOST");
//$request_uri = getenv("SCRIPT_NAME");
$http_host = ‘www.keepthree.com’;
$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”;
$request->setAmountInput($this->getAmount());
$request->setTxnData1($a->getStreet(1));# whatever you want to appear
$request->setTxnData2($a->getStreet(2)); # whatever you want to appear
$request->setTxnData3($a->getCity() . ‘Post code: ‘.$data[’customer’][’shipping_post_code’]); # whatever you want to appear
$request->setTxnType("Purchase");
$request->setInputCurrency("NZD");
$request->setMerchantReference("123456"); # fill this with your order number
$request->setEmailAddress($a->getEmail());
$request->setUrlFail(Mage::getUrl(’checkout/cart/’)); # can be a dedicated failure page
$request->setUrlSuccess(Mage::getUrl(’paypal/express/saveOrder’)); # can be a dedicated success page
#Call makeResponse of PxPay object to obtain the 3-DES encrypted payment request
$request_string = $pxpay->makeRequest($request);
$response = new MifMessage( $request_string );
$url = $response->get_element_text("URI");
$valid = $response->get_attribute("valid");
$this->setRedirectUrl($url);
return $resArr;
}
Thanks zentrale for your help.
|