MageBase_DpsPaymentExpress - Version 1.0.0

Version Notes

First stable release

Download this release

Release Info

Developer Magento Core Team
Extension MageBase_DpsPaymentExpress
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (36) hide show
  1. app/code/community/MageBase/DpsPaymentExpress/Block/Form/Pxpay.php +159 -0
  2. app/code/community/MageBase/DpsPaymentExpress/Block/Form/Pxpost.php +35 -0
  3. app/code/community/MageBase/DpsPaymentExpress/Block/Info/Pxpay.php +115 -0
  4. app/code/community/MageBase/DpsPaymentExpress/Block/Info/Pxpost.php +41 -0
  5. app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Form.php +38 -0
  6. app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Info.php +42 -0
  7. app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Redirect.php +49 -0
  8. app/code/community/MageBase/DpsPaymentExpress/Block/Pxpost/Form.php +35 -0
  9. app/code/community/MageBase/DpsPaymentExpress/Block/Pxpost/Info.php +41 -0
  10. app/code/community/MageBase/DpsPaymentExpress/Helper/Data.php +50 -0
  11. app/code/community/MageBase/DpsPaymentExpress/Model/Debug.php +29 -0
  12. app/code/community/MageBase/DpsPaymentExpress/Model/Method/Common.php +85 -0
  13. app/code/community/MageBase/DpsPaymentExpress/Model/Method/Pxpay.php +522 -0
  14. app/code/community/MageBase/DpsPaymentExpress/Model/Method/Pxpost.php +501 -0
  15. app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Debug.php +29 -0
  16. app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Debug/Collection.php +29 -0
  17. app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Setup.php +26 -0
  18. app/code/community/MageBase/DpsPaymentExpress/Model/System/Logos.php +58 -0
  19. app/code/community/MageBase/DpsPaymentExpress/Model/System/PaymentAction.php +38 -0
  20. app/code/community/MageBase/DpsPaymentExpress/Model/System/PendingOrder.php +27 -0
  21. app/code/community/MageBase/DpsPaymentExpress/controllers/PxpayController.php +145 -0
  22. app/code/community/MageBase/DpsPaymentExpress/etc/config.xml +122 -0
  23. app/code/community/MageBase/DpsPaymentExpress/etc/system.xml +282 -0
  24. app/code/community/MageBase/DpsPaymentExpress/sql/magebasedps_setup/mysql4-install-0.5.0.php +42 -0
  25. app/code/community/MageBase/DpsPaymentExpress/sql/magebasedps_setup/mysql4-upgrade-0.5.0-1.0.0.php +28 -0
  26. app/etc/modules/MageBase_DpsPaymentExpress.xml +9 -0
  27. package.xml +18 -0
  28. skin/frontend/default/default/images/magebase/dps/AmexLogo.png +0 -0
  29. skin/frontend/default/default/images/magebase/dps/DinersLogo.png +0 -0
  30. skin/frontend/default/default/images/magebase/dps/JCBLogo.png +0 -0
  31. skin/frontend/default/default/images/magebase/dps/MCSecureCodeLogo.png +0 -0
  32. skin/frontend/default/default/images/magebase/dps/MasterCardLogo.png +0 -0
  33. skin/frontend/default/default/images/magebase/dps/VisaLogo.png +0 -0
  34. skin/frontend/default/default/images/magebase/dps/VisaVerifiedLogo.png +0 -0
  35. skin/frontend/default/default/images/magebase/dps/dpslogo.png +0 -0
  36. skin/frontend/default/default/images/magebase/dps/dpspxlogo.png +0 -0
