Version Notes
This module will integrate Amex payment method using its Api.
Download this release
Release Info
Developer | Nikul Doshi |
Extension | ND_Amex |
Version | 0.1.1 |
Comparing to | |
See all releases |
Code changes from version 0.1.0 to 0.1.1
- app/code/local/ND/Amex/Block/Server/Redirect.php +7 -3
- app/code/local/ND/Amex/Model/Info.php +58 -42
- app/code/local/ND/Amex/Model/Server.php +48 -57
- app/code/local/ND/Amex/controllers/ServerController.php +12 -7
- app/code/local/ND/Amex/etc/config.xml +1 -1
- app/code/local/ND/Amex/etc/system.xml +17 -1
- package.xml +4 -4
app/code/local/ND/Amex/Block/Server/Redirect.php
CHANGED
@@ -25,14 +25,18 @@ class ND_Amex_Block_Server_Redirect extends Mage_Core_Block_Abstract
|
|
25 |
protected function _toHtml()
|
26 |
{
|
27 |
$server = $this->getOrder()->getPayment()->getMethodInstance();
|
28 |
-
|
|
|
|
|
|
|
|
|
|
|
29 |
$form = new Varien_Data_Form();
|
30 |
//$form->setAction($server->getAmexServerUrl())
|
31 |
$form->setId('amex_server_checkout')
|
32 |
->setName('amex_server_checkout')
|
33 |
->setMethod('POST')
|
34 |
-
->setUseContainer(true);
|
35 |
-
|
36 |
foreach ($server->getFormFields() as $field=>$value) {
|
37 |
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
38 |
}
|
25 |
protected function _toHtml()
|
26 |
{
|
27 |
$server = $this->getOrder()->getPayment()->getMethodInstance();
|
28 |
+
if(!$server->getFormFields()) {
|
29 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Some of the information you have provided is incorrect, please do try again. If the problem persists, please call American Express Customer Service Unit on toll free 800 124 2229 within the Kingdom of Saudi Arabia or +9661 474 9035 outside of the Kingdom. Thank you.'));
|
30 |
+
$url = Mage::getUrl('checkout/cart');
|
31 |
+
Mage::app()->getResponse()->setRedirect($url);
|
32 |
+
return;
|
33 |
+
}
|
34 |
$form = new Varien_Data_Form();
|
35 |
//$form->setAction($server->getAmexServerUrl())
|
36 |
$form->setId('amex_server_checkout')
|
37 |
->setName('amex_server_checkout')
|
38 |
->setMethod('POST')
|
39 |
+
->setUseContainer(true);
|
|
|
40 |
foreach ($server->getFormFields() as $field=>$value) {
|
41 |
$form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
|
42 |
}
|
app/code/local/ND/Amex/Model/Info.php
CHANGED
@@ -1,24 +1,4 @@
|
|
1 |
<?php
|
2 |
-
/**
|
3 |
-
* ND Amex payment gateway
|
4 |
-
*
|
5 |
-
* NOTICE OF LICENSE
|
6 |
-
*
|
7 |
-
* This source file is subject to the Open Software License (OSL 3.0)
|
8 |
-
* that is bundled with this package in the file LICENSE.txt.
|
9 |
-
* It is also available through the world-wide-web at this URL:
|
10 |
-
* http://opensource.org/licenses/osl-3.0.php
|
11 |
-
* If you did not receive a copy of the license and are unable to
|
12 |
-
* obtain it through the world-wide-web, please send an email
|
13 |
-
* to license@magentocommerce.com so you can be sent a copy immediately.
|
14 |
-
*
|
15 |
-
* Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
|
16 |
-
*
|
17 |
-
* @category ND
|
18 |
-
* @package ND_Amex
|
19 |
-
* @copyright Copyright (c) 2010 ND Amex
|
20 |
-
* @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
|
21 |
-
*/
|
22 |
class ND_Amex_Model_Info
|
23 |
{
|
24 |
/**
|
@@ -26,9 +6,18 @@ class ND_Amex_Model_Info
|
|
26 |
*
|
27 |
* @var string
|
28 |
*/
|
29 |
-
const
|
30 |
-
const
|
31 |
-
const
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
|
33 |
/**
|
34 |
* All payment information map
|
@@ -36,9 +25,18 @@ class ND_Amex_Model_Info
|
|
36 |
* @var array
|
37 |
*/
|
38 |
protected $_paymentMap = array(
|
39 |
-
self::
|
40 |
-
self::
|
41 |
-
self::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
);
|
43 |
|
44 |
/**
|
@@ -46,11 +44,11 @@ class ND_Amex_Model_Info
|
|
46 |
*
|
47 |
* @var string
|
48 |
*/
|
49 |
-
const PAYMENTSTATUS_NONE = '
|
50 |
-
const PAYMENTSTATUS_ACCEPTED = '
|
51 |
-
const PAYMENTSTATUS_REJECTED = '
|
52 |
-
const PAYMENTSTATUS_REVIEWED = '
|
53 |
-
const PAYMENTSTATUS_NOTCHECKED = '
|
54 |
const PAYMENTSTATUS_SYSREJECT = 'system_rejected';
|
55 |
|
56 |
/**
|
@@ -78,7 +76,7 @@ class ND_Amex_Model_Info
|
|
78 |
*/
|
79 |
public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
80 |
{
|
81 |
-
// collect
|
82 |
$result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
|
83 |
|
84 |
// add last_trans_id
|
@@ -234,7 +232,7 @@ class ND_Amex_Model_Info
|
|
234 |
case 'multicurrency':
|
235 |
return Mage::helper('payment')->__('The payment curency does not match any of the merchant\'s balances currency.');
|
236 |
case 'paymentreview':
|
237 |
-
return Mage::helper('payment')->__('The payment is pending while it is being reviewed by
|
238 |
case 'unilateral':
|
239 |
return Mage::helper('payment')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
|
240 |
case 'verify':
|
@@ -244,7 +242,7 @@ class ND_Amex_Model_Info
|
|
244 |
case 'none': // break is intentionally omitted
|
245 |
case 'other': // break is intentionally omitted
|
246 |
default:
|
247 |
-
return Mage::helper('payment')->__('Unknown reason. Please contact
|
248 |
}
|
249 |
}
|
250 |
|
@@ -274,12 +272,12 @@ class ND_Amex_Model_Info
|
|
274 |
case 'none': // break is intentionally omitted
|
275 |
case 'other':
|
276 |
default:
|
277 |
-
return Mage::helper('payment')->__('Unknown reason. Please contact
|
278 |
}
|
279 |
}
|
280 |
|
281 |
/**
|
282 |
-
* Whether a reversal/refund can be disputed with
|
283 |
*
|
284 |
* @param string $code
|
285 |
* @return bool;
|
@@ -346,12 +344,30 @@ class ND_Amex_Model_Info
|
|
346 |
protected function _getLabel($key)
|
347 |
{
|
348 |
switch ($key) {
|
349 |
-
case '
|
350 |
-
return Mage::helper('payment')->__('
|
351 |
-
case '
|
352 |
-
return Mage::helper('payment')->__('
|
353 |
-
case '
|
354 |
-
return Mage::helper('payment')->__('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
355 |
}
|
356 |
return '';
|
357 |
}
|
1 |
<?php
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
2 |
class ND_Amex_Model_Info
|
3 |
{
|
4 |
/**
|
6 |
*
|
7 |
* @var string
|
8 |
*/
|
9 |
+
const AUTHORIZE_ID = 'vpc_authorize_id';
|
10 |
+
const ORDER_INFO = 'vpc_OrderInfo';
|
11 |
+
const RECEIPT_NO = 'vpc_ReceiptNo';
|
12 |
+
const TRANSACTION_NO = 'vpc_TransactionNo';
|
13 |
+
const MERCH_TXN_REF = 'vpc_MerchTxnRef';
|
14 |
+
const BATCH_NO = 'vpc_BatchNo';
|
15 |
+
const TRANSACTION_CODE = 'vpc_TxnResponseCode';
|
16 |
+
const AVS_RESULT_CODE = 'vpc_AVSResultCode';
|
17 |
+
const AVS_RESPONSE_CODE = 'vpc_AcqAVSRespCode';
|
18 |
+
const ACQ_CSC_RESPONSE_CODE = 'vpc_AcqCSCRespCode';
|
19 |
+
const RISK_OVERALL_RESULT = 'vpc_risk_overall_result';
|
20 |
+
const THREED_SENROLLED = 'vpc_threedsenrolled';
|
21 |
|
22 |
/**
|
23 |
* All payment information map
|
25 |
* @var array
|
26 |
*/
|
27 |
protected $_paymentMap = array(
|
28 |
+
self::AUTHORIZE_ID => 'vpc_authorize_id',
|
29 |
+
self::ORDER_INFO => 'vpc_OrderInfo',
|
30 |
+
self::RECEIPT_NO => 'vpc_ReceiptNo',
|
31 |
+
self::TRANSACTION_NO => 'vpc_TransactionNo',
|
32 |
+
self::MERCH_TXN_REF => 'vpc_MerchTxnRef',
|
33 |
+
self::BATCH_NO => 'vpc_BatchNo',
|
34 |
+
self::TRANSACTION_CODE => 'vpc_TxnResponseCode',
|
35 |
+
self::AVS_RESULT_CODE => 'vpc_AVSResultCode',
|
36 |
+
self::AVS_RESPONSE_CODE => 'vpc_AcqAVSRespCode',
|
37 |
+
self::ACQ_CSC_RESPONSE_CODE => 'vpc_AcqCSCRespCode',
|
38 |
+
self::RISK_OVERALL_RESULT => 'vpc_risk_overall_result',
|
39 |
+
self::THREED_SENROLLED => 'vpc_threedsenrolled',
|
40 |
);
|
41 |
|
42 |
/**
|
44 |
*
|
45 |
* @var string
|
46 |
*/
|
47 |
+
const PAYMENTSTATUS_NONE = 'none';
|
48 |
+
const PAYMENTSTATUS_ACCEPTED = 'accepted';
|
49 |
+
const PAYMENTSTATUS_REJECTED = 'rejected';
|
50 |
+
const PAYMENTSTATUS_REVIEWED = 'reviewed';
|
51 |
+
const PAYMENTSTATUS_NOTCHECKED = 'not_checked';
|
52 |
const PAYMENTSTATUS_SYSREJECT = 'system_rejected';
|
53 |
|
54 |
/**
|
76 |
*/
|
77 |
public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
|
78 |
{
|
79 |
+
// collect Amex-specific info
|
80 |
$result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
|
81 |
|
82 |
// add last_trans_id
|
232 |
case 'multicurrency':
|
233 |
return Mage::helper('payment')->__('The payment curency does not match any of the merchant\'s balances currency.');
|
234 |
case 'paymentreview':
|
235 |
+
return Mage::helper('payment')->__('The payment is pending while it is being reviewed by Migs for risk.');
|
236 |
case 'unilateral':
|
237 |
return Mage::helper('payment')->__('The payment is pending because it was made to an email address that is not yet registered or confirmed.');
|
238 |
case 'verify':
|
242 |
case 'none': // break is intentionally omitted
|
243 |
case 'other': // break is intentionally omitted
|
244 |
default:
|
245 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Migs customer service.');
|
246 |
}
|
247 |
}
|
248 |
|
272 |
case 'none': // break is intentionally omitted
|
273 |
case 'other':
|
274 |
default:
|
275 |
+
return Mage::helper('payment')->__('Unknown reason. Please contact Migs customer service.');
|
276 |
}
|
277 |
}
|
278 |
|
279 |
/**
|
280 |
+
* Whether a reversal/refund can be disputed with Migs
|
281 |
*
|
282 |
* @param string $code
|
283 |
* @return bool;
|
344 |
protected function _getLabel($key)
|
345 |
{
|
346 |
switch ($key) {
|
347 |
+
case 'vpc_authorize_id':
|
348 |
+
return Mage::helper('payment')->__('Authorize ID');
|
349 |
+
case 'vpc_OrderInfo':
|
350 |
+
return Mage::helper('payment')->__('Order Info');
|
351 |
+
case 'vpc_ReceiptNo':
|
352 |
+
return Mage::helper('payment')->__('Receipt No');
|
353 |
+
case 'vpc_TransactionNo':
|
354 |
+
return Mage::helper('payment')->__('Transaction No');
|
355 |
+
case 'vpc_MerchTxnRef':
|
356 |
+
return Mage::helper('payment')->__('Merchant Transaction Reference');
|
357 |
+
case 'vpc_BatchNo':
|
358 |
+
return Mage::helper('payment')->__('Batch No');
|
359 |
+
case 'vpc_AVSResultCode':
|
360 |
+
return Mage::helper('payment')->__('AVS Result Code');
|
361 |
+
case 'vpc_AcqAVSRespCode':
|
362 |
+
return Mage::helper('payment')->__('AVS Response Code');
|
363 |
+
case 'vpc_AcqCSCRespCode':
|
364 |
+
return Mage::helper('payment')->__('ACQ AVS Reponse Code');
|
365 |
+
case 'vpc_risk_overall_result':
|
366 |
+
return Mage::helper('payment')->__('Overall Result');
|
367 |
+
case 'vpc_threedsenrolled':
|
368 |
+
return Mage::helper('payment')->__('3D secure');
|
369 |
+
case 'vpc_TransactionCode':
|
370 |
+
return Mage::helper('payment')->__('Transaction Code');
|
371 |
}
|
372 |
return '';
|
373 |
}
|
app/code/local/ND/Amex/Model/Server.php
CHANGED
@@ -91,6 +91,18 @@ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
|
|
91 |
$password = Mage::getStoreConfig('payment/' . $this->getCode() . '/password');
|
92 |
return $password;
|
93 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
|
95 |
public function validate()
|
96 |
{
|
@@ -101,7 +113,7 @@ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
|
|
101 |
{
|
102 |
$url = Mage::getUrl('amex/' . $this->_paymentMethod . '/redirect');
|
103 |
if(!$url) {
|
104 |
-
$url = 'https://
|
105 |
}
|
106 |
return $url;
|
107 |
}
|
@@ -112,66 +124,45 @@ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
|
|
112 |
* @return array
|
113 |
*/
|
114 |
public function getFormFields()
|
115 |
-
{
|
|
|
116 |
$fieldsArr = array();
|
117 |
-
$paymentInfo = $this->getInfoInstance();
|
118 |
$lengs = 0;
|
119 |
-
|
120 |
-
/*$currency_code = Mage::app()->getStore()-> getCurrentCurrencyCode();
|
121 |
$fields = array(
|
122 |
-
"
|
123 |
-
"
|
124 |
-
"
|
125 |
-
"
|
126 |
-
"
|
127 |
-
"
|
128 |
-
"
|
129 |
-
"
|
130 |
-
"
|
131 |
-
"
|
132 |
-
"
|
133 |
-
|
134 |
-
|
135 |
-
);
|
136 |
-
|
137 |
foreach($fields as $key => $val)
|
138 |
{
|
139 |
-
$
|
140 |
-
}*/
|
141 |
-
|
142 |
-
$order_id = $paymentInfo->getOrder()->getRealOrderId();
|
143 |
-
$coutry_code = "GBR"; //Mage::getStoreConfig('general/country/default');
|
144 |
-
$language_code = "GBR";
|
145 |
-
$merchant_id = $this->getMerchantId();
|
146 |
-
$merchant_pwd = $this->getPassword();
|
147 |
-
$gateway_url=$this->getAmexServerUrl();
|
148 |
-
$amount = $this->_getAmount();
|
149 |
-
$currency_code = "SAR"; //Mage::app()->getStore()->getCurrentCurrencyCode();
|
150 |
-
$url = $gateway_url."?SupplierID=".$merchant_id."&Password=".$merchant_pwd."&Reference=".$order_id."&Amount=".$amount."&CurrencyCode=".$currency_code."&CountryCode=".$coutry_code. "&Language=" . $language_code . "&AmexOnly=Y&CVV=Y&OrientationCode=ltr&BypassMPI=Y&AutoLevel1Settlement=Y&CMName=Y&Reference1=N&Reference2=N&OnCompletionURL=".Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true))."&OnErrorURL=".Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true)) ;
|
151 |
-
//echo $url;die;
|
152 |
-
$ch = curl_init();
|
153 |
-
curl_setopt($ch, CURLOPT_URL,$url);
|
154 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
155 |
-
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
156 |
-
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
|
157 |
-
$ch_result = curl_exec($ch);
|
158 |
-
//$ch_error = curl_error($ch);
|
159 |
-
//curl_getinfo($ch);
|
160 |
-
curl_close($ch);
|
161 |
-
/*$start = strpos($ch_result, "<PaypageURL>")+12;
|
162 |
-
$end = strpos($ch_result, "</PaypageURL>") - $start;
|
163 |
-
$this->_paymentUrl = htmlspecialchars_decode(substr($ch_result, $start, $end));*/
|
164 |
-
|
165 |
-
//print_r($ch_result);die;
|
166 |
-
$xmlString = simplexml_load_string($ch_result);
|
167 |
-
if($xmlString->Code=='0')
|
168 |
-
$this->_paymentUrl = $xmlString->PaypageURL;
|
169 |
-
else {
|
170 |
-
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Some of the information you have provided is incorrect, please do try again. If the problem persists, please call American Express Customer Service Unit on toll free 800 124 2229 within the Kingdom of Saudi Arabia or +9661 474 9035 outside of the Kingdom. Thank you.'));
|
171 |
-
$this->_redirect('checkout/cart');
|
172 |
-
return;
|
173 |
}
|
174 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
175 |
|
176 |
return $fieldsArr;
|
177 |
}
|
@@ -184,7 +175,7 @@ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
|
|
184 |
public function getAmexServerUrl()
|
185 |
{
|
186 |
if (!$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_url')) {
|
187 |
-
$url = 'https://
|
188 |
}
|
189 |
return $url;
|
190 |
}
|
@@ -192,7 +183,7 @@ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
|
|
192 |
public function getAmexTransactionUrl()
|
193 |
{
|
194 |
if (!$this->_paymentUrl) {
|
195 |
-
$this->_paymentUrl = 'https://
|
196 |
}
|
197 |
return $this->_paymentUrl;
|
198 |
}
|
91 |
$password = Mage::getStoreConfig('payment/' . $this->getCode() . '/password');
|
92 |
return $password;
|
93 |
}
|
94 |
+
|
95 |
+
public function getAccessCode()
|
96 |
+
{
|
97 |
+
$access_code = Mage::getStoreConfig('payment/' . $this->getCode() . '/access_code');
|
98 |
+
return $access_code;
|
99 |
+
}
|
100 |
+
|
101 |
+
public function getSecureHashKey()
|
102 |
+
{
|
103 |
+
$secure_hash_key = Mage::getStoreConfig('payment/' . $this->getCode() . '/secure_hash_secret');
|
104 |
+
return $secure_hash_key;
|
105 |
+
}
|
106 |
|
107 |
public function validate()
|
108 |
{
|
113 |
{
|
114 |
$url = Mage::getUrl('amex/' . $this->_paymentMethod . '/redirect');
|
115 |
if(!$url) {
|
116 |
+
$url = 'https://vpos.amxvpos.com/vpcpay';
|
117 |
}
|
118 |
return $url;
|
119 |
}
|
124 |
* @return array
|
125 |
*/
|
126 |
public function getFormFields()
|
127 |
+
{
|
128 |
+
$gateway_url=$this->getAmexServerUrl();
|
129 |
$fieldsArr = array();
|
|
|
130 |
$lengs = 0;
|
131 |
+
$paymentInfo = $this->getInfoInstance();
|
|
|
132 |
$fields = array(
|
133 |
+
//"Title"=>'Amex VPC',
|
134 |
+
"vpc_AccessCode"=>$this->getAccessCode(),
|
135 |
+
"vpc_Amount"=>$this->_getAmount(), // 1000 - For Testing
|
136 |
+
"vpc_Command"=>"pay",
|
137 |
+
"vpc_Locale"=>"en",
|
138 |
+
"vpc_MerchTxnRef"=>$paymentInfo->getOrder()->getRealOrderId(),
|
139 |
+
"vpc_Merchant"=>$this->getMerchantId(),
|
140 |
+
"vpc_OrderInfo"=>$paymentInfo->getOrder()->getRealOrderId(),
|
141 |
+
"vpc_ReturnURL"=>Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true)),
|
142 |
+
"vpc_TicketNo"=>'1',
|
143 |
+
"vpc_Version"=>'1'
|
144 |
+
);
|
145 |
+
$str = '';
|
|
|
|
|
146 |
foreach($fields as $key => $val)
|
147 |
{
|
148 |
+
$str .= $val;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
+
|
151 |
+
$secure_hash_key = strtoupper(md5($this->getSecureHashKey().$str));
|
152 |
+
|
153 |
+
//$fieldsArr['Title'] = 'Amex VPC';
|
154 |
+
$fieldsArr['vpc_AccessCode'] = $this->getAccessCode();
|
155 |
+
$fieldsArr['vpc_Amount'] = $this->_getAmount();
|
156 |
+
$fieldsArr['vpc_Command'] = 'pay';
|
157 |
+
//$fieldsArr['vpc_Currency']='USD';
|
158 |
+
$fieldsArr['vpc_Locale'] = 'en';
|
159 |
+
$fieldsArr['vpc_MerchTxnRef'] = $paymentInfo->getOrder()->getRealOrderId();
|
160 |
+
$fieldsArr['vpc_Merchant'] = $this->getMerchantId();
|
161 |
+
$fieldsArr['vpc_OrderInfo'] = $paymentInfo->getOrder()->getRealOrderId();
|
162 |
+
$fieldsArr['vpc_ReturnURL'] = Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true));
|
163 |
+
$fieldsArr['vpc_TicketNo'] = '1';
|
164 |
+
$fieldsArr['vpc_Version'] = '1';
|
165 |
+
$fieldsArr['vpc_SecureHash'] = $secure_hash_key;
|
166 |
|
167 |
return $fieldsArr;
|
168 |
}
|
175 |
public function getAmexServerUrl()
|
176 |
{
|
177 |
if (!$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_url')) {
|
178 |
+
$url = 'https://vpos.amxvpos.com/vpcpay';
|
179 |
}
|
180 |
return $url;
|
181 |
}
|
183 |
public function getAmexTransactionUrl()
|
184 |
{
|
185 |
if (!$this->_paymentUrl) {
|
186 |
+
$this->_paymentUrl = 'https://vpos.amxvpos.com/vpcpay';
|
187 |
}
|
188 |
return $this->_paymentUrl;
|
189 |
}
|
app/code/local/ND/Amex/controllers/ServerController.php
CHANGED
@@ -26,25 +26,30 @@ class ND_Amex_ServerController extends ND_Amex_Controller_Abstract
|
|
26 |
|
27 |
public function responseAction()
|
28 |
{
|
29 |
-
$
|
30 |
-
$responseParams = simplexml_load_string($responseXml['XML']);
|
31 |
//echo '<pre>';print_r($responseParams);die;
|
32 |
-
|
|
|
|
|
33 |
{
|
34 |
-
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('
|
35 |
$this->_redirect('checkout/cart');
|
36 |
return;
|
37 |
}
|
38 |
-
elseif($responseParams
|
39 |
{
|
40 |
-
Mage::getModel('
|
|
|
|
|
|
|
|
|
41 |
//Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__($responseParams['vpc_Message']));
|
42 |
$this->_redirect('checkout/onepage/success');
|
43 |
return;
|
44 |
}
|
45 |
else
|
46 |
{
|
47 |
-
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('
|
48 |
$this->_redirect('checkout/cart');
|
49 |
return;
|
50 |
}
|
26 |
|
27 |
public function responseAction()
|
28 |
{
|
29 |
+
$responseParams = $this->getRequest()->getParams();
|
|
|
30 |
//echo '<pre>';print_r($responseParams);die;
|
31 |
+
/*$this->loadLayout();
|
32 |
+
$this->renderLayout();*/
|
33 |
+
if($responseParams['vpc_TxnResponseCode']=='7')
|
34 |
{
|
35 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__($responseParams['vpc_Message']));
|
36 |
$this->_redirect('checkout/cart');
|
37 |
return;
|
38 |
}
|
39 |
+
elseif($responseParams['vpc_TxnResponseCode']=='0')
|
40 |
{
|
41 |
+
Mage::getModel('migsvpc/server')->afterSuccessOrder($responseParams);
|
42 |
+
$cart = Mage::getSingleton('checkout/cart');
|
43 |
+
$cart->truncate();
|
44 |
+
$cart->save();
|
45 |
+
$cart->getItems()->clear()->save();
|
46 |
//Mage::getSingleton('core/session')->addSuccess(Mage::helper('core')->__($responseParams['vpc_Message']));
|
47 |
$this->_redirect('checkout/onepage/success');
|
48 |
return;
|
49 |
}
|
50 |
else
|
51 |
{
|
52 |
+
Mage::getSingleton('core/session')->addError(Mage::helper('core')->__($responseParams['vpc_Message']));
|
53 |
$this->_redirect('checkout/cart');
|
54 |
return;
|
55 |
}
|
app/code/local/ND/Amex/etc/config.xml
CHANGED
@@ -24,7 +24,7 @@
|
|
24 |
<config>
|
25 |
<modules>
|
26 |
<ND_Amex>
|
27 |
-
<version>0.1.
|
28 |
</ND_Amex>
|
29 |
</modules>
|
30 |
<global>
|
24 |
<config>
|
25 |
<modules>
|
26 |
<ND_Amex>
|
27 |
+
<version>0.1.1</version>
|
28 |
</ND_Amex>
|
29 |
</modules>
|
30 |
<global>
|
app/code/local/ND/Amex/etc/system.xml
CHANGED
@@ -28,7 +28,7 @@
|
|
28 |
<amex_server translate="label" module="payment">
|
29 |
<label>Amex Express</label>
|
30 |
<frontend_type>text</frontend_type>
|
31 |
-
<sort_order>
|
32 |
<show_in_default>1</show_in_default>
|
33 |
<show_in_website>1</show_in_website>
|
34 |
<show_in_store>0</show_in_store>
|
@@ -67,6 +67,22 @@
|
|
67 |
<show_in_website>1</show_in_website>
|
68 |
<show_in_store>0</show_in_store>
|
69 |
</password>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
70 |
<api_url translate="label">
|
71 |
<label>API Gateway URL</label>
|
72 |
<frontend_type>text</frontend_type>
|
28 |
<amex_server translate="label" module="payment">
|
29 |
<label>Amex Express</label>
|
30 |
<frontend_type>text</frontend_type>
|
31 |
+
<sort_order>401</sort_order>
|
32 |
<show_in_default>1</show_in_default>
|
33 |
<show_in_website>1</show_in_website>
|
34 |
<show_in_store>0</show_in_store>
|
67 |
<show_in_website>1</show_in_website>
|
68 |
<show_in_store>0</show_in_store>
|
69 |
</password>
|
70 |
+
<access_code translate="label">
|
71 |
+
<label>Access Code</label>
|
72 |
+
<frontend_type>text</frontend_type>
|
73 |
+
<sort_order>50</sort_order>
|
74 |
+
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>0</show_in_store>
|
77 |
+
</access_code>
|
78 |
+
<secure_hash_secret translate="label">
|
79 |
+
<label>Secure Hash Secret</label>
|
80 |
+
<frontend_type>text</frontend_type>
|
81 |
+
<sort_order>60</sort_order>
|
82 |
+
<show_in_default>1</show_in_default>
|
83 |
+
<show_in_website>1</show_in_website>
|
84 |
+
<show_in_store>0</show_in_store>
|
85 |
+
</secure_hash_secret>
|
86 |
<api_url translate="label">
|
87 |
<label>API Gateway URL</label>
|
88 |
<frontend_type>text</frontend_type>
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ND_Amex</name>
|
4 |
-
<version>0.1.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
@@ -10,9 +10,9 @@
|
|
10 |
<description>This module will integrate Amex payment method using its Api.</description>
|
11 |
<notes>This module will integrate Amex payment method using its Api.</notes>
|
12 |
<authors><author><name>Nikul Doshi</name><user>nikulonline</user><email>nikulonline@gmail.com</email></author></authors>
|
13 |
-
<date>
|
14 |
-
<time>
|
15 |
-
<contents><target name="magelocal"><dir name="ND"><dir name="Amex"><dir name="Block"><file name="Form.php" hash="5274e086aa14e46c3f418e74c02318fc"/><file name="Info.php" hash="107012a9d5e50cd2f2e227d5a7f9cb5d"/><dir name="Payment"><file name="Info.php" hash="29f650baf496d3d65bcdeab65b7c78d1"/></dir><dir name="Server"><file name="Failure.php" hash="4bc33161e1d1c221e68cd0234aa9cb00"/><file name="Form.php" hash="ab263fbbaa584a6374f3681b4d0d2110"/><file name="Redirect.php" hash="
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>ND_Amex</name>
|
4 |
+
<version>0.1.1</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
|
7 |
<channel>community</channel>
|
10 |
<description>This module will integrate Amex payment method using its Api.</description>
|
11 |
<notes>This module will integrate Amex payment method using its Api.</notes>
|
12 |
<authors><author><name>Nikul Doshi</name><user>nikulonline</user><email>nikulonline@gmail.com</email></author></authors>
|
13 |
+
<date>2014-10-18</date>
|
14 |
+
<time>10:21:35</time>
|
15 |
+
<contents><target name="magelocal"><dir name="ND"><dir name="Amex"><dir name="Block"><file name="Form.php" hash="5274e086aa14e46c3f418e74c02318fc"/><file name="Info.php" hash="107012a9d5e50cd2f2e227d5a7f9cb5d"/><dir name="Payment"><file name="Info.php" hash="29f650baf496d3d65bcdeab65b7c78d1"/></dir><dir name="Server"><file name="Failure.php" hash="4bc33161e1d1c221e68cd0234aa9cb00"/><file name="Form.php" hash="ab263fbbaa584a6374f3681b4d0d2110"/><file name="Redirect.php" hash="b265a9c50352bfd70745f7239f39b230"/><file name="Response.php" hash="cdc291119a3ac642d4b0e2595b8888ce"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="d79d2176d9eca6b0abb8bc59bdaae6da"/></dir><dir name="Helper"><file name="Data.php" hash="ec005848cf9242ee45ea818ceee01e94"/></dir><dir name="Model"><file name="Info.php" hash="30b74b0ff8f20a3032a6941d72c009bb"/><file name="Server.php" hash="95574c6b872846975c031852be8441a8"/></dir><dir name="controllers"><file name="ServerController.php" hash="b198ba194fd139368b1bb342466f9725"/></dir><dir name="etc"><file name="config.xml" hash="fb1658cca8435c2b357d96ec91c44b14"/><file name="system.xml" hash="5d8514366ac98cd017602e4108915521"/></dir><dir name="sql"><dir name="migsvpc_setup"><file name="mysql4-install-0.1.0.php" hash="807e55283d420d745aa65b31f376e22c"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="amex.xml" hash="37a6915378acaf8137359ff824f7ffe0"/></dir><dir name="template"><dir name="amex"><file name="form.phtml" hash="416411ec28758fa15de6c4d8ba6b102c"/><file name="info.phtml" hash="c13fe64ae97929b3b732d25b695527ea"/><dir name="method"><dir name="payment"><dir name="bpay"><file name="form.phtml" hash="4ec688f6b5e63186a91ff2414a567f81"/><file name="info.phtml" hash="7d010d2286e619e4a51de4f086ab71c1"/><file name="success.phtml" hash="55572c890d2fb68ded98b051502c31bd"/></dir><dir name="directdeposit"><file name="form.phtml" hash="ed7e15aa93805a227c00997961f7fb93"/><file name="info.phtml" hash="025c3e3b932f9864b0ccb46a58b6df78"/><file name="success.phtml" hash="d460923ed13b3e27abdebed921689490"/></dir></dir><file name="postcode-checkout.phtml" hash="dba2b90faf906a4ff17c72229600a259"/><file name="postcode.phtml" hash="e7c5e5c23f5c7750772321e1c4ffe06b"/></dir><dir name="server"><file name="form.phtml" hash="fcb0d5002d5efea2faeeefb5f66d0600"/><file name="response.phtml" hash="8a3f5b9be4901568104472399b1b1398"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="ND_Amex.xml" hash="811bcf28abb00dbfd03cc966c354eb0c"/></dir></target></contents>
|
16 |
<compatible/>
|
17 |
<dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
|
18 |
</package>
|