app/code/community/MageBase/DpsPaymentExpress/Block/Form/Pxpay.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Mage_Payment_Block_Form_Cc extends Mage_Payment_Block_Form
29
+ {
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('payment/form/cc.phtml');
34
+ }
35
+
36
+ /**
37
+ * Retrieve payment configuration object
38
+ *
39
+ * @return Mage_Payment_Model_Config
40
+ */
41
+ protected function _getConfig()
42
+ {
43
+ return Mage::getSingleton('payment/config');
44
+ }
45
+
46
+ /**
47
+ * Retrieve availables credit card types
48
+ *
49
+ * @return array
50
+ */
51
+ public function getCcAvailableTypes()
52
+ {
53
+ $types = $this->_getConfig()->getCcTypes();
54
+ if ($method = $this->getMethod()) {
55
+ $availableTypes = $method->getConfigData('cctypes');
56
+ if ($availableTypes) {
57
+ $availableTypes = explode(',', $availableTypes);
58
+ foreach ($types as $code=>$name) {
59
+ if (!in_array($code, $availableTypes)) {
60
+ unset($types[$code]);
61
+ }
62
+ }
63
+ }
64
+ }
65
+ return $types;
66
+ }
67
+
68
+ /**
69
+ * Retrieve credit card expire months
70
+ *
71
+ * @return array
72
+ */
73
+ public function getCcMonths()
74
+ {
75
+ $months = $this->getData('cc_months');
76
+ if (is_null($months)) {
77
+ $months[0] = $this->__('Month');
78
+ $months = array_merge($months, $this->_getConfig()->getMonths());
79
+ $this->setData('cc_months', $months);
80
+ }
81
+ return $months;
82
+ }
83
+
84
+ /**
85
+ * Retrieve credit card expire years
86
+ *
87
+ * @return array
88
+ */
89
+ public function getCcYears()
90
+ {
91
+ $years = $this->getData('cc_years');
92
+ if (is_null($years)) {
93
+ $years = $this->_getConfig()->getYears();
94
+ $years = array(0=>$this->__('Year'))+$years;
95
+ $this->setData('cc_years', $years);
96
+ }
97
+ return $years;
98
+ }
99
+
100
+ /**
101
+ * Retrive has verification configuration
102
+ *
103
+ * @return boolean
104
+ */
105
+ public function hasVerification()
106
+ {
107
+ if ($this->getMethod()) {
108
+ $configData = $this->getMethod()->getConfigData('useccv');
109
+ if(is_null($configData)){
110
+ return true;
111
+ }
112
+ return (bool) $configData;
113
+ }
114
+ return true;
115
+ }
116
+
117
+ /*
118
+ * Whether switch/solo card type available
119
+ */
120
+ public function hasSsCardType()
121
+ {
122
+ $availableTypes =$this->getMethod()->getConfigData('cctypes');
123
+ if ($availableTypes && in_array('SS', explode(',', $availableTypes))) {
124
+ return true;
125
+ }
126
+ return false;
127
+ }
128
+
129
+ /*
130
+ * solo/switch card start year
131
+ * @return array
132
+ */
133
+ public function getSsStartYears()
134
+ {
135
+ $years = array();
136
+ $first = date("Y");
137
+
138
+ for ($index=5; $index>=0; $index--) {
139
+ $year = $first - $index;
140
+ $years[$year] = $year;
141
+ }
142
+ $years = array(0=>$this->__('Year'))+$years;
143
+ return $years;
144
+ }
145
+
146
+ /**
147
+ * Render block HTML
148
+ *
149
+ * @return string
150
+ */
151
+ protected function _toHtml()
152
+ {
153
+ Mage::dispatchEvent('payment_form_block_to_html_before', array(
154
+ 'block' => $this
155
+ ));
156
+ return parent::_toHtml();
157
+ }
158
+ }
159
+
app/code/community/MageBase/DpsPaymentExpress/Block/Form/Pxpost.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Mage_Payment_Block_Form_Purchaseorder extends Mage_Payment_Block_Form
29
+ {
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('payment/form/purchaseorder.phtml');
34
+ }
35
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Info/Pxpay.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Credit card generic payment info
29
+ */
30
+ class Mage_Payment_Block_Info_Cc extends Mage_Payment_Block_Info
31
+ {
32
+ /**
33
+ * Retrieve credit card type name
34
+ *
35
+ * @return string
36
+ */
37
+ public function getCcTypeName()
38
+ {
39
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
40
+ $ccType = $this->getInfo()->getCcType();
41
+ if (isset($types[$ccType])) {
42
+ return $types[$ccType];
43
+ }
44
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
45
+ }
46
+
47
+ /**
48
+ * Retrieve CC expiration month
49
+ *
50
+ * @return string
51
+ */
52
+ public function getCcExpMonth()
53
+ {
54
+ $month = $this->getInfo()->getCcExpMonth();
55
+ if ($month<10) {
56
+ $month = '0'.$month;
57
+ }
58
+ return $month;
59
+ }
60
+
61
+ /**
62
+ * Retrieve CC expiration date
63
+ *
64
+ * @return Zend_Date
65
+ */
66
+ public function getCcExpDate()
67
+ {
68
+ $date = Mage::app()->getLocale()->date(0);
69
+ $date->setYear($this->getInfo()->getCcExpYear());
70
+ $date->setMonth($this->getInfo()->getCcExpMonth());
71
+ return $date;
72
+ }
73
+
74
+ /**
75
+ * Prepare credit card related payment info
76
+ *
77
+ * @param Varien_Object|array $transport
78
+ * @return Varien_Object
79
+ */
80
+ protected function _prepareSpecificInformation($transport = null)
81
+ {
82
+ if (null !== $this->_paymentSpecificInformation) {
83
+ return $this->_paymentSpecificInformation;
84
+ }
85
+ $transport = parent::_prepareSpecificInformation($transport);
86
+ $data[Mage::helper('payment')->__('Credit Card Type')] = $this->getCcTypeName();
87
+
88
+ if ($this->getInfo()->getCcLast4()) {
89
+ $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
90
+ } else {
91
+ $data[Mage::helper('payment')->__('Credit Card Number')] = Mage::helper('payment')->__('N/A');
92
+ }
93
+ if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
94
+ $data[Mage::helper('payment')->__('Switch/Solo Issue Number')] = $ccSsIssue;
95
+ }
96
+ if (!$this->getIsSecureMode()) {
97
+ if ($year = $this->getInfo()->getCcSsStartYear() && $month = $this->getInfo()->getCcStartMonth()) {
98
+ $data[Mage::helper('payment')->__('Switch/Solo Start Date')] = $this->_formatCardDate($year, $month);
99
+ }
100
+ }
101
+ return $transport->setData(array_merge($data, $transport->getData()));
102
+ }
103
+
104
+ /**
105
+ * Format year/month on the credit card
106
+ *
107
+ * @param string $year
108
+ * @param string $month
109
+ * @return string
110
+ */
111
+ protected function _formatCardDate($year, $month)
112
+ {
113
+ return sprintf('%s/%s', sprintf('%02d', $month), $year);
114
+ }
115
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Info/Pxpost.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+
28
+ class Mage_Payment_Block_Info_Purchaseorder extends Mage_Payment_Block_Info
29
+ {
30
+ protected function _construct()
31
+ {
32
+ parent::_construct();
33
+ $this->setTemplate('payment/info/purchaseorder.phtml');
34
+ }
35
+
36
+ public function toPdf()
37
+ {
38
+ $this->setTemplate('payment/info/pdf/purchaseorder.phtml');
39
+ return $this->toHtml();
40
+ }
41
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Form.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Block_Pxpay_Form extends Mage_Payment_Block_Form
24
+ {
25
+
26
+ protected function _construct()
27
+ {
28
+ parent::_construct();
29
+ $this->setTemplate('magebase/dps/pxpay/form.phtml');
30
+ }
31
+
32
+ public function getLogosToDisplay()
33
+ {
34
+ return explode(",", Mage::getStoreConfig('payment/magebasedpspxpay/display_logos'));
35
+ }
36
+
37
+ }
38
+
app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Info.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Block_Pxpay_Info extends Mage_Payment_Block_Info
24
+ {
25
+
26
+ protected function _construct()
27
+ {
28
+ parent::_construct();
29
+ $this->setTemplate('magebase/dps/pxpay/info.phtml');
30
+ }
31
+
32
+ public function toPdf()
33
+ {
34
+ $this->setTemplate('magebase/dps/pxpay/pdf/pxpay.phtml');
35
+ return $this->toHtml();
36
+ }
37
+
38
+ public function getAdditionalData($key)
39
+ {
40
+ return Mage::helper('magebasedps')->getAdditionalData($this->getInfo(), $key);
41
+ }
42
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Pxpay/Redirect.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
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
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Paypal
23
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+ class MageBase_DpsPaymentExpress_Block_Pxpay_Redirect extends Mage_Core_Block_Abstract
27
+ {
28
+ protected function _toHtml()
29
+ {
30
+ $standard = Mage::getModel('paypal/standard');
31
+
32
+ $form = new Varien_Data_Form();
33
+ $form->setAction($standard->getConfig()->getPaypalUrl())
34
+ ->setId('paypal_standard_checkout')
35
+ ->setName('paypal_standard_checkout')
36
+ ->setMethod('POST')
37
+ ->setUseContainer(true);
38
+ foreach ($standard->getStandardCheckoutFormFields() as $field=>$value) {
39
+ $form->addField($field, 'hidden', array('name'=>$field, 'value'=>$value));
40
+ }
41
+ $html = '<html><body>';
42
+ $html.= $this->__('You will be redirected to DPS in a few seconds.');
43
+ $html.= $form->toHtml();
44
+ $html.= '<script type="text/javascript">document.getElementById("paypal_standard_checkout").submit();</script>';
45
+ $html.= '</body></html>';
46
+
47
+ return $html;
48
+ }
49
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Pxpost/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Block_Pxpost_Form extends Mage_Payment_Block_Form_Cc
24
+ {
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('magebase/dps/pxpost/form.phtml');
29
+ }
30
+
31
+ public function getLogosToDisplay()
32
+ {
33
+ return explode(",", Mage::getStoreConfig('payment/magebasedpspxpost/display_logos'));
34
+ }
35
+ }
app/code/community/MageBase/DpsPaymentExpress/Block/Pxpost/Info.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Block_Pxpost_Info extends Mage_Payment_Block_Info_Cc
24
+ {
25
+ protected function _construct()
26
+ {
27
+ parent::_construct();
28
+ $this->setTemplate('magebase/dps/pxpost/info.phtml');
29
+ }
30
+
31
+ public function toPdf()
32
+ {
33
+ $this->setTemplate('magebase/dps/pxpost/pdf/pxpost.phtml');
34
+ return $this->toHtml();
35
+ }
36
+
37
+ public function getAdditionalData($key)
38
+ {
39
+ return Mage::helper('magebasedps')->getAdditionalData($this->getInfo(), $key);
40
+ }
41
+ }
app/code/community/MageBase/DpsPaymentExpress/Helper/Data.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Helper_Data extends Mage_Core_Helper_Abstract
24
+ {
25
+
26
+ /**
27
+ * Currency codes supported by DPS
28
+ * @var array
29
+ */
30
+ protected $_supportedCurrencyCodes = array('CHF','EUR','FRF','GBP','HKD','JPY','NZD','SGD','USD','ZAR',
31
+ 'AUD','WST','VUV','TOP','SBD','PNG','MYR','KWD','FJD');
32
+
33
+ public function canUseCurrency($currencyCode)
34
+ {
35
+ return in_array($currencyCode, $this->_supportedCurrencyCodes);
36
+ }
37
+
38
+ public function getAdditionalData($info,$key = null)
39
+ {
40
+ $data = array();
41
+ if ($info->getAdditionalData()) {
42
+ $data = unserialize($info->getAdditionalData());
43
+ }
44
+ if (!empty($key) && isset($data[$key])) {
45
+ return $data[$key];
46
+ } else {
47
+ return '';
48
+ }
49
+ }
50
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Debug.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Debug extends Mage_Core_Model_Abstract
24
+ {
25
+ protected function _construct()
26
+ {
27
+ $this->_init('magebasedps/debug');
28
+ }
29
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Method/Common.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Method_Common extends Mage_Payment_Model_Method_Abstract
24
+ {
25
+
26
+ /*
27
+ Auth Authorizes a transactions. Must be completed within 7 days using the "Complete" TxnType.
28
+ Complete Completes (settles) a pre-approved Auth Transaction. The DpsTxnRef value returned
29
+ by the original approved Auth transaction must be supplied.
30
+ Purchase Purchase - Funds are transferred immediately.
31
+ Refund Refund - Funds transferred immediately. Must be enabled as a special option.
32
+ Validate Validation Transaction. Effects a $1.00 Auth to validate card details including expiry date.
33
+ Often utilised with the EnableAddBillCard property set to 1 to automatically
34
+ add to Billing Database if the transaction is approved.
35
+ */
36
+ const ACTION_AUTHORIZE = 'Auth';
37
+ const ACTION_COMPLETE = 'Complete';
38
+ const ACTION_PURCHASE = 'Purchase';
39
+ const ACTION_REFUND = 'Refund';
40
+ const ACTION_VALIDATE = 'Validate';
41
+
42
+ /**
43
+ * Credit Card Logos
44
+ */
45
+ const LOGOFILE_VISA = 'VisaLogo.png';
46
+ const LOGOFILE_VISAVERIFIED = 'VisaVerifiedLogo.png';
47
+ const LOGOFILE_MASTERCARD = 'MasterCardLogo.png';
48
+ const LOGOFILE_MASTERCARDSECURE = 'MCSecureCodeLogo.png';
49
+ const LOGOFILE_AMEX = 'AmexLogo.png';
50
+ const LOGOFILE_JCB = 'JCBLogo.png';
51
+ const LOGOFILE_DINERS = 'DinersLogo.png';
52
+
53
+
54
+ const STATUS_ERROR = 0;
55
+ const STATUS_OK_INVOICE = 2;
56
+ const STATUS_OK_DONT_INVOICE = 3;
57
+ const STATUS_OK_ALREADY_INVOICED = 4;
58
+
59
+ /**
60
+ * Error Codes
61
+ * Code => Description
62
+ */
63
+ public $errorCodes = array(
64
+ 'IC' => 'Invalid Key or Username. Also check that if a TxnId is being supplied that it is unique.',
65
+ 'ID' => 'Invalid transaction type. Esure that the transaction type is either Auth or Purchase.',
66
+ 'IK' => 'Invalid UrlSuccess. Ensure that the URL being supplied does not contain a query string.',
67
+ 'IL' => 'Invalid UrlFail. Ensure that the URL being supplied does not contain a query string.',
68
+ 'IM' => 'Invalid PxPayUserId.',
69
+ 'IN' => 'Blank PxPayUserId.',
70
+ 'IP' => 'Invalid parameter. Ensure that only documented properties are being supplied.',
71
+ 'IQ' => 'Invalid TxnType. Ensure that the transaction type being submitted is either "Auth" or "Purchase".',
72
+ 'IT' => 'Invalid currency. Ensure that the CurrencyInput is correct and in the correct format e.g. "USD".',
73
+ 'IU' => 'Invalid AmountInput. Ensure that the amount is in the correct format e.g. "20.00".',
74
+ 'NF' => 'Invalid Username.',
75
+ 'NK' => 'Request not found. Check the key and the mcrypt library if in use.',
76
+ 'NL' => 'User not enabled. Contact DPS.',
77
+ 'NM' => 'User not enabled. Contact DPS.',
78
+ 'NN' => 'Invalid MAC.',
79
+ 'NO' => 'Request contains non ASCII characters.',
80
+ 'NP' => 'PXPay Closing Request tag not found.',
81
+ 'NQ' => 'User not enabled for PxPay. Contact DPS.',
82
+ 'NT' => 'Key is not 64 characters.'
83
+ );
84
+
85
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Method/Pxpay.php ADDED
@@ -0,0 +1,522 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Method_Pxpay extends Mage_Payment_Model_Method_Abstract
24
+ {
25
+
26
+ const URL_PXPAY = 'https://sec2.paymentexpress.com/pxpay/pxaccess.aspx';
27
+ const URL_PXPAY_SUCCESS = 'magebasedps/pxpay/success';
28
+ const URL_PXPAY_FAIL = 'magebasedps/pxpay/fail';
29
+
30
+ const DPS_LOG_FILENAME = 'magebase_dps_pxpay.log';
31
+
32
+ protected $_code = 'magebasedpspxpay';
33
+ protected $_formBlockType = 'magebasedps/pxpay_form';
34
+ protected $_infoBlockType = 'magebasedps/pxpay_info';
35
+
36
+ /**
37
+ * Payment Method features
38
+ * @var bool
39
+ */
40
+ protected $_isGateway = false;
41
+ protected $_canAuthorize = false;
42
+ protected $_canCapture = false;
43
+ protected $_canCapturePartial = false;
44
+ protected $_canRefund = false;
45
+ protected $_canRefundInvoicePartial = false;
46
+ protected $_canVoid = false;
47
+ protected $_canUseInternal = true;
48
+ protected $_canUseCheckout = true;
49
+ protected $_canUseForMultishipping = false;
50
+ protected $_isInitializeNeeded = true;
51
+
52
+ protected $_order;
53
+
54
+ /**
55
+ * is PxPay enabled
56
+ *
57
+ * @return string
58
+ */
59
+ private function _isActive()
60
+ {
61
+ return Mage::getStoreConfigFlag('payment/'.$this->_code.'/active');
62
+ }
63
+
64
+ /**
65
+ * retrieve PxPayUserId from database
66
+ *
67
+ * @return string
68
+ */
69
+ private function _getPxPayUserId()
70
+ {
71
+ return Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/'.$this->_code.'/pxpayuserid'));
72
+ }
73
+
74
+ /**
75
+ * retrieve PxPayKey from database
76
+ *
77
+ * @return string
78
+ */
79
+ private function _getPxPayKey()
80
+ {
81
+ return Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/'.$this->_code.'/pxpaykey'));
82
+ }
83
+
84
+ /**
85
+ * retrieve payment action from database
86
+ * Auth or Purchase
87
+ *
88
+ * @return int
89
+ */
90
+ private function _getPxPayPaymentAction()
91
+ {
92
+ switch(Mage::getStoreConfig('payment/'.$this->_code.'/payment_action')) {
93
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
94
+ return MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_AUTHORIZE;
95
+ break;
96
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
97
+ return MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_PURCHASE;
98
+ break;
99
+ }
100
+ }
101
+
102
+ /**
103
+ * retrieve order matching MerchantReference
104
+ *
105
+ * @param SimpleXMLElement $resultXml
106
+ * @return Mage_Sales_Model_Order
107
+ */
108
+ private function _getOrder($resultXml)
109
+ {
110
+ if (!$this->_order) {
111
+ $this->_order = Mage::getModel('sales/order')->loadByIncrementId($resultXml->MerchantReference);
112
+ if (!$this->_order->getId()) {
113
+ $this->_order = false;
114
+ }
115
+ }
116
+ return $this->_order;
117
+ }
118
+
119
+ /**
120
+ * check if returned userId matches value from database
121
+ *
122
+ * @param $userId
123
+ * @return bool
124
+ */
125
+ public function validateUserId($userId)
126
+ {
127
+ return $this->_getPxPayUserId() == $userId;
128
+ }
129
+
130
+ /**
131
+ * Return redirect url to DPS after order has been placed
132
+ *
133
+ * @return string
134
+ */
135
+ public function getOrderPlaceRedirectUrl()
136
+ {
137
+ if (!$this->_isActive()) {
138
+ throw new Exception("Payment method is not available.");
139
+ return false;
140
+ }
141
+ $url = $this->_getPxPayUrl();
142
+ if (!$url) {
143
+ throw new Exception("Payment method is not available.");
144
+ return false;
145
+ }
146
+ return $url;
147
+ }
148
+
149
+ /**
150
+ * Instantiate state and set it to state object
151
+ * @param string $paymentAction
152
+ * @param Varien_Object
153
+ */
154
+ public function initialize($paymentAction, $stateObject)
155
+ {
156
+ $state = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
157
+ $stateObject->setState($state);
158
+ $stateObject->setStatus(Mage::getStoreConfig('payment/'.$this->_code.'/unpaid_order_status'));
159
+ $stateObject->setIsNotified(false);
160
+ }
161
+
162
+ /**
163
+ * check if current currency code is allowed for this payment method
164
+ *
165
+ * @param string $currencyCode
166
+ * @return bool
167
+ */
168
+ public function canUseForCurrency($currencyCode)
169
+ {
170
+ return Mage::helper('magebasedps')->canUseCurrency($currencyCode);
171
+ }
172
+
173
+ /**
174
+ * process the DPS result string (GET) when succesful
175
+ *
176
+ * @param string $result [encrypted]
177
+ * @return SimpleXMLElement
178
+ */
179
+ public function processSuccessResponse($result)
180
+ {
181
+ if (!$this->_isActive()) {
182
+ throw new Exception("Payment method is not available.");
183
+ } else {
184
+ $responseXml = $this->getRealResponse($result);
185
+ switch ($this->_validateResponse($responseXml)){
186
+ case MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_INVOICE:
187
+ $this->_registerPayment($responseXml);
188
+ Mage::getModel('sales/quote')->load($responseXml->TxnData2)->setIsActive(false)->save();
189
+ break;
190
+ case MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_DONT_INVOICE:
191
+ $this->_acknowledgeOrder($responseXml);
192
+ Mage::getModel('sales/quote')->load($responseXml->TxnData2)->setIsActive(false)->save();
193
+ break;
194
+ case MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_ALREADY_INVOICED:
195
+ Mage::getModel('sales/quote')->load($responseXml->TxnData2)->setIsActive(false)->save();
196
+ break;
197
+ default:
198
+ $this->_cancelOrderAfterFailure($responseXml);
199
+ return false;
200
+ break;
201
+ }
202
+ }
203
+ }
204
+
205
+ /**
206
+ * process the DPS result string (GET) after failure
207
+ *
208
+ * @param string $result [encrypted]
209
+ * @return SimpleXMLElement
210
+ */
211
+ public function processFailResponse($result) {
212
+ if(!$this->_isActive()) {
213
+ throw new Exception("Payment method is not available.");
214
+ }
215
+ $responseXml = $this->getRealResponse($result);
216
+ $this->_cancelOrderAfterFailure($responseXml);
217
+ return $responseXml;
218
+ }
219
+
220
+ /**
221
+ * retrieve PxPayUrl to redirect customer to (generated by DPS)
222
+ *
223
+ * @return string
224
+ */
225
+ protected function _getPxPayUrl()
226
+ {
227
+ try{
228
+ $txnId = substr(uniqid(rand()), 0, 16);
229
+ $client = new Zend_Http_Client();
230
+ $client->setUri(self::URL_PXPAY);
231
+ $client->setConfig(
232
+ array(
233
+ 'maxredirects'=>0,
234
+ 'timeout'=>30,
235
+ )
236
+ );
237
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
238
+
239
+ $xml = new SimpleXMLElement('<GenerateRequest></GenerateRequest>');
240
+ $xml->addChild('PxPayUserId', htmlentities($this->_getPxPayUserId()));
241
+ $xml->addChild('PxPayKey', htmlentities($this->_getPxPayKey()));
242
+ $xml->addChild('AmountInput', trim(htmlentities(sprintf("%9.2f", $quote->getBaseGrandTotal()))));
243
+ $xml->addChild('BillingId', '');
244
+ $xml->addChild('CurrencyInput', htmlentities($quote->getBaseCurrencyCode()));
245
+ $xml->addChild('EmailAddress', htmlentities($quote->getCustomerEmail()));
246
+ $xml->addChild('EnableAddBillCard', '0');
247
+ $xml->addChild('MerchantReference', htmlentities($quote->getReservedOrderId()));
248
+ $xml->addChild('TxnData1', $quote->getStore()->getName());
249
+ $xml->addChild('TxnData2', $quote->getId());
250
+ $xml->addChild('TxnData3', '');
251
+ $xml->addChild('TxnType', htmlentities($this->_getPxPayPaymentAction()));
252
+ $xml->addChild('TxnId', $txnId);
253
+ $xml->addChild('BillingId', '');
254
+ $xml->addChild('UrlFail', htmlentities(Mage::getUrl(self::URL_PXPAY_FAIL)));
255
+ $xml->addChild('UrlSuccess', htmlentities(Mage::getUrl(self::URL_PXPAY_SUCCESS)));
256
+ $xml->addChild('Opt', '');
257
+
258
+ $client->setParameterPost('xml', $xml->asXML());
259
+
260
+ if ($this->debugToDb()) {
261
+ $debugEntry = Mage::getModel('magebasedps/debug')
262
+ ->setRequestBody($xml->asXML())
263
+ ->save();
264
+ }
265
+ $response = $client->request('POST');
266
+
267
+ $responseXml = simplexml_load_string($response->getBody());
268
+ if ($this->debugToDb()) {
269
+ $debugEntry->setResponseBody($response->getBody())
270
+ ->save();
271
+ }
272
+ if ($responseXml['valid'] == 1) {
273
+ return strval($responseXml->URI);
274
+ }
275
+ return false;
276
+ }catch (Exception $e){
277
+ Mage::logException($e);
278
+ return false;
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Query DPS Server to obtain real ProcessResponse from encrypted response
284
+ *
285
+ * @param string $result [encrypted]
286
+ * @return SimpleXMLElement
287
+ */
288
+ public function getRealResponse($result)
289
+ {
290
+ try {
291
+ $client = new Zend_Http_Client();
292
+ $client->setUri(self::URL_PXPAY);
293
+ $client->setConfig(
294
+ array(
295
+ 'maxredirects'=>0,
296
+ 'timeout'=>30,
297
+ )
298
+ );
299
+ $xml = new SimpleXMLElement('<ProcessResponse></ProcessResponse>');
300
+ $xml->addChild('PxPayUserId', htmlentities($this->_getPxPayUserId()));
301
+ $xml->addChild('PxPayKey', htmlentities($this->_getPxPayKey()));
302
+ $xml->addChild('Response', $result);
303
+
304
+ $client->setParameterPost('xml', $xml->asXML());
305
+
306
+ if ($this->debugToDb()) {
307
+ $debugEntry = Mage::getModel('magebasedps/debug')
308
+ ->setRequestBody($xml->asXML())
309
+ ->save();
310
+ }
311
+
312
+ $response = $client->request('POST');
313
+
314
+ $responseXml = simplexml_load_string($response->getBody());
315
+ if ($responseXml && $this->debugToDb()) {
316
+ $debugEntry->setResponseBody($responseXml->asXML())
317
+ ->save();
318
+ }
319
+ if ($responseXml['valid'] == 1) {
320
+ return $responseXml;
321
+ } else {
322
+ throw new Exception("DPS did not return a valid response.");
323
+ }
324
+ }catch (Exception $e) {
325
+ Mage::logException($e);
326
+ Mage::log("Error in DPS obtaining ProcessResponse ".$e->getMessage(), null, self::DPS_LOG_FILENAME);
327
+ return false;
328
+ }
329
+ }
330
+
331
+ /**
332
+ * validate returned response and determine if an invoice should be created
333
+ * checks: success = 1
334
+ * amount settled = base grand total
335
+ * currency settled = base currency
336
+ * order exists
337
+ *
338
+ * @param SimpleXMLElement $resultXml
339
+ * @return int
340
+ */
341
+ protected function _validateResponse($resultXml)
342
+ {
343
+ try {
344
+ if ((int)$resultXml->Success != 1) {
345
+ Mage::log("Error in DPS Response Validation: Unsuccessful", null, self::DPS_LOG_FILENAME);
346
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
347
+ }
348
+ $order = $this->_getOrder($resultXml);
349
+ if (!$order->getId()) {
350
+ Mage::log("Error in DPS Response Validation: No Order", null, self::DPS_LOG_FILENAME);
351
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
352
+ }
353
+ if ((float)$resultXml->AmountSettlement != $order->getBaseGrandTotal()) {
354
+ Mage::log(
355
+ $order->getIncrementId(). " Error in DPS Response Validation: Mismatched totals",
356
+ null,
357
+ self::DPS_LOG_FILENAME
358
+ );
359
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
360
+ }
361
+ if((float)$resultXml->CurrencySettlement != $order->getBaseCurrencyCode()) {
362
+ Mage::log(
363
+ $order->getIncrementId(). " Error in DPS Response Validation: Mismatched currencies",
364
+ null,
365
+ self::DPS_LOG_FILENAME
366
+ );
367
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
368
+ }
369
+ switch ($order->getState()) {
370
+ case Mage_Sales_Model_Order::STATE_NEW:
371
+ case Mage_Sales_Model_Order::STATE_PENDING_PAYMENT:
372
+ if ((string)$resultXml->TxnType == MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_AUTHORIZE) {
373
+ Mage::log(
374
+ $order->getIncrementId()." DPS Response: Authorize OK",
375
+ null,
376
+ self::DPS_LOG_FILENAME
377
+ );
378
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_DONT_INVOICE;
379
+ break;
380
+ } elseif((string)$resultXml->TxnType == MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_PURCHASE) {
381
+ if ($order->canInvoice()) {
382
+ Mage::log(
383
+ $order->getIncrementId(). " DPS Response: Purchase OK - create Invoice",
384
+ null,
385
+ self::DPS_LOG_FILENAME
386
+ );
387
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_INVOICE;
388
+ break;
389
+ } else {
390
+ Mage::log(
391
+ $order->getIncrementId(). " DPS Response: Purchase OK - don't Invoice",
392
+ null,
393
+ self::DPS_LOG_FILENAME
394
+ );
395
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_DONT_INVOICE;
396
+ break;
397
+ }
398
+ }
399
+ //not supported
400
+ Mage::log(
401
+ $order->getIncrementId(). " Error in DPS Response Validation: Not supported action",
402
+ null,
403
+ self::DPS_LOG_FILENAME
404
+ );
405
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
406
+ break;
407
+ default:
408
+ Mage::log(
409
+ $order->getIncrementId(). " DPS Validation: Order already processed - current state (".$order->getState().")",
410
+ null,
411
+ self::DPS_LOG_FILENAME
412
+ );
413
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_OK_ALREADY_INVOICED;
414
+ break;
415
+ }
416
+ }catch (Exception $e) {
417
+ Mage::log(
418
+ "Error in DPS Response Validation ".$e->getMessage(),
419
+ null,
420
+ self::DPS_LOG_FILENAME
421
+ );
422
+ return MageBase_DpsPaymentExpress_Model_Method_Common::STATUS_ERROR;
423
+ }
424
+
425
+ }
426
+
427
+ /**
428
+ * save all useful returned info from DPS to additional information field
429
+ * on order payment object
430
+ *
431
+ * @param SimpleXMLElement $responseXml
432
+ * @param Mage_Sales_Model_Order_Payment $payment ?
433
+ * @return void
434
+ */
435
+ public function setAdditionalData($responseXml,$payment)
436
+ {
437
+ $data = array (
438
+ 'AuthCode' => (string)$responseXml->AuthCode,
439
+ 'CardName' => (string)$responseXml->CardName,
440
+ 'CurrencySettlement'=> (string)$responseXml->CurrencySettlement,
441
+ 'AmountSettlement'=> (string)$responseXml->AmountSettlement,
442
+ 'CardHolderName' => (string)$responseXml->CardHolderName,
443
+ 'CardNumber' => (string)$responseXml->CardNumber,
444
+ 'CardNumber2' => (string)$responseXml->CardNumber2,
445
+ 'TxnType' => (string)$responseXml->TxnType,
446
+ 'TxnId' => (string)$responseXml->TxnId,
447
+ 'DpsTxnRef' => (string)$responseXml->DpsTxnRef,
448
+ 'BillingId' => (string)$responseXml->BillingId,
449
+ 'DpsBillingId' => (string)$responseXml->DpsBillingId,
450
+ 'TxnMac' => (string)$responseXml->TxnMac,
451
+ 'ResponseText' => (string)$responseXml->ResponseText
452
+ );
453
+ $payment->setAdditionalData(serialize($data));
454
+
455
+ }
456
+
457
+ /**
458
+ * Create invoice, save info to payment and send email to customer
459
+ *
460
+ * @param SimpleXMLElement $responseXml
461
+ */
462
+ protected function _registerPayment($responseXml)
463
+ {
464
+ $order = $this->_getOrder($responseXml);
465
+ $payment = $order->getPayment();
466
+ $this->setAdditionalData($responseXml, $payment);
467
+ $invoice = $order->prepareInvoice();
468
+ $invoice->register();
469
+ $order->addRelatedObject($invoice);
470
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, '');
471
+ $order->setStatus(Mage::getStoreConfig('payment/'.$this->_code.'/order_status'));
472
+ $order->sendNewOrderEmail();
473
+ $order->setEmailSent(true);
474
+ $order->save();
475
+ }
476
+
477
+ /**
478
+ * Save info to payment and send email to customer
479
+ *
480
+ * @param SimpleXMLElement $responseXml
481
+ */
482
+ protected function _acknowledgeOrder($responseXml)
483
+ {
484
+ $order = $this->_getOrder($responseXml);
485
+ $payment = $order->getPayment();
486
+ $this->setAdditionalData($responseXml, $payment);
487
+ if (!$order->getEmailSent()) {
488
+ $order->sendNewOrderEmail();
489
+ $order->setEmailSent(true);
490
+ }
491
+ $order->save();
492
+ }
493
+
494
+ /**
495
+ * cancel the order when we aren't successful
496
+ *
497
+ * @param SimpleXMLElement $responseXml
498
+ */
499
+ protected function _cancelOrderAfterFailure($responseXml=null)
500
+ {
501
+ if ($responseXml) {
502
+ $order = $this->_getOrder($responseXml);
503
+ $this->setAdditionalData($responseXml, $order->getPayment());
504
+ } else {
505
+ $order = Mage::getModel('sales/order')->load(Mage::getSingleton('checkout/session')->getLastOrderId());
506
+ }
507
+ if ($order->getId() && $order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
508
+ $order->cancel()->save();
509
+ }
510
+ }
511
+
512
+ /**
513
+ * get flag if we should log debug info to database
514
+ *
515
+ * @return bool
516
+ */
517
+ public function debugToDb()
518
+ {
519
+ return Mage::getStoreConfig('payment/'.$this->_code.'/debug');
520
+ }
521
+
522
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Method/Pxpost.php ADDED
@@ -0,0 +1,501 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2009 Irubin Consulting Inc. DBA Varien (http://www.varien.com)
19
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
20
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
21
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
+ */
23
+
24
+ class MageBase_DpsPaymentExpress_Model_Method_Pxpost extends Mage_Payment_Model_Method_Cc
25
+ {
26
+ const URL_PXPOST = 'https://www.paymentexpress.com/pxpost.aspx';
27
+
28
+ const DPS_LOG_FILENAME = 'magebase_dps_pxpost.log';
29
+
30
+ protected $_code = 'magebasedpspxpost';
31
+ protected $_formBlockType = 'magebasedps/pxpost_form';
32
+ protected $_infoBlockType = 'magebasedps/pxpost_info';
33
+ /**
34
+ * Payment Method features
35
+ * @var bool
36
+ */
37
+ protected $_isGateway = true;
38
+ protected $_canAuthorize = true;
39
+ protected $_canCapture = true;
40
+ protected $_canCapturePartial = true;
41
+ protected $_canRefund = true;
42
+ protected $_canRefundInvoicePartial = true;
43
+ protected $_canVoid = false;
44
+ protected $_canUseInternal = true;
45
+ protected $_canUseCheckout = true;
46
+ protected $_canUseForMultishipping = true;
47
+ protected $_isInitializeNeeded = false;
48
+ protected $_canSaveCc = false;
49
+
50
+ protected $_order;
51
+
52
+ /**
53
+ * retrieve PostUsername from database
54
+ *
55
+ * @return string
56
+ */
57
+ protected function _getPostUsername()
58
+ {
59
+ return Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/'.$this->_code.'/postusername'));
60
+ }
61
+
62
+ /**
63
+ * retrieve PostPassword from database
64
+ *
65
+ * @return string
66
+ */
67
+ protected function _getPostPassword()
68
+ {
69
+ return Mage::helper('core')->decrypt(Mage::getStoreConfig('payment/'.$this->_code.'/postpassword'));
70
+ }
71
+
72
+ /**
73
+ * retrieve payment action from database
74
+ * Auth or Purchase
75
+ *
76
+ * @return int
77
+ */
78
+ protected function _getPxPostPaymentAction()
79
+ {
80
+ switch(Mage::getStoreConfig('payment/'.$this->_code.'/payment_action')) {
81
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
82
+ return MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_AUTHORIZE;
83
+ break;
84
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
85
+ return MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_PURCHASE;
86
+ break;
87
+ }
88
+ }
89
+
90
+ /**
91
+ * check if current currency code is allowed for this payment method
92
+ *
93
+ * @param string $currencyCode
94
+ * @return bool
95
+ */
96
+ public function canUseForCurrency($currencyCode)
97
+ {
98
+ return Mage::helper('magebasedps')->canUseCurrency($currencyCode);
99
+ }
100
+
101
+ /**
102
+ * validate the CC info entered
103
+ * on onepage checkout called after payment and before review stage
104
+ *
105
+ * @return MageBase_DpsPaymentExpress_Model_Method_Pxpost
106
+ */
107
+ public function validate()
108
+ {
109
+ parent::validate();
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * authorize the amount to be taken later from CC
115
+ *
116
+ * @param Varien_Object $payment
117
+ * @param float $amount
118
+ * @return MageBase_DpsPaymentExpress_Model_Method_Pxpost
119
+ */
120
+ public function authorize(Varien_Object $payment, $amount)
121
+ {
122
+ $this->setAmount($amount)
123
+ ->setPayment($payment)
124
+ ->setPaymentAction(MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_AUTHORIZE);
125
+ $result = $this->buildRequestAndSubmitToDps()!==false;
126
+ if ($result) {
127
+ $payment->setStatus(self::STATUS_APPROVED)
128
+ ->setLastTransId($this->getTransactionId());
129
+ } else {
130
+ $e = $this->getError();
131
+ if (isset($e['message'])) {
132
+ $message = Mage::helper('magebasedps')->__('There has been an error processing your payment.')
133
+ . $e['message'];
134
+ } else {
135
+ $message = Mage::helper('magebasedps')->__(
136
+ 'There has been an error processing your payment. Please try later or contact us for help.'
137
+ );
138
+ }
139
+ Mage::throwException($message);
140
+ }
141
+ return $this;
142
+ }
143
+
144
+ /**
145
+ * get the money
146
+ *
147
+ * @param Varien_Object $payment
148
+ * @param float $amount
149
+ * @return MageBase_DpsPaymentExpress_Model_Method_Pxpost
150
+ */
151
+ public function capture(Varien_Object $payment, $amount)
152
+ {
153
+ $this->setAmount($amount)
154
+ ->setPayment($payment);
155
+ if (Mage::helper('magebasedps')->getAdditionalData($payment, 'DpsTxnRef')) {
156
+ $this->setPaymentAction(MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_COMPLETE);
157
+ } else {
158
+ $this->setPaymentAction(MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_PURCHASE);
159
+ }
160
+
161
+ $result = $this->buildRequestAndSubmitToDps()!==false;
162
+
163
+ if ($result) {
164
+ $payment->setStatus(self::STATUS_APPROVED)
165
+ ->setLastTransId($this->getTransactionId());
166
+ } else {
167
+ $e = $this->getError();
168
+ if (isset($e['message'])) {
169
+ $message = Mage::helper('magebasedps')->__('There has been an error processing your payment.')
170
+ . $e['message'];
171
+ } else {
172
+ $message = Mage::helper('magebasedps')->__(
173
+ 'There has been an error processing your payment. Please try later or contact us for help.'
174
+ );
175
+ }
176
+ Mage::throwException($message);
177
+ }
178
+ return $this;
179
+ }
180
+
181
+ public function refund(Varien_Object $payment, $amount)
182
+ {
183
+ $this->setAmount($amount)
184
+ ->setPayment($payment)
185
+ ->setPaymentAction(MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_REFUND);
186
+ $result = $this->buildRequestAndSubmitToDps()!==false;
187
+ if ($result) {
188
+ $payment->setStatus(self::STATUS_APPROVED)
189
+ ->setLastTransId($this->getTransactionId());
190
+ } else {
191
+ $e = $this->getError();
192
+ if (isset($e['message'])) {
193
+ $message = Mage::helper('magebasedps')->__('There has been an error processing your payment.')
194
+ . $e['message'];
195
+ } else {
196
+ $message = Mage::helper('magebasedps')->__(
197
+ 'There has been an error processing your payment. Please try later or contact us for help.'
198
+ );
199
+ }
200
+ Mage::throwException($message);
201
+ }
202
+ return $this;
203
+ }
204
+
205
+ /**
206
+ * create transaction object in xml and submit to server
207
+ *
208
+ * @return bool
209
+ */
210
+ public function buildRequestAndSubmitToDps()
211
+ {
212
+
213
+ $payment = $this->getPayment();
214
+
215
+ $client = new Zend_Http_Client();
216
+ $client->setUri(self::URL_PXPOST);
217
+ $client->setConfig(
218
+ array(
219
+ 'maxredirects'=>0,
220
+ 'timeout'=>30,
221
+ )
222
+ );
223
+ //Completing a previously authorized transaction
224
+ //or refunding
225
+ if ($this->getPaymentAction() == MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_COMPLETE ||
226
+ $this->getPaymentAction() == MageBase_DpsPaymentExpress_Model_Method_Common::ACTION_REFUND ) {
227
+ $xml = new SimpleXMLElement('<Txn></Txn>');
228
+ $xml->addChild('PostUsername', htmlentities($this->_getPostUsername()));
229
+ $xml->addChild('PostPassword', htmlentities($this->_getPostPassword()));
230
+ $xml->addChild('Amount', trim(sprintf("%9.2f", $this->getAmount())));
231
+ $xml->addChild('TxnType', $this->getPaymentAction());
232
+ $xml->addChild('MerchantReference', $this->_getOrderId());
233
+ $xml->addChild('DpsTxnRef', Mage::helper('magebasedps')->getAdditionalData($payment, 'DpsTxnRef'));
234
+ $this->setTransactionId(Mage::helper('magebasedps')->getAdditionalData($payment, 'DpsTxnRef'));
235
+ } else {
236
+ //authorise or purchase
237
+ $txnId = substr(uniqid(rand()), 0, 16);
238
+ $this->setTransactionId($txnId);
239
+ $xml = new SimpleXMLElement('<Txn></Txn>');
240
+ $xml->addChild('Amount', trim(sprintf("%9.2f", $this->getAmount())));
241
+ $xml->addChild('CardHolderName', htmlentities(trim($payment->getCcOwner()), ENT_QUOTES, 'UTF-8'));
242
+ $xml->addChild('CardNumber', $payment->getCcNumber());
243
+ //$xml->addChild('BillingId', '');
244
+ $xml->addChild('Cvc2', htmlentities($payment->getCcCid()));
245
+ $xml->addChild(
246
+ 'DateExpiry',
247
+ str_pad($payment->getCcExpMonth(), 2, '0', STR_PAD_LEFT).substr($payment->getCcExpYear(), 2, 2)
248
+ );
249
+ //$xml->addChild('DpsBillingId', '');
250
+ //$xml->addChild('DpsTxnRef', '');
251
+ //$xml->addChild('EnableAddBillCard', '');
252
+ $xml->addChild('InputCurrency', $this->_getCurrencyCode());
253
+ $xml->addChild('MerchantReference', $this->_getOrderId());
254
+ $xml->addChild('PostUsername', htmlentities($this->_getPostUsername()));
255
+ $xml->addChild('PostPassword', htmlentities($this->_getPostPassword()));
256
+ $xml->addChild('TxnType', $this->getPaymentAction());
257
+ //$xml->addChild('TxnData1', '');
258
+ //$xml->addChild('TxnData2', '');
259
+ //$xml->addChild('TxnData3', '');
260
+ $xml->addChild('TxnId', $txnId);
261
+ //$xml->addChild('EnableAvsData', '');
262
+ //$xml->addChild('AvsAction', '');
263
+ //$xml->addChild('AvsPostCode', '');
264
+ //$xml->addChild('AvsStreetAddress', '');
265
+ //$xml->addChild('DateStart', '');
266
+ //$xml->addChild('IssueNumber', '');
267
+ //$xml->addChild('Track2', '');
268
+ }
269
+ $responseXml = $this->_requestResponse($client, $xml);
270
+
271
+ //check if we have to send another Post to request the status of the transaction
272
+ if ((int)$responseXml->Transaction[0]->StatusRequired) {
273
+ $xml = new SimpleXMLElement('<Txn></Txn>');
274
+ $xml->addChild('PostUsername', htmlentities($this->_getPostUsername()));
275
+ $xml->addChild('PostPassword', htmlentities($this->_getPostPassword()));
276
+ $xml->addChild('TxnType', 'Status');
277
+ $xml->addChild('TxnId', $txnId);
278
+ $responseXml = $this->_requestResponse($client, $xml);
279
+ }
280
+
281
+ if ($this->_validateResponse($responseXml)) {
282
+ $this->unsError();
283
+ $this->setAdditionalData($responseXml, $payment);
284
+ return true;
285
+ }
286
+
287
+ return false;
288
+
289
+ }
290
+
291
+ /**
292
+ * send xml as http request to server
293
+ *
294
+ * @param Zend_Http_Client $client
295
+ * @param SimpleXMLElement $xml
296
+ * @return bool
297
+ */
298
+ private function _requestResponse($client,$xml)
299
+ {
300
+ $client->setParameterPost('xml', $xml->asXML());
301
+ if ($this->debugToDb()) {
302
+ //mask out card number in debug log
303
+ if ($xml->CardNumber) {
304
+ $xml->CardNumber = substr($xml->CardNumber, 0, 6).".........".substr($xml->CardNumber, -1);
305
+ }
306
+ Mage::getModel('magebasedps/debug')
307
+ ->setRequestBody($xml->asXML())
308
+ ->save();
309
+ }
310
+ $response = $client->request('POST');
311
+ if ($this->debugToDb()) {
312
+ Mage::getModel('magebasedps/debug')
313
+ ->setResponseBody($response->getBody())
314
+ ->save();
315
+ }
316
+ return simplexml_load_string($response->getBody());
317
+ }
318
+
319
+
320
+ /**
321
+ * validate returned response
322
+ * checks: Success Response
323
+ * Authorized Response
324
+ * amount = base grand total
325
+ * currency settled = base currency
326
+ * order exists
327
+ *
328
+ * @param SimpleXMLElement $resultXml
329
+ * @return bool
330
+ */
331
+ protected function _validateResponse($resultXml)
332
+ {
333
+ try {
334
+ if ((int)$resultXml->Transaction[0]->StatusRequired) {
335
+ Mage::log(
336
+ "Error in DPS Response Validation: No correct status even after retrying.",
337
+ null,
338
+ self::DPS_LOG_FILENAME
339
+ );
340
+ }
341
+ if (!(int)$resultXml->Transaction[0]['success'] && !(int)$resultXml->Transaction[0]->Authorized) {
342
+ $common = Mage::getModel('magebasedps/method_common');
343
+ try{
344
+ Mage::log(
345
+ "Error in DPS Response Validation: ".
346
+ $common->errorCodes[$resultXml->Transaction[0]['reco']], null, self::DPS_LOG_FILENAME
347
+ );
348
+ }catch(Exception $e){
349
+ Mage::log(
350
+ "Error in DPS Response Validation: Failed with unknown error code
351
+ (".$resultXml->Transaction[0]['reco'].")", null, self::DPS_LOG_FILENAME
352
+ );
353
+ }
354
+ $this->setError(array('message' => $resultXml->HelpText));
355
+ return false;
356
+ }
357
+ $order = $this->_getOrder();
358
+ if (!$order) {
359
+ Mage::log("Error in DPS Response Validation: No Order", null, self::DPS_LOG_FILENAME);
360
+ return false;
361
+ }
362
+ if ((float)$resultXml->Transaction[0]->Amount != $order->getBaseGrandTotal()) {
363
+ Mage::log("Error in DPS Response Validation: Mismatched totals", null, self::DPS_LOG_FILENAME);
364
+ return false;
365
+ }
366
+ if ((float)$resultXml->Transaction[0]->CurrencySettlement != $order->getBaseCurrencyCode()) {
367
+ Mage::log("Error in DPS Response Validation: Mismatched currencies", null, self::DPS_LOG_FILENAME);
368
+ return false;
369
+ }
370
+ return true;
371
+
372
+ }catch (Exception $e) {
373
+ Mage::logException($e);
374
+ Mage::log("Error in DPS Response Validation ".$e->getMessage(), null, self::DPS_LOG_FILENAME);
375
+ return false;
376
+ }
377
+
378
+ }
379
+
380
+ /**
381
+ * get flag if we should log debug info to database
382
+ *
383
+ * @return bool
384
+ */
385
+ public function debugToDb()
386
+ {
387
+ return Mage::getStoreConfig('payment/'.$this->_code.'/debug');
388
+ }
389
+
390
+ /**
391
+ * save all useful returned info from DPS to additional information field
392
+ * on order payment object
393
+ *
394
+ * @param SimpleXMLElement $responseXml
395
+ * @param Mage_Sales_Model_Order_Payment $payment ?
396
+ * @return void
397
+ */
398
+ public function setAdditionalData($responseXml,$payment)
399
+ {
400
+ $data = array (
401
+ 'ReCo' => (string)$responseXml->Transaction[0]['reco'],
402
+ 'AuthCode' => (string)$responseXml->Transaction[0]->AuthCode,
403
+ 'CardName' => (string)$responseXml->Transaction[0]->CardName,
404
+ 'CurrencyName'=> (string)$responseXml->Transaction[0]->CurrencyName,
405
+ 'Amount'=> (string) $responseXml->Transaction[0]->Amount,
406
+ 'CardHolderName' => (string)$responseXml->Transaction[0]->CardHolderName,
407
+ 'CardNumber' => (string)$responseXml->Transaction[0]->CardNumber,
408
+ 'CardNumber2' => (string)$responseXml->Transaction[0]->CardNumber2,
409
+ 'TxnType' => (string)$responseXml->Transaction[0]->TxnType,
410
+ 'TransactionId' => (string)$responseXml->Transaction[0]->TransactionId,
411
+ 'DpsTxnRef' => (string)$responseXml->Transaction[0]->DpsTxnRef,
412
+ 'BillingId' => (string)$responseXml->Transaction[0]->BillingId,
413
+ 'DpsBillingId' => (string)$responseXml->Transaction[0]->DpsBillingId,
414
+ 'TxnMac' => (string)$responseXml->Transaction[0]->TxnMac,
415
+ 'ResponseText' => (string)$responseXml->ResponseText,
416
+ 'HelpText' => (string)$responseXml->HelpText,
417
+ 'AcquirerTxnRef' => (string)$responseXml->Transaction[0]->AcquirerTxnRef
418
+ );
419
+ $payment->setAdditionalData(serialize($data));
420
+
421
+ }
422
+
423
+ /**
424
+ * Order increment ID getter (either real from order or a reserved from quote)
425
+ *
426
+ * @return string
427
+ */
428
+ private function _getOrderId()
429
+ {
430
+ $info = $this->getInfoInstance();
431
+
432
+ if ($this->_isPlaceOrder()) {
433
+ return $info->getOrder()->getIncrementId();
434
+ } else {
435
+ if (!$info->getQuote()->getReservedOrderId()) {
436
+ $info->getQuote()->reserveOrderId();
437
+ }
438
+ return $info->getQuote()->getReservedOrderId();
439
+ }
440
+ }
441
+
442
+ /**
443
+ * Grand total getter
444
+ *
445
+ * @return string
446
+ */
447
+ private function _getAmount()
448
+ {
449
+ $info = $this->getInfoInstance();
450
+ if ($this->_isPlaceOrder()) {
451
+ return (double)$info->getOrder()->getQuoteBaseGrandTotal();
452
+ } else {
453
+ return (double)$info->getQuote()->getBaseGrandTotal();
454
+ }
455
+ }
456
+
457
+ /**
458
+ * Currency code getter
459
+ *
460
+ * @return string
461
+ */
462
+ private function _getCurrencyCode()
463
+ {
464
+ $info = $this->getInfoInstance();
465
+
466
+ if ($this->_isPlaceOrder()) {
467
+ return $info->getOrder()->getBaseCurrencyCode();
468
+ } else {
469
+ return $info->getQuote()->getBaseCurrencyCode();
470
+ }
471
+ }
472
+
473
+ /**
474
+ * Whether current operation is order placement
475
+ *
476
+ * @return bool
477
+ */
478
+ private function _isPlaceOrder()
479
+ {
480
+ $info = $this->getInfoInstance();
481
+ if ($info instanceof Mage_Sales_Model_Quote_Payment) {
482
+ return false;
483
+ } elseif ($info instanceof Mage_Sales_Model_Order_Payment) {
484
+ return true;
485
+ }
486
+ }
487
+
488
+ /**
489
+ * retrieve curent order
490
+ *
491
+ * @return Mage_Sales_Model_Order
492
+ */
493
+ private function _getOrder()
494
+ {
495
+ if (!$this->_order) {
496
+ $this->_order = $this->getInfoInstance()->getOrder();
497
+ }
498
+ return $this->_order;
499
+ }
500
+
501
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Debug.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Mysql4_Debug extends Mage_Core_Model_Mysql4_Abstract
24
+ {
25
+ protected function _construct()
26
+ {
27
+ $this->_init('magebasedps/debug', 'debug_id');
28
+ }
29
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Debug/Collection.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Mysql4_Debug_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
24
+ {
25
+ protected function _construct()
26
+ {
27
+ $this->_init('magebasedps/debug');
28
+ }
29
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/Mysql4/Setup.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
24
+ {
25
+
26
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/System/Logos.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_System_Logos
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array(
29
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_VISA,
30
+ 'label' => Mage::helper('magebasedps')->__('Visa')
31
+ ),
32
+ array(
33
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_VISAVERIFIED,
34
+ 'label' => Mage::helper('magebasedps')->__('Verified by Visa')
35
+ ),
36
+ array(
37
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_MASTERCARD,
38
+ 'label' => Mage::helper('magebasedps')->__('MasterCard')
39
+ ),
40
+ array(
41
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_MASTERCARDSECURE,
42
+ 'label' => Mage::helper('magebasedps')->__('MasterCard SecureCode')
43
+ ),
44
+ array(
45
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_AMEX,
46
+ 'label' => Mage::helper('magebasedps')->__('American Express')
47
+ ),
48
+ array(
49
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_JCB,
50
+ 'label' => Mage::helper('magebasedps')->__('JCB')
51
+ ),
52
+ array(
53
+ 'value' => MageBase_DpsPaymentExpress_Model_Method_Common::LOGOFILE_DINERS,
54
+ 'label' => Mage::helper('magebasedps')->__('Diners')
55
+ ),
56
+ );
57
+ }
58
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/System/PaymentAction.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_System_PaymentAction
24
+ {
25
+ public function toOptionArray()
26
+ {
27
+ return array(
28
+ array(
29
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE,
30
+ 'label' => Mage::helper('magebasedps')->__('Authorize Only')
31
+ ),
32
+ array(
33
+ 'value' => Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE,
34
+ 'label' => Mage::helper('magebasedps')->__('Purchase')
35
+ ),
36
+ );
37
+ }
38
+ }
app/code/community/MageBase/DpsPaymentExpress/Model/System/PendingOrder.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_Model_System_PendingOrder
24
+ extends Mage_Adminhtml_Model_System_Config_Source_Order_Status
25
+ {
26
+ protected $_stateStatuses = Mage_Sales_Model_Order::STATE_PENDING_PAYMENT;
27
+ }
app/code/community/MageBase/DpsPaymentExpress/controllers/PxpayController.php ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class MageBase_DpsPaymentExpress_PxpayController extends Mage_Core_Controller_Front_Action
24
+ {
25
+
26
+ public function successAction()
27
+ {
28
+ if ($this->_validateUserId($this->getRequest()->getParam('userid'))) {
29
+
30
+ /* successAction is called twice
31
+ * once by DPS's FailProofNotification
32
+ * and also by the customer when returning
33
+ * DPS has no session
34
+ * only the DPS response is processed to prevent double handling
35
+ */
36
+ $session = Mage::getSingleton('checkout/session');
37
+ if ($session->getLastOrderId()) {
38
+ Mage::log(
39
+ $session->getLastRealOrderId().' MageBaseDps User returned to Success Url',
40
+ null,
41
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
42
+ );
43
+ $result = $this->getRequest()->getParam('result');
44
+ $resultXml = $this->_getRealResponse($result);
45
+ if ($resultXml) {
46
+ if ((int)$resultXml->Success == 1) {
47
+ $session->setLastQuoteId((int)$resultXml->TxnData2)
48
+ ->setLastOrderId(
49
+ Mage::getModel('sales/order')->loadByIncrementId((string)$resultXml->MerchantReference)
50
+ ->getId()
51
+ )
52
+ ->setLastRealOrderId((string)$resultXml->MerchantReference)
53
+ ->setLastSuccessQuoteId((int)$resultXml->TxnData2);
54
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
55
+ } else {
56
+ $this->_redirect('checkout/onepage/failure', array('_secure'=>true));
57
+ }
58
+ } else {
59
+ $session->setLastQuoteId((int)$resultXml->TxnData2)
60
+ ->setLastOrderId(
61
+ Mage::getModel('sales/order')->loadByIncrementId((string)$resultXml->MerchantReference)
62
+ ->getId()
63
+ )
64
+ ->setLastRealOrderId((string)$resultXml->MerchantReference);
65
+ $this->_redirect('checkout/onepage/failure', array('_secure'=>true));
66
+ }
67
+ } else {
68
+ try {
69
+ $result = $this->getRequest()->getParam('result');
70
+ Mage::log(
71
+ 'DPS result from url: '.$result,
72
+ null,
73
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
74
+ );
75
+ if (empty ($result)) {
76
+ throw new Exception(
77
+ "Can't retrieve result from GET variable result. Check your server configuration."
78
+ );
79
+ }
80
+ $resultXml = $this->_processSuccessResponse($this->getRequest()->getParam('result'));
81
+ }catch (Exception $e){
82
+ $resultXml = false;
83
+ Mage::logException($e);
84
+ Mage::log(
85
+ 'MageBaseDps failed with exception - see exception.log',
86
+ null,
87
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
88
+ );
89
+ $this->_redirect('checkout/onepage/failure', array('_secure'=>true));
90
+ }
91
+ $this->_redirect('checkout/onepage/success', array('_secure'=>true));
92
+ }
93
+ } else {
94
+ Mage::log(
95
+ 'MageBaseDps successAction, but wrong PxPayUserId',
96
+ null,
97
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
98
+ );
99
+ $this->_redirect('checkout/onepage/failure', array('_secure'=>true));
100
+ }
101
+ }
102
+
103
+ public function failAction()
104
+ {
105
+ Mage::log(
106
+ 'MageBaseDps failAction',
107
+ null,
108
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
109
+ );
110
+ if (!$this->_validateUserId($this->getRequest()->getParam('userid'))) {
111
+ Mage::log(
112
+ 'MageBaseDps failAction - wrong PxPayUserId',
113
+ null,
114
+ MageBase_DpsPaymentExpress_Model_Method_Pxpay::DPS_LOG_FILENAME
115
+ );
116
+ }
117
+ $resultXml = $this->_processFailResponse($this->getRequest()->getParam('result'));
118
+ if ($session = Mage::getSingleton('checkout/session')) {
119
+ $session->setLastQuoteId((int)$resultXml->TxnData2)
120
+ ->setLastRealOrderId((string)$resultXml->MerchantReference);
121
+ $this->_redirect('checkout/onepage/failure', array('_secure'=>true));
122
+ }
123
+ }
124
+
125
+ private function _getRealResponse($result)
126
+ {
127
+ return Mage::getSingleton('magebasedps/method_pxpay')->getRealResponse($result);
128
+ }
129
+
130
+ private function _processSuccessResponse($result)
131
+ {
132
+ return Mage::getSingleton('magebasedps/method_pxpay')->processSuccessResponse($result);
133
+ }
134
+
135
+ private function _processFailResponse($result)
136
+ {
137
+ return Mage::getSingleton('magebasedps/method_pxpay')->processFailResponse($result);
138
+ }
139
+
140
+ private function _validateUserId($userId)
141
+ {
142
+ return Mage::getSingleton('magebasedps/method_pxpay')->validateUserId($userId);
143
+ }
144
+
145
+ }
app/code/community/MageBase/DpsPaymentExpress/etc/config.xml ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MageBase_DpsPaymentExpress>
5
+ <version>1.0.0</version>
6
+ </MageBase_DpsPaymentExpress>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <magebasedps>
11
+ <class>MageBase_DpsPaymentExpress_Model</class>
12
+ <resourceModel>magebasedps_mysql4</resourceModel>
13
+ </magebasedps>
14
+ <magebasedps_mysql4>
15
+ <class>MageBase_DpsPaymentExpress_Model_Mysql4</class>
16
+ <entities>
17
+ <debug><table>magebasedps_debug</table></debug>
18
+ </entities>
19
+ </magebasedps_mysql4>
20
+ </models>
21
+ <blocks>
22
+ <magebasedps>
23
+ <class>MageBase_DpsPaymentExpress_Block</class>
24
+ </magebasedps>
25
+ </blocks>
26
+ <helpers>
27
+ <magebasedps>
28
+ <class>MageBase_DpsPaymentExpress_Helper</class>
29
+ </magebasedps>
30
+ </helpers>
31
+ <resources>
32
+ <magebasedps_setup>
33
+ <setup>
34
+ <module>MageBase_DpsPaymentExpress</module>
35
+ <class>MageBase_DpsPaymentExpress_Model_Mysql4_Setup</class>
36
+ </setup>
37
+ <connection>
38
+ <use>core_setup</use>
39
+ </connection>
40
+ </magebasedps_setup>
41
+ <magebasedps_write>
42
+ <connection>
43
+ <use>core_write</use>
44
+ </connection>
45
+ </magebasedps_write>
46
+ <magebasedps_read>
47
+ <connection>
48
+ <use>core_read</use>
49
+ </connection>
50
+ </magebasedps_read>
51
+ </resources>
52
+ <sales>
53
+ <order>
54
+ <statuses>
55
+ <pending_dps translate="label"><label>Pending Payment (DPS)</label></pending_dps>
56
+ <processing_dps_auth translate="label"><label>Processing (DPS - Amount authorized)</label></processing_dps_auth>
57
+ <processing_dps_paid translate="label"><label>Processing (DPS - Amount paid)</label></processing_dps_paid>
58
+ </statuses>
59
+ <states>
60
+ <pending_payment>
61
+ <statuses>
62
+ <pending_dps/>
63
+ </statuses>
64
+ </pending_payment>
65
+ <processing>
66
+ <statuses>
67
+ <processing_dps_auth/>
68
+ <processing_dps_paid/>
69
+ </statuses>
70
+ </processing>
71
+ </states>
72
+ </order>
73
+ </sales>
74
+ </global>
75
+ <frontend>
76
+ <routers>
77
+ <magebasedps>
78
+ <use>standard</use>
79
+ <args>
80
+ <module>MageBase_DpsPaymentExpress</module>
81
+ <frontName>magebasedps</frontName>
82
+ </args>
83
+ </magebasedps>
84
+ </routers>
85
+ </frontend>
86
+ <default>
87
+ <payment>
88
+ <magebasedpspxpost>
89
+ <active>0</active>
90
+ <postusername/>
91
+ <postpassword/>
92
+ <cctypes>VI,MC</cctypes>
93
+ <model>magebasedps/method_pxpost</model>
94
+ <payment_action>authorize_capture</payment_action>
95
+ <order_status>processing</order_status>
96
+ <title>Credit Card (DPS PxPost)</title>
97
+ <display_logos/>
98
+ <allowspecific>0</allowspecific>
99
+ <min_order_total>0</min_order_total>
100
+ <max_order_total>0</max_order_total>
101
+ <sort_order>1</sort_order>
102
+ <debug>0</debug>
103
+ </magebasedpspxpost>
104
+ <magebasedpspxpay>
105
+ <active>0</active>
106
+ <model>magebasedps/method_pxpay</model>
107
+ <pxpayuserid/>
108
+ <pxpaykey/>
109
+ <payment_action>authorize_capture</payment_action>
110
+ <unpaid_order_status>pending_dps</unpaid_order_status>
111
+ <order_status>processing</order_status>
112
+ <title>Credit Card (DPS PxPay)</title>
113
+ <display_logos/>
114
+ <allowspecific>0</allowspecific>
115
+ <min_order_total>0</min_order_total>
116
+ <max_order_total>0</max_order_total>
117
+ <sort_order>1</sort_order>
118
+ <debug>0</debug>
119
+ </magebasedpspxpay>
120
+ </payment>
121
+ </default>
122
+ </config>
app/code/community/MageBase/DpsPaymentExpress/etc/system.xml ADDED
@@ -0,0 +1,282 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <magebasedpspxpost translate="label" module="magebasedps">
7
+ <label>DPS PxPost by MageBase</label>
8
+ <frontend_type>text</frontend_type>
9
+ <sort_order>50</sort_order>
10
+ <show_in_default>1</show_in_default>
11
+ <show_in_website>1</show_in_website>
12
+ <show_in_store>1</show_in_store>
13
+ <fields>
14
+ <active translate="label">
15
+ <label>Enabled</label>
16
+ <frontend_type>select</frontend_type>
17
+ <source_model>adminhtml/system_config_source_yesno</source_model>
18
+ <sort_order>1</sort_order>
19
+ <show_in_default>1</show_in_default>
20
+ <show_in_website>1</show_in_website>
21
+ <show_in_store>0</show_in_store>
22
+ </active>
23
+ <title translate="label">
24
+ <label>Title</label>
25
+ <frontend_type>text</frontend_type>
26
+ <sort_order>3</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>1</show_in_store>
30
+ </title>
31
+ <cctypes translate="label">
32
+ <label>Credit Card Types</label>
33
+ <frontend_type>multiselect</frontend_type>
34
+ <source_model>adminhtml/system_config_source_payment_cctype</source_model>
35
+ <sort_order>5</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>0</show_in_store>
39
+ <can_be_empty>1</can_be_empty>
40
+ </cctypes>
41
+ <postusername translate="label">
42
+ <label>PostUsername</label>
43
+ <frontend_type>text</frontend_type>
44
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
45
+ <sort_order>6</sort_order>
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </postusername>
50
+ <postpassword translate="label">
51
+ <label>PostPassword</label>
52
+ <frontend_type>text</frontend_type>
53
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
54
+ <sort_order>7</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </postpassword>
59
+ <payment_action translate="label">
60
+ <label>Payment Action</label>
61
+ <frontend_type>select</frontend_type>
62
+ <source_model>magebasedps/system_paymentAction</source_model>
63
+ <sort_order>8</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>0</show_in_store>
67
+ </payment_action>
68
+ <order_status translate="label">
69
+ <label>New order status</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
72
+ <sort_order>10</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </order_status>
77
+ <display_logos translate="label">
78
+ <label>Logos to display</label>
79
+ <comment>Displayed during checkout.</comment>
80
+ <frontend_type>multiselect</frontend_type>
81
+ <source_model>magebasedps/system_logos</source_model>
82
+ <sort_order>20</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
+ </display_logos>
87
+ <allowspecific translate="label">
88
+ <label>Payment from applicable countries</label>
89
+ <frontend_type>allowspecific</frontend_type>
90
+ <sort_order>50</sort_order>
91
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
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
+ </allowspecific>
96
+ <specificcountry translate="label">
97
+ <label>Payment from Specific countries</label>
98
+ <frontend_type>multiselect</frontend_type>
99
+ <sort_order>51</sort_order>
100
+ <source_model>adminhtml/system_config_source_country</source_model>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>0</show_in_store>
104
+ <can_be_empty>1</can_be_empty>
105
+ </specificcountry>
106
+ <min_order_total translate="label">
107
+ <label>Minimum Order Total</label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>98</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>0</show_in_store>
113
+ </min_order_total>
114
+ <max_order_total translate="label">
115
+ <label>Maximum Order Total</label>
116
+ <frontend_type>text</frontend_type>
117
+ <sort_order>99</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>0</show_in_store>
121
+ </max_order_total>
122
+ <sort_order translate="label">
123
+ <label>Sort order</label>
124
+ <frontend_type>text</frontend_type>
125
+ <sort_order>100</sort_order>
126
+ <show_in_default>1</show_in_default>
127
+ <show_in_website>1</show_in_website>
128
+ <show_in_store>0</show_in_store>
129
+ </sort_order>
130
+ <debug translate="label">
131
+ <label>Enable Logging/Debug</label>
132
+ <frontend_type>select</frontend_type>
133
+ <source_model>adminhtml/system_config_source_yesno</source_model>
134
+ <comment>Log all request and responses to the database</comment>
135
+ <sort_order>110</sort_order>
136
+ <show_in_default>1</show_in_default>
137
+ <show_in_website>1</show_in_website>
138
+ <show_in_store>0</show_in_store>
139
+ </debug>
140
+ </fields>
141
+ </magebasedpspxpost>
142
+ <magebasedpspxpay translate="label" module="magebasedps">
143
+ <label>DPS PxPay by MageBase</label>
144
+ <frontend_type>text</frontend_type>
145
+ <sort_order>50</sort_order>
146
+ <show_in_default>1</show_in_default>
147
+ <show_in_website>1</show_in_website>
148
+ <show_in_store>1</show_in_store>
149
+ <fields>
150
+ <active translate="label">
151
+ <label>Enabled</label>
152
+ <frontend_type>select</frontend_type>
153
+ <source_model>adminhtml/system_config_source_yesno</source_model>
154
+ <sort_order>1</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ </active>
159
+ <title translate="label">
160
+ <label>Title</label>
161
+ <frontend_type>text</frontend_type>
162
+ <sort_order>5</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>1</show_in_store>
166
+ </title>
167
+ <pxpayuserid translate="label">
168
+ <label>PxPayUserId</label>
169
+ <frontend_type>text</frontend_type>
170
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
171
+ <sort_order>6</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>1</show_in_store>
175
+ </pxpayuserid>
176
+ <pxpaykey translate="label">
177
+ <label>PxPayKey</label>
178
+ <frontend_type>text</frontend_type>
179
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
180
+ <sort_order>7</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>1</show_in_store>
184
+ </pxpaykey>
185
+ <payment_action translate="label">
186
+ <label>Payment Action</label>
187
+ <frontend_type>select</frontend_type>
188
+ <source_model>magebasedps/system_paymentAction</source_model>
189
+ <sort_order>8</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ </payment_action>
194
+ <unpaid_order_status translate="label">
195
+ <label>Unpaid order status</label>
196
+ <frontend_type>select</frontend_type>
197
+ <comment>Status before payment is received</comment>
198
+ <source_model>magebasedps/system_pendingOrder</source_model>
199
+ <sort_order>10</sort_order>
200
+ <show_in_default>1</show_in_default>
201
+ <show_in_website>1</show_in_website>
202
+ <show_in_store>0</show_in_store>
203
+ </unpaid_order_status>
204
+ <order_status translate="label">
205
+ <label>New order status</label>
206
+ <frontend_type>select</frontend_type>
207
+ <comment>Status after receiving a positive response from DPS</comment>
208
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
209
+ <sort_order>12</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>0</show_in_store>
213
+ </order_status>
214
+ <display_logos translate="label">
215
+ <label>Logos to display</label>
216
+ <comment>Displayed during checkout.</comment>
217
+ <frontend_type>multiselect</frontend_type>
218
+ <source_model>magebasedps/system_logos</source_model>
219
+ <sort_order>20</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>1</show_in_website>
222
+ <show_in_store>0</show_in_store>
223
+ </display_logos>
224
+ <allowspecific translate="label">
225
+ <label>Payment from applicable countries</label>
226
+ <frontend_type>allowspecific</frontend_type>
227
+ <sort_order>50</sort_order>
228
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>1</show_in_website>
231
+ <show_in_store>0</show_in_store>
232
+ </allowspecific>
233
+ <specificcountry translate="label">
234
+ <label>Payment from Specific countries</label>
235
+ <frontend_type>multiselect</frontend_type>
236
+ <sort_order>51</sort_order>
237
+ <source_model>adminhtml/system_config_source_country</source_model>
238
+ <show_in_default>1</show_in_default>
239
+ <show_in_website>1</show_in_website>
240
+ <show_in_store>0</show_in_store>
241
+ <can_be_empty>1</can_be_empty>
242
+ </specificcountry>
243
+ <min_order_total translate="label">
244
+ <label>Minimum Order Total</label>
245
+ <frontend_type>text</frontend_type>
246
+ <sort_order>98</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ </min_order_total>
251
+ <max_order_total translate="label">
252
+ <label>Maximum Order Total</label>
253
+ <frontend_type>text</frontend_type>
254
+ <sort_order>99</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>0</show_in_store>
258
+ </max_order_total>
259
+ <sort_order translate="label">
260
+ <label>Sort order</label>
261
+ <frontend_type>text</frontend_type>
262
+ <sort_order>100</sort_order>
263
+ <show_in_default>1</show_in_default>
264
+ <show_in_website>1</show_in_website>
265
+ <show_in_store>0</show_in_store>
266
+ </sort_order>
267
+ <debug translate="label">
268
+ <label>Enable Logging/Debug</label>
269
+ <frontend_type>select</frontend_type>
270
+ <source_model>adminhtml/system_config_source_yesno</source_model>
271
+ <comment>Log all request and responses to the database</comment>
272
+ <sort_order>110</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>0</show_in_store>
276
+ </debug>
277
+ </fields>
278
+ </magebasedpspxpay>
279
+ </groups>
280
+ </payment>
281
+ </sections>
282
+ </config>
app/code/community/MageBase/DpsPaymentExpress/sql/magebasedps_setup/mysql4-install-0.5.0.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ $installer = $this;
24
+ /* @var $installer MageBase_DpsPaymentExpress_Model_Mysql4_Setup */
25
+
26
+ $installer->startSetup();
27
+
28
+ $installer->run(
29
+ "
30
+ -- DROP TABLE IF EXISTS `{$this->getTable('magebasedps_debug')}`;
31
+ CREATE TABLE `{$this->getTable('magebasedps_debug')}` (
32
+ `debug_id` int(10) unsigned NOT NULL auto_increment,
33
+ `debug_at` timestamp NOT NULL default CURRENT_TIMESTAMP on update CURRENT_TIMESTAMP,
34
+ `request_body` text,
35
+ `response_body` text,
36
+ PRIMARY KEY (`debug_id`),
37
+ KEY `debug_at` (`debug_at`)
38
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
39
+ "
40
+ );
41
+
42
+ $installer->endSetup();
app/code/community/MageBase/DpsPaymentExpress/sql/magebasedps_setup/mysql4-upgrade-0.5.0-1.0.0.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * MageBase DPS Payment Express
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 Magento 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 MageBase
16
+ * @package MageBase_DpsPaymentExpress
17
+ * @author Kristof Ringleff
18
+ * @copyright Copyright (c) 2010 MageBase (http://www.magebase.com)
19
+ * @copyright Copyright (c) 2010 Fooman Ltd (http://www.fooman.co.nz)
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ $installer = $this;
24
+ /* @var $installer MageBase_DpsPaymentExpress_Model_Mysql4_Setup */
25
+
26
+ $installer->startSetup();
27
+
28
+ $installer->endSetup();
app/etc/modules/MageBase_DpsPaymentExpress.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <MageBase_DpsPaymentExpress>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </MageBase_DpsPaymentExpress>
8
+ </modules>
9
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>MageBase_DpsPaymentExpress</name>
4
+ <version>1.0.0</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>Accept credit card payments via Payment Express from DPS - this extension supports PxPay and PxPost.</summary>
10
+ <description>Accept credit card payments via Payment Express from DPS - this extension supports PxPay and PxPost.</description>
11
+ <notes>First stable release</notes>
12
+ <authors><author><name>Kristof Ringleff</name><user>auto-converted</user><email>info@magebase.com</email></author></authors>
13
+ <date>2010-06-24</date>
14
+ <time>04:39:14</time>
15
+ <contents><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="MageBase_DpsPaymentExpress.xml" hash="fae6ba260c006016d14d9a508d17cf14"/></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="images"><dir name="magebase"><dir name="dps"><file name="AmexLogo.png" hash="775a3f26a4b5f7a6201b1331e4fe5579"/><file name="DinersLogo.png" hash="64500fdde86e960ac894f7cf0c44b2d8"/><file name="dpslogo.png" hash="8cc607a6a0bb32cea44d71fdc6086970"/><file name="dpspxlogo.png" hash="2f4e2d293b1e67f4a380f034bb49c788"/><file name="JCBLogo.png" hash="73f9e8b87c6c2dbf252bbb0de43591bc"/><file name="MasterCardLogo.png" hash="801014f81e405cec951076f4080b04f5"/><file name="MCSecureCodeLogo.png" hash="9f31e5ccadd98dc15d0110d0e3b450f7"/><file name="VisaLogo.png" hash="17173fb8723d34cea61a50c01c4845ed"/><file name="VisaVerifiedLogo.png" hash="af7f6a27a6449a50d1d623d925585c47"/></dir></dir></dir></dir></dir></dir></target><target name="magecommunity"><dir name="MageBase"><dir name="DpsPaymentExpress"><dir name="Block"><dir name="Form"><file name="Pxpay.php" hash="cfee1e51334484335b8f4b6640a502c6"/><file name="Pxpost.php" hash="d16ec81082d5a3c3f7a9f0ec017c1138"/></dir><dir name="Info"><file name="Pxpay.php" hash="9807aac8b02f40efa157c0afceb54438"/><file name="Pxpost.php" hash="cca613e91361f3411e4bcd56bc02b56f"/></dir><dir name="Pxpay"><file name="Form.php" hash="0513bd45150f03dab2c2b08dc0456de8"/><file name="Info.php" hash="68328c0824a4666c618cf3742dd4baff"/><file name="Redirect.php" hash="6b14c55b1f8aa8361891e7816bcb95b8"/></dir><dir name="Pxpost"><file name="Form.php" hash="48cda517e5c97bf8b031d195b79d76f9"/><file name="Info.php" hash="498c831213c26a78c12e28203273e937"/></dir></dir><dir name="controllers"><file name="PxpayController.php" hash="3cbf83bd7bc38dcea6667be113f814f7"/></dir><dir name="etc"><file name="config.xml" hash="99922fd81fcb25a2af0ad4347e1fb7e3"/><file name="system.xml" hash="87051f2d48e3720938b28142e7f37bb1"/></dir><dir name="Helper"><file name="Data.php" hash="0eea8b0b6d3c48e7e64666d4576d9a30"/></dir><dir name="Model"><dir name="Method"><file name="Common.php" hash="1261a0121dff3725f85d9a7c955ada7c"/><file name="Pxpay.php" hash="f37760308de4eeb065dc1a870fb00cbb"/><file name="Pxpost.php" hash="238fad0dbacddb9420131907385eb9e8"/></dir><dir name="Mysql4"><dir name="Debug"><file name="Collection.php" hash="6ef2919222f3dcb32599349245e76214"/></dir><file name="Debug.php" hash="56eb2bc341b9cb4ba8d9ae239169766e"/><file name="Setup.php" hash="8a395090a44fda7530548abd2d87835e"/></dir><dir name="System"><file name="Logos.php" hash="bfca463fa7d292fbd2b69a33d332d55a"/><file name="PaymentAction.php" hash="0be4f9a5c602b2d2723203ec56f51a8c"/><file name="PendingOrder.php" hash="31d7bd6f5fad8e1fa4315d32d123be0f"/></dir><file name="Debug.php" hash="dadf96f68c9cf4d09aad73ff0bacab0e"/></dir><dir name="sql"><dir name="magebasedps_setup"><file name="mysql4-install-0.5.0.php" hash="c512ded8c0dd63b1dcd8e8cbfb5893e8"/><file name="mysql4-upgrade-0.5.0-1.0.0.php" hash="6dbc67541449a0f2d43460acb9b6bbff"/></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies/>
18
+ </package>
skin/frontend/default/default/images/magebase/dps/AmexLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/DinersLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/JCBLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/MCSecureCodeLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/MasterCardLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/VisaLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/VisaVerifiedLogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/dpslogo.png ADDED
Binary file
skin/frontend/default/default/images/magebase/dps/dpspxlogo.png ADDED
Binary file