UnionPay - Version 1.0.18

Version Notes

To Create Order Object In magneto After Gateway Approval

Download this release

Release Info

Developer mohd shamim
Extension UnionPay
Version 1.0.18
Comparing to
See all releases


Version 1.0.18

Files changed (82) hide show
  1. app/code/community/PlanetPayment/Upop/Block/Adminhtml/Checkout/Upop.php +42 -0
  2. app/code/community/PlanetPayment/Upop/Block/Adminhtml/Customer/Edit/Tab/Upop.php +77 -0
  3. app/code/community/PlanetPayment/Upop/Block/Adminhtml/Customer/Edit/Tabs.php +46 -0
  4. app/code/community/PlanetPayment/Upop/Block/Adminhtml/Payment/Form.php +32 -0
  5. app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Export.php +52 -0
  6. app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Purge.php +54 -0
  7. app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Test.php +54 -0
  8. app/code/community/PlanetPayment/Upop/Block/Checkout/.DS_Store +0 -0
  9. app/code/community/PlanetPayment/Upop/Block/Checkout/Cart/Totals.php +78 -0
  10. app/code/community/PlanetPayment/Upop/Block/Onepage.php +50 -0
  11. app/code/community/PlanetPayment/Upop/Block/Onepage/Upop.php +59 -0
  12. app/code/community/PlanetPayment/Upop/Block/Payment/Form.php +62 -0
  13. app/code/community/PlanetPayment/Upop/Block/Payment/Info.php +36 -0
  14. app/code/community/PlanetPayment/Upop/Block/Sales/Order/Totals.php +135 -0
  15. app/code/community/PlanetPayment/Upop/Helper/Data.php +128 -0
  16. app/code/community/PlanetPayment/Upop/Helper/Error.php +160 -0
  17. app/code/community/PlanetPayment/Upop/Model/Checkout.php +307 -0
  18. app/code/community/PlanetPayment/Upop/Model/Currency/Import/Upop.php +84 -0
  19. app/code/community/PlanetPayment/Upop/Model/CurrencyCode.php +36 -0
  20. app/code/community/PlanetPayment/Upop/Model/Log.php +36 -0
  21. app/code/community/PlanetPayment/Upop/Model/Observer.php +54 -0
  22. app/code/community/PlanetPayment/Upop/Model/Observer/Abstract.php +62 -0
  23. app/code/community/PlanetPayment/Upop/Model/Observer/Checkout.php +41 -0
  24. app/code/community/PlanetPayment/Upop/Model/Observer/Log.php +46 -0
  25. app/code/community/PlanetPayment/Upop/Model/Profile.php +174 -0
  26. app/code/community/PlanetPayment/Upop/Model/Resource/CurrencyCode.php +35 -0
  27. app/code/community/PlanetPayment/Upop/Model/Resource/CurrencyCode/Collection.php +36 -0
  28. app/code/community/PlanetPayment/Upop/Model/Resource/Log.php +35 -0
  29. app/code/community/PlanetPayment/Upop/Model/Resource/Log/Collection.php +36 -0
  30. app/code/community/PlanetPayment/Upop/Model/Resource/Profile.php +35 -0
  31. app/code/community/PlanetPayment/Upop/Model/Resource/Profile/Collection.php +41 -0
  32. app/code/community/PlanetPayment/Upop/Model/Session.php +21 -0
  33. app/code/community/PlanetPayment/Upop/Model/System/Config/General/Encryption.php +40 -0
  34. app/code/community/PlanetPayment/Upop/Model/System/Config/General/Mode.php +44 -0
  35. app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Cctype.php +76 -0
  36. app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Currency.php +52 -0
  37. app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/PaymentAction.php +44 -0
  38. app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Service.php +43 -0
  39. app/code/community/PlanetPayment/Upop/Model/System/Config/Source/Enabledisable.php +24 -0
  40. app/code/community/PlanetPayment/Upop/Model/Type/Onepage.php +59 -0
  41. app/code/community/PlanetPayment/Upop/Model/Upop.php +839 -0
  42. app/code/community/PlanetPayment/Upop/Model/Xml/Abstract.php +186 -0
  43. app/code/community/PlanetPayment/Upop/Model/Xml/Request.php +1165 -0
  44. app/code/community/PlanetPayment/Upop/Model/Xml/Response.php +123 -0
  45. app/code/community/PlanetPayment/Upop/controllers/Adminhtml/CheckoutController.php +111 -0
  46. app/code/community/PlanetPayment/Upop/controllers/Adminhtml/CustomerController.php +110 -0
  47. app/code/community/PlanetPayment/Upop/controllers/Adminhtml/OrderController.php +61 -0
  48. app/code/community/PlanetPayment/Upop/controllers/Adminhtml/SystemController.php +88 -0
  49. app/code/community/PlanetPayment/Upop/controllers/IndexController.php +231 -0
  50. app/code/community/PlanetPayment/Upop/controllers/OnepageController.php +131 -0
  51. app/code/community/PlanetPayment/Upop/controllers/ProfileController.php +192 -0
  52. app/code/community/PlanetPayment/Upop/data/upop_setup/data-install-1.0.0.php +252 -0
  53. app/code/community/PlanetPayment/Upop/data/upop_setup/data-install-1.0.1.php +22 -0
  54. app/code/community/PlanetPayment/Upop/data/upop_setup/data-upgrade-1.0.4-1.0.5.php +243 -0
  55. app/code/community/PlanetPayment/Upop/etc/adminhtml.xml +50 -0
  56. app/code/community/PlanetPayment/Upop/etc/config.xml +248 -0
  57. app/code/community/PlanetPayment/Upop/etc/system.xml +344 -0
  58. app/code/community/PlanetPayment/Upop/sql/upop_setup/install-1.0.0.php +38 -0
  59. app/code/community/PlanetPayment/Upop/sql/upop_setup/install-1.0.1.php +40 -0
  60. app/code/community/PlanetPayment/Upop/sql/upop_setup/install-2.0.1.php +21 -0
  61. app/code/community/PlanetPayment/Upop/sql/upop_setup/upgrade-1.0.13-1.0.17.php +9 -0
  62. app/code/community/PlanetPayment/Upop/sql/upop_setup/upgrade-1.0.17-1.0.18.php +10 -0
  63. app/design/adminhtml/default/default/layout/upop.xml +4 -0
  64. app/design/adminhtml/default/default/template/upop/.DS_Store +0 -0
  65. app/design/adminhtml/default/default/template/upop/checkout/currency_selector.phtml +65 -0
  66. app/design/adminhtml/default/default/template/upop/customer/.DS_Store +0 -0
  67. app/design/adminhtml/default/default/template/upop/customer/tab/upop.phtml +58 -0
  68. app/design/adminhtml/default/default/template/upop/payment/form.phtml +29 -0
  69. app/design/adminhtml/default/default/template/upop/payment/info.phtml +31 -0
  70. app/design/adminhtml/default/default/template/upop/system/.DS_Store +0 -0
  71. app/design/adminhtml/default/default/template/upop/system/config/export.phtml +43 -0
  72. app/design/adminhtml/default/default/template/upop/system/config/purge.phtml +44 -0
  73. app/design/adminhtml/default/default/template/upop/system/config/test.phtml +42 -0
  74. app/design/frontend/base/default/layout/upop.xml +4 -0
  75. app/design/frontend/base/default/template/upop/checkout/onepage/currency_selector.phtml +139 -0
  76. app/design/frontend/base/default/template/upop/payment/form.phtml +32 -0
  77. app/design/frontend/base/default/template/upop/payment/info.phtml +31 -0
  78. app/design/frontend/base/default/template/upop/payment/mark.phtml +32 -0
  79. app/etc/modules/PlanetPayment_Upop.xml +15 -0
  80. app/locale/zh_CN/PlanetPayment_Upop.csv +1 -0
  81. package.xml +18 -0
  82. skin/adminhtml/default/default/js/upop/upop.js +62 -0
app/code/community/PlanetPayment/Upop/Block/Adminhtml/Checkout/Upop.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Block_Adminhtml_Checkout_Upop extends Mage_Adminhtml_Block_Template {
29
+
30
+ public function getCurrencyOptions() {
31
+ return $this->getResponse()->getPycCurrencyOptions();
32
+ }
33
+
34
+ public function hasOptions() {
35
+ if ($this->getResponse()) {
36
+ return true;
37
+ }
38
+
39
+ return false;
40
+ }
41
+
42
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/Customer/Edit/Tab/Upop.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Block_Adminhtml_Customer_Edit_Tab_Upop extends Mage_Adminhtml_Block_Template {
29
+
30
+ protected function _construct() {
31
+ parent::_construct();
32
+ $this->setTemplate('upop/customer/tab/upop.phtml');
33
+ }
34
+
35
+ /**
36
+ * Returns the registry customer.
37
+ *
38
+ * @return Mage_Customer_Model_Customer
39
+ */
40
+ public function getCustomer() {
41
+ return Mage::registry('current_customer');
42
+ }
43
+
44
+ /**
45
+ * Returns a collection of payment profiles for the registry customer.
46
+ *
47
+ * @return PlanetPayment_Upop_Model_Resource_PaymentProfile_Collection
48
+ */
49
+ // public function getCimPaymentProfiles() {
50
+ // return Mage::getModel('upop/profile')->getCollection()
51
+ // ->addCustomerFilter($this->getCustomer());
52
+ // }
53
+
54
+ /**
55
+ * URL to create/recreate Upop profile.
56
+ *
57
+ * @return string
58
+ */
59
+ public function getCimRegisterUrl() {
60
+ return $this->getUrl('upopadmin/adminhtml_customer/register', array('customer_id' => $this->getCustomer()->getId()));
61
+ }
62
+
63
+ /**
64
+ * URL to delete a Upop payment profile.
65
+ *
66
+ * @param PlanetPayment_Upop_Model_PaymentProfile $profile
67
+ * @return string
68
+ */
69
+ public function getUpopProfileDeleteUrl(PlanetPayment_Upop_Model_Profile $profile) {
70
+ $params = array(
71
+ 'customer_id' => $this->getCustomer()->getId(),
72
+ 'profile_id' => $profile->getId()
73
+ );
74
+ return $this->getUrl('upopadmin/adminhtml_customer/deletePaymentProfile', $params);
75
+ }
76
+
77
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/Customer/Edit/Tabs.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Block_Adminhtml_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Customer_Edit_Tabs {
29
+
30
+ /**
31
+ * Insert the CIM tab.
32
+ *
33
+ * @return PlanetPayment_Upop_Block_Adminhtml_Customer_Edit_Tabs
34
+ */
35
+ protected function _beforeToHtml() {
36
+ if (Mage::registry('current_customer')->getId() && Mage::getStoreConfig('payment/upop/tokenize')) {
37
+ $this->addTab('upop', array(
38
+ 'label' => Mage::helper('upop')->__('Planet Payment'),
39
+ 'content' => $this->getLayout()->createBlock('upop/adminhtml_customer_edit_tab_upop')->toHtml(),
40
+ 'after' => 'tags'
41
+ ));
42
+ }
43
+ return parent::_beforeToHtml();
44
+ }
45
+
46
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/Payment/Form.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+
29
+ class PlanetPayment_Upop_Block_Adminhtml_Payment_Form extends PlanetPayment_Upop_Block_Payment_Form {
30
+
31
+
32
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Export.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ /**
21
+ * Planet Payment
22
+ *
23
+ * @category PlanetPayment
24
+ * @package PlanetPayment_Upop
25
+ * @author One Pica Codemaster <codemaster@onepica.com>
26
+ */
27
+ class PlanetPayment_Upop_Block_Adminhtml_System_Config_Export extends Mage_Adminhtml_Block_System_Config_Form_Field {
28
+
29
+ protected function _construct() {
30
+ parent::_construct();
31
+ $this->setTemplate('upop/system/config/export.phtml');
32
+ }
33
+
34
+ /**
35
+ * @return string
36
+ */
37
+ public function getExportUrl() {
38
+ return $this->getUrl('upop/adminhtml_system/export');
39
+ }
40
+
41
+ /**
42
+ * Get the button and scripts contents
43
+ *
44
+ * @param Varien_Data_Form_Element_Abstract $element
45
+ * @return string
46
+ */
47
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
48
+ $this->setElement($element);
49
+ return $this->_toHtml();
50
+ }
51
+
52
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Purge.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Adminhtml_System_Config_Purge extends Mage_Adminhtml_Block_System_Config_Form_Field {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('upop/system/config/purge.phtml');
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getPurgeUrl() {
40
+ return $this->getUrl('upop/adminhtml_system/purge');
41
+ }
42
+
43
+ /**
44
+ * Get the button and scripts contents
45
+ *
46
+ * @param Varien_Data_Form_Element_Abstract $element
47
+ * @return string
48
+ */
49
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
50
+ $this->setElement($element);
51
+ return $this->_toHtml();
52
+ }
53
+
54
+ }
app/code/community/PlanetPayment/Upop/Block/Adminhtml/System/Config/Test.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Adminhtml_System_Config_Test extends Mage_Adminhtml_Block_System_Config_Form_Field {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('upop/system/config/test.phtml');
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getTestUrl() {
40
+ return $this->getUrl('upop/adminhtml_system/test');
41
+ }
42
+
43
+ /**
44
+ * Get the button and scripts contents
45
+ *
46
+ * @param Varien_Data_Form_Element_Abstract $element
47
+ * @return string
48
+ */
49
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
50
+ $this->setElement($element);
51
+ return $this->_toHtml();
52
+ }
53
+
54
+ }
app/code/community/PlanetPayment/Upop/Block/Checkout/.DS_Store ADDED
Binary file
app/code/community/PlanetPayment/Upop/Block/Checkout/Cart/Totals.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Checkout_Cart_Totals extends Mage_Checkout_Block_Cart_Totals {
30
+
31
+ /**
32
+ * Check if we have display grand total in base currency
33
+ *
34
+ * @return bool
35
+ */
36
+ public function needDisplayBaseGrandtotal() {
37
+ $quote = $this->getQuote();
38
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode() ||
39
+ ($this->_isPyc() && $quote->getQuoteCurrencyCode() != $quote->getPayment()->getUpopCurrencyCode())) {
40
+ return true;
41
+ }
42
+ return false;
43
+ }
44
+
45
+ /**
46
+ * Get formated in base currency base grand total value
47
+ *
48
+ * @return string
49
+ */
50
+ public function displayBaseGrandtotal() {
51
+ $firstTotal = reset($this->_totals);
52
+ if ($firstTotal) {
53
+ $quote = $this->getQuote();
54
+ $exchangeRate = $quote->getUpopExchangeRate();
55
+ if ($this->_isPyc() && $exchangeRate) {
56
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
57
+ $currency = Mage::app()->getLocale()->currency($quote->getPayment()->getUpopCurrencyCode())->getSymbol() . " " . number_format($total * $exchangeRate, 2);
58
+ } elseif ($this->_isMcp()) {
59
+ $total = $firstTotal->getAddress()->getGrandTotal();
60
+ $currency = Mage::app()->getStore()->getCurrentCurrency()->format($total, array(), true);
61
+ } else {
62
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
63
+ $currency = Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
64
+ }
65
+ return $currency;
66
+ }
67
+ return '-';
68
+ }
69
+
70
+ protected function _isPyc() {
71
+ return Mage::getmodel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC;
72
+ }
73
+
74
+ protected function _isMcp() {
75
+ return Mage::getmodel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP;
76
+ }
77
+
78
+ }
app/code/community/PlanetPayment/Upop/Block/Onepage.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ /**
21
+ * Planet Payment
22
+ *
23
+ * @category PlanetPayment
24
+ * @package PlanetPayment_Upop
25
+ * @author One Pica Codemaster <codemaster@onepica.com>
26
+ */
27
+
28
+ class PlanetPayment_Upop_Block_Onepage extends Mage_Checkout_Block_Onepage
29
+ {
30
+ public function getSteps()
31
+ {
32
+ $steps = array();
33
+
34
+ if (!$this->isCustomerLoggedIn()) {
35
+ $steps['login'] = $this->getCheckout()->getStepData('login');
36
+ }
37
+
38
+ $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'review');
39
+
40
+ if (Mage::helper('core')->isModuleEnabled('PlanetPayment_IpayGateway')) {
41
+ $stepCodes = array('billing', 'shipping', 'shipping_method', 'payment', 'currency_selector', 'review');
42
+ }
43
+
44
+ foreach ($stepCodes as $step) {
45
+ $steps[$step] = $this->getCheckout()->getStepData($step);
46
+ }
47
+
48
+ return $steps;
49
+ }
50
+ }
app/code/community/PlanetPayment/Upop/Block/Onepage/Upop.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Onepage_Upop extends Mage_Checkout_Block_Onepage_Abstract {
30
+
31
+ protected function _construct() {
32
+
33
+ if (Mage::helper('core')->isModuleEnabled('PlanetPayment_IpayGateway')) {
34
+ $this->getCheckout()->setStepData('currency_selector', array(
35
+ 'label' => Mage::helper('upop')->__('Payment Currency (Planet Payment)'),
36
+ 'is_show' => true
37
+ ));
38
+ }
39
+
40
+ parent::_construct();
41
+ }
42
+
43
+ public function getExchangeRate() {
44
+ return $this->getResponse()->getExchangeRate();
45
+ }
46
+
47
+ public function getMarkUp() {
48
+ return $this->getResponse()->getMarkUp();
49
+ }
50
+
51
+ public function hasOptions() {
52
+ if ($this->getResponse()) {
53
+ return true;
54
+ }
55
+
56
+ return false;
57
+ }
58
+
59
+ }
app/code/community/PlanetPayment/Upop/Block/Payment/Form.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Payment_Form extends Mage_Payment_Block_Form_Cc {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+
34
+ $mark = Mage::getConfig()->getBlockClassName('core/template');
35
+ $mark = new $mark;
36
+ $mark->setTemplate('upop/payment/mark.phtml')
37
+ ->setPaymentAcceptanceMarkSrc('http://en.unionpay.com//images/english/logo.jpg');
38
+
39
+ $this->setTemplate('upop/payment/form.phtml')
40
+ ->setMethodLabelAfterHtml($mark->toHtml());
41
+
42
+ }
43
+
44
+ /**
45
+ * Returns true if it's guest checkout.
46
+ *
47
+ * @return bool
48
+ */
49
+ public function isGuestCheckout() {
50
+ return Mage::helper('upop')->isGuestCheckout();
51
+ }
52
+
53
+ /**
54
+ * Returns the logged in user.
55
+ *
56
+ * @return Mage_Customer_Model_Customer
57
+ */
58
+ public function getCustomer() {
59
+ return Mage::helper('upop')->getCustomer();
60
+ }
61
+
62
+ }
app/code/community/PlanetPayment/Upop/Block/Payment/Info.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Payment_Info extends Mage_Payment_Block_Info_Cc {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('upop/payment/info.phtml');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/Upop/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals {
30
+
31
+ /**
32
+ * Initialize order totals array
33
+ *
34
+ * @return Mage_Sales_Block_Order_Totals
35
+ */
36
+ protected function _initTotals() {
37
+ $source = $this->getSource();
38
+
39
+ $this->_totals = array();
40
+ $this->_totals['subtotal'] = new Varien_Object(array(
41
+ 'code' => 'subtotal',
42
+ 'value' => $source->getSubtotal(),
43
+ 'label' => $this->__('Subtotal')
44
+ ));
45
+
46
+
47
+ /**
48
+ * Add shipping
49
+ */
50
+ if (!$source->getIsVirtual() && ((float) $source->getShippingAmount() || $source->getShippingDescription())) {
51
+ $this->_totals['shipping'] = new Varien_Object(array(
52
+ 'code' => 'shipping',
53
+ 'field' => 'shipping_amount',
54
+ 'value' => $this->getSource()->getShippingAmount(),
55
+ 'label' => $this->__('Shipping & Handling')
56
+ ));
57
+ }
58
+
59
+ /**
60
+ * Add discount
61
+ */
62
+ if (((float) $this->getSource()->getDiscountAmount()) != 0) {
63
+ if ($this->getSource()->getDiscountDescription()) {
64
+ $discountLabel = $this->__('Discount (%s)', $source->getDiscountDescription());
65
+ } else {
66
+ $discountLabel = $this->__('Discount');
67
+ }
68
+ $this->_totals['discount'] = new Varien_Object(array(
69
+ 'code' => 'discount',
70
+ 'field' => 'discount_amount',
71
+ 'value' => $source->getDiscountAmount(),
72
+ 'label' => $discountLabel
73
+ ));
74
+ }
75
+
76
+ $this->_totals['grand_total'] = new Varien_Object(array(
77
+ 'code' => 'grand_total',
78
+ 'field' => 'grand_total',
79
+ 'strong' => true,
80
+ 'value' => $source->getGrandTotal(),
81
+ 'label' => $this->__('Grand Total')
82
+ ));
83
+
84
+ /**
85
+ * Base grandtotal
86
+ */
87
+ if ($this->needDisplayBaseGrandtotal()) {
88
+ $quoteId = $this->getOrder()->getQuoteId();
89
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
90
+ if($quote->getId()) {
91
+ $exchangeRate = $quote->getUpopExchangeRate();
92
+ if ($this->_isPyc() && $exchangeRate) {
93
+ $total = $source->getBaseGrandTotal();
94
+ $currency = Mage::app()->getLocale()->currency($this->getOrder()->getPayment()->getUpopCurrencyCode())->getSymbol() . " " . number_format($total * $exchangeRate, 2);
95
+ } elseif ($this->_isMcp()) {
96
+ $total = $source->getGrandTotal();
97
+ $currency = Mage::app()->getStore()->getCurrentCurrency()->format($total, array(), true);
98
+ } else {
99
+ $total = $source->getBaseGrandTotal();
100
+ $currency = Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
101
+ }
102
+ $this->_totals['base_grandtotal'] = new Varien_Object(array(
103
+ 'code' => 'base_grandtotal',
104
+ 'value' => $currency,
105
+ 'label' => $this->__('Grand Total to be Charged'),
106
+ 'is_formated' => true,
107
+ ));
108
+ }
109
+ }
110
+ return $this;
111
+ }
112
+
113
+ /**
114
+ * Check if we have display grand total in base currency
115
+ *
116
+ * @return bool
117
+ */
118
+ public function needDisplayBaseGrandtotal() {
119
+ $order = $this->getOrder();
120
+ if ($order->getBaseCurrencyCode() != $order->getQuoteCurrencyCode() ||
121
+ ($this->_isPyc() && $order->getQuoteCurrencyCode() != $order->getPayment()->getUpopCurrencyCode())) {
122
+ return true;
123
+ }
124
+ return false;
125
+ }
126
+
127
+ protected function _isPyc() {
128
+ return Mage::getModel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC;
129
+ }
130
+
131
+ protected function _isMcp() {
132
+ return Mage::getModel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP;
133
+ }
134
+
135
+ }
app/code/community/PlanetPayment/Upop/Helper/Data.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Helper_Data extends Mage_Core_Helper_Abstract {
29
+
30
+ /**
31
+ * Debug log setting from the config.
32
+ *
33
+ * @var bool
34
+ */
35
+ protected $_debugLog = null;
36
+
37
+ /**
38
+ * Logs a debug message to db
39
+ *
40
+ * @param mixed $message
41
+ * @param string $logFile
42
+ */
43
+ public function log($request, $response, $currency= false) {
44
+ $global = Mage::getStoreConfig('planet_payment/upop_logging/mode');
45
+ $method = $this->getConfigData('logging');
46
+ $currencyConvertor = Mage::getStoreConfig('currency/upop/logging');
47
+ $logModel = Mage::getModel('upop/log');
48
+
49
+ if ($global) {
50
+ if (!$currency && $method) {
51
+ $logModel->setRequest($request)
52
+ ->setResponse($response)
53
+ ->save();
54
+ } else if($currency && $currencyConvertor) {
55
+ $logModel->setRequest($request)
56
+ ->setResponse($response)
57
+ ->save();
58
+ }
59
+ }
60
+
61
+ return $logModel;
62
+ }
63
+
64
+ /**
65
+ * Returns data from the store config.
66
+ *
67
+ * @param string $key
68
+ * @return string
69
+ */
70
+ public function getConfigData($key) {
71
+ $path = 'payment/upop/' . $key;
72
+ return Mage::getStoreConfig($path);
73
+ }
74
+
75
+ /**
76
+ * Returns the checkout session.
77
+ *
78
+ * @return Mage_Core_Model_Session_Abstract
79
+ */
80
+ public function getCheckout() {
81
+ if (Mage::app()->getStore()->isAdmin()) {
82
+ return Mage::getSingleton('adminhtml/session_quote');
83
+ } else {
84
+ return Mage::getSingleton('checkout/session');
85
+ }
86
+ }
87
+
88
+ /**
89
+ * Returns the quote.
90
+ *
91
+ * @return Mage_Sales_Model_Quote
92
+ */
93
+ public function getQuote() {
94
+ return $this->getCheckout()->getQuote();
95
+ }
96
+
97
+ /**
98
+ * Returns the logged in user.
99
+ *
100
+ * @return Mage_Customer_Model_Customer
101
+ */
102
+ public function getCustomer() {
103
+ return $this->getQuote()->getCustomer();
104
+ }
105
+
106
+ /**
107
+ * Returns true if it's guest checkout.
108
+ *
109
+ * @return bool
110
+ */
111
+ public function isGuestCheckout() {
112
+ if (Mage::app()->getStore()->isAdmin()) {
113
+ return!$this->getCheckout()->getCustomerId();
114
+ } else {
115
+ return $this->getQuote()->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST;
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Is the payment method enabled?
121
+ *
122
+ * @return bool
123
+ */
124
+ public function isEnabled() {
125
+ return (bool) $this->getConfigData('active');
126
+ }
127
+
128
+ }
app/code/community/PlanetPayment/Upop/Helper/Error.php ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Helper_Error extends Mage_Core_Helper_Abstract {
29
+
30
+ private $__arcs = array(
31
+ 'code' => 'Definition',
32
+ '00' => 'Approval',
33
+ '1' => 'See RESPONSE_TEXT for issuer phone number',
34
+ '2' => 'See RESPONSE_TEXT for issuer phone number',
35
+ '3' => 'Invalid merchant ID',
36
+ '4' => 'Pick up card',
37
+ '05' => 'Do not honor',
38
+ '6' => 'General error',
39
+ '7' => 'Do not honor',
40
+ '8' => 'Honor with customer ID',
41
+ '10' => 'Partial approval for the authorized amount returned',
42
+ '11' => 'VIP approval',
43
+ '12' => 'Invalid transaction',
44
+ '13' => 'Invalid transaction amount',
45
+ '14' => 'Invalid card number',
46
+ '15' => 'No such issuer',
47
+ '17' => 'Customer cancellation',
48
+ '19' => 'Re-enter transaction',
49
+ '21' => 'Unable to back out transaction',
50
+ '25' => 'Unable to locate record in file, or account number is missing from inquiry',
51
+ '27' => 'Issuer File Update field edit error',
52
+ '28' => 'Temporarily unavailable',
53
+ '30' => 'Format error',
54
+ '32' => 'Partial reversal',
55
+ '40' => 'Requested function not supported',
56
+ '41' => 'Pickup card—lost',
57
+ '43' => 'Pickup card—stolen',
58
+ '51' => 'Insufficient funds',
59
+ '52' => 'No checking account',
60
+ '53' => 'No savings account',
61
+ '54' => 'Expired card',
62
+ '55' => 'Incorrect PIN',
63
+ '57' => 'Transaction not permitted—card',
64
+ '58' => 'Transaction not permitted—terminal',
65
+ '59' => 'Suspected fraud',
66
+ '61' => 'Exceeds withdrawal limit',
67
+ '62' => 'Invalid service code, restricted',
68
+ '63' => 'Security violation',
69
+ '65' => 'Activity limit exceeded',
70
+ '68' => 'Response received late',
71
+ '75' => 'PIN tries exceeded',
72
+ '76' => 'Unable to locate',
73
+ '77' => 'Inconsistent data, rev. or repeat',
74
+ '78' => 'No account',
75
+ '79' => 'Already reversed',
76
+ '80' => 'Invalid date',
77
+ '81' => 'Cryptographic error',
78
+ '82' => 'CVV data incorrect',
79
+ '83' => 'Cannot verify PIN',
80
+ '84' => 'Invalid authorization life cycle',
81
+ '85' => 'No reason to decline',
82
+ '86' => 'Cannot verify PIN',
83
+ '87' => 'Network unavailable',
84
+ '91' => 'Issuer unavailable',
85
+ '92' => 'Destination not found',
86
+ '93' => 'Violation, cannot complete',
87
+ '94' => 'Duplicate transmission detected',
88
+ '96' => 'Re-send, system error',
89
+ 'AX' => 'Amount exceeds either the minimum or maximum allowed amount',
90
+ 'B1' => 'Surcharge amount not permitted on Visa cards or EBT food stamps',
91
+ 'ER' => 'Error—see MRC response',
92
+ 'N0' => 'Force STIP',
93
+ 'N3' => 'Cash back service not available',
94
+ 'N4' => 'Exceeds issuer withdrawal limit',
95
+ 'N7' => 'CVV2 value supplied is invalid',
96
+ 'P2' => 'Invalid biller information',
97
+ 'P5' => 'PIN charge/unblock declined',
98
+ 'P6' => 'Unsafe PIN',
99
+ 'Q1' => 'Card authentication failed',
100
+ 'R0' => 'Customer requested stop of specific recurring payment.',
101
+ 'R1' => 'Customer requested stop of all recurring payments from specific merchant.',
102
+ 'R3' => 'Revocation of All Authorizations Order',
103
+ 'SD' => 'Transaction is declined by the Gateway based on merchant’s settings for ACCOUNT_VALIDATION and CONSUMER_VALIDATION',
104
+ 'TO' => 'Re-submit',
105
+ 'XA' => 'Forward to issuer',
106
+ 'XD' => 'Forward to issuer',
107
+ 'Z3' => 'Unable to go online, declined.',);
108
+
109
+ private $__mrcs = array(
110
+ 'Code' => 'Definition',
111
+ '0' => 'Payment server validation approved',
112
+ 'AE' => 'AUTH_EXPIRED authorizations are held for 10 days and then released',
113
+ 'AR' => 'ACCOUNT_NUMBER BIN is not setup to process',
114
+ 'AX' => 'Transaction amount value requirements exceeded, see response text for details',
115
+ 'CD' => 'Commercial data already associated',
116
+ 'CF' => 'Credit refused, must have a relevant sale in order to process credit',
117
+ 'DC' => 'Data conflict',
118
+ 'DF' => 'Data-Frequency mismatch. The combination of fields has violated the Gateway frequency logic.',
119
+ 'DR' => 'Delete refused—data integrity enforcement',
120
+ 'IB' => 'Invalid base64 encoding',
121
+ 'IC' => 'Missing/invalid company key',
122
+ 'ID' => 'Missing/invalid transaction data',
123
+ 'IE' => 'Invalid encryption',
124
+ 'IK' => 'Invalid key (See RESPONSE_TEXT for the invalid key)',
125
+ 'IS' => 'Inactive service',
126
+ 'IT' => 'Invalid XML transmission format',
127
+ 'IX' => 'Invalid XML transaction format',
128
+ 'IY' => 'Invalid type attribute',
129
+ 'IZ' => 'Invalid compression (future use)',
130
+ 'LM' => 'Field LAST_FOUR did not match last four digits of cardholder’s acct. no. contained in TRACK_DATA',
131
+ 'MK' => 'Missing key (See RESPONSE_TEXT for the missing key)',
132
+ 'MY' => 'Missing type attribute',
133
+ 'NF' => 'Transaction not found',
134
+ 'NM' => 'No data mapping; please call Planet Payment',
135
+ 'NS' => 'Transaction not settled',
136
+ 'NX' => 'No XML "FIELDS" node present',
137
+ 'SE' => 'System error; please call Planet Payment',
138
+ 'SU' => 'System unavailable, retry',
139
+ 'TC' => 'Transaction already captured',
140
+ 'TD' => 'Transaction already deleted',
141
+ 'TR' => 'Transaction already reversed',
142
+ 'TS' => 'Transaction already settled',
143
+ 'TV' => 'Transaction already voided',
144
+ 'UP' => 'Unable to process at this time, retry',
145
+ 'VR' => 'VOID_REFUSED Merchants receiving a decline for a sale transaction will not be able to void it.',
146
+ 'XE' => 'Currency conversion error; please call Planet Payment',);
147
+
148
+ public function getErrorMessage($code, $type = 'arc') {
149
+ if ($type == 'arc') {
150
+ if (isset($this->__arcs[$code])) {
151
+ return $this->__arcs[$code];
152
+ }
153
+ } else if (isset($this->__mrcs[$code])) {
154
+ return $this->__mrcs[$code];
155
+ } else {
156
+ return '';
157
+ }
158
+ }
159
+
160
+ }
app/code/community/PlanetPayment/Upop/Model/Checkout.php ADDED
@@ -0,0 +1,307 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_Upop
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Hold Method For Starting Checkout Process
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_Upop
24
+ * @author mohds
25
+ */
26
+ class PlanetPayment_Upop_Model_Checkout {
27
+
28
+ /**
29
+ * Hold Instance of Upop Request Model
30
+ *
31
+ * @var string
32
+ */
33
+ protected $_apiType = 'upop/xml_request';
34
+
35
+ /**
36
+ * Hold Upop Model Type
37
+ *
38
+ * @var string
39
+ */
40
+ protected $_upopType = 'upop/upop';
41
+
42
+ /**
43
+ * Hold Instance of Upop Model
44
+ *
45
+ * @var PlanetPayment_Upop_Model_Upop
46
+ */
47
+ protected $_upop;
48
+
49
+ /**
50
+ * Hold Instance of Request Model Api
51
+ *
52
+ * @var PlanetPayment_Upop_Model_Xml_Request
53
+ */
54
+ protected $_api;
55
+
56
+ /**
57
+ * Hold Instance Of Quote Model
58
+ *
59
+ * @var Mage_Sales_Model_Quote
60
+ */
61
+ protected $_quote = null;
62
+
63
+ /**
64
+ * Hold Instance Of Customer Model
65
+ *
66
+ * @var Mage_Customer_Model_Session
67
+ */
68
+ protected $_customerSession;
69
+
70
+ /**
71
+ * Create Billing Agreement flag
72
+ *
73
+ * @var bool
74
+ */
75
+ protected $_isBARequested = false;
76
+
77
+ /**
78
+ * Customer ID
79
+ *
80
+ * @var int
81
+ */
82
+ protected $_customerId = null;
83
+
84
+ /**
85
+ * Recurring payment profiles
86
+ *
87
+ * @var array
88
+ */
89
+ protected $_recurringPaymentProfiles = array();
90
+
91
+ /**
92
+ * Billing agreement that might be created during order placing
93
+ *
94
+ * @var Mage_Sales_Model_Billing_Agreement
95
+ */
96
+ protected $_billingAgreement = null;
97
+
98
+ /**
99
+ * Order
100
+ *
101
+ * @var Mage_Sales_Model_QuoteMage_Sales_Model_Quote
102
+ */
103
+ protected $_order = null;
104
+
105
+ /**
106
+ * Set quote and config instances
107
+ *
108
+ * @param array $params
109
+ */
110
+ public function __construct($params = array()) {
111
+ if (isset($params['quote']) && $params['quote'] instanceof Mage_Sales_Model_Quote) {
112
+ $this->_quote = $params['quote'];
113
+ } else {
114
+ throw new Exception('Quote instance is required.');
115
+ }
116
+
117
+ $this->_customerSession = Mage::getSingleton('customer/session');
118
+ }
119
+
120
+ /**
121
+ * Send First Pass Authentication Request To Ipay
122
+ *
123
+ * @return \SimpleXMLElement|boolean
124
+ */
125
+ public function start() {
126
+ $this->_quote->collectTotals();
127
+
128
+ if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
129
+ Mage::throwException(Mage::helper('upop')->__('Upop does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
130
+ }
131
+
132
+ //Prepare API
133
+ $this->_getApi();
134
+
135
+ //Instantiate UPOP model
136
+ $this->_getUpop();
137
+ $this->_api->setQuoteCurrencyCode($this->_quote->getQuoteCurrencyCode());
138
+
139
+ $paymentType = $this->_upop->getPaymentType();
140
+ $this->_api->setAmount($this->_quote->getBaseGrandTotal());
141
+
142
+ if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
143
+ $this->_api->setUpopCurrencyCode($this->_quote->getQuoteCurrencyCode());
144
+ $this->_api->generateApiRequestForPycAuth();
145
+ } else if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP) {
146
+ $this->_api->setAmountInStoreCurrency($this->_quote->getGrandTotal());
147
+ $this->_api->generateApiRequestForMcpAuth();
148
+ } else {
149
+ Mage::log("Couldn't process your request. Please try again later.", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
150
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later."));
151
+ }
152
+
153
+ // supress or export shipping address
154
+ if ($this->_quote->getIsVirtual()) {
155
+ $this->_api->setRequireBillingAddress(1);
156
+ $this->_api->setSuppressShipping(true);
157
+ } else {
158
+ $address = $this->_quote->getShippingAddress();
159
+ $isOverriden = 0;
160
+ if (true === $address->validate()) {
161
+ $isOverriden = 1;
162
+ $this->_api->setAddress($address);
163
+ }
164
+ //$this->_quote->getPayment()->save();
165
+ }
166
+
167
+ // call first pass API and return uppayload
168
+ $this->_api->send();
169
+ $response = $this->_api->getResponse();
170
+ $result = $response->getXmlContent();
171
+ if ($result instanceof SimpleXMLElement) {
172
+ $this->_getUopSession()->setData('first_pass', $result->asXML());
173
+ $this->_quote->setData('first_pass', $result->asXML())->save();
174
+ return $result;
175
+ } else {
176
+ return false;
177
+ }
178
+ }
179
+
180
+ /**
181
+ * Send second pass request to Upop
182
+ *
183
+ * @param Array $param
184
+ * @return \SimpleXMLElement|boolean
185
+ */
186
+ public function secondPass($param) {
187
+ try {
188
+ $this->_getApi();
189
+ $this->_api->setParam($param);
190
+
191
+ /* $upPayload = '';
192
+ foreach ($param as $key => $value) {
193
+ if ($key == 'respMsg') {
194
+ $value = $this->strToHex($value); //up_payload diable hex decimal
195
+ }
196
+
197
+ if ($key != 'signature') {
198
+ $upPayload .= ($upPayload ? '&' : '') . $key . '=' . $value; //up_payload diable signature
199
+ }
200
+ }
201
+ if (isset($param['signature'])) {
202
+ $upPayload .= ($upPayload ? '&' : '') . 'signature=' . $param['signature'];
203
+ }
204
+ */
205
+ $upPayload64 = http_build_query($param);
206
+ $this->_getUpop();
207
+ if ($this->_upop->getConfigData('payment_action') == PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE) {
208
+ $transactionalType = 'AUTH';
209
+ } else if ($this->_upop->getConfigData('payment_action') == PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
210
+ $transactionalType = 'SALE';
211
+ }
212
+
213
+ $this->_api->setTransactionType($transactionalType);
214
+ //$this->_api->setUpPayload($upPayload);
215
+ $this->_api->setUpPayload64(base64_encode($upPayload64));
216
+ $this->_api->generateSecondPassiPayRequest();
217
+ $this->_api->send();
218
+
219
+ $response = $this->_api->getResponse();
220
+ $result = $response->getXmlContent();
221
+ if ($result instanceof SimpleXMLElement) {
222
+ $this->_getUopSession()->setData('second_pass', $result->asXML());
223
+ $this->_quote->setData('second_pass', $result->asXML());
224
+ return $result;
225
+ } else {
226
+ return false;
227
+ }
228
+ } catch (Exception $ex) {
229
+ Mage::log($ex->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
230
+ Mage::throwException($ex->getmessage());
231
+ }
232
+ }
233
+
234
+ /**
235
+ * Convert string to hexadecimal
236
+ *
237
+ * @param string $string
238
+ * @return string
239
+ */
240
+ public function strToHex($string) {
241
+ $hex = '';
242
+ for ($i = 0; $i < strlen($string); $i++) {
243
+ $hex .= '%' . dechex(ord($string[$i]));
244
+ }
245
+ return $hex;
246
+ }
247
+
248
+ /**
249
+ * UPOP session instance getter
250
+ *
251
+ * @return PlanetPayment_Upop_Model_Session
252
+ */
253
+ private function _getUopSession() {
254
+ return Mage::getSingleton('upop/session');
255
+ }
256
+
257
+ /**
258
+ * Return Request Model Intsance
259
+ *
260
+ * @return PlanetPayment_Model_Xml_Request
261
+ */
262
+ protected function _getApi() {
263
+ if (null === $this->_api) {
264
+ $this->_api = Mage::getModel($this->_apiType);
265
+ }
266
+ return $this->_api;
267
+ }
268
+
269
+ /**
270
+ * Return Upop Model Instance
271
+ *
272
+ * @return PlanetPayment_Model_Upop
273
+ */
274
+ protected function _getUpop() {
275
+ if (null === $this->_upop) {
276
+ $this->_upop = Mage::getModel($this->_upopType);
277
+ }
278
+ return $this->_upop;
279
+ }
280
+
281
+ /**
282
+ * Setter for customer with billing and shipping address changing ability
283
+ *
284
+ * @param Mage_Customer_Model_Customer $customer
285
+ * @param Mage_Sales_Model_Quote_Address $billingAddress
286
+ * @param Mage_Sales_Model_Quote_Address $shippingAddress
287
+ * @return PlanetPayment_Model_Upop_Checkout
288
+ */
289
+ public function setCustomerWithAddressChange($customer, $billingAddress = null, $shippingAddress = null) {
290
+ $this->_quote->assignCustomerWithAddressChange($customer, $billingAddress, $shippingAddress);
291
+ $this->_customerId = $customer->getId();
292
+ return $this;
293
+ }
294
+
295
+ /**
296
+ * Return checkout quote object
297
+ *
298
+ * @return Mage_Sale_Model_Quote
299
+ */
300
+ private function _getQuote() {
301
+ if (!$this->_quote) {
302
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
303
+ }
304
+ return $this->_quote;
305
+ }
306
+
307
+ }
app/code/community/PlanetPayment/Upop/Model/Currency/Import/Upop.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_Upop_Model_Currency_Import_Upop extends Mage_Directory_Model_Currency_Import_Abstract {
29
+
30
+ protected $_messages = array();
31
+ protected $_rates = array();
32
+
33
+ public function __construct() {
34
+ $request = $this->_getRequestModel()
35
+ ->generateCurrencyRateLookUpRequest()
36
+ ->send();
37
+ if ($request->getResponse()->isSuccess()) {
38
+ $this->_rates = $this->_formatConvertionXml($request->getResponse());
39
+ } else {
40
+ Mage::throwException("Communication Error! Please try later");
41
+ }
42
+ }
43
+
44
+ protected function _convert($currencyFrom, $currencyTo, $retry=0) {
45
+ if (count($this->_rates)) {
46
+ try {
47
+ $nativeCurrency = $this->_getRequestModel()->getNativeCurrency();
48
+ if ($currencyFrom != $nativeCurrency) {
49
+ $this->_messages[] = Mage::helper('upop')->__('Ipay Native currency is different from store base currency');
50
+ } else if (isset($this->_rates[$currencyTo])){
51
+ return $this->_rates[$currencyTo];
52
+ } else {
53
+ $this->_messages[] = Mage::helper('upop')->__("Unable to retrieve the conversion rate from %s to %s",$currencyFrom, $currencyTo);
54
+ }
55
+ } catch (Exception $e) {
56
+ if ($retry == 0) {
57
+ $this->_convert($currencyFrom, $currencyTo, 1);
58
+ } else {
59
+ $this->_messages[] = Mage::helper('upop')->__('Cannot retrieve rate from Upop');
60
+ }
61
+ }
62
+ } else {
63
+ $this->_messages[] = Mage::helper('upop')->__("Unable to retrieve the conversion rate from %s to %s",$currencyFrom, $currencyTo);
64
+ }
65
+ }
66
+
67
+ protected function _formatConvertionXml($response) {
68
+ $responsexml = $response->getXmlContent();
69
+ $currencyRates = array();
70
+ if ($responsexml) {
71
+ $rates = $responsexml->FIELDS->RATES;
72
+ foreach ($rates->RATE as $rate) {
73
+ $attributes = $rate->CURRENCY_CODE->Attributes();
74
+ $currencyRates[(string) $attributes['ALPHA']] = 1 / (float) $rate->EXCHANGE_RATE;
75
+ }
76
+ }
77
+ return $currencyRates;
78
+ }
79
+
80
+ protected function _getRequestModel() {
81
+ return Mage::getSingleton('upop/xml_request');
82
+ }
83
+
84
+ }
app/code/community/PlanetPayment/Upop/Model/CurrencyCode.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_CurrencyCode extends Mage_Core_Model_Abstract {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->_init('upop/currencyCode');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/Upop/Model/Log.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Log extends Mage_Core_Model_Abstract {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->_init('upop/log');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/Upop/Model/Observer.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Observer extends Mage_Core_Model_Abstract {
30
+
31
+ /**
32
+ * Display debit status button in case of fail in UPOP payment authorization
33
+ *
34
+ * @param Varien_Event_Observer $observer
35
+ */
36
+ public function addDbtStatusButton(Varien_Event_Observer $observer) {
37
+
38
+ $block = $observer->getEvent()->getData('block');
39
+
40
+ if(get_class($block) == 'Mage_Adminhtml_Block_Sales_Order_View' && $block->getRequest()->getControllerName() == 'sales_order')
41
+ {
42
+ $order = $block->getOrder();
43
+ if(!$order->getData('dbt_status') && $order->getPayment()->getMethod()==PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
44
+ $block->addButton('dbt_status', array(
45
+ 'label' => 'Debit Status',
46
+ 'onclick' => 'setLocation(\'' . $block->getUrl('upopadmin/adminhtml_order/getDbtStatus') . '\')',
47
+ 'class' => 'go'
48
+ ));
49
+ }
50
+ }
51
+
52
+ }
53
+
54
+ }
app/code/community/PlanetPayment/Upop/Model/Observer/Abstract.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ abstract class PlanetPayment_Upop_Model_Observer_Abstract extends Varien_Object {
30
+
31
+ /**
32
+ * Returns true if the CIM payment method is available.
33
+ *
34
+ * @return bool
35
+ */
36
+ public function isEnabled() {
37
+ return $this->getConfigData('active');
38
+ }
39
+
40
+ /**
41
+ * Returns system config data.
42
+ *
43
+ * @param string $key
44
+ * @return mixed
45
+ */
46
+ public function getConfigData($key) {
47
+ return Mage::helper('upop')->getConfigData($key);
48
+ }
49
+
50
+ /**
51
+ * Returns the logged in user.
52
+ *
53
+ * @return Mage_Customer_Model_Customer
54
+ */
55
+ public function getCustomer() {
56
+ if ($this->hasCustomer()) {
57
+ return $this->getData('customer');
58
+ }
59
+ return Mage::getSingleton('customer/session')->getCustomer();
60
+ }
61
+
62
+ }
app/code/community/PlanetPayment/Upop/Model/Observer/Checkout.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Observer_Checkout extends PlanetPayment_Upop_Model_Observer_Abstract {
30
+
31
+ /**
32
+ * Saves the profile if save this card is checked
33
+ *
34
+ * @see Mage_Sales_Model_Order::place()
35
+ * @param Varien_Event_Observer $observer
36
+ */
37
+ public function placeOrderAfter(Varien_Event_Observer $observer) {
38
+ return;
39
+ }
40
+
41
+ }
app/code/community/PlanetPayment/Upop/Model/Observer/Log.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Observer_Log extends PlanetPayment_Upop_Model_Observer_Abstract {
30
+
31
+ public function cleanLog() {
32
+ $logCleanConfig = Mage::getStoreConfig('planet_payment/upop_logging/lifetime');
33
+
34
+ $daysBefore = strtotime("-$logCleanConfig days", time());
35
+ $formated = date('Y-m-d H:i:s', $daysBefore);
36
+ $logs = Mage::getModel('upop/log')->getCollection()->addFieldToFilter('create_date', array('lt' => $formated));
37
+
38
+ if (count($logs)) {
39
+ foreach ($logs as $log) {
40
+ Mage::getModel('upop/log')->load($log->getId())->delete();
41
+ }
42
+ }
43
+ return $this;
44
+ }
45
+
46
+ }
app/code/community/PlanetPayment/Upop/Model/Profile.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Profile extends Mage_Core_Model_Abstract {
30
+
31
+ protected $_backupData = array();
32
+
33
+ protected function _construct() {
34
+ parent::_construct();
35
+ $this->_init('upop/profile');
36
+ }
37
+
38
+ /**
39
+ * Loads the payment profile by payment profile id
40
+ * @param string $paymentProfileId
41
+ * @return PlanetPayment_Upop_Model_Profile
42
+ */
43
+ public function loadByPaymentProfileId($paymentProfileId) {
44
+ return $this->load((int) $paymentProfileId);
45
+ }
46
+
47
+ /**
48
+ * Exports payment data to $payment
49
+ *
50
+ * @param Varien_Object $payment
51
+ * @return PlanetPayment_Upop_Model_Profile
52
+ */
53
+ public function exportPayment(Varien_Object $payment) {
54
+ Mage::helper('core')->copyFieldset('upop_paymentprofile_payment', 'to_payment', $this, $payment);
55
+ //$payment->setCcLast4(substr($this->getCardNumber(), -4));
56
+ return $this;
57
+ }
58
+
59
+ /**
60
+ * Imports address data to $address
61
+ *
62
+ * @param Varien_Object $address
63
+ * @return PlanetPayment_Upop_Model_Profile
64
+ */
65
+ public function exportAddress(Varien_Object $address) {
66
+ Mage::helper('core')->copyFieldset('upop_paymentprofile_address', 'to_address', $this, $address);
67
+ return $this;
68
+ }
69
+
70
+ /**
71
+ * Formats the profile for display.
72
+ *
73
+ * @param string $type
74
+ * @param array $params
75
+ */
76
+ public function format($type, array $params = array()) {
77
+ $renderer = Mage::app()->getLayout()->createBlock('upop/profile');
78
+ /* @var $renderer PlanetPayment_Upop_Block_PaymentProfile */
79
+ $renderer->setPaymentProfile($this)
80
+ ->setType($type)
81
+ ->setParams($params);
82
+
83
+ return $renderer->toHtml();
84
+ }
85
+
86
+ /**
87
+ * Returns the card type, unabbreviated.
88
+ *
89
+ * @return string
90
+ */
91
+ public function getCardTypeName() {
92
+ $type = $this->getCardType();
93
+ foreach (Mage::getSingleton('payment/config')->getCcTypes() as $code => $name) {
94
+ if ($type == $code) {
95
+ return $name;
96
+ }
97
+ }
98
+ return '';
99
+ }
100
+
101
+ /**
102
+ * @return string
103
+ */
104
+ public function getName() {
105
+ return $this->getFirstName() . ' ' . $this->getLastName();
106
+ }
107
+
108
+ /**
109
+ * Concats the exp month and year.
110
+ *
111
+ * @return string
112
+ */
113
+ public function getExpirationDate() {
114
+ if (!$this->getData('expiration_date')) {
115
+ $this->setExpirationDate($this->getExpirationYear() . '-' . str_pad($this->getExpirationMonth(), 2, '0', STR_PAD_LEFT));
116
+ }
117
+ return $this->getData('expiration_date');
118
+ }
119
+
120
+ /**
121
+ * Proxies to the card number if the last4 isn't set.
122
+ *
123
+ * @return string
124
+ */
125
+ public function getCardNumberLast4() {
126
+ if ($this->getData('card_number_last4') === null) {
127
+ if ($this->getCardNumber()) {
128
+ $this->setCardNumberLast4(substr($this->getCardNumber(), -4));
129
+ }
130
+ }
131
+ return $this->getData('card_number_last4');
132
+ }
133
+
134
+ /**
135
+ *
136
+ * @param type $id
137
+ * @param type $field
138
+ * @return type
139
+ */
140
+ public function load($id, $field = null) {
141
+ $this->_backupData = $this->getData();
142
+ return parent::load($id, $field);
143
+ }
144
+
145
+ /**
146
+ * After load
147
+ * @return type
148
+ */
149
+ protected function _afterLoad() {
150
+ foreach ($this->_backupData as $key => $value) {
151
+ if ($value !== null) {
152
+ $this->setData($key, $value);
153
+ }
154
+ }
155
+ return parent::_afterLoad();
156
+ }
157
+
158
+ /**
159
+ * HTML-ifies the payment profile.
160
+ *
161
+ * @param bool $showExpirationDate
162
+ * @param bool $showAddress
163
+ * @return string
164
+ * @deprecated use $this->format()
165
+ */
166
+ public function toHtml($showExpirationDate = true, $showAddress = true) {
167
+ $params = array(
168
+ 'show_exp_date' => $showExpirationDate,
169
+ 'show_address' => $showAddress
170
+ );
171
+ return $this->format('html', $params);
172
+ }
173
+
174
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/CurrencyCode.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_CurrencyCode extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('upop/currencyCodes', 'currency');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/CurrencyCode/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_CurrencyCode_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('upop/currency');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/Log.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_Log extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('upop/log', 'id');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/Log/Collection.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_Log_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('upop/log');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/Profile.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_Profile extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('upop/paymentProfile', 'id');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/Upop/Model/Resource/Profile/Collection.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Resource_Profile_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('upop/profile');
34
+ }
35
+
36
+ public function addCustomerFilter(Mage_Customer_Model_Customer $customer) {
37
+ $this->addFieldToFilter('customer_id', $customer->getId());
38
+ return $this;
39
+ }
40
+
41
+ }
app/code/community/PlanetPayment/Upop/Model/Session.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ /**
10
+ * Description of Session
11
+ * Custom Added
12
+ *
13
+ * @author mohds
14
+ */
15
+ class PlanetPayment_Upop_Model_Session extends Mage_Core_Model_Session_Abstract
16
+ {
17
+ public function __construct()
18
+ {
19
+ $this->init('upop');
20
+ }
21
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/General/Encryption.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_General_Encryption {
30
+
31
+ public function toOptionArray() {
32
+ $options = array();
33
+ $options[] = array(
34
+ 'value' => "triple-des",
35
+ 'label' => "Triple-DES"
36
+ );
37
+ return $options;
38
+ }
39
+
40
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/General/Mode.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_General_Mode {
30
+
31
+ public function toOptionArray() {
32
+ $options = array();
33
+ $options[] = array(
34
+ 'value' => 'testing',
35
+ 'label' => "Testing"
36
+ );
37
+ $options[] = array(
38
+ 'value' => 'production',
39
+ 'label' => "Production"
40
+ );
41
+ return $options;
42
+ }
43
+
44
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Cctype.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_Payment_Cctype extends Mage_Adminhtml_Model_System_Config_Source_Payment_Cctype {
30
+
31
+ //Allowed CC TYPES
32
+ //Add New CC TYPE to the array inorder to show that in the select box
33
+ private $__allowedCcTypes = array(
34
+ 'AE',
35
+ 'VI',
36
+ 'DI',
37
+ 'MC',
38
+ 'JCB'
39
+ );
40
+
41
+ private $__additionalCcTypes = array(
42
+ array(
43
+ 'value' => 'DIN',
44
+ 'label' => 'Diners'
45
+ ),
46
+ // array(
47
+ // 'value' => 'CUP',
48
+ // 'label' => 'CUP'
49
+ // )
50
+ );
51
+
52
+ public function toOptionArray() {
53
+ $options = parent::toOptionArray();
54
+ $allowedOptions = array();
55
+ foreach ($options as $option) {
56
+ if (isset($option['value'])) {
57
+ if (in_array($option['value'], $this->__allowedCcTypes)) {
58
+ array_push($allowedOptions, $option);
59
+ }
60
+ }
61
+ }
62
+ //Adding Additional CCTypes to Options
63
+ $allowedOptions = array_merge($allowedOptions, $this->__additionalCcTypes);
64
+ return $allowedOptions;
65
+ }
66
+
67
+ public function getAdditionalCcTypes() {
68
+ $addtional = array();
69
+ foreach($this->__additionalCcTypes as $type) {
70
+ $addtional[$type['value']] = $type['label'];
71
+ }
72
+
73
+ return $addtional;
74
+ }
75
+
76
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Currency.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_Payment_Currency extends Mage_Adminhtml_Model_System_Config_Source_Currency {
30
+
31
+ //Allowed Currencies
32
+ //Add New currecny code to the array inorder to show that in the select box
33
+ private $__allowedCurrencies = array(
34
+ 'USD',
35
+ 'CAD',
36
+ 'HKD'
37
+ );
38
+
39
+ public function toOptionArray($isMultiSelect) {
40
+ $options = parent::toOptionArray($isMultiSelect);
41
+ $allowedOptions = array();
42
+ foreach ($options as $option) {
43
+ if (isset($option['value'])) {
44
+ if (in_array($option['value'], $this->__allowedCurrencies)) {
45
+ array_push($allowedOptions, $option);
46
+ }
47
+ }
48
+ }
49
+ return $allowedOptions;
50
+ }
51
+
52
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/PaymentAction.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_Payment_PaymentAction {
30
+
31
+ public function toOptionArray() {
32
+ return array(
33
+ array(
34
+ 'value' => PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE,
35
+ 'label' => Mage::helper('upop')->__('Authorize Only')
36
+ ),
37
+ array(
38
+ 'value' => PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE_CAPTURE,
39
+ 'label' => Mage::helper('upop')->__('Authorize and Capture')
40
+ )
41
+ );
42
+ }
43
+
44
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/Payment/Service.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_System_Config_Payment_Service {
30
+
31
+ public function toOptionArray($isMultiSelect) {
32
+ return array(
33
+ array(
34
+ 'value' => PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC,
35
+ 'label' => Mage::helper('upop')->__('PYC')
36
+ ),
37
+ array(
38
+ 'value' => PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP,
39
+ 'label' => Mage::helper('upop')->__('MCP')
40
+ )
41
+ );
42
+ }
43
+ }
app/code/community/PlanetPayment/Upop/Model/System/Config/Source/Enabledisable.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ /**
10
+ * Description of Enabledisable
11
+ *
12
+ * @author mohds
13
+ */
14
+ class PlanetPayment_Upop_Model_System_Config_Source_Enabledisable {
15
+
16
+ //put your code here
17
+ public function toOptionArray()
18
+ {
19
+ return array(
20
+ array('value'=>1, 'label'=>Mage::helper('adminhtml')->__('Enable'))
21
+
22
+ );
23
+ }
24
+ }
app/code/community/PlanetPayment/Upop/Model/Type/Onepage.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Type_Onepage extends Mage_Checkout_Model_Type_Onepage {
30
+
31
+ public function initCheckout() {
32
+
33
+ $checkout = $this->getCheckout();
34
+ if (is_array($checkout->getStepData())) {
35
+ foreach ($checkout->getStepData() as $step => $data) {
36
+ if (!($step === 'login'
37
+ || Mage::getSingleton('customer/session')->isLoggedIn() && $step === 'billing')) {
38
+ $checkout->setStepData($step, 'allow', false);
39
+ }
40
+ }
41
+ }
42
+
43
+
44
+ /*
45
+ * want to laod the correct customer information by assiging to address
46
+ * instead of just loading from sales/quote_address
47
+ */
48
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
49
+ if ($customer) {
50
+ $this->getQuote()->assignCustomer($customer);
51
+ }
52
+ if ($this->getQuote()->getIsMultiShipping()) {
53
+ $this->getQuote()->setIsMultiShipping(false);
54
+ $this->getQuote()->save();
55
+ }
56
+ return $this;
57
+ }
58
+
59
+ }
app/code/community/PlanetPayment/Upop/Model/Upop.php ADDED
@@ -0,0 +1,839 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Upop extends Mage_Payment_Model_Method_Cc {
30
+
31
+ const GATEWAY_URL_PRODUCTION = 'https://prd.txngw.com';
32
+ const GATEWAY_URL_TESTING = 'http://uap.txngw.com';
33
+ const PAYMENT_ACTION_AUTHORIZE = "authorize";
34
+ const PAYMENT_ACTION_AUTHORIZE_CAPTURE = "authorize_capture";
35
+ const PAYMENT_SERVICE_PYC = "pyc";
36
+ const PAYMENT_SERVICE_MCP = "mcp";
37
+ const PAYMENT_SERVICE_NORMAL = "normal";
38
+ const VALIDATE_EXISTING = 1;
39
+ const VALIDATE_NEW = 2;
40
+ const METHOD_CODE = 'upop';
41
+ // Xmls wil be logged in this file if any error occures while authorising,
42
+ // ie the authorize process is wrapped inside a mysql transaction in magento,
43
+ // if anything goes wrong,
44
+ // The complete process will be rolled back. Since our database logging
45
+ // is inside this transaction, we will loose the log.
46
+ const LOG_FILE = 'upop_log.txt';
47
+
48
+ /**
49
+ * Hold the Upop Payment Form Block
50
+ *
51
+ * @var string
52
+ */
53
+ protected $_formBlockType = 'upop/payment_form';
54
+
55
+ /**
56
+ * Hold The Admin payment Form For Upop
57
+ *
58
+ * @var string
59
+ */
60
+ protected $_formBlockTypeAdmin = 'upop/adminhtml_payment_form';
61
+
62
+ /**
63
+ * Hold Payment Method Code
64
+ *
65
+ * @var constant
66
+ */
67
+ protected $_code = self::METHOD_CODE;
68
+
69
+ /**
70
+ * Hold Upop Payment Info Block
71
+ *
72
+ * @var string
73
+ */
74
+ protected $_infoBlockType = 'upop/payment_info';
75
+
76
+ /**
77
+ * Hold Bool Value
78
+ *
79
+ * @var bool
80
+ */
81
+ protected $_isGateway = true;
82
+
83
+ /**
84
+ * Hold Bool Value
85
+ *
86
+ * @var bool
87
+ */
88
+ protected $_canAuthorize = true;
89
+
90
+ /**
91
+ * Hold Bool Value
92
+ *
93
+ * @var bool
94
+ */
95
+ protected $_canCapture = true;
96
+
97
+ /**
98
+ * Hold Bool Value
99
+ *
100
+ * @var bool
101
+ */
102
+ protected $_canCapturePartial = false;
103
+
104
+ /**
105
+ * Hold Bool Value
106
+ *
107
+ * @var bool
108
+ */
109
+ protected $_canRefund = true;
110
+
111
+ /**
112
+ * Hold Bool Value
113
+ *
114
+ * @var bool
115
+ */
116
+ protected $_canRefundInvoicePartial = true;
117
+
118
+ /**
119
+ * Hold Bool Value
120
+ *
121
+ * @var bool
122
+ */
123
+ protected $_canVoid = true;
124
+
125
+ /**
126
+ * Hold Bool Value
127
+ *
128
+ * @var bool
129
+ */
130
+ protected $_canUseInternal = false; // enables admin use
131
+
132
+ /**
133
+ * Hold Bool Value
134
+ *
135
+ * @var bool
136
+ */
137
+ protected $_canUseCheckout = true; // enables frontend use
138
+
139
+ /**
140
+ * Hold Bool Value
141
+ *
142
+ * @var bool
143
+ */
144
+ protected $_canUseForMultishipping = true;
145
+
146
+ /**
147
+ * Hold Bool Value
148
+ *
149
+ * @var bool
150
+ */
151
+ protected $_canSaveCc = true;
152
+
153
+ /**
154
+ * Hold Null Value
155
+ *
156
+ * @var empty
157
+ */
158
+ protected $_redirectParam = '';
159
+
160
+ /**
161
+ * Assigning data
162
+ *
163
+ * @param string $data
164
+ * @return PlanetPayment_Upop_Model_Upop
165
+ */
166
+ public function assignData($data) {
167
+ if (!($data instanceof Varien_Object)) {
168
+ $data = new Varien_Object($data);
169
+ }
170
+
171
+ parent::assignData($data);
172
+ $this->getInfoInstance()
173
+ ->setIsVisible($data->getIsVisible());
174
+ $this->setValidationMode(self::VALIDATE_NEW);
175
+ return $this;
176
+ }
177
+
178
+ /**
179
+ * Capture previously Athorized payment
180
+ *
181
+ * @param Varien_Object $payment
182
+ * @param int $amount
183
+ */
184
+ public function capture(Varien_Object $payment, $amount) {
185
+ try {
186
+ if (!$payment->getTransactionId() && $this->getConfigData('payment_action') == self::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
187
+ return $this->sale($payment, $amount);
188
+ }
189
+
190
+ $payment->setAmount($amount);
191
+ $request = $this->_getRequest();
192
+ $request->setPayment($payment)
193
+ ->setAmount($amount)
194
+ ->setAmountInStoreCurrency(round($payment->getOrder()->getGrandTotal(), 2));
195
+
196
+ $request->generateRequestForCapture();
197
+ $request->send();
198
+ $response = $request->getResponse();
199
+
200
+ $result = $response->getXmlContent();
201
+
202
+ if ($result->FIELDS->RESPONSE_TEXT == 'Approved') {
203
+ $this->_redirectParam =(string)$result->FIELDS->UP_PAYLOAD;
204
+ $session = $this->_getSession();
205
+ $session->setRedirectParam('' . $this->_redirectParam);
206
+ $payment->setLastTransId((string)$result->FIELDS->TRANSACTION_ID);
207
+ if (!$payment->getParentTransactionId() || (string)$result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
208
+ $payment->setTransactionalId((string)$result->FIELDS->TRANSACTION_ID);
209
+ }
210
+ $payment->setIsFraudDetected(false); //to set the fraud detection false
211
+ } else {
212
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
213
+ if ((string)$result->FIELDS->ARC == 'PF') {
214
+ Mage::throwException(Mage::helper('upop')->__("Please Retry to Capture"));
215
+ } else {
216
+ Mage::log("Couldn't process your request. Please try again later or contact us", null, self::LOG_FILE, true);
217
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later or contact us"));
218
+ }
219
+ }
220
+
221
+ if ($response->isSuccess()) {
222
+ $result = $response->getXmlContent();
223
+ $payment->setStatus(self::STATUS_APPROVED);
224
+ //$payment->setCcTransId($result->getTransactionId());
225
+ $payment->setLastTransId((string)$result->FIELDS->TRANSACTION_ID);
226
+ if (!$payment->getParentTransactionId() || (string)$result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
227
+ $payment->setTransactionId((string)$result->FIELDS->TRANSACTION_ID);
228
+ }
229
+ } else {
230
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
231
+ if ((string)$result->FIELDS->ARC == 'PF') {
232
+ Mage::log("Please Retry to Capture", null, self::LOG_FILE);
233
+ Mage::throwException(Mage::helper('upop')->__("Please Retry to Capture"));
234
+ } else {
235
+ Mage::log("Couldn't process your request. Please try again later or contact us", null, self::LOG_FILE);
236
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later or contact us"));
237
+ }
238
+ }
239
+ } catch (Exception $e) {
240
+ Mage::log($e->getMessage(), null, self::LOG_FILE);
241
+ Mage::throwException(Mage::helper('upop')->__($e->getMessage()));
242
+ }
243
+ }
244
+
245
+ /**
246
+ * Capture previously athorized payment
247
+ *
248
+ * @param Varien_Object $payment
249
+ * @param type $amount
250
+ */
251
+ /* public function capture(Varien_Object $payment, $amount) {
252
+ try {
253
+ if (!$payment->getTransactionId() && $this->getConfigData('payment_action') == self::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
254
+ return $this->sale($payment, $amount);
255
+ }
256
+
257
+ $payment->setAmount($amount);
258
+ $request = $this->_getRequest();
259
+ $request->setPayment($payment)
260
+ ->setAmount($amount)
261
+ ->setAmountInStoreCurrency(round($payment->getOrder()->getGrandTotal(), 2));
262
+
263
+ $request->generateRequestForCapture();
264
+ $request->send();
265
+ $response = $request->getResponse();
266
+
267
+ $result = $response->getXmlContent();
268
+
269
+ if ($result->FIELDS->RESPONSE_TEXT == 'Approved') {
270
+ $this->_redirectParam = $result->FIELDS->UP_PAYLOAD;
271
+ $session = $this->_getSession();
272
+ $session->setRedirectParam('' . $this->_redirectParam);
273
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
274
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
275
+ $payment->setTransactionalId($result->FIELDS->TRANSACTION_ID);
276
+ }
277
+ $payment->setIsFraudDetected(false); //to set the fraud detection false
278
+ } else {
279
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
280
+ if ($result->FIELDS->ARC == 'PF') {
281
+ Mage::throwException(Mage::helper('upop')->__("Please Retry to Capture"));
282
+ } else {
283
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later or contact us"));
284
+ }
285
+ }
286
+
287
+ if ($response->isSuccess()) {
288
+ $result = $response->getXmlContent();
289
+ $payment->setStatus(self::STATUS_APPROVED);
290
+ //$payment->setCcTransId($result->getTransactionId());
291
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
292
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
293
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
294
+ }
295
+ } else {
296
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
297
+ if ($result->FIELDS->ARC == 'PF') {
298
+ Mage::throwException(Mage::helper('upop')->__("Please Retry to Capture"));
299
+ } else {
300
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later or contact us"));
301
+ }
302
+ }
303
+ } catch (Exception $e) {
304
+ Mage::throwException(Mage::helper('upop')->__($e->getMessage()));
305
+ }
306
+ } */
307
+
308
+ /**
309
+ * Authorize and Capture
310
+ *
311
+ * @param Varien_Object $payment
312
+ * @param int $amount
313
+ */
314
+ public function sale(Varien_Object $payment, $amount) {
315
+ try {
316
+ $secondpassdata = $this->_getSessionUpop()->getData('second_pass');
317
+ if (is_null($secondpassdata)) {
318
+ Mage::throwException(Mage::helper('upop')->__("Session is timeout for second pass auth/sale with iPay."));
319
+ }
320
+ $quoteCurrency = Mage::helper('upop')->getQuote()->getQuoteCurrencyCode();
321
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
322
+ $secondpassdata_xml_obj = simplexml_load_string($secondpassdata);
323
+ if ($secondpassdata_xml_obj instanceof SimpleXMLElement) {
324
+ $transaction_id_last =(string)$secondpassdata_xml_obj->FIELDS->TRANSACTION_ID;
325
+ $transaction_id = (string)$secondpassdata_xml_obj->FIELDS->TRANSACTION_ID;
326
+ $upop_order_number = (string)$secondpassdata_xml_obj->FIELDS->UP_ORDERNUMBER;
327
+ $paymentType = $this->getPaymentType();
328
+ $exchangeRate = ($paymentType == self::PAYMENT_SERVICE_PYC) ? (1 / (double)$secondpassdata_xml_obj->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('upop')->getQuote()->getBaseToQuoteRate();
329
+ $payment->setAmount($amount);
330
+ $payment->setLastTransId($transaction_id_last)
331
+ ->setTransactionId($transaction_id)
332
+ ->setUpopOrderNumber($upop_order_number)
333
+ ->setUpopExchangeRate($exchangeRate)
334
+ ->setUpopCurrencyCode($currency_code)
335
+ ->setIsTransactionClosed(0);
336
+ $payment->setStatus(self::STATUS_APPROVED);
337
+ $payment->setIsFraudDetected(false);
338
+ } else {
339
+ Mage::log("Second pass auth/sale response in not valid.", null, self::LOG_FILE);
340
+ Mage::throwException(Mage::helper('upop')->__("Second pass auth/sale response in not valid."));
341
+ }
342
+ } catch (Exception $e) {
343
+ Mage::log($e->getMessage(), null, self::LOG_FILE);
344
+ Mage::throwException(Mage::helper('upop')->__($e->getMessage()));
345
+ }
346
+ }
347
+
348
+ /**
349
+ * Authorize and Capture
350
+ *
351
+ * @param Varien_Object $payment
352
+ * @param type $amount
353
+ */
354
+ /* public function sale(Varien_Object $payment, $amount) {
355
+ try {
356
+ $payment->setAmount($amount);
357
+ $request = $this->_getRequest();
358
+ $request->setPayment($payment)
359
+ ->setAmount($amount)
360
+ ->setAmountInStoreCurrency(round($payment->getOrder()->getGrandTotal(), 2));
361
+
362
+ $request->generateRequestForSale();
363
+ $request->send();
364
+
365
+ $response = $request->getResponse();
366
+ $result = $response->getXmlContent();
367
+
368
+ if ($result->FIELDS->UP_PAYLOAD) {
369
+ $this->_redirectParam = $result->FIELDS->UP_PAYLOAD;
370
+ $session = $this->_getSession();
371
+ $session->setRedirectParam('' . $this->_redirectParam);
372
+ $session->setOrderId($payment->getOrder()->getId());
373
+
374
+ $exchangeRate = ($paymentType == self::PAYMENT_SERVICE_PYC) ? (1 / $result->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('upop')->getQuote()->getBaseToQuoteRate();
375
+ $payment->setUpopOrderNumber($result->FIELDS->UP_ORDERNUMBER)
376
+ ->setUpopExchangeRate($exchangeRate)
377
+ ->setIsTransactionPending(true)
378
+ ->setIsTransactionClosed(0);
379
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
380
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
381
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
382
+ }
383
+ } else {
384
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
385
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try again later or contact us"));
386
+ }
387
+ } catch (Exception $e) {
388
+ Mage::throwException(Mage::helper('upop')->__($e->getMessage()));
389
+ }
390
+ } */
391
+
392
+ /**
393
+ * Authorizing payment
394
+ *
395
+ * @param Varien_Object $payment
396
+ * @param int $amount
397
+ * @return PlanetPayment_Upop_Model_Upop
398
+ */
399
+ public function authorize(Varien_Object $payment, $amount) {
400
+ if ($amount <= 0) {
401
+ Mage::throwException(Mage::helper('upop')->__('Invalid amount for authorization.'));
402
+ }
403
+
404
+ try {
405
+ $secondpassdata = $this->_getSessionUpop()->getData('second_pass');
406
+ if (is_null($secondpassdata)) {
407
+ Mage::throwException(Mage::helper('upop')->__("Session is timeout for second pass auth/sale with iPay."));
408
+ }
409
+ $quoteCurrency = Mage::helper('upop')->getQuote()->getQuoteCurrencyCode();
410
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
411
+ $secondpassdata_xml_obj = simplexml_load_string($secondpassdata);
412
+ if ($secondpassdata_xml_obj instanceof SimpleXMLElement) {
413
+ $transaction_id_last = (string)$secondpassdata_xml_obj->FIELDS->TRANSACTION_ID;
414
+ $transaction_id = (string)$secondpassdata_xml_obj->FIELDS->TRANSACTION_ID;
415
+ $upop_order_number = (string)$secondpassdata_xml_obj->FIELDS->UP_ORDERNUMBER;
416
+ $paymentType = $this->getPaymentType();
417
+ $exchangeRate = ($paymentType == self::PAYMENT_SERVICE_PYC) ? (1 / (double)$secondpassdata_xml_obj->FIELDS->EXCHANGE_RATE) : Mage::helper('upop')->getQuote()->getBaseToQuoteRate();
418
+ $payment->setAmount($amount);
419
+ $payment->setLastTransId($transaction_id)
420
+ ->setTransactionId($transaction_id_last)
421
+ ->setUpopOrderNumber($upop_order_number)
422
+ ->setUpopExchangeRate($exchangeRate)
423
+ ->setUpopCurrencyCode($currency_code)
424
+ ->setIsTransactionClosed(0);
425
+ //$payment->setStatus(self::STATUS_APPROVED);
426
+ $payment->setIsFraudDetected(false); //to set the fraud detection false
427
+ } else {
428
+ Mage::log("Second pass auth/sale response from iPay in not valid.", null, self::LOG_FILE);
429
+ Mage::throwException(Mage::helper('upop')->__("Second pass auth/sale response from iPay in not valid."));
430
+ }
431
+ } catch (Exception $e) {
432
+ Mage::log('Payment authorization error.', null, self::LOG_FILE);
433
+ //Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
434
+ Mage::throwException(Mage::helper('upop')->__('Payment authorization error.'));
435
+ }
436
+
437
+ return $this;
438
+ }
439
+
440
+ /**
441
+ * Authorizing payment
442
+ *
443
+ * @param Varien_Object $payment
444
+ * @param type $amount
445
+ * @return PlanetPayment_Upop_Model_Upop
446
+ */
447
+ /* public function authorize(Varien_Object $payment, $amount) {
448
+ if ($amount <= 0) {
449
+ Mage::throwException(Mage::helper('upop')->__('Invalid amount for authorization.'));
450
+ }
451
+
452
+ $payment->setAmount($amount);
453
+ $request = $this->_getRequest();
454
+ $request->setTransactionType(self::PAYMENT_ACTION_AUTHORIZE)
455
+ ->setPayment($payment)
456
+ ->setAmount($amount);
457
+ $paymentType = $this->getPaymentType();
458
+
459
+ if ($paymentType == self::PAYMENT_SERVICE_PYC) {
460
+ $request->generateRequestForPycAuth();
461
+ } else if ($paymentType == self::PAYMENT_SERVICE_MCP) {
462
+ $request->setAmountInStoreCurrency(round(Mage::helper('upop')->getQuote()->getGrandTotal(), 2));
463
+ $request->generateRequestForMcpAuth();
464
+ } else {
465
+ Mage::throwException(Mage::helper('upop')->__("Couldn't process your request. Please try agin later."));
466
+ }
467
+ $request->send();
468
+
469
+ $response = $request->getResponse();
470
+ $result = $response->getXmlContent();
471
+
472
+ if ($result->FIELDS->UP_PAYLOAD) {
473
+ $this->_redirectParam = $result->FIELDS->UP_PAYLOAD;
474
+ $session = $this->_getSession();
475
+ $session->setRedirectParam('' . $this->_redirectParam);
476
+ $session->setOrderId($payment->getOrder()->getId());
477
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1 / $result->FIELDS->EXCHANGE_RATE) : Mage::helper('upop')->getQuote()->getBaseToQuoteRate();
478
+
479
+ $order = $payment->getOrder();
480
+ $order->setUpopOrderNumber($result->FIELDS->UP_ORDERNUMBER);
481
+
482
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID)
483
+ ->setTransactionId($result->FIELDS->TRANSACTION_ID)
484
+ ->setUpopOrderNumber($result->FIELDS->UP_ORDERNUMBER)
485
+ ->setIsTransactionPending(true)
486
+ ->setUpopExchangeRate($exchangeRate)
487
+ ->setIsTransactionClosed(0);
488
+
489
+ $payment->setIsFraudDetected(false); //to set the fraud detection false
490
+ } else {
491
+ //The last added log will be rolled back if error occured. So if any
492
+ //exception occured, the xmls will be logged in var/log/upop_log.txt
493
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
494
+ Mage::throwException(Mage::helper('upop')->__('Payment authorization error.'));
495
+ }
496
+
497
+ return $this;
498
+ } */
499
+
500
+ /**
501
+ * Void the payment through gateway
502
+ *
503
+ * @param Varien_Object $payment
504
+ * @return PlanetPayment_Upop_Model_Upop
505
+ */
506
+ public function void(Varien_Object $payment) {
507
+ /* @var $payment Mage_Sales_Model_Order_Payment */
508
+ if ($payment->getParentTransactionId()) {
509
+ $request = $this->_getRequest();
510
+ $request->setPayment($payment);
511
+
512
+ $request->generateRequestForVoid()
513
+ ->send();
514
+
515
+ $response = $request->getResponse();
516
+ $result = $response->getXmlContent();
517
+
518
+ if ($response->isSuccess()) {
519
+ $payment->setStatus(self::STATUS_SUCCESS);
520
+ return $this;
521
+ } else {
522
+ $payment->setStatus(self::STATUS_ERROR);
523
+ Mage::log($response->getMessage(), null, self::LOG_FILE);
524
+ Mage::throwException(Mage::helper('upop')->__('Error in void the payment. Message:' . $response->getMessage()));
525
+ }
526
+ } else {
527
+ $payment->setStatus(self::STATUS_ERROR);
528
+ Mage::log("Invalid transaction id", null, self::LOG_FILE);
529
+ Mage::throwException(Mage::helper('upop')->__('Invalid transaction id'));
530
+ }
531
+ }
532
+
533
+ /**
534
+ * Refund the amount with transaction id
535
+ *
536
+ * @param Varien_Object $payment
537
+ * @param decimal $amount
538
+ * @return PlanetPayment_Upop_Model_Upop
539
+ * @todo Ensure removal of -capture in logs
540
+ */
541
+ public function refund(Varien_Object $payment, $amount) {
542
+ /* @var $payment Mage_Sales_Model_Order_Payment */
543
+ if ($payment->getRefundTransactionId() && $amount > 0) {
544
+ if ($amount == $payment->getBaseAmountPaid()) {
545
+ //avoid a rounding error
546
+ $amountConverted = round($payment->getAmountPaid(), 2);
547
+ } else {
548
+ //calculate the amount based on the payment exchange rate
549
+ $amountConverted = round($amount * $payment->getUpopExchangeRate(), 2);
550
+ }
551
+
552
+ $request = $this->_getRequest();
553
+ $request->setPayment($payment)
554
+ ->setAmount($amount)
555
+ ->setAmountInStoreCurrency($amountConverted);
556
+
557
+ $request->generateRequestForRefund()
558
+ ->send();
559
+
560
+ $response = $request->getResponse();
561
+ $result = $response->getXmlContent();
562
+
563
+ if ($response->isSuccess()) {
564
+ $payment->setStatus(self::STATUS_SUCCESS);
565
+ return $this;
566
+ } else {
567
+ $payment->setStatus(self::STATUS_ERROR);
568
+ Mage::log($response->getMessage(), null, self::LOG_FILE);
569
+ Mage::throwException(Mage::helper('upop')->__('Error in refunding the payment. Message:' . $response->getMessage()));
570
+ }
571
+ }
572
+ Mage::log("Error in refunding the payment", null, self::LOG_FILE);
573
+ Mage::throwException(Mage::helper('upop')->__('Error in refunding the payment'));
574
+ }
575
+
576
+ /**
577
+ * Second-Pass request payment
578
+ *
579
+ * @param Varien_Object $payment
580
+ * @param Array $param
581
+ * @return PlanetPayment_Upop_Model_Upop
582
+ */
583
+ public function secondPass(Varien_Object $payment, $param) {
584
+
585
+ $order = $payment->getOrder();
586
+ $upPayload64 = http_build_query($param);
587
+ /* $upPayload = '';
588
+ foreach ($param as $key => $value) {
589
+ if ($key == 'respMsg') {
590
+ $value = $this->strToHex($value); //up_payload diable hex decimal
591
+ }
592
+
593
+ if ($key != 'signature') {
594
+ $upPayload .= ($upPayload ? '&' : '') . $key . '=' . $value; //up_payload diable signature
595
+ }
596
+ }
597
+ if (isset($param['signature'])) {
598
+ $upPayload .= ($upPayload ? '&' : '') . 'signature=' . $param['signature'];
599
+ } */
600
+
601
+ if ($this->getConfigData('payment_action') == self::PAYMENT_ACTION_AUTHORIZE) {
602
+ $transactionalType = 'AUTH';
603
+ } else if ($this->getConfigData('payment_action') == self::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
604
+ $transactionalType = 'SALE';
605
+ }
606
+
607
+ $paymentType = $this->getPaymentType();
608
+
609
+ $request = $this->_getRequest();
610
+ $request->setPayment($payment);
611
+ $request->setTransactionType($transactionalType);
612
+ //$request->setUpPayload($upPayload);
613
+ $request->setUpPayload64(base64_encode($upPayload64));
614
+ $request->setParam($param);
615
+ $request->generateSecondRequest();
616
+ $request->send();
617
+
618
+ $response = $request->getResponse();
619
+ $result = $response->getXmlContent();
620
+
621
+ if ($result->FIELDS->RESPONSE_TEXT == 'Approved') {
622
+
623
+ $order->setData('dbt_status', '1'); //to add dbt status
624
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
625
+ $status = true;
626
+ $amount = round($payment->getAmountOrdered(), 2);
627
+ $formatedPrice = $order->getBaseCurrency()->formatTxt($amount);
628
+ $transactionId = $result->FIELDS->TRANSACTION_ID;
629
+ $orderTransactionId = $payment->getLastTransId();
630
+
631
+ if ($transactionalType == 'SALE') {
632
+ $message = Mage::helper('upop')->__('Capturing amount of %s is approved.', $formatedPrice);
633
+ } else if ($transactionalType == 'AUTH') {
634
+ $message = Mage::helper('upop')->__('Authorized amount of %s.', $formatedPrice);
635
+ } else {
636
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
637
+ Mage::throwException(Mage::helper('upop')->__('Payment second-pass error.'));
638
+ }
639
+
640
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1 / $result->FIELDS->EXCHANGE_RATE) : Mage::helper('upop')->getQuote()->getBaseToQuoteRate();
641
+ $payment->setLastTransId($transactionId);
642
+ if ($transactionalType == 'AUTH') {
643
+ $payment->setTransactionId($transactionId);
644
+ $payment->setParentTransactionId($orderTransactionId);
645
+ } else {
646
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
647
+ $payment->setTransactionId($transactionId);
648
+ }
649
+ }
650
+ $payment->setUpopOrderNumber($result->FIELDS->UP_ORDERNUMBER);
651
+ $payment->setUpopExchangeRate($result->FIELDS->EXCHANGE_RATE);
652
+ $payment->setIsTransactionClosed(0);
653
+ $payment->setStatus(self::STATUS_APPROVED);
654
+ $payment->setIsFraudDetected(false); //to set the fraud detection false
655
+
656
+ if ($transactionalType == 'AUTH') {
657
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, false, $message);
658
+ $transaction->setParentTxnId($orderTransactionId);
659
+ $transaction->setIsClosed(0);
660
+ $transaction->save();
661
+ } else if ($transactionalType == 'SALE') {
662
+ if ($order->hasInvoices()) {
663
+ foreach ($order->getInvoiceCollection() as $invoice) {
664
+ $invoice->setTransactionId($transactionId);
665
+ $invoice->pay()->save();
666
+ break;
667
+ }
668
+ }
669
+ }
670
+ $message = Mage::helper('upop')->__('Order status was change.');
671
+ $order->setState($state, true, $message)->save();
672
+ } else {
673
+ $order->setData('dbt_status', '0'); //to add response for dbt query
674
+ //The last added log will be rolled back if error occured. So if any
675
+ //exception occured, the xmls will be logged in var/log/upop_log.txt
676
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, true);
677
+ Mage::throwException(Mage::helper('upop')->__('Payment error.'));
678
+ }
679
+
680
+ return $this;
681
+ }
682
+
683
+ /**
684
+ * Identifying the payment type PYC or MCP
685
+ *
686
+ * @return string
687
+ */
688
+ public function getPaymentType() {
689
+ $typeConfig = $this->getConfigData("service");
690
+ $nativeCurrency = $this->getConfigData("currency");
691
+ $quoteCurrency = Mage::helper('upop')->getQuote()->getQuoteCurrencyCode();
692
+ $acceptedCurrencies = explode(",", $this->getConfigData("accepted_currencies"));
693
+
694
+ if ($typeConfig == self::PAYMENT_SERVICE_PYC) {
695
+ if ($quoteCurrency == $nativeCurrency) {
696
+ return self::PAYMENT_SERVICE_PYC;
697
+ }
698
+ } else if (in_array($quoteCurrency, $acceptedCurrencies)) {
699
+ return self::PAYMENT_SERVICE_MCP;
700
+ }
701
+
702
+ return self::PAYMENT_SERVICE_NORMAL;
703
+ }
704
+
705
+ /**
706
+ * Retrieve block type for method form generation
707
+ *
708
+ * @return string
709
+ */
710
+ public function getFormBlockType() {
711
+ if (Mage::app()->getStore()->isAdmin()) {
712
+ return $this->_formBlockTypeAdmin;
713
+ } else {
714
+ return $this->_formBlockType;
715
+ }
716
+ }
717
+
718
+ /**
719
+ * returns the Xml request object
720
+ *
721
+ * @return object PlanetPayment_Upop_Model_Xml_Request
722
+ */
723
+ protected function _getRequest() {
724
+ return Mage::getmodel('upop/xml_request');
725
+ }
726
+
727
+ /**
728
+ * Returns checkout session
729
+ *
730
+ * @return Mage_Checkout_Model_Session
731
+ */
732
+ protected function _getSession() {
733
+ return Mage::getSingleton('checkout/session');
734
+ }
735
+
736
+ /**
737
+ * Returns UPOP session
738
+ *
739
+ * @return PlanetPayment_Upop_Model_Session
740
+ */
741
+ protected function _getSessionUpop() {
742
+ return Mage::getSingleton('upop/session');
743
+ }
744
+
745
+ /**
746
+ * Validate payment method information object
747
+ *
748
+ * @param Mage_Payment_Model_Info $info
749
+ * @return Mage_Payment_Model_Abstract
750
+ */
751
+ public function validate() {
752
+ /*
753
+ * calling parent validate function
754
+ */
755
+ if ($this->getValidationMode() == self::VALIDATE_NEW) {
756
+
757
+ //This must be after all validation conditions
758
+ if ($this->getIsCentinelValidationEnabled()) {
759
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
760
+ }
761
+ } else {
762
+ Mage_Payment_Model_Method_Abstract::validate();
763
+ }
764
+
765
+ return $this;
766
+ }
767
+
768
+ /**
769
+ * Convert string to Hexadecimal
770
+ *
771
+ * @param string $string
772
+ * @return string
773
+ */
774
+ public function strToHex($string) {
775
+ $hex = '';
776
+ for ($i = 0; $i < strlen($string); $i++) {
777
+ $hex .= '%' . dechex(ord($string[$i]));
778
+ }
779
+ return $hex;
780
+ }
781
+
782
+ /**
783
+ * Redirect url to ogone submit form
784
+ *
785
+ * @return string
786
+ */
787
+ /* public function getOrderPlaceRedirecgtUrl() {
788
+ return Mage::getUrl('upop/onepage/redirect', array('_secure' => true));
789
+ } */
790
+
791
+ /**
792
+ * Checkout redirect URL getter for onepage checkout (hardcode)
793
+ *
794
+ * @see Mage_Checkout_OnepageController::savePaymentAction()
795
+ * @see Mage_Sales_Model_Quote_Payment::getCheckoutRedirectUrl()
796
+ * @return string
797
+ */
798
+ public function getCheckoutRedirectUrl() {
799
+ return Mage::getUrl('upop/index/start');
800
+ }
801
+
802
+ /**
803
+ * Cancel payment
804
+ *
805
+ * @param Mage_Sales_Model_Order_Payment $payment
806
+ * @return Mage_Paypal_Model_Express
807
+ */
808
+ public function cancel(Varien_Object $payment) {
809
+ $this->void($payment);
810
+
811
+ return $this;
812
+ }
813
+
814
+ /**
815
+ * Send UPOP authorization debit status query
816
+ *
817
+ * @param int $id
818
+ */
819
+ public function getDbtStatus($id) {
820
+ $order = Mage::getModel('sales/order')->load($id);
821
+ if (!$order->getId()) {
822
+ return false;
823
+ }
824
+ $request = $this->_getRequest();
825
+ $request->setOrder($order);
826
+ try {
827
+ $request->generateRequestForDBT();
828
+ $request->send();
829
+ } catch (Exception $e) {
830
+ Mage::log($e->getMessage(), null, self::LOG_FILE, true);
831
+ Mage::throwException($e->getMessage());
832
+ }
833
+
834
+ $response = $request->getResponse();
835
+ $result = $response->getXmlContent();
836
+ return $result;
837
+ }
838
+
839
+ }
app/code/community/PlanetPayment/Upop/Model/Xml/Abstract.php ADDED
@@ -0,0 +1,186 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Xml_Abstract extends Mage_Core_Model_Abstract {
30
+
31
+ protected $_generalConfigPath = "planet_payment_upop/upop_general/";
32
+ protected $_paymentConfigPath = "payment/upop/";
33
+ protected $_testKey = "123451234512345115432154321543214512345112345123";
34
+
35
+ const CONFIG_KEY = 'Magento';
36
+ const APP_NAME = 'PP_Upop';
37
+
38
+ /**
39
+ * returns planet payment general configurations based on the parameters
40
+ * @param string $path
41
+ */
42
+ protected function _getConfig($path, $type = 'payment') {
43
+ if ($type == 'payment') {
44
+ $configPath = $this->_paymentConfigPath . $path;
45
+ } else {
46
+ $configPath = $this->_generalConfigPath . $path;
47
+ }
48
+
49
+ return Mage::getStoreConfig($configPath, Mage::app()->getStore()->getId());
50
+ }
51
+
52
+ public function getNativeCurrency() {
53
+ return $this->_getConfig('currency');
54
+ }
55
+
56
+ protected function _getCurrencyIsoCode($currency) {
57
+ $currencyCodeObject = Mage::getModel('upop/currencyCode')->load($currency);
58
+ if ($currencyCodeObject->getId()) {
59
+ return $currencyCodeObject->getCurrencyCode();
60
+ } else {
61
+ return false;
62
+ }
63
+ }
64
+
65
+ protected function _getCurrencyFromIsoCode($currencyCode) {
66
+ $currencyCodeObject = Mage::getModel('upop/currencyCode')->load($currencyCode, 'currency_code');
67
+ if ($currencyCodeObject->getId()) {
68
+ return $currencyCodeObject->getCurrency();
69
+ } else {
70
+ return false;
71
+ }
72
+ }
73
+
74
+ protected function _generateKey() {
75
+ if ($this->_isProductionMode()) {
76
+ $hex = $this->_getConfig('encryption_key', 'upop_general');
77
+ } else {
78
+ $hex = $this->_testKey;
79
+ }
80
+
81
+ $rv = '';
82
+ foreach (str_split($hex, 2) as $b) {
83
+ $rv .= chr(hexdec($b));
84
+ }
85
+ return $rv;
86
+ }
87
+
88
+ protected function _isProductionMode() {
89
+ return $this->_getConfig('url', 'upop_general') == 'production';
90
+ }
91
+
92
+ protected function _hasEncryption() {
93
+ return (bool) $this->_getConfig('encryption', 'upop_general');
94
+ }
95
+
96
+ /**
97
+ * Accespts the request xml and encrypt TRANSACTION NODE
98
+ * @param Varien_Simplexml_Element $request
99
+ */
100
+ protected function _encryptRequest(Varien_Simplexml_Element &$request) {
101
+ if ($this->_getConfig('encryption_type', 'upop_general') == 'triple-des') {
102
+ $transactionToEncrypt = $request->TRANSACTION;
103
+ $transactionToEncryptAsXml = $transactionToEncrypt->asXML();
104
+ $key = $this->_generateKey();
105
+ $encryptedTransactionXml = base64_encode(mcrypt_encrypt(MCRYPT_3DES, $key, $transactionToEncryptAsXml, MCRYPT_MODE_ECB));
106
+ $request = $this->_getRootNode(true, $encryptedTransactionXml);
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Accespts the response xml and decrypt TRANSACTION NODE
112
+ * @param Varien_Simplexml_Element $request
113
+ */
114
+ protected function _decryptResponse($response) {
115
+ if ($this->_getConfig('encryption_type', 'upop_general') == 'triple-des') {
116
+ $transactionToDecrypt = $response[0];
117
+ $key = $this->_generateKey();
118
+ $response = mcrypt_decrypt(MCRYPT_3DES, $key, base64_decode($transactionToDecrypt), MCRYPT_MODE_ECB);
119
+ }
120
+
121
+ return $response;
122
+ }
123
+
124
+ protected function _getPaymentType($payment) {
125
+ if ($payment) {
126
+ $typeConfig = $this->_getConfig("service");
127
+ $nativeCurrency = $this->_getConfig("currency");
128
+ $orderCurrency = $payment->getOrder()->getOrderCurrencyCode();
129
+ $acceptedCurrencies = explode(",", $this->_getConfig("accepted_currencies"));
130
+ if ($typeConfig == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
131
+ if ($orderCurrency == $nativeCurrency) {
132
+ return PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC;
133
+ }
134
+ } else if (in_array($orderCurrency, $acceptedCurrencies)) {
135
+ return PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP;
136
+ }
137
+
138
+ return PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_NORMAL;
139
+ }
140
+ }
141
+
142
+ /**
143
+ * Generates client name to pass with communications
144
+ *
145
+ * Parts:
146
+ * - MyERP: the ERP that this connector is for (not always applicable)
147
+ * - Majver: version info for the ERP (not always applicable)
148
+ * - MinVer: version info for the ERP (not always applicable)
149
+ * - MyConnector: Name of the OEM's connector AND the name of the OEM (company) *required*
150
+ * - Majver: OEM's connector version *required*
151
+ * - MinVer: OEM's connector version *required*
152
+ *
153
+ * @example Magento,1.4,.0.1,Upop by Planet Payment,2,0.1
154
+ * @return string
155
+ */
156
+ protected function _getClientName() {
157
+ //return "TEST STRING";
158
+ $mageVersion = Mage::getVersion();
159
+ $mageVerParts = explode('.', $mageVersion, 2);
160
+
161
+ $opVersion = Mage::getResourceModel('core/resource')->getDbVersion('upop_setup');
162
+ $opVerParts = explode('.', $opVersion, 2);
163
+
164
+ $part = array();
165
+ $part[] = self::CONFIG_KEY;
166
+ $part[] = $mageVerParts[0];
167
+ $part[] = $mageVerParts[1];
168
+ $part[] = self::APP_NAME;
169
+ $part[] = $opVerParts[0];
170
+ $part[] = $opVerParts[1];
171
+ return implode(',', $part);
172
+ }
173
+
174
+ /**
175
+ * Set Upop cart instance
176
+ *
177
+ * @param Mage_Upop_Model_Cart $cart
178
+ * @return Mage_Upop_Model_Xml_Abstract
179
+ */
180
+ public function setUpopCart(Mage_Upop_Model_Cart $cart)
181
+ {
182
+ $this->_cart = $cart;
183
+ return $this;
184
+ }
185
+
186
+ }
app/code/community/PlanetPayment/Upop/Model/Xml/Request.php ADDED
@@ -0,0 +1,1165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Xml_Request extends PlanetPayment_Upop_Model_Xml_Abstract {
30
+
31
+ /**
32
+ * Returns CC Expiration date in Palnet Payment's Format
33
+ *
34
+ * @param string $month
35
+ * @param int $year
36
+ * @return string
37
+ */
38
+ protected function _getCcExpiration($month, $year) {
39
+ if (strlen($month) == 1) {
40
+ $month = '0' . $month;
41
+ }
42
+
43
+ return (string) $month . substr($year, -2);
44
+ }
45
+
46
+ /**
47
+ * Returns the response model object
48
+ *
49
+ * @return object PlanetPayment_Upop_Model_Xml_Response
50
+ */
51
+ protected function _getResponseModel() {
52
+ return Mage::getModel('upop/xml_response');
53
+ }
54
+
55
+ /**
56
+ * Returns the root node. Two options here, either get a simple xml root node
57
+ * as a varien_simplexml object or get the complete encrypted request wrapped in
58
+ * root node.
59
+ *
60
+ * @param bool $afterEncrypt
61
+ * @param string $encryptedXml
62
+ * @return Varien_Simplexml_Element
63
+ */
64
+ protected function _getRootNode($afterEncrypt = false, $encryptedXml = false) {
65
+ $hasEncryption = $this->_hasEncryption();
66
+
67
+ $key = $this->_getConfig('key', 'upop_general');
68
+ $encryption = $hasEncryption ? '1' : '0';
69
+ if ($afterEncrypt) {
70
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1">' . $encryptedXml . '</REQUEST>';
71
+ } else {
72
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1"/>';
73
+ }
74
+
75
+ return new Varien_Simplexml_Element($rootNodeString);
76
+ }
77
+
78
+ /**
79
+ * Condition the address text passed in to be limited to 30 characters
80
+ *
81
+ * @param string $text
82
+ * * @return string
83
+ */
84
+ protected function _conditionAddress($text) {
85
+ if (!$text || $text == "" || strlen($text) <= 30) {
86
+ return $text;
87
+ }
88
+
89
+ /**
90
+ * Two instances of calls in this file used to call htmlentities on the
91
+ * value, which I don't think we actually want. HTML Encoding will only
92
+ * make the values longer...
93
+ */
94
+ //htmlentities($profile->getAddress(), ENT_QUOTES);
95
+ return substr($text, 0, 30);
96
+ }
97
+
98
+ /**
99
+ * If postal code is longer than 9 characters, strip to the first five. This
100
+ * handles U.S. formatted postal codes inserted with a hyphen (i.e. 12345-6789)
101
+ *
102
+ * In that case, 12345 will be returned. Any text shorter than 9 characters
103
+ * passed to this function will be returned unchanged.
104
+ * @param string $text
105
+ * @return string
106
+ */
107
+ protected function _conditionPostalCode($text) {
108
+ if (!$text || $text == "" || strlen($text) <= 9) {
109
+ return $text;
110
+ }
111
+
112
+ return substr($text, 0, 5);
113
+ }
114
+
115
+ /**
116
+ * Generates the Transaction Xml for authorization
117
+ *
118
+ * @return PlanetPayment_Upop_Model_Xml_Request
119
+ */
120
+ /* public function generateRequestForPycAuth() {
121
+ try {
122
+ $payment = $this->getPayment();
123
+ $hasEncryption = $this->_hasEncryption();
124
+
125
+ $key = $this->_getConfig('key', 'upop_general');
126
+ $encryption = $hasEncryption ? '1' : '0';
127
+
128
+ $request = $this->_getRootNode();
129
+ $transaction = $request->addChild('TRANSACTION');
130
+ $fields = $transaction->addChild('FIELDS');
131
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
132
+ $fields->addChild('SERVICE', 'DBT');
133
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
134
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
135
+ $fields->addChild('SERVICE_FORMAT', '1010');
136
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
137
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
138
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
139
+ //If a different currecy is selected by the customer
140
+ if ($payment->getId() && $payment->getUpopCurrencyCode()) {
141
+ if ($payment->getUpopCurrencyCode() == $this->getNativeCurrency()) {
142
+ $fields->addChild('CURRENCY_INDICATOR', '0');
143
+ } else {
144
+ $fields->addChild('CURRENCY_INDICATOR', '1');
145
+ }
146
+ } else {
147
+ $fields->addChild('CURRENCY_INDICATOR', '0');
148
+ }
149
+
150
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmount(), 2, '.', ''));
151
+
152
+ //$url = ($_SERVER['REQUEST_SCHEME']?$_SERVER['REQUEST_SCHEME']:($_SERVER['HTTPS']?'https':'http')).'://' . $_SERVER['HTTP_HOST'];
153
+ $url = Mage::getUrl('upop/onepage/response', array('_secure' => true));
154
+ $fields->addChild('UP_FRONTENDURL', $url);
155
+ //$fields->addChild('ENTRY_MODE', '');
156
+ //$fields->addChild('FESP_IND', '9'); //added
157
+ // $fields->addChild('CLIENT_IP', $_SERVER['SERVER_ADDR']);//alredy here
158
+ //Sending Few Additional data to Gateway
159
+ $this->addAdditionalData($fields, true);
160
+ $this->setTransactionForLog($request);
161
+
162
+ if ($hasEncryption) {
163
+ $this->_encryptRequest($request);
164
+ }
165
+ $this->setTransaction($request);
166
+ } catch (Exception $e) {
167
+ Mage::throwException($e->getmessage());
168
+ }
169
+
170
+ return $this;
171
+ } */
172
+
173
+ /**
174
+ * Generates the Transaction Xml for authorization
175
+ *
176
+ * @return PlanetPayment_Upop_Model_Xml_Request
177
+ */
178
+ public function generateApiRequestForPycAuth() {
179
+ try {
180
+ $hasEncryption = $this->_hasEncryption();
181
+
182
+ //$key = $this->_getConfig('key', 'upop_general');
183
+ //$encryption = $hasEncryption ? '1' : '0';
184
+
185
+ $request = $this->_getRootNode();
186
+ $transaction = $request->addChild('TRANSACTION');
187
+ $fields = $transaction->addChild('FIELDS');
188
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
189
+ $fields->addChild('SERVICE', 'DBT');
190
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
191
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
192
+ $fields->addChild('SERVICE_FORMAT', '1010');
193
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
194
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
195
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
196
+ //If a different currecy is selected by the customer
197
+ if ($this->getUpopCurrencyCode() == $this->getNativeCurrency()) {
198
+ $fields->addChild('CURRENCY_INDICATOR', '0');
199
+ } else {
200
+ $fields->addChild('CURRENCY_INDICATOR', '1');
201
+ }
202
+
203
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmount(), 2, '.', ''));
204
+
205
+ $url = Mage::getUrl('upop/onepage/response', array('_secure' => true));
206
+ $fields->addChild('UP_FRONTENDURL', $url);
207
+ $this->addAdditionalData($fields, true);
208
+ $this->setTransactionForLog($request);
209
+
210
+ if ($hasEncryption) {
211
+ $this->_encryptRequest($request);
212
+ }
213
+ $this->setTransaction($request);
214
+ } catch (Exception $e) {
215
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
216
+
217
+ Mage::throwException($e->getmessage());
218
+ }
219
+
220
+ return $this;
221
+ }
222
+
223
+ /**
224
+ * Generates the Transaction Xml for authorization
225
+ *
226
+ * @return PlanetPayment_Upop_Model_Xml_Request
227
+ */
228
+ /* public function generateRequestForMcpAuth() {
229
+ try {
230
+ $payment = $this->getPayment();
231
+ $quote = Mage::helper('upop')->getQuote();
232
+ $quoteCurrency = $quote->getQuoteCurrencyCode();
233
+ $billingAddress = $quote->getBillingAddress();
234
+ $hasEncryption = $this->_hasEncryption();
235
+
236
+ $key = $this->_getConfig('key', 'upop_general');
237
+ $encryption = $hasEncryption ? '1' : '0';
238
+
239
+ $request = $this->_getRootNode();
240
+ $transaction = $request->addChild('TRANSACTION');
241
+ $fields = $transaction->addChild('FIELDS');
242
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
243
+ $fields->addChild('SERVICE', 'DBT');
244
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
245
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
246
+ $fields->addChild('SERVICE_FORMAT', '1010');
247
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
248
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
249
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($quoteCurrency));
250
+ if ($quoteCurrency != $this->getNativeCurrency()) {
251
+ $fields->addChild('CURRENCY_INDICATOR', '1');
252
+ } else {
253
+ $fields->addChild('CURRENCY_INDICATOR', '0');
254
+ }
255
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmountInStoreCurrency(), 2, '.', ''));
256
+ $url = Mage::getUrl('upop/onepage/response', array('_secure' => true));
257
+ $fields->addChild('UP_FRONTENDURL', $url);
258
+ //$fields->addChild('ENTRY_MODE', '');
259
+ // $fields->addChild('CLIENT_IP', $_SERVER['SERVER_ADDR']);
260
+ // $fields->addChild('FESP_IND', '9'); //uncomment
261
+ //Sending Few Additional data to Gateway
262
+ $this->addAdditionalData($fields, true);
263
+ $this->setTransactionForLog($request);
264
+
265
+ if ($hasEncryption) {
266
+ $this->_encryptRequest($request);
267
+ }
268
+ $this->setTransaction($request);
269
+ } catch (Exception $e) {
270
+ Mage::throwException($e->getmessage());
271
+ }
272
+
273
+ return $this;
274
+ } */
275
+
276
+ /**
277
+ * Generates the Transaction Xml for authorization
278
+ *
279
+ * @return PlanetPayment_Upop_Model_Xml_Request
280
+ */
281
+ public function generateApiRequestForMcpAuth() {
282
+ try {
283
+ //$payment = $this->getPayment();
284
+ //$quote = Mage::helper('upop')->getQuote();
285
+ $quoteCurrency = $this->getQuoteCurrencyCode();
286
+ //$billingAddress = $quote->getBillingAddress();
287
+ $hasEncryption = $this->_hasEncryption();
288
+ $request = $this->_getRootNode();
289
+ $transaction = $request->addChild('TRANSACTION');
290
+ $fields = $transaction->addChild('FIELDS');
291
+
292
+ $payment_action = Mage::getModel('upop/upop')->getConfigData('payment_action');
293
+ if ($payment_action == PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE) {
294
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
295
+ } elseif ($payment_action == PlanetPayment_Upop_Model_Upop::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
296
+ $fields->addChild('SERVICE_SUBTYPE', 'SALE');
297
+ }
298
+
299
+
300
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
301
+ $fields->addChild('SERVICE', 'DBT');
302
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
303
+
304
+ //$fields->addChild('SERVICE_SUBTYPE', 'SALE');
305
+ $fields->addChild('SERVICE_FORMAT', '1010');
306
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
307
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
308
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($quoteCurrency));
309
+ if ($quoteCurrency != $this->getNativeCurrency()) {
310
+ $fields->addChild('CURRENCY_INDICATOR', '1');
311
+ } else {
312
+ $fields->addChild('CURRENCY_INDICATOR', '0');
313
+ }
314
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmountInStoreCurrency(), 2, '.', ''));
315
+ $url = Mage::getUrl('upop/index/response', array('_secure' => true));
316
+ $fields->addChild('UP_FRONTENDURL', $url);
317
+ $this->addAdditionalData($fields, true);
318
+ $this->setTransactionForLog($request);
319
+
320
+ if ($hasEncryption) {
321
+ $this->_encryptRequest($request);
322
+ }
323
+ $this->setTransaction($request);
324
+ } catch (Exception $e) {
325
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
326
+ Mage::throwException($e->getmessage());
327
+ }
328
+
329
+ return $this;
330
+ }
331
+
332
+ /**
333
+ * Generates the Transaction Xml Fo Pyc Currency rate query
334
+ *
335
+ * @return PlanetPayment_Upop_Model_Xml_Request
336
+ */
337
+ public function generatePycCurrencyRateQueryRequest() {
338
+ //print "3";exit;//
339
+ try {
340
+ $payment = $this->getPayment();
341
+ $profile = $this->_getProfile($payment->getUpopProfileId());
342
+ $quote = $this->getQuote();
343
+ $currencyCode = $this->_getCurrencyIsoCode($quote->getQuoteCurrencyCode());
344
+ $hasEncryption = $this->_hasEncryption();
345
+
346
+ $key = $this->_getConfig('key', 'upop_general');
347
+ $encryption = $hasEncryption ? '1' : '0';
348
+
349
+ $request = $this->_getRootNode();
350
+ $transaction = $request->addChild('TRANSACTION');
351
+ $fields = $transaction->addChild('FIELDS');
352
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
353
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
354
+ $fields->addChild('SERVICE_FORMAT', '0000');
355
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
356
+ $fields->addChild('CURRENCY_INDICATOR', '2');
357
+ $fields->addChild('SERVICE', 'CURRENCY');
358
+ $fields->addChild('SERVICE_TYPE', 'RATE');
359
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
360
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmount(), 2, '.', ''));
361
+ if ($profile->getAccountId()) {
362
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
363
+ } else {
364
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($payment->getCcExpMonth(), $payment->getCcExpYear()));
365
+ $fields->addChild('ACCOUNT_NUMBER', $payment->getCcNumber());
366
+ }
367
+ $fields->addChild('QUERY_TYPE', '0');
368
+ // $fields->addChild('FESP_IND', '9');
369
+ //Sending Few Additional data to Gateway
370
+ $this->addAdditionalData($fields, true);
371
+
372
+ $this->setTransactionForLog($request);
373
+
374
+ if ($hasEncryption) {
375
+ $this->_encryptRequest($request);
376
+ }
377
+
378
+ $this->setTransaction($request);
379
+ } catch (Exception $e) {
380
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
381
+ Mage::throwException($e->getmessage());
382
+ }
383
+
384
+ return $this;
385
+ }
386
+
387
+ /**
388
+ * Transaction request for currency rate look up for mcp
389
+ *
390
+ * @return PlanetPayment_Upop_Model_Xml_Request
391
+ */
392
+ public function generateCurrencyRateLookUpRequest() {
393
+ //print "4";exit;//
394
+ try {
395
+ $hasEncryption = $this->_hasEncryption();
396
+
397
+ $key = $this->_getConfig('key', 'upop_general');
398
+ $encryption = $hasEncryption ? '1' : '0';
399
+ $request = $this->_getRootNode();
400
+ $transaction = $request->addChild('TRANSACTION');
401
+ $fields = $transaction->addChild('FIELDS');
402
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
403
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
404
+ $fields->addChild('SERVICE_FORMAT', '0000');
405
+ $fields->addChild('CURRENCY_INDICATOR', '1');
406
+ $fields->addChild('SERVICE', 'CURRENCY');
407
+ $fields->addChild('SERVICE_TYPE', 'RATE');
408
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
409
+ $fields->addChild('QUERY_TYPE', '1');
410
+ // $fields->addChild('FESP_IND', '9'); //added
411
+ //Sending Few Additional data to Gateway
412
+ $this->addAdditionalData($fields, true);
413
+ $this->setTransactionForLog($request);
414
+ $this->setCurrencyRate(true);
415
+
416
+ if ($hasEncryption) {
417
+ $this->_encryptRequest($request);
418
+ }
419
+
420
+ $this->setTransaction($request);
421
+ } catch (Exception $e) {
422
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
423
+ Mage::throwException($e->getmessage());
424
+ }
425
+
426
+ return $this;
427
+ }
428
+
429
+ /**
430
+ * Generating transaction request for adding a new Client Profille
431
+ *
432
+ * @return PlanetPayment_Upop_Model_Xml_Request
433
+ */
434
+ public function generateNewWalletProfileRequest() {
435
+ //print "5";exit;//
436
+ try {
437
+ $profile = $this->getUpopPaymentProfile();
438
+ if ($profile) {
439
+ $hasEncryption = $this->_hasEncryption();
440
+
441
+ $key = $this->_getConfig('key', 'upop_general');
442
+ $encryption = $hasEncryption ? '1' : '0';
443
+ $request = $this->_getRootNode();
444
+ $transaction = $request->addChild('TRANSACTION');
445
+ $fields = $transaction->addChild('FIELDS');
446
+ $fields->addChild('SERVICE', 'WALLET');
447
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
448
+ $fields->addChild('SERVICE_SUBTYPE', 'INSERT');
449
+ $fields->addChild('SERVICE_FORMAT', '1010');
450
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
451
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
452
+ $fields->addChild('FIRST_NAME', htmlentities($profile->getFirstName(), ENT_QUOTES));
453
+ $fields->addChild('LAST_NAME', htmlentities($profile->getLastName(), ENT_QUOTES));
454
+ $fields->addChild('ADDRESS', $this->_conditionAddress($profile->getAddress()));
455
+ $fields->addChild('CITY', htmlentities($profile->getCity(), ENT_QUOTES));
456
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($profile->getZip()));
457
+ $fields->addChild('STATE', htmlentities($profile->getState(), ENT_QUOTES));
458
+ $fields->addChild('COUNTRY', htmlentities($profile->getCountry(), ENT_QUOTES));
459
+ $fields->addChild('ACCOUNT', 'CC');
460
+ $fields->addChild('ACCOUNT_NUMBER', $profile->getCardNumber());
461
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
462
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($profile->getExpirationMonth(), $profile->getExpirationYear()));
463
+ $fields->addChild('CVV', $profile->getCardCode());
464
+ $fields->addChild('BILLING_TRANSACTION', '2');
465
+ //$fields->addChild('FESP_IND', '9');
466
+ //Sending Few Additional data to Gateway
467
+ $this->addAdditionalData($fields, true);
468
+
469
+ $this->setTransactionForLog($request);
470
+
471
+
472
+ if ($hasEncryption) {
473
+ $this->_encryptRequest($request);
474
+ }
475
+
476
+ $this->setTransaction($request);
477
+ } else {
478
+ Mage::log("failed to create payment profile", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
479
+ Mage::throwException("failed to create payment profile");
480
+ }
481
+ } catch (Exception $e) {
482
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
483
+ Mage::throwException($e->getmessage());
484
+ }
485
+
486
+ return $this;
487
+ }
488
+
489
+ /**
490
+ * Generate Xml request for updating customer profile
491
+ *
492
+ * @return PlanetPayment_Upop_Model_Xml_Request
493
+ */
494
+ public function generateUpdateClientRequest() {
495
+ //print "6";exit;//
496
+ try {
497
+ $profile = $this->getUpopPaymentProfile();
498
+ if ($profile) {
499
+ $hasEncryption = $this->_hasEncryption();
500
+
501
+ $key = $this->_getConfig('key', 'upop_general');
502
+ $encryption = $hasEncryption ? '1' : '0';
503
+ $request = $this->_getRootNode();
504
+ $transaction = $request->addChild('TRANSACTION');
505
+ $fields = $transaction->addChild('FIELDS');
506
+ $fields->addChild('SERVICE', 'WALLET');
507
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
508
+ $fields->addChild('SERVICE_SUBTYPE', 'MODIFY');
509
+ $fields->addChild('SERVICE_FORMAT', '1010');
510
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
511
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
512
+ $fields->addChild('CLIENT_ID', $profile->getClientId());
513
+ $fields->addChild('FIRST_NAME', htmlentities($profile->getFirstName(), ENT_QUOTES));
514
+ $fields->addChild('LAST_NAME', htmlentities($profile->getLastName(), ENT_QUOTES));
515
+ $fields->addChild('ADDRESS', $this->_conditionAddress($profile->getAddress()));
516
+ $fields->addChild('CITY', htmlentities($profile->getCity(), ENT_QUOTES));
517
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($profile->getZip()));
518
+ $fields->addChild('STATE', htmlentities($profile->getState(), ENT_QUOTES));
519
+ $fields->addChild('COUNTRY', htmlentities($profile->getCountry(), ENT_QUOTES));
520
+ //$fields->addChild('FESP_IND', '9');
521
+ //Sending Few Additional data to Gateway
522
+ $this->addAdditionalData($fields, true);
523
+
524
+ $this->setTransactionForLog($request);
525
+
526
+
527
+ if ($hasEncryption) {
528
+ $this->_encryptRequest($request);
529
+ }
530
+
531
+ $this->setTransaction($request);
532
+ } else {
533
+ Mage::log("failed to Update payment profile", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
534
+ Mage::throwException("failed to Update payment profile");
535
+ }
536
+ } catch (Exception $e) {
537
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
538
+ Mage::throwException($e->getmessage());
539
+ }
540
+
541
+ return $this;
542
+ }
543
+
544
+ /**
545
+ * Generating the xml reauest for updating customer card details
546
+ *
547
+ * @return PlanetPayment_Upop_Model_Xml_Request
548
+ */
549
+ public function generateUpdateAccountRequest() {
550
+ //print "8";exit;//
551
+ try {
552
+ $profile = $this->getUpopPaymentProfile();
553
+ if ($profile) {
554
+ $hasEncryption = $this->_hasEncryption();
555
+
556
+ $key = $this->_getConfig('key', 'upop_general');
557
+ $encryption = $hasEncryption ? '1' : '0';
558
+ $request = $this->_getRootNode();
559
+ $transaction = $request->addChild('TRANSACTION');
560
+ $fields = $transaction->addChild('FIELDS');
561
+ $fields->addChild('SERVICE', 'WALLET');
562
+ $fields->addChild('SERVICE_TYPE', 'ACCOUNT');
563
+ $fields->addChild('SERVICE_SUBTYPE', 'MODIFY');
564
+ $fields->addChild('SERVICE_FORMAT', '1010');
565
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
566
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
567
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
568
+ $fields->addChild('ACCOUNT_NUMBER', $profile->getCardNumber());
569
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
570
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($profile->getExpirationMonth(), $profile->getExpirationYear()));
571
+ $fields->addChild('CVV', $profile->getCardCode());
572
+ //$fields->addChild('FESP_IND', '9');
573
+ //Sending Few Additional data to Gateway
574
+ $this->addAdditionalData($fields, true);
575
+
576
+ $this->setTransactionForLog($request);
577
+
578
+
579
+ if ($hasEncryption) {
580
+ $this->_encryptRequest($request);
581
+ } else {
582
+ $fields->addChild('PIN', $this->_getConfig('terminal_id', 'pin'));
583
+ }
584
+
585
+ $this->setTransaction($request);
586
+ } else {
587
+ Mage::log("failed to update payment profile", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
588
+ Mage::throwException("failed to update payment profile");
589
+ }
590
+ } catch (Exception $e) {
591
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
592
+ Mage::throwException($e->getmessage());
593
+ }
594
+
595
+ return $this;
596
+ }
597
+
598
+ /**
599
+ * Deleting Customer profile from Planet payment
600
+ *
601
+ * @return PlanetPayment_Upop_Model_Xml_Request
602
+ */
603
+ public function generateDeleteClientRequest() {
604
+ //print "8";exit;//
605
+ try {
606
+ $profile = $this->getUpopPaymentProfile();
607
+ if ($profile) {
608
+ $hasEncryption = $this->_hasEncryption();
609
+
610
+ $key = $this->_getConfig('key', 'upop_general');
611
+ $encryption = $hasEncryption ? '1' : '0';
612
+ $request = $this->_getRootNode();
613
+ $transaction = $request->addChild('TRANSACTION');
614
+ $fields = $transaction->addChild('FIELDS');
615
+ $fields->addChild('SERVICE', 'WALLET');
616
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
617
+ $fields->addChild('SERVICE_SUBTYPE', 'DELETE');
618
+ $fields->addChild('SERVICE_FORMAT', '1010');
619
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
620
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
621
+ $fields->addChild('CLIENT_ID', $profile->getClientId());
622
+ // $fields->addChild('FESP_IND', '9');
623
+ //Sending Few Additional data to Gateway
624
+ $this->addAdditionalData($fields, true);
625
+
626
+ $this->setTransactionForLog($request);
627
+
628
+ if ($hasEncryption) {
629
+ $this->_encryptRequest($request);
630
+ }
631
+
632
+ $this->setTransaction($request);
633
+ } else {
634
+ Mage::log("failed to delete payment profile", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
635
+ Mage::throwException("failed to delete payment profile");
636
+ }
637
+ } catch (Exception $e) {
638
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
639
+ Mage::throwException($e->getmessage());
640
+ }
641
+
642
+ return $this;
643
+ }
644
+
645
+ /**
646
+ * Test configurations
647
+ * @return \PlanetPayment_Upop_Model_Xml_Request
648
+ */
649
+ public function generateTestConfigurationRequest() {
650
+ //print "9";exit;//
651
+ try {
652
+ $hasEncryption = $this->_hasEncryption();
653
+
654
+ $key = $this->_getConfig('key', 'upop_general');
655
+ $encryption = $hasEncryption ? '1' : '0';
656
+ $request = $this->_getRootNode();
657
+ $transaction = $request->addChild('TRANSACTION');
658
+ $fields = $transaction->addChild('FIELDS');
659
+ $fields->addChild('SERVICE', 'NETWORK');
660
+ $fields->addChild('SERVICE_TYPE', 'STATUS');
661
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
662
+ $fields->addChild('SERVICE_FORMAT', '0000');
663
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
664
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
665
+ //$fields->addChild('FESP_IND', '9');
666
+ //Sending Few Additional data to Gateway
667
+ $this->addAdditionalData($fields, false);
668
+
669
+ $this->setTransactionForLog($request);
670
+
671
+ if ($hasEncryption) {
672
+ $this->_encryptRequest($request);
673
+ }
674
+
675
+ $this->setTransaction($request);
676
+ } catch (Exception $e) {
677
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
678
+ Mage::throwException($e->getmessage());
679
+ }
680
+
681
+ return $this;
682
+ }
683
+
684
+ /**
685
+ * Generate Request for Capture
686
+ *
687
+ * @return \PlanetPayment_Upop_Model_Xml_Request
688
+ */
689
+ public function generateRequestForCapture() {
690
+ //print "10";exit;//
691
+ try {
692
+ $payment = $this->getPayment();
693
+ if ($payment) {
694
+ $hasEncryption = $this->_hasEncryption();
695
+ $billingAddress = $payment->getOrder()->getBillingAddress();
696
+ $key = $this->_getConfig('key', 'upop_general');
697
+ $encryption = $hasEncryption ? '1' : '0';
698
+ $request = $this->_getRootNode();
699
+ $transaction = $request->addChild('TRANSACTION');
700
+ $fields = $transaction->addChild('FIELDS');
701
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
702
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
703
+ $fields->addChild('SERVICE_FORMAT', '1010');
704
+ $paymentType = $this->_getPaymentType($payment);
705
+
706
+ if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
707
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
708
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
709
+ $fields->addChild('CURRENCY_INDICATOR', '2');
710
+ } else {
711
+ $fields->addChild('CURRENCY_INDICATOR', '0');
712
+ }
713
+ } elseif ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP) {
714
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
715
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
716
+ $fields->addChild('CURRENCY_INDICATOR', '1');
717
+ } else {
718
+ $fields->addChild('CURRENCY_INDICATOR', '0');
719
+ }
720
+ }
721
+
722
+ $fields->addChild('TRANSACTION_ID', $payment->getLastTransId());
723
+ $fields->addChild('SERVICE', 'DBT');
724
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
725
+ $fields->addChild('SERVICE_SUBTYPE', 'CAPTURE');
726
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmountInStoreCurrency(), 2, '.', ''));
727
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
728
+ // $fields->addChild('FESP_IND', '9');
729
+ //Sending Few Additional data to Gateway
730
+ $this->addAdditionalData($fields, false);
731
+
732
+ $this->setTransactionForLog($request);
733
+
734
+ if ($hasEncryption) {
735
+ $this->_encryptRequest($request);
736
+ }
737
+
738
+ $this->setTransaction($request);
739
+ } else {
740
+ Mage::log("Unable to capture", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
741
+ Mage::throwException("Unable to capture");
742
+ }
743
+ } catch (Exception $e) {
744
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
745
+ Mage::throwException($e->getmessage());
746
+ }
747
+
748
+ return $this;
749
+ }
750
+
751
+ /**
752
+ * Generate Request for Sale
753
+ *
754
+ * @return \PlanetPayment_Upop_Model_Xml_Request
755
+ */
756
+ public function generateRequestForSale() {
757
+
758
+ try {
759
+ $payment = $this->getPayment();
760
+ $quote = Mage::helper('upop')->getQuote();
761
+ $billingAddress = $quote->getBillingAddress();
762
+
763
+ $hasEncryption = $this->_hasEncryption();
764
+
765
+ $key = $this->_getConfig('key', 'upop_general');
766
+ $encryption = $hasEncryption ? '1' : '0';
767
+
768
+ $request = $this->_getRootNode();
769
+ $transaction = $request->addChild('TRANSACTION');
770
+ $fields = $transaction->addChild('FIELDS');
771
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
772
+ $fields->addChild('SERVICE', 'DBT');
773
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
774
+ $fields->addChild('SERVICE_SUBTYPE', 'SALE');
775
+ $fields->addChild('SERVICE_FORMAT', '1010');
776
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
777
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
778
+ $paymentType = $this->_getPaymentType($payment);
779
+ if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
780
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
781
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
782
+ $fields->addChild('CURRENCY_INDICATOR', '2');
783
+ } else {
784
+ $fields->addChild('CURRENCY_INDICATOR', '0');
785
+ }
786
+ } elseif ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP) {
787
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
788
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
789
+
790
+ $fields->addChild('CURRENCY_INDICATOR', '1');
791
+ } else {
792
+ $fields->addChild('CURRENCY_INDICATOR', '0');
793
+ }
794
+ }
795
+ $fields->addChild('AMOUNT', round($quote->getGrandTotal(), 2));
796
+ $url = Mage::getUrl('upop/onepage/response', array('_secure' => true));
797
+ $fields->addChild('UP_FRONTENDURL', $url);
798
+ $fields->addChild('ENTRY_MODE', '3');
799
+ // $fields->addChild('CLIENT_IP', $_SERVER['SERVER_ADDR']);
800
+ // $fields->addChild('FESP_IND', '9');
801
+ //Sending Few Additional data to Gateway
802
+ $this->addAdditionalData($fields, true);
803
+ $this->setTransactionForLog($request);
804
+
805
+ if ($hasEncryption) {
806
+ $this->_encryptRequest($request);
807
+ }
808
+ $this->setTransaction($request);
809
+ } catch (Exception $e) {
810
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
811
+ Mage::throwException($e->getmessage());
812
+ }
813
+
814
+ return $this;
815
+ }
816
+
817
+ /**
818
+ * Generate Request for Void
819
+ *
820
+ * @return \PlanetPayment_Upop_Model_Xml_Request
821
+ */
822
+ public function generateRequestForVoid() {
823
+ //print "12";exit;
824
+ try {
825
+ $payment = $this->getPayment();
826
+ if ($payment) {
827
+ $hasEncryption = $this->_hasEncryption();
828
+
829
+ $key = $this->_getConfig('key', 'upop_general');
830
+ $encryption = $hasEncryption ? '1' : '0';
831
+ $request = $this->_getRootNode();
832
+ $transaction = $request->addChild('TRANSACTION');
833
+ $fields = $transaction->addChild('FIELDS');
834
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
835
+ $fields->addChild('SERVICE_FORMAT', '1010');
836
+ $fields->addChild('TRANSACTION_ID', $payment->getLastTransId());
837
+ $fields->addChild('SERVICE', 'DBT');
838
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
839
+ $fields->addChild('SERVICE_SUBTYPE', 'VOID');
840
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
841
+ // $fields->addChild('FESP_IND', '9');
842
+ //Sending Few Additional data to Gateway
843
+ $this->addAdditionalData($fields, false);
844
+ $this->setTransactionForLog($request);
845
+
846
+ if ($hasEncryption) {
847
+ $this->_encryptRequest($request);
848
+ }
849
+
850
+ $this->setTransaction($request);
851
+ } else {
852
+ Mage::log("Unable to Void", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
853
+ Mage::throwException("Unable to Void");
854
+ }
855
+ } catch (Exception $e) {
856
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
857
+ Mage::throwException($e->getmessage());
858
+ }
859
+
860
+ return $this;
861
+ }
862
+
863
+ /**
864
+ * Generate Request for Refund
865
+ *
866
+ * @return \PlanetPayment_Upop_Model_Xml_Request
867
+ */
868
+ public function generateRequestForRefund() {
869
+ try {
870
+ $payment = $this->getPayment();
871
+ if ($payment) {
872
+ $hasEncryption = $this->_hasEncryption();
873
+
874
+ $key = $this->_getConfig('key', 'upop_general');
875
+ $encryption = $hasEncryption ? '1' : '0';
876
+ $request = $this->_getRootNode();
877
+ $transaction = $request->addChild('TRANSACTION');
878
+ $fields = $transaction->addChild('FIELDS');
879
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
880
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
881
+ $fields->addChild('SERVICE_FORMAT', '1010');
882
+ $paymentType = $this->_getPaymentType($payment);
883
+
884
+ if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
885
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
886
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
887
+ $fields->addChild('CURRENCY_INDICATOR', '2');
888
+ } else {
889
+ $fields->addChild('CURRENCY_INDICATOR', '0');
890
+ }
891
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmount(), 2, '.', ''));
892
+ } elseif ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP) {
893
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
894
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
895
+ $fields->addChild('CURRENCY_INDICATOR', '1');
896
+ } else {
897
+ $fields->addChild('CURRENCY_INDICATOR', '0');
898
+ }
899
+ $fields->addChild('AMOUNT', number_format((float) $this->getAmountInStoreCurrency(), 2, '.', '')); //refund in the currency of the charge
900
+ }
901
+
902
+ $fields->addChild('TRANSACTION_ID', $payment->getRefundTransactionId());
903
+ $fields->addChild('SERVICE', 'DBT');
904
+ $fields->addChild('SERVICE_TYPE', 'CREDIT');
905
+ $fields->addChild('SERVICE_SUBTYPE', 'REFUND');
906
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
907
+ // $fields->addChild('FESP_IND', '9'); //uncomment
908
+ //Sending Few Additional data to Gateway
909
+ $this->addAdditionalData($fields, false);
910
+ $this->setTransactionForLog($request);
911
+
912
+ if ($hasEncryption) {
913
+ $this->_encryptRequest($request);
914
+ }
915
+
916
+ $this->setTransaction($request);
917
+ } else {
918
+ Mage::log("Unable to Refund", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
919
+ Mage::throwException("Unable to Refund");
920
+ }
921
+ } catch (Exception $e) {
922
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
923
+ Mage::throwException($e->getmessage());
924
+ }
925
+
926
+ return $this;
927
+ }
928
+
929
+ /**
930
+ * Generates the Transaction Xml for seond-pass request
931
+ *
932
+ * @return PlanetPayment_Upop_Model_Xml_Request
933
+ */
934
+ public function generateSecondRequest() {
935
+ try {
936
+ //Get Payment instance
937
+ $payment = $this->getPayment();
938
+ $param = $this->getParam();
939
+
940
+ $hasEncryption = $this->_hasEncryption();
941
+
942
+ $key = $this->_getConfig('key', 'upop_general');
943
+ $encryption = $hasEncryption ? '1' : '0';
944
+
945
+ $request = $this->_getRootNode();
946
+ $transaction = $request->addChild('TRANSACTION');
947
+ $fields = $transaction->addChild('FIELDS');
948
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
949
+ $fields->addChild('SERVICE', 'DBT');
950
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
951
+
952
+ $fields->addChild('SERVICE_SUBTYPE', $this->getTransactionType());
953
+ $fields->addChild('SERVICE_FORMAT', '1010');
954
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
955
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
956
+ $fields->addChild('CURRENCY_CODE', $param['orderCurrency']);
957
+ //If a different currency is selected by the customer
958
+ if ($param['orderCurrency']) {
959
+ if ($this->_getCurrencyFromIsoCode($param['orderCurrency']) == $this->getNativeCurrency()) {
960
+ $fields->addChild('CURRENCY_INDICATOR', '0');
961
+ } else {
962
+ $fields->addChild('CURRENCY_INDICATOR', '1');
963
+ }
964
+ } else {
965
+ $fields->addChild('CURRENCY_INDICATOR', '0');
966
+ }
967
+ $fields->addChild('AMOUNT', number_format($param['orderAmount'] / 100, 2, '.', ''));
968
+ $fields->addChild('UP_ORDERNUMBER', $param['orderNumber']);
969
+ // $fields->addChild('UP_PAYLOAD', htmlspecialchars($this->getUpPayload()));
970
+ $fields->addChild('UP_PAYLOAD64', $this->getUpPayload64());
971
+
972
+ //Sending Few Additional data to Gateway
973
+ $this->addAdditionalData($fields, true);
974
+ $this->setTransactionForLog($request);
975
+
976
+ if ($hasEncryption) {
977
+ $this->_encryptRequest($request);
978
+ }
979
+ $this->setTransaction($request);
980
+ } catch (Exception $e) {
981
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
982
+ Mage::throwException($e->getmessage());
983
+ }
984
+
985
+ return $this;
986
+ }
987
+
988
+ /**
989
+ * Generates the Transaction Xml for seond-pass request
990
+ *
991
+ * @return PlanetPayment_Upop_Model_Xml_Request
992
+ */
993
+ public function generateSecondPassiPayRequest() {
994
+ try {
995
+ $param = $this->getParam();
996
+
997
+ $hasEncryption = $this->_hasEncryption();
998
+
999
+ $key = $this->_getConfig('key', 'upop_general');
1000
+ $encryption = $hasEncryption ? '1' : '0';
1001
+
1002
+ $request = $this->_getRootNode();
1003
+ $transaction = $request->addChild('TRANSACTION');
1004
+ $fields = $transaction->addChild('FIELDS');
1005
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
1006
+ $fields->addChild('SERVICE', 'DBT');
1007
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
1008
+
1009
+ $fields->addChild('SERVICE_SUBTYPE', $this->getTransactionType());
1010
+ $fields->addChild('SERVICE_FORMAT', '1010');
1011
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
1012
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
1013
+ $fields->addChild('CURRENCY_CODE', $param['orderCurrency']);
1014
+ //If a different currency is selected by the customer
1015
+ if ($param['orderCurrency']) {
1016
+ if ($this->_getCurrencyFromIsoCode($param['orderCurrency']) == $this->getNativeCurrency()) {
1017
+ $fields->addChild('CURRENCY_INDICATOR', '0');
1018
+ } else {
1019
+ $fields->addChild('CURRENCY_INDICATOR', '1');
1020
+ }
1021
+ } else {
1022
+ $fields->addChild('CURRENCY_INDICATOR', '0');
1023
+ }
1024
+ $fields->addChild('AMOUNT', number_format($param['orderAmount'] / 100, 2, '.', ''));
1025
+ $fields->addChild('UP_ORDERNUMBER', $param['orderNumber']);
1026
+ //$fields->addChild('UP_PAYLOAD', htmlspecialchars($this->getUpPayload()));
1027
+ $fields->addChild('UP_PAYLOAD64', $this->getUpPayload64());
1028
+
1029
+ //Sending Few Additional data to Gateway
1030
+ $this->addAdditionalData($fields, true);
1031
+ $this->setTransactionForLog($request);
1032
+
1033
+ if ($hasEncryption) {
1034
+ $this->_encryptRequest($request);
1035
+ }
1036
+ $this->setTransaction($request);
1037
+ } catch (Exception $e) {
1038
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
1039
+ Mage::throwException($e->getmessage());
1040
+ }
1041
+
1042
+ return $this;
1043
+ }
1044
+
1045
+ /**
1046
+ * Sending the DBT STATUS request to Planet Payment
1047
+ *
1048
+ * @return PlanetPayment_Upop_Model_Xml_Request
1049
+ */
1050
+ public function generateRequestForDBT() {
1051
+ try {
1052
+ $order = $this->getOrder();
1053
+ $payment = $order->getPayment();
1054
+ $this->setPayment($payment);
1055
+ $hasEncryption = $this->_hasEncryption();
1056
+ $request = $this->_getRootNode();
1057
+ $transaction = $request->addChild('TRANSACTION');
1058
+ $fields = $transaction->addChild('FIELDS');
1059
+ $fields->addChild('AMOUNT', round($payment->getOrder()->getGrandTotal(), 2));
1060
+ $fields->addChild('SERVICE', 'DBT');
1061
+ $fields->addChild('SERVICE_TYPE', 'STATUS');
1062
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
1063
+ $fields->addChild('SERVICE_FORMAT', '1010');
1064
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'upop_general'));
1065
+ $fields->addChild('TRANSACTION_ID', $payment->getLastTransId());
1066
+ $fields->addChild('PIN', $this->_getConfig('pin', 'upop_general'));
1067
+ $this->addAdditionalData($fields, false);
1068
+ $this->setTransactionForLog($request);
1069
+ if ($hasEncryption) {
1070
+ $this->_encryptRequest($request);
1071
+ }
1072
+ $this->setTransaction($request);
1073
+ } catch (Exception $e) {
1074
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
1075
+ Mage::throwException($e->getmessage());
1076
+ }
1077
+ return $this;
1078
+ }
1079
+
1080
+ /**
1081
+ * Adding Order Id and Incremented Order id and Customer Ip to Request XML
1082
+ *
1083
+ * @param obj $fields
1084
+ * @param boolean $frontrequest
1085
+ */
1086
+ public function addAdditionalData($fields, $frontrequest = false) {
1087
+ $payment = $this->getPayment();
1088
+ if ($payment) {
1089
+ $order = $payment->getOrder(); //to create a order object
1090
+ //Set User data
1091
+ if ($order) {
1092
+ $fields->addChild('TICKET', $order->getIncrementId());
1093
+ $fields->addChild('USER_DATA_1', $order->getId());
1094
+ $fields->addChild('CLIENT_IP', $order->getData('remote_ip'));
1095
+ $fields->addChild('FESP_IND', '9');
1096
+ //Get Store Details from where order placed...
1097
+ $store = $order->getData('store_name');
1098
+ $store = str_replace(array("<br>", "\n", "\r"), '-', $store);
1099
+ $stores = explode('-', $store);
1100
+ $fields->addChild('USER_DATA_3', $stores[0]);
1101
+ $fields->addChild('USER_DATA_4', $stores[1]);
1102
+ $fields->addChild('USER_DATA_5', $stores[2]);
1103
+
1104
+ $frontrequest = false;
1105
+ }
1106
+ }
1107
+
1108
+ if ($frontrequest) {
1109
+ $fields->addChild('CLIENT_IP', $_SERVER['REMOTE_ADDR']);
1110
+ $fields->addChild('FESP_IND', '9');
1111
+ $fields->addChild('USER_DATA_3', Mage::app()->getWebsite()->getName());
1112
+ $fields->addChild('USER_DATA_4', Mage::app()->getGroup()->getName());
1113
+ $fields->addChild('USER_DATA_5', Mage::app()->getStore()->getName());
1114
+ }
1115
+
1116
+ $fields->addChild('USER_DATA_6', (string) Mage::getConfig()->getNode()->modules->PlanetPayment_Upop->version);
1117
+ $fields->addChild('USER_DATA_7', Mage::getVersion());
1118
+ }
1119
+
1120
+ /**
1121
+ * Sending the request to Planet Payment
1122
+ *
1123
+ * @return PlanetPayment_Upop_Model_Xml_Request
1124
+ */
1125
+ public function send() {
1126
+ $transaction = $this->getTransaction();
1127
+
1128
+ if ($transaction) {
1129
+ try {
1130
+ $isProduction = $this->_isProductionMode();
1131
+ if ($isProduction) {
1132
+ $url = PlanetPayment_Upop_Model_Upop::GATEWAY_URL_PRODUCTION;
1133
+ } else {
1134
+ $url = PlanetPayment_Upop_Model_Upop::GATEWAY_URL_TESTING;
1135
+ }
1136
+ //Selecting port based on the url
1137
+ $port = 86;
1138
+ if (strstr($url, 'https://')) {
1139
+ $port = 443;
1140
+ }
1141
+ //print $transaction->asXML();exit;
1142
+ $client = new Zend_Http_Client($url, array('keepalive' => true, 'timeout' => 360));
1143
+ $client->getUri()->setPort($port);
1144
+ $client->setRawData($transaction->asXML(), 'text/xml');
1145
+ $client->setMethod(Zend_Http_Client::POST);
1146
+ $response = $client->request()->getBody();
1147
+
1148
+ //Setting response to response model object
1149
+ $responseModel = $this->_getResponseModel();
1150
+ $responseModel->setUpopRequest($this);
1151
+ $responseModel->setUpopResponse($response);
1152
+ $this->setResponse($responseModel);
1153
+ } catch (Exception $e) {
1154
+ Mage::log($e->getmessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
1155
+ Mage::throwException($e->getmessage());
1156
+ }
1157
+
1158
+ return $this;
1159
+ } else {
1160
+ Mage::log("invalid Transaction", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
1161
+ Mage::throwException('invalid Transaction');
1162
+ }
1163
+ }
1164
+
1165
+ }
app/code/community/PlanetPayment/Upop/Model/Xml/Response.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Model_Xml_Response extends PlanetPayment_Upop_Model_Xml_Abstract {
30
+
31
+ protected $_responseXml = null;
32
+
33
+ /**
34
+ * returns the response after decryption
35
+ * @return object SImpleXML
36
+ */
37
+ protected function _getResponse() {
38
+ $response = $this->getUpopResponse();
39
+ if ($response) {
40
+ $xmlResponse = simplexml_load_string($response);
41
+ if ($xmlResponse instanceof SimpleXMLElement) {
42
+
43
+ /* if ($this->_hasEncryption() && $this->_isProductionMode()) {
44
+ $this->_responseXml = simplexml_load_string($this->_decryptResponse($xmlResponse[0]));
45
+ } elseif($this->_hasEncryption() && !$this->_isProductionMode()) {
46
+ $encoded_data = $xmlResponse[0];
47
+ $base64_encoded_data = base64_decode($encoded_data);
48
+ $this->_responseXml = simplexml_load_string($base64_encoded_data);
49
+ }
50
+ else {
51
+ $this->_responseXml = $xmlResponse->RESPONSE;
52
+ }*/
53
+
54
+
55
+ if ($this->_hasEncryption()) {
56
+ $this->_responseXml = simplexml_load_string($this->_decryptResponse($xmlResponse[0]));
57
+ } else {
58
+ $this->_responseXml = $xmlResponse->RESPONSE;
59
+ }
60
+
61
+ //Logging
62
+
63
+ $requestXml = $this->_getRequestObject()->getTransactionForLog()->asXML();
64
+ $requestXml = preg_replace("/<ACCOUNT_NUMBER>[0-9]+([0-9]{4})/", '<ACCOUNT_NUMBER>************$1', $requestXml);
65
+ $requestXml = preg_replace("/<CVV>([0-9]+)<\/CVV>/", '<CVV>***</CVV>', $requestXml);
66
+ $loggedInfo = Mage::helper('upop')->log($requestXml, $this->_responseXml->asXML(), $this->_getRequestObject()->getCurrencyRate());
67
+ Mage::log("Print Request : " . $loggedInfo->getRequest(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE, true);
68
+ Mage::log("Print Response : " . $loggedInfo->getResponse(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE, true);
69
+
70
+ //This will be saved in log file if any error occured while Auth.
71
+ //The database transaction will be rolled back if error.
72
+ $this->setlogInfo("\n \t Request:" . $loggedInfo->getRequest() . "\n \t Response:" . $loggedInfo->getResponse());
73
+ } else {
74
+ Mage::throwException('Invalid response');
75
+ }
76
+ } else {
77
+ Mage::throwException('Invalid response');
78
+ }
79
+
80
+ return $this->_responseXml;
81
+ }
82
+
83
+ /**
84
+ * Checking whether the request was successful
85
+ * @return bool
86
+ */
87
+ public function isSuccess() {
88
+ $responseXml = $this->_getResponse();
89
+ if ($responseXml->FIELDS->ARC) {
90
+ if ($responseXml->FIELDS->ARC == '00' && $responseXml->FIELDS->MRC == '00') {
91
+ return true;
92
+ } else {
93
+ $errorHelper = Mage::helper('upop/error');
94
+ $arcMsg = $errorHelper->getErrorMessage((string) $responseXml->FIELDS->ARC, 'arc');
95
+ $mrcMsg = $errorHelper->getErrorMessage((string) $responseXml->FIELDS->MRC, 'mrc');
96
+ $this->setMessage("<i> (" . $arcMsg . ", " . $mrcMsg . ")</i><br/>RESPONSE TEXT:" . $responseXml->FIELDS->RESPONSE_TEXT);
97
+ }
98
+ }
99
+
100
+ return false;
101
+ }
102
+
103
+ /**
104
+ * Returns the Xml content of response
105
+ * @return type
106
+ */
107
+ public function getXmlContent() {
108
+ if (!$this->_responseXml) {
109
+ $this->_getResponse();
110
+ }
111
+
112
+ return $this->_responseXml;
113
+ }
114
+
115
+ /**
116
+ * Returning the request object of this response
117
+ * @return type
118
+ */
119
+ protected function _getRequestObject() {
120
+ return $this->getUpopRequest();
121
+ }
122
+
123
+ }
app/code/community/PlanetPayment/Upop/controllers/Adminhtml/CheckoutController.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Adminhtml_CheckoutController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ public function getUpopCurrenciesAction() {
32
+ $postData = $this->getRequest()->getpost('payment', array());
33
+ $result['update_section'] = array(
34
+ 'name' => 'currency_selector',
35
+ 'html' => ''
36
+ );
37
+ try {
38
+ if ($postData) {
39
+ if (isset($postData['cc_number'])) {
40
+ $postData['cc_last4'] = substr($postData['cc_number'], 0, -4);
41
+ }
42
+ $quote = Mage::helper('upop')->getQuote();
43
+ $payment = $quote->getPayment();
44
+ $payment->importData($postData);
45
+
46
+ $quote->save();
47
+ if (isset($postData['method']) && $postData['method'] == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
48
+ try {
49
+ $method = $payment->getMethodInstance();
50
+ $paymentType = $method->getPaymentType();
51
+ if ($paymentType == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC) {
52
+ // //Preparing & Sending request for PYC Rate Query
53
+ // $quote->setUpopProfileId($payment->getUpopProfileId());
54
+ $request = $this->_getUpopRequestModel()
55
+ ->setPayment($payment)
56
+ ->setQuote($quote)
57
+ ->setAmount($quote->getGrandTotal());
58
+
59
+ $request->generatePycCurrencyRateQueryRequest()
60
+ ->send();
61
+
62
+ //Getting Response Object
63
+ $response = $request->getResponse();
64
+ //Checking whether the request succeed
65
+ if ($response->isSuccess()) {
66
+ //Loading Currency section if request succeed
67
+ $this->loadLayout('upopadmin_adminhtml_checkout_getUpopCurrencies');
68
+ $result['update_section'] = array(
69
+ 'name' => 'currency_selector',
70
+ 'html' => $this->_getCurrencySelectorHtml($response)
71
+ );
72
+ } else {
73
+ //Throwing an error to load the review section
74
+ $result['error'] = true;
75
+ $result['message'] = "Upop Request Failed. Message: {$response->getMessage()}";
76
+ }
77
+ }
78
+ } catch (Exception $e) {
79
+ $result['error'] = true;
80
+ $result['message'] = $e->getMessage();
81
+ }
82
+ }
83
+ }
84
+ } catch (Exception $e) {
85
+ $result['error'] = true;
86
+ $result['message'] = $e->getMessage();
87
+ }
88
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
89
+ }
90
+
91
+ public function updateCurrencyAction() {
92
+ $postData = $this->getRequest()->getpost('payment', array());
93
+ if ($postData) {
94
+ if (isset($postData['selected_currency'])) {
95
+ $quote = Mage::helper('upop')->getQuote();
96
+ $payment = $quote->getPayment();
97
+ $payment->setUpopCurrencyCode($postData['selected_currency']);
98
+ $quote->save();
99
+ }
100
+ }
101
+ }
102
+
103
+ protected function _getUpopRequestModel() {
104
+ return Mage::getModel('upop/xml_request');
105
+ }
106
+
107
+ protected function _getCurrencySelectorHtml($response) {
108
+ return $this->getLayout()->getBlock('root')->setResponse($response)->toHtml();
109
+ }
110
+
111
+ }
app/code/community/PlanetPayment/Upop/controllers/Adminhtml/CustomerController.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Adminhtml_CustomerController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ /**
32
+ * Inits the customer from the request.
33
+ *
34
+ * @return Mage_Customer_Model_Customer | false
35
+ */
36
+ protected function _initCustomer() {
37
+ $customerId = $this->getRequest()->getParam('customer_id');
38
+ if ($customerId) {
39
+ $customer = Mage::getModel('customer/customer')->load($customerId);
40
+ if ($customer->getId()) {
41
+ //Mage::register('current_customer', $customer);
42
+ return $customer;
43
+ }
44
+ }
45
+ return false;
46
+ }
47
+
48
+ /**
49
+ * Purges a customer profile and any payment profiles.
50
+ *
51
+ * @param Mage_Customer_Model_Customer $customer
52
+ * @return PlanetPayment_Upop_Adminhtml_CustomerController
53
+ */
54
+ // protected function _purgeProfile(Mage_Customer_Model_Customer $customer) {
55
+ // $profileId = $customer->getCimProfileId();
56
+ //
57
+ // // delete with CIM
58
+ // Mage::getModel('authnetcim/xml_customer')
59
+ // ->setCustomer($customer)
60
+ // ->delete();
61
+ //
62
+ // // delete local profiles
63
+ // Mage::getModel('authnetcim/paymentProfile')
64
+ // ->getResource()
65
+ // ->deleteByCustomerProfileId($profileId);
66
+ // }
67
+
68
+ /**
69
+ * Deletes a payment profile.
70
+ */
71
+ // public function deletePaymentProfileAction() {
72
+ // $customer = $this->_initCustomer();
73
+ // if ($customer) {
74
+ // $profileId = $this->getRequest()->getParam('profile_id');
75
+ // $profile = Mage::getModel('upop/profile')->load($profileId);
76
+ // if ($profile->getId()) {
77
+ // try {
78
+ // $requestModel = Mage::getModel('upop/xml_request')->setUpopPaymentProfile($profile)
79
+ // ->generateDeleteClientRequest()
80
+ // ->send();
81
+ // $response = $requestModel->getResponse();
82
+ // if ($response->isSuccess()) {
83
+ // $profile->delete();
84
+ // $this->_getSession()->addSuccess($this->__('The profile has been deleted.'));
85
+ // } else {
86
+ // Mage::throwException("failed to delete your profile from Upop. please try later.");
87
+ // }
88
+ // } catch (Exception $e) {
89
+ // Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
90
+ // }
91
+ // } else {
92
+ // Mage::getSingleton('adminhtml/session')->addError(Mage::helper('upop')->__('Payment Profile not found.'));
93
+ // }
94
+ // $this->_redirect('adminhtml/customer/edit', array('id' => $customer->getId(), 'tab' => 'upop'));
95
+ // return;
96
+ // }
97
+ // Mage::getSingleton('adminhtml/session')->addError(Mage::helper('upop')->__('Customer not found.'));
98
+ // $this->_redirect('adminhtml/customer');
99
+ // }
100
+
101
+ /**
102
+ * ACL check.
103
+ *
104
+ * @return bool
105
+ */
106
+ protected function _isAllowed() {
107
+ return Mage::getSingleton('admin/session')->isAllowed('customer/manage');
108
+ }
109
+
110
+ }
app/code/community/PlanetPayment/Upop/controllers/Adminhtml/OrderController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ /**
32
+ * Debit Status Action
33
+ */
34
+ public function getDbtStatusAction() {
35
+
36
+ $order_id = $this->getRequest()->getParam('order_id');
37
+ $upop = Mage::getModel('upop/upop');
38
+ $error = false;
39
+ try {
40
+ $result = $upop->getDbtStatus($order_id);
41
+ if(!$result) {
42
+ $error = true;
43
+ }
44
+
45
+ if(!$error) {
46
+ $response_text = $result->FIELDS->RESPONSE_TEXT;// to show the message on click of dbt status button
47
+ if($response_text=='Approved') {
48
+ $this->_getSession()->addSuccess($this->__('%s', $response_text));
49
+ } else {
50
+ $this->_getSession()->addError($this->__('%s', $response_text));
51
+ }
52
+ }
53
+ } catch (Exception $e) {
54
+ $this->_getSession()->addError($e->getMessage());
55
+ }
56
+
57
+ $url = Mage::helper("adminhtml")->getUrl('adminhtml/sales_order/view', array('order_id' => $order_id));
58
+ $this->getResponse()->setRedirect($url);
59
+ }
60
+
61
+ }
app/code/community/PlanetPayment/Upop/controllers/Adminhtml/SystemController.php ADDED
@@ -0,0 +1,88 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_Adminhtml_SystemController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ /**
32
+ * Exports the logs into a text file
33
+ */
34
+ public function exportAction() {
35
+ try {
36
+ $logModel = Mage::getmodel('upop/log');
37
+ $logs = $logModel->getCollection();
38
+ if (count($logs)) {
39
+ $content = "CREATE TABLE IF NOT EXISTS `" . $logModel->getResource()->getTable('upop/log') . "`
40
+ (
41
+ `id` int(10) NOT NULL AUTO_INCREMENT,
42
+ `request` text NULL,
43
+ `response` text NULL,
44
+ `create_date` timestamp DEFAULT CURRENT_TIMESTAMP,
45
+ PRIMARY KEY (`id`)
46
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
47
+ $content .= "INSERT INTO `" . $logModel->getResource()->getTable('upop/log') . "` (`request`, `response` , `create_date`) VALUES ";
48
+ $i = 0;
49
+ foreach ($logs as $log) {
50
+ $content .= $i != 0 ? ", " : "";
51
+ $content .= "('" . addslashes($log->getRequest()) . "','" . addslashes($log->getResponse()) . "','" . $log->getCreateDate() . "')";
52
+ $i++;
53
+ }
54
+ $this->_prepareDownloadResponse("LogExport.sql", $content);
55
+ return;
56
+ } else {
57
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('upop')->__('Log is empty'));
58
+ }
59
+ } catch (Exception $e) {
60
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
61
+ }
62
+ $this->_redirectReferer();
63
+ }
64
+
65
+ public function testAction() {
66
+ $requestModel = Mage::getModel('upop/xml_request')->generateTestConfigurationRequest()
67
+ ->send();
68
+ $response = $requestModel->getResponse();
69
+
70
+ if ($response->isSuccess()) {
71
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('upop')->__('Configurations tested successfully.'));
72
+ } else {
73
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('upop')->__('Error in configuration.</br> Message:'.$response->getMessage()));
74
+ }
75
+ $this->_redirectReferer();
76
+ }
77
+
78
+ /**
79
+ * ACL check.
80
+ *
81
+ * @return bool
82
+ */
83
+ protected function _isAllowed() {
84
+ $actionName = $this->getRequest()->getActionName();
85
+ return Mage::getSingleton('admin/session')->isAllowed('upop/system/' . $actionName);
86
+ }
87
+
88
+ }
app/code/community/PlanetPayment/Upop/controllers/IndexController.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_Upop
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * To Call For Method For Starting Chekout Process
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_Upop
24
+ * @author mohds
25
+ */
26
+ class PlanetPayment_Upop_IndexController extends Mage_Core_Controller_Front_Action {
27
+
28
+ /**
29
+ * Contain the Checkout model object
30
+ *
31
+ * @var PlanetPayment_Upop_Model_Checkout
32
+ */
33
+ protected $_checkout = null;
34
+
35
+ /**
36
+ * Contain the Quote object
37
+ *
38
+ * @var Mage_Sales_Model_Quote
39
+ */
40
+ protected $_quote = false;
41
+
42
+ /**
43
+ * Initilize The Parent Front Action Controller Action
44
+ */
45
+ protected function _construct() {
46
+ parent::_construct();
47
+ }
48
+
49
+ /**
50
+ * Start the Checkout Process for Order
51
+ *
52
+ * @return Null
53
+ */
54
+ public function startAction() {
55
+ try {
56
+
57
+ $this->_initCheckout();
58
+
59
+ if ($this->_getQuote()->getIsMultiShipping()) {
60
+ $this->_getQuote()->setIsMultiShipping(false);
61
+ $this->_getQuote()->removeAllAddresses();
62
+ }
63
+
64
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
65
+ if ($customer && $customer->getId()) {
66
+ $this->_checkout->setCustomerWithAddressChange(
67
+ $customer, $this->_getQuote()->getBillingAddress(), $this->_getQuote()->getShippingAddress()
68
+ );
69
+ }
70
+
71
+ //First pass request
72
+ $response = $this->_checkout->start();
73
+ if ($response) {
74
+ $up_payload = $response->FIELDS->UP_PAYLOAD;
75
+ if ($up_payload) {
76
+ $this->getResponse()->setBody($up_payload);
77
+ return;
78
+ } else {
79
+ Mage::log("Couldn't process your request. Please try again later or contact us.", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
80
+ $this->_getCheckoutSession()->addError($this->__("Couldn't process your request. Please try again later or contact us."));
81
+ $this->_redirect('checkout/cart/index');
82
+ }
83
+ } else {
84
+ Mage::log("Unable to authorize first pass with iPay.", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
85
+ $this->_getCheckoutSession()->addError($this->__('Unable to authorize first pass with iPay.'));
86
+ $this->_redirect('checkout/cart/index');
87
+ }
88
+ } catch (Exception $e) {
89
+ Mage::log($e->getMessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
90
+ $this->_getCheckoutSession()->addError($this->__('%s', $e->getMessage()));
91
+ $this->_redirect('checkout/cart/index');
92
+ }
93
+ }
94
+
95
+ /**
96
+ * Return from the Payment Gateway
97
+ *
98
+ * @return Null
99
+ */
100
+ public function responseAction() {
101
+ $param = $this->getRequest()->getPost();
102
+ try {
103
+ $this->_initCheckout();
104
+ $response = $this->_checkout->secondPass($param);
105
+ if ($response) {
106
+ if ($response->FIELDS->RESPONSE_TEXT == 'Approved') {
107
+ $result = array();
108
+ try {
109
+ $this->_getQuote()->collectTotals()->save();
110
+ $this->getOnepage()->saveOrder();
111
+
112
+ $result['success'] = true;
113
+ $result['error'] = false;
114
+ } catch (Mage_Payment_Model_Info_Exception $e) {
115
+ Mage::log($e->getMessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
116
+ $message = $e->getMessage();
117
+ if (!empty($message)) {
118
+ $result['success'] = false;
119
+ $result['error'] = true;
120
+ $result['error_messages'] = $message;
121
+ }
122
+ } catch (Mage_Core_Exception $e) {
123
+ Mage::log($e->getMessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
124
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
125
+ $result['success'] = false;
126
+ $result['error'] = true;
127
+ $result['error_messages'] = $e->getMessage();
128
+ } catch (Exception $e) {
129
+ Mage::log($e->getMessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
130
+ Mage::helper('checkout')->sendPaymentFailedEmail($this->getOnepage()->getQuote(), $e->getMessage());
131
+ $result['success'] = false;
132
+ $result['error'] = true;
133
+ $result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
134
+ }
135
+ } else {
136
+ Mage::log("There was an error processing your order. Please contact us or try again later.", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
137
+ $result['success'] = false;
138
+ $result['error'] = true;
139
+ $result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
140
+ }
141
+ } else {
142
+ Mage::log("There was an error processing your order. Please contact us or try again later.", null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
143
+ $result['success'] = false;
144
+ $result['error'] = true;
145
+ $result['error_messages'] = $this->__('There was an error processing your order. Please contact us or try again later.');
146
+ }
147
+ } catch (Exception $e) {
148
+ Mage::log($e->getMessage(), null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
149
+ $result['success'] = false;
150
+ $result['error'] = true;
151
+ $result['error_messages'] = $this->__('%s', $e->getMessage());
152
+ }
153
+
154
+ if ($result['error'] === true) {
155
+ Mage::log($result['error_messages'], null, PlanetPayment_Upop_Model_Upop::LOG_FILE);
156
+ $this->_getCheckoutSession()->addError($this->__("%s", $result['error_messages']));
157
+ $this->_redirect('checkout/cart');
158
+ return;
159
+ }
160
+
161
+ $this->getOnepage()->getQuote()->save();
162
+ $this->_getUopSession()->unsetAll();
163
+ $this->_redirect('checkout/onepage/success');
164
+ return;
165
+ }
166
+
167
+ /**
168
+ * Instantiate quote and checkout
169
+ *
170
+ * @throws Mage_Core_Exception
171
+ */
172
+ private function _initCheckout() {
173
+ $quote = $this->_getQuote();
174
+ if (!$quote->hasItems() || $quote->getHasError()) {
175
+ $this->getResponse()->setHeader('HTTP/1.1', '403 Forbidden');
176
+ Mage::throwException(Mage::helper('upop')->__('Unable to initialize UPOP Checkout.'));
177
+ }
178
+ $this->_checkout = Mage::getSingleton('upop/checkout', array(
179
+ 'quote' => $quote,
180
+ ));
181
+ }
182
+
183
+ /**
184
+ * UPOP session instance getter
185
+ *
186
+ * @return PlanetPayment_Upop_Model_Session
187
+ */
188
+ private function _getUopSession() {
189
+ return Mage::getSingleton('upop/session');
190
+ }
191
+
192
+ /**
193
+ * Return checkout session object
194
+ *
195
+ * @return Mage_Checkout_Model_Session
196
+ */
197
+ private function _getCheckoutSession() {
198
+ return Mage::getSingleton('checkout/session');
199
+ }
200
+
201
+ /**
202
+ * Return checkout quote object
203
+ *
204
+ * @return Mage_Sale_Model_Quote
205
+ */
206
+ private function _getQuote() {
207
+ if (!$this->_quote) {
208
+ $this->_quote = $this->_getCheckoutSession()->getQuote();
209
+ }
210
+ return $this->_quote;
211
+ }
212
+
213
+ /**
214
+ * To Get The Upop Model Object
215
+ *
216
+ * @return PlanetPayment_Upop_Model_Upop
217
+ */
218
+ protected function _getUpopModel() {
219
+ return Mage::getModel('upop/upop');
220
+ }
221
+
222
+ /**
223
+ * Get one page checkout model
224
+ *
225
+ * @return Mage_Checkout_Model_Type_Onepage
226
+ */
227
+ public function getOnepage() {
228
+ return Mage::getSingleton('checkout/type_onepage');
229
+ }
230
+
231
+ }
app/code/community/PlanetPayment/Upop/controllers/OnepageController.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
30
+
31
+ class PlanetPayment_Upop_OnepageController extends Mage_Checkout_OnepageController {
32
+
33
+ /**
34
+ * Save payment ajax action
35
+ *
36
+ * Sets either redirect or a JSON response
37
+ */
38
+ public function savePaymentAction() {
39
+ if ($this->_expireAjax()) {
40
+ return;
41
+ }
42
+
43
+ $data = $this->getRequest()->getPost('payment', array());
44
+ try {
45
+ if (!$this->getRequest()->isPost()) {
46
+ $this->_ajaxRedirectResponse();
47
+ return;
48
+ }
49
+
50
+ // set payment to quote
51
+ $result = array();
52
+ $result = $this->getOnepage()->savePayment($data);
53
+
54
+ // get section and redirect data
55
+ $redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
56
+
57
+ if (empty($result['error']) && !$redirectUrl) {
58
+ $this->loadLayout('checkout_onepage_review');
59
+ $result['goto_section'] = 'review';
60
+ $result['update_section'] = array(
61
+ 'name' => 'review',
62
+ 'html' => $this->_getReviewHtml()
63
+ );
64
+ }
65
+ if ($redirectUrl) {
66
+ $result['redirect'] = $redirectUrl;
67
+ }
68
+ } catch (Mage_Payment_Exception $e) {
69
+ if ($e->getFields()) {
70
+ $result['fields'] = $e->getFields();
71
+ }
72
+ $result['error'] = $e->getMessage();
73
+ } catch (Mage_Core_Exception $e) {
74
+ $result['error'] = $e->getMessage();
75
+ } catch (Exception $e) {
76
+ Mage::logException($e);
77
+ $result['error'] = $this->__('Unable to set Payment Method.');
78
+ }
79
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
80
+ }
81
+
82
+ public function redirectAction() {
83
+ $session = Mage::getSingleton('checkout/session');
84
+ $this->getResponse()->setBody('<p>'.$this->__('You will be redirected to the UnionPay website in a few seconds.').'</p>'.$session->getRedirectParam());
85
+ $session->unsRedirectUrl();
86
+ }
87
+
88
+ public function responseAction() {
89
+
90
+ $param = $this->getRequest()->getPost();
91
+ $session = Mage::getSingleton('checkout/session');
92
+ //$order = Mage::getModel('sales/order')->load($session->getOrderId());
93
+ $order = Mage::getModel('sales/order')->loadByIncrementId($session->getLastRealOrderId());
94
+ $payment = $order->getPayment();
95
+
96
+ try {
97
+ $requestModel = $this->_getUpopModel()->secondPass($payment, $param);
98
+ if ($requestModel) {
99
+ $this->_getSession()->addSuccess($this->__('The order has been approved.'));
100
+ $this->_redirectUrl(Mage::getUrl('checkout/onepage/success', array('_secure'=>true)));
101
+ }
102
+ } catch (Mage_Core_Exception $e) {
103
+ $this->_getSession()->addError($e->getMessage());
104
+ $this->_redirectUrl(Mage::getUrl('checkout/onepage/failure', array('_secure'=>true)));
105
+ } catch (Exception $e) {
106
+ Mage::logException($e);
107
+ $this->_getSession()->addException($e, $this->__('An error occurred while send second-pass request.'));
108
+ $this->_redirectUrl(Mage::getUrl('checkout/onepage/failure', array('_secure'=>true)));
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Retrieve customer session object
114
+ *
115
+ * @return Mage_Customer_Model_Session
116
+ */
117
+ protected function _getSession() {
118
+ return Mage::getSingleton('core/session');
119
+ }
120
+
121
+ protected function _getUpopRequestModel() {
122
+ return Mage::getModel('upop/xml_request');
123
+ }
124
+
125
+ protected function _getUpopModel() {
126
+ return Mage::getModel('upop/upop');
127
+ }
128
+
129
+
130
+
131
+ }
app/code/community/PlanetPayment/Upop/controllers/ProfileController.php ADDED
@@ -0,0 +1,192 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Upop_ProfileController extends Mage_Core_Controller_Front_Action {
30
+
31
+ public function preDispatch() {
32
+ parent::preDispatch();
33
+ if (!$this->_getSession()->authenticate($this) || !Mage::helper('upop')->isEnabled()) {
34
+ $this->setFlag('', 'no-dispatch', true);
35
+ }
36
+ }
37
+
38
+ /**
39
+ * Store CC profile list action.
40
+ */
41
+ public function indexAction() {
42
+ $this->loadLayout();
43
+ $this->_initLayoutMessages('customer/session');
44
+ $this->renderLayout();
45
+ }
46
+
47
+ /**
48
+ * Edit a payment profile.
49
+ */
50
+ public function editAction() {
51
+ $this->loadLayout();
52
+ $this->_initLayoutMessages('customer/session');
53
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
54
+ if ($navigationBlock) {
55
+ $navigationBlock->setActive('upop/profile');
56
+ }
57
+ $this->renderLayout();
58
+ }
59
+
60
+ /**
61
+ * Add a profile.
62
+ */
63
+ public function newAction() {
64
+ $this->_forward('edit');
65
+ }
66
+
67
+ /**
68
+ * Save edit changes.
69
+ */
70
+ public function editPostAction() {
71
+ if (!$this->_validateFormKey()) {
72
+ return $this->_redirect('*/*/');
73
+ }
74
+ $profileId = $this->getRequest()->getPost('profile_id');
75
+ if ($this->getRequest()->isPost()) {
76
+ $customer = $this->_getSession()->getCustomer();
77
+ /* @var $profile PlanetPayment_Upop_Model_PaymentProfile */
78
+ $profile = Mage::getModel('upop/profile');
79
+ if ($profileId) {
80
+ $profile = Mage::getModel('upop/profile')->load($profileId);
81
+ if ($profile->getCustomerId() != $customer->getId()) {
82
+ $this->_getSession()->addError($this->__('The profile does not belong to this customer.'));
83
+ $this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
84
+ return;
85
+ }
86
+ }
87
+ try {
88
+ Mage::helper('core')->copyFieldset('upop_paymentprofile_form', 'to_paymentprofile', $this->getRequest()->getPost(), $profile);
89
+ $profile->setCardNumberLast4(substr($profile->getCardNumber(), -4))
90
+ ->setCustomerId($customer->getId());
91
+ $requestModel = Mage::getModel('upop/xml_request')->setUpopPaymentProfile($profile)
92
+ ->setCustomer($customer);
93
+ // post to Upop
94
+ if ($profile->getId()) { // update
95
+ try {
96
+ $request = $requestModel->generateUpdateClientRequest()
97
+ ->send();
98
+ $response = $request->getResponse()
99
+ //defined in Xml_Response Model
100
+ ->setUpdatedPaymentProfile();
101
+ if ($response->isSuccess()) {
102
+ $request = $requestModel->generateUpdateAccountRequest()
103
+ ->send();
104
+ $response = $request->getResponse()
105
+ //defined in Xml_Response Model
106
+ ->setUpdatedPaymentProfile();
107
+ if ($response->isSuccess()) {
108
+ $profile = $response->getUpopPaymentProfile();
109
+ $profile->setIsVisible(true)->save();
110
+ } else {
111
+ Mage::throwException("Failed to update the Profile.");
112
+ }
113
+ } else {
114
+ Mage::throwException("Failed to update the Profile. Message:");
115
+ }
116
+ } catch (Exception $e) {
117
+ $this->_getSession()
118
+ ->addError($e->getMessage());
119
+ $this->_redirectError(Mage::getUrl('*/*/edit', array('profile_id' => $profileId)));
120
+ return;
121
+ }
122
+ } else {
123
+ $request = $requestModel->generateNewWalletProfileRequest()
124
+ ->send();
125
+ $response = $request->getResponse()
126
+ ->setPaymentProfile();
127
+ if ($response->isSuccess()) {
128
+ $profile = $response->getUpopPaymentProfile();
129
+ $profile->setIsVisible(true)->save();
130
+ } else {
131
+ Mage::throwException("Failed to add the Profile.");
132
+ }
133
+ }
134
+ $this->_getSession()->setProfileFormData(array())
135
+ ->addSuccess($this->__('The profile was successfully updated.'));
136
+ $this->_redirectSuccess(Mage::getUrl('*/*/index'));
137
+ return;
138
+ } catch (Mage_Core_Exception $e) {
139
+ $this->_getSession()->setProfileFormData($this->getRequest()->getPost())
140
+ ->addException($e, $e->getMessage());
141
+ Mage::logException($e);
142
+ } catch (Exception $e) {
143
+ $this->_getSession()->setProfileFormData($this->getRequest()->getPost())
144
+ ->addException($e, $e->getMessage());
145
+ Mage::logException($e);
146
+ }
147
+ }
148
+ return $this->_redirectError(Mage::getUrl('*/*/edit', array('profile_id' => $profileId)));
149
+ }
150
+
151
+ /**
152
+ * Delete a payment profile.
153
+ */
154
+ public function deleteAction() {
155
+ $profileId = $this->getRequest()->getParam('profile_id');
156
+ if ($profileId) {
157
+ $profile = Mage::getModel('upop/profile')->load($profileId);
158
+ if ($profile->getCustomerId() != $this->_getSession()->getCustomer()->getId()) {
159
+ $this->_getSession()->addError($this->__('The profile does not belong to this customer.'));
160
+ $this->getResponse()->setRedirect(Mage::getUrl('*/*/index'));
161
+ return;
162
+ }
163
+
164
+ try {
165
+ $requestModel = Mage::getModel('upop/xml_request')->setUpopPaymentProfile($profile)
166
+ ->generateDeleteClientRequest()
167
+ ->send();
168
+ $response = $requestModel->getResponse();
169
+ if ($response->isSuccess()) {
170
+ $profile->delete();
171
+ $this->_getSession()->addSuccess($this->__('The profile has been deleted.'));
172
+ } else {
173
+ Mage::throwException("failed to delete your profile from Upop. please try later.");
174
+ }
175
+ } catch (Exception $e) {
176
+ $this->_getSession()->addException($e, $this->__('An error occurred while deleting the profile.'));
177
+ Mage::logException($e);
178
+ }
179
+ }
180
+ $this->_redirect('*/*/index');
181
+ }
182
+
183
+ /**
184
+ * Retrieve customer session object
185
+ *
186
+ * @return Mage_Customer_Model_Session
187
+ */
188
+ protected function _getSession() {
189
+ return Mage::getSingleton('customer/session');
190
+ }
191
+
192
+ }
app/code/community/PlanetPayment/Upop/data/upop_setup/data-install-1.0.0.php ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //Adding Upop Supporting Currency Codes
4
+ $installer = $this;
5
+
6
+ $data = array(
7
+ array('currency' => 'DZD',
8
+ 'currency_code' => '012'
9
+ ),
10
+ array('currency' => 'ARS',
11
+ 'currency_code' => '032'
12
+ ),
13
+ array('currency' => 'AUD',
14
+ 'currency_code' => '036'
15
+ ),
16
+ array('currency' => 'BSD',
17
+ 'currency_code' => '044'
18
+ ),
19
+ array('currency' => 'BHD',
20
+ 'currency_code' => '048'
21
+ ),
22
+ array('currency' => 'BDT',
23
+ 'currency_code' => '050'
24
+ ),
25
+ array('currency' => 'OMR',
26
+ 'currency_code' => '051'
27
+ ),
28
+ array('currency' => 'BBD',
29
+ 'currency_code' => '052'
30
+ ),
31
+ array('currency' => 'BMD',
32
+ 'currency_code' => '060'
33
+ ),
34
+ array('currency' => 'BOB',
35
+ 'currency_code' => '068'
36
+ ),
37
+ array('currency' => 'BWP',
38
+ 'currency_code' => '072'
39
+ ),
40
+ array('currency' => 'BZD',
41
+ 'currency_code' => '084'
42
+ ),
43
+ array('currency' => 'BND',
44
+ 'currency_code' => '096'
45
+ ),
46
+ array('currency' => 'PL',
47
+ 'currency_code' => '098'
48
+ ),
49
+ array('currency' => 'CAD',
50
+ 'currency_code' => '124'
51
+ ),
52
+ array('currency' => 'KYD',
53
+ 'currency_code' => '136'
54
+ ),
55
+ array('currency' => 'LKR',
56
+ 'currency_code' => '144'
57
+ ),
58
+ array('currency' => 'CLP',
59
+ 'currency_code' => '152'
60
+ ),
61
+ array('currency' => 'CNY',
62
+ 'currency_code' => '156'
63
+ ),
64
+ array('currency' => 'COP',
65
+ 'currency_code' => '170'
66
+ ),
67
+ array('currency' => 'CRC',
68
+ 'currency_code' => '188'
69
+ ),
70
+ array('currency' => 'CZK',
71
+ 'currency_code' => '203'
72
+ ),
73
+ array('currency' => 'DKK',
74
+ 'currency_code' => '208'
75
+ ),
76
+ array('currency' => 'DOP',
77
+ 'currency_code' => '214'
78
+ ),
79
+ array('currency' => 'GTQ',
80
+ 'currency_code' => '320'
81
+ ),
82
+ array('currency' => 'HKD',
83
+ 'currency_code' => '344'
84
+ ),
85
+ array('currency' => 'HUF',
86
+ 'currency_code' => '348'
87
+ ),
88
+ array('currency' => 'ISK',
89
+ 'currency_code' => '352'
90
+ ),
91
+ array('currency' => 'INR',
92
+ 'currency_code' => '356'
93
+ ),
94
+ array('currency' => 'IDR',
95
+ 'currency_code' => '360'
96
+ ),
97
+ array('currency' => 'ILS',
98
+ 'currency_code' => '376'
99
+ ),
100
+ array('currency' => 'JMD',
101
+ 'currency_code' => '388'
102
+ ),
103
+ array('currency' => 'JPY',
104
+ 'currency_code' => '392'
105
+ ),
106
+ array('currency' => 'KZT',
107
+ 'currency_code' => '398'
108
+ ),
109
+ array('currency' => 'JOD',
110
+ 'currency_code' => '400'
111
+ ),
112
+ array('currency' => 'KRW',
113
+ 'currency_code' => '410'
114
+ ),
115
+ array('currency' => 'KWD',
116
+ 'currency_code' => '414'
117
+ ),
118
+ array('currency' => 'LBP',
119
+ 'currency_code' => '422'
120
+ ),
121
+ array('currency' => 'LSL',
122
+ 'currency_code' => '426'
123
+ ),
124
+ array('currency' => 'LVL',
125
+ 'currency_code' => '428'
126
+ ),
127
+ array('currency' => 'MOP',
128
+ 'currency_code' => '446'
129
+ ),
130
+ array('currency' => 'MYR',
131
+ 'currency_code' => '458'
132
+ ),
133
+ array('currency' => 'MVR',
134
+ 'currency_code' => '462'
135
+ ),
136
+ array('currency' => 'MUR',
137
+ 'currency_code' => '480'
138
+ ),
139
+ array('currency' => 'MXN',
140
+ 'currency_code' => '484'
141
+ ),
142
+ array('currency' => 'NAD',
143
+ 'currency_code' => '516'
144
+ ),
145
+ array('currency' => 'NZD',
146
+ 'currency_code' => '554'
147
+ ),
148
+ array('currency' => 'NGN',
149
+ 'currency_code' => '566'
150
+ ),
151
+ array('currency' => 'NOK',
152
+ 'currency_code' => '578'
153
+ ),
154
+ array('currency' => 'PKR',
155
+ 'currency_code' => '586'
156
+ ),
157
+ array('currency' => 'PAB',
158
+ 'currency_code' => '590'
159
+ ),
160
+ array('currency' => 'PYG',
161
+ 'currency_code' => '600'
162
+ ),
163
+ array('currency' => 'PEN',
164
+ 'currency_code' => '604'
165
+ ),
166
+ array('currency' => 'PHP',
167
+ 'currency_code' => '608'
168
+ ),
169
+ array('currency' => 'QAR',
170
+ 'currency_code' => '634'
171
+ ),
172
+ array('currency' => 'RUB',
173
+ 'currency_code' => '643'
174
+ ),
175
+ array('currency' => 'SAR',
176
+ 'currency_code' => '682'
177
+ ),
178
+ array('currency' => 'SGD',
179
+ 'currency_code' => '702'
180
+ ),
181
+ array('currency' => 'ZAR',
182
+ 'currency_code' => '710'
183
+ ),
184
+ array('currency' => 'SEK',
185
+ 'currency_code' => '752'
186
+ ),
187
+ array('currency' => 'CHF',
188
+ 'currency_code' => '756'
189
+ ),
190
+ array('currency' => 'SYP',
191
+ 'currency_code' => '760'
192
+ ),
193
+ array('currency' => 'THB',
194
+ 'currency_code' => '764'
195
+ ),
196
+ array('currency' => 'TTD',
197
+ 'currency_code' => '780'
198
+ ),
199
+ array('currency' => 'AED',
200
+ 'currency_code' => '784'
201
+ ),
202
+ array('currency' => 'EGP',
203
+ 'currency_code' => '818'
204
+ ),
205
+ array('currency' => 'GBP',
206
+ 'currency_code' => '826'
207
+ ),
208
+ array('currency' => 'TZS',
209
+ 'currency_code' => '834'
210
+ ),
211
+ array('currency' => 'USD',
212
+ 'currency_code' => '840'
213
+ ),
214
+ array('currency' => 'UYU',
215
+ 'currency_code' => '858'
216
+ ),
217
+ array('currency' => 'TWD',
218
+ 'currency_code' => '901'
219
+ ),
220
+ array('currency' => 'GHS',
221
+ 'currency_code' => '936'
222
+ ),
223
+ array('currency' => 'VEF',
224
+ 'currency_code' => '937'
225
+ ),
226
+ array('currency' => 'AZN',
227
+ 'currency_code' => '944'
228
+ ),
229
+ array('currency' => 'TRY',
230
+ 'currency_code' => '949'
231
+ ),
232
+ array('currency' => 'XAF',
233
+ 'currency_code' => '950'
234
+ ),
235
+ array('currency' => 'XCD',
236
+ 'currency_code' => '951'
237
+ ),
238
+ array('currency' => 'AOA',
239
+ 'currency_code' => '973'
240
+ ),
241
+ array('currency' => 'EUR',
242
+ 'currency_code' => '978'
243
+ ),
244
+ array('currency' => 'UAH',
245
+ 'currency_code' => '980'
246
+ ),
247
+ array('currency' => 'BRL',
248
+ 'currency_code' => '986'
249
+ ),
250
+ );
251
+
252
+ $installer->getConnection()->insertMultiple($installer->getTable('upop/currencyCodes'), $data);
app/code/community/PlanetPayment/Upop/data/upop_setup/data-install-1.0.1.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //Adding Upop Supporting Currency Codes
4
+ $installer = $this;
5
+
6
+ $installer->run("
7
+ DELETE IGNORE FROM `{$this->getTable('upop/currencyCodes')}`;
8
+ ");
9
+
10
+ $data = array(
11
+ array('currency' => 'CAD',
12
+ 'currency_code' => '124'
13
+ ),
14
+ array('currency' => 'HKD',
15
+ 'currency_code' => '344'
16
+ ),
17
+ array('currency' => 'USD',
18
+ 'currency_code' => '840'
19
+ ),
20
+ );
21
+
22
+ $installer->getConnection()->insertMultiple($installer->getTable('upop/currencyCodes'), $data);
app/code/community/PlanetPayment/Upop/data/upop_setup/data-upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,243 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //Adding Upop Supporting Currency Codes
4
+ $installer = $this;
5
+
6
+ $data = array(
7
+ array('currency' => 'DZD',
8
+ 'currency_code' => '012'
9
+ ),
10
+ array('currency' => 'ARS',
11
+ 'currency_code' => '032'
12
+ ),
13
+ array('currency' => 'AUD',
14
+ 'currency_code' => '036'
15
+ ),
16
+ array('currency' => 'BSD',
17
+ 'currency_code' => '044'
18
+ ),
19
+ array('currency' => 'BHD',
20
+ 'currency_code' => '048'
21
+ ),
22
+ array('currency' => 'BDT',
23
+ 'currency_code' => '050'
24
+ ),
25
+ array('currency' => 'OMR',
26
+ 'currency_code' => '051'
27
+ ),
28
+ array('currency' => 'BBD',
29
+ 'currency_code' => '052'
30
+ ),
31
+ array('currency' => 'BMD',
32
+ 'currency_code' => '060'
33
+ ),
34
+ array('currency' => 'BOB',
35
+ 'currency_code' => '068'
36
+ ),
37
+ array('currency' => 'BWP',
38
+ 'currency_code' => '072'
39
+ ),
40
+ array('currency' => 'BZD',
41
+ 'currency_code' => '084'
42
+ ),
43
+ array('currency' => 'BND',
44
+ 'currency_code' => '096'
45
+ ),
46
+ array('currency' => 'PL',
47
+ 'currency_code' => '098'
48
+ ),
49
+ array('currency' => 'KYD',
50
+ 'currency_code' => '136'
51
+ ),
52
+ array('currency' => 'LKR',
53
+ 'currency_code' => '144'
54
+ ),
55
+ array('currency' => 'CLP',
56
+ 'currency_code' => '152'
57
+ ),
58
+ array('currency' => 'CNY',
59
+ 'currency_code' => '156'
60
+ ),
61
+ array('currency' => 'COP',
62
+ 'currency_code' => '170'
63
+ ),
64
+ array('currency' => 'CRC',
65
+ 'currency_code' => '188'
66
+ ),
67
+ array('currency' => 'CZK',
68
+ 'currency_code' => '203'
69
+ ),
70
+ array('currency' => 'DKK',
71
+ 'currency_code' => '208'
72
+ ),
73
+ array('currency' => 'DOP',
74
+ 'currency_code' => '214'
75
+ ),
76
+ array('currency' => 'GTQ',
77
+ 'currency_code' => '320'
78
+ ),
79
+ array('currency' => 'HUF',
80
+ 'currency_code' => '348'
81
+ ),
82
+ array('currency' => 'ISK',
83
+ 'currency_code' => '352'
84
+ ),
85
+ array('currency' => 'INR',
86
+ 'currency_code' => '356'
87
+ ),
88
+ array('currency' => 'IDR',
89
+ 'currency_code' => '360'
90
+ ),
91
+ array('currency' => 'ILS',
92
+ 'currency_code' => '376'
93
+ ),
94
+ array('currency' => 'JMD',
95
+ 'currency_code' => '388'
96
+ ),
97
+ array('currency' => 'JPY',
98
+ 'currency_code' => '392'
99
+ ),
100
+ array('currency' => 'KZT',
101
+ 'currency_code' => '398'
102
+ ),
103
+ array('currency' => 'JOD',
104
+ 'currency_code' => '400'
105
+ ),
106
+ array('currency' => 'KRW',
107
+ 'currency_code' => '410'
108
+ ),
109
+ array('currency' => 'KWD',
110
+ 'currency_code' => '414'
111
+ ),
112
+ array('currency' => 'LBP',
113
+ 'currency_code' => '422'
114
+ ),
115
+ array('currency' => 'LSL',
116
+ 'currency_code' => '426'
117
+ ),
118
+ array('currency' => 'LVL',
119
+ 'currency_code' => '428'
120
+ ),
121
+ array('currency' => 'MOP',
122
+ 'currency_code' => '446'
123
+ ),
124
+ array('currency' => 'MYR',
125
+ 'currency_code' => '458'
126
+ ),
127
+ array('currency' => 'MVR',
128
+ 'currency_code' => '462'
129
+ ),
130
+ array('currency' => 'MUR',
131
+ 'currency_code' => '480'
132
+ ),
133
+ array('currency' => 'MXN',
134
+ 'currency_code' => '484'
135
+ ),
136
+ array('currency' => 'NAD',
137
+ 'currency_code' => '516'
138
+ ),
139
+ array('currency' => 'NZD',
140
+ 'currency_code' => '554'
141
+ ),
142
+ array('currency' => 'NGN',
143
+ 'currency_code' => '566'
144
+ ),
145
+ array('currency' => 'NOK',
146
+ 'currency_code' => '578'
147
+ ),
148
+ array('currency' => 'PKR',
149
+ 'currency_code' => '586'
150
+ ),
151
+ array('currency' => 'PAB',
152
+ 'currency_code' => '590'
153
+ ),
154
+ array('currency' => 'PYG',
155
+ 'currency_code' => '600'
156
+ ),
157
+ array('currency' => 'PEN',
158
+ 'currency_code' => '604'
159
+ ),
160
+ array('currency' => 'PHP',
161
+ 'currency_code' => '608'
162
+ ),
163
+ array('currency' => 'QAR',
164
+ 'currency_code' => '634'
165
+ ),
166
+ array('currency' => 'RUB',
167
+ 'currency_code' => '643'
168
+ ),
169
+ array('currency' => 'SAR',
170
+ 'currency_code' => '682'
171
+ ),
172
+ array('currency' => 'SGD',
173
+ 'currency_code' => '702'
174
+ ),
175
+ array('currency' => 'ZAR',
176
+ 'currency_code' => '710'
177
+ ),
178
+ array('currency' => 'SEK',
179
+ 'currency_code' => '752'
180
+ ),
181
+ array('currency' => 'CHF',
182
+ 'currency_code' => '756'
183
+ ),
184
+ array('currency' => 'SYP',
185
+ 'currency_code' => '760'
186
+ ),
187
+ array('currency' => 'THB',
188
+ 'currency_code' => '764'
189
+ ),
190
+ array('currency' => 'TTD',
191
+ 'currency_code' => '780'
192
+ ),
193
+ array('currency' => 'AED',
194
+ 'currency_code' => '784'
195
+ ),
196
+ array('currency' => 'EGP',
197
+ 'currency_code' => '818'
198
+ ),
199
+ array('currency' => 'GBP',
200
+ 'currency_code' => '826'
201
+ ),
202
+ array('currency' => 'TZS',
203
+ 'currency_code' => '834'
204
+ ),
205
+ array('currency' => 'UYU',
206
+ 'currency_code' => '858'
207
+ ),
208
+ array('currency' => 'TWD',
209
+ 'currency_code' => '901'
210
+ ),
211
+ array('currency' => 'GHS',
212
+ 'currency_code' => '936'
213
+ ),
214
+ array('currency' => 'VEF',
215
+ 'currency_code' => '937'
216
+ ),
217
+ array('currency' => 'AZN',
218
+ 'currency_code' => '944'
219
+ ),
220
+ array('currency' => 'TRY',
221
+ 'currency_code' => '949'
222
+ ),
223
+ array('currency' => 'XAF',
224
+ 'currency_code' => '950'
225
+ ),
226
+ array('currency' => 'XCD',
227
+ 'currency_code' => '951'
228
+ ),
229
+ array('currency' => 'AOA',
230
+ 'currency_code' => '973'
231
+ ),
232
+ array('currency' => 'EUR',
233
+ 'currency_code' => '978'
234
+ ),
235
+ array('currency' => 'UAH',
236
+ 'currency_code' => '980'
237
+ ),
238
+ array('currency' => 'BRL',
239
+ 'currency_code' => '986'
240
+ ),
241
+ );
242
+
243
+ $installer->getConnection()->insertMultiple($installer->getTable('upop/currencyCodes'), $data);
app/code/community/PlanetPayment/Upop/etc/adminhtml.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <acl>
32
+ <resources>
33
+ <admin>
34
+ <children>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <planet_payment_upop translate="title" module="cms">
40
+ <title>Planet Payment UPOP</title>
41
+ </planet_payment_upop>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/community/PlanetPayment/Upop/etc/config.xml ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <modules>
32
+ <PlanetPayment_Upop>
33
+ <version>1.0.18</version>
34
+ </PlanetPayment_Upop>
35
+ </modules>
36
+ <global>
37
+ <currency>
38
+ <import>
39
+ <services>
40
+ <upop>
41
+ <name>Planet Payment</name>
42
+ <model>upop/currency_import_upop</model>
43
+ </upop>
44
+ </services>
45
+ </import>
46
+ </currency>
47
+ <models>
48
+ <upop>
49
+ <class>PlanetPayment_Upop_Model</class>
50
+ <resourceModel>upop_resource</resourceModel>
51
+ </upop>
52
+ <checkout>
53
+ <rewrite>
54
+ <type_onepage>PlanetPayment_Upop_Model_Type_Onepage</type_onepage>
55
+ </rewrite>
56
+ </checkout>
57
+ <upop_resource>
58
+ <class>PlanetPayment_Upop_Model_Resource</class>
59
+ <entities>
60
+ <currencyCodes>
61
+ <table>upop_currency_codes</table>
62
+ </currencyCodes>
63
+ <log>
64
+ <table>upop_log</table>
65
+ </log>
66
+ </entities>
67
+ </upop_resource>
68
+ </models>
69
+ <blocks>
70
+ <upop>
71
+ <class>PlanetPayment_Upop_Block</class>
72
+ </upop>
73
+ <checkout>
74
+ <rewrite>
75
+ <cart_totals>PlanetPayment_Upop_Block_Checkout_Cart_Totals</cart_totals>
76
+ <onepage>PlanetPayment_Upop_Block_Onepage</onepage>
77
+ </rewrite>
78
+ </checkout>
79
+ <sales>
80
+ <rewrite>
81
+ <order_totals>PlanetPayment_Upop_Block_Sales_Order_Totals</order_totals>
82
+ </rewrite>
83
+ </sales>
84
+ </blocks>
85
+ <helpers>
86
+ <upop>
87
+ <class>PlanetPayment_Upop_Helper</class>
88
+ </upop>
89
+ </helpers>
90
+ <rewrite>
91
+ <upop_onepage>
92
+ <from><![CDATA[#^/checkout/onepage/#]]></from>
93
+ <to>/upop/onepage/</to>
94
+ </upop_onepage>
95
+ </rewrite>
96
+ <resources>
97
+ <upop_setup>
98
+ <setup>
99
+ <module>PlanetPayment_Upop</module>
100
+ <class>Mage_Customer_Model_Entity_Setup</class>
101
+ </setup>
102
+ </upop_setup>
103
+ </resources>
104
+ <fieldsets>
105
+ <sales_convert_quote_payment>
106
+ <upop_currency_code>
107
+ <to_order_payment>*</to_order_payment>
108
+ </upop_currency_code>
109
+ <upop_order_number>
110
+ <to_order_payment>*</to_order_payment>
111
+ </upop_order_number>
112
+ <is_visible>
113
+ <to_order_payment>*</to_order_payment>
114
+ </is_visible>
115
+ <upop_exchange_rate>
116
+ <to_order_payment>*</to_order_payment>
117
+ </upop_exchange_rate>
118
+ </sales_convert_quote_payment>
119
+ </fieldsets>
120
+ <events>
121
+ <sales_order_place_before>
122
+ <observers>
123
+ <upop_order_payment_place_after>
124
+ <class>upop/observer_checkout</class>
125
+ <method>placeOrderAfter</method>
126
+ <type>singleton</type>
127
+ </upop_order_payment_place_after>
128
+ </observers>
129
+ </sales_order_place_before>
130
+
131
+ <!--<core_block_abstract_to_html_before>
132
+ <observers>
133
+ <upop_dbt_status_button>
134
+ <class>PlanetPayment_Upop_Model_Observer</class>
135
+ <method>addDbtStatusButton</method>
136
+ <type>model</type>
137
+ </upop_dbt_status_button>
138
+ </observers>
139
+ </core_block_abstract_to_html_before> -->
140
+ </events>
141
+ </global>
142
+ <frontend>
143
+ <layout>
144
+ <updates>
145
+ <upop>
146
+ <file>upop.xml</file>
147
+ </upop>
148
+ </updates>
149
+ </layout>
150
+ <routers>
151
+ <upop>
152
+ <use>standard</use>
153
+ <args>
154
+ <module>PlanetPayment_Upop</module>
155
+ <frontName>upop</frontName>
156
+ </args>
157
+ </upop>
158
+ </routers>
159
+ <translate>
160
+ <modules>
161
+ <PlanetPayment_Upop>
162
+ <files>
163
+ <default>PlanetPayment_Upop.csv</default>
164
+ </files>
165
+ </PlanetPayment_Upop>
166
+ </modules>
167
+ </translate>
168
+ <secure_url>
169
+ <uspslabel_order>/upop/customer/</uspslabel_order>
170
+ </secure_url>
171
+ </frontend>
172
+ <crontab>
173
+ <jobs>
174
+ <upop_log_clean>
175
+ <schedule>
176
+ <cron_expr>*/5 * * * *</cron_expr>
177
+ </schedule>
178
+ <run>
179
+ <model>upop/observer_log::cleanLog</model>
180
+ </run>
181
+ </upop_log_clean>
182
+ </jobs>
183
+ </crontab>
184
+ <admin>
185
+ <routers>
186
+ <upopadmin>
187
+ <use>admin</use>
188
+ <args>
189
+ <module>PlanetPayment_Upop</module>
190
+ <frontName>upopadmin</frontName>
191
+ </args>
192
+ </upopadmin>
193
+ </routers>
194
+ </admin>
195
+
196
+ <adminhtml>
197
+ <layout>
198
+ <updates>
199
+ <upop>
200
+ <file>upop.xml</file>
201
+ </upop>
202
+ </updates>
203
+ </layout>
204
+ <translate>
205
+ <modules>
206
+ <PlanetPayment_Upop>
207
+ <files>
208
+ <default>PlanetPayment_Upop.csv</default>
209
+ </files>
210
+ </PlanetPayment_Upop>
211
+ </modules>
212
+ </translate>
213
+ </adminhtml>
214
+ <default>
215
+ <payment>
216
+ <upop>
217
+ <active>1</active>
218
+ <model>upop/upop</model>
219
+ <title>Credit Card (Planet Payment UPOP)</title>
220
+ <payment_action>authorize</payment_action>
221
+ <order_status>processing</order_status>
222
+ <currency>USD</currency>
223
+ <accepted_currencies>USD</accepted_currencies>
224
+ <service>pyc</service>
225
+ <cctypes>AE,VI,MC,DI,DIN,JCB</cctypes>
226
+ <tokenize>0</tokenize>
227
+ <logging>1</logging>
228
+ <validation_mode>none</validation_mode>
229
+ <debug>0</debug>
230
+ </upop>
231
+ </payment>
232
+ <planet_payment>
233
+ <upop_general>
234
+ <url>production</url>
235
+ <encryption>0</encryption>
236
+ </upop_general>
237
+ <upop_logging>
238
+ <mode>1</mode>
239
+ <lifetime>14</lifetime>
240
+ </upop_logging>
241
+ </planet_payment>
242
+ <currency>
243
+ <upop>
244
+ <logging>1</logging>
245
+ </upop>
246
+ </currency>
247
+ </default>
248
+ </config>
app/code/community/PlanetPayment/Upop/etc/system.xml ADDED
@@ -0,0 +1,344 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <sections>
32
+ <payment>
33
+ <groups>
34
+ <upop translate="label">
35
+ <label>Planet Payment UPOP</label>
36
+ <frontend_type>text</frontend_type>
37
+ <sort_order>100</sort_order>
38
+ <show_in_default>1</show_in_default>
39
+ <show_in_website>1</show_in_website>
40
+ <show_in_store>1</show_in_store>
41
+ <fields>
42
+ <active translate="label">
43
+ <label>Enable</label>
44
+ <frontend_type>select</frontend_type>
45
+ <source_model>adminhtml/system_config_source_yesno</source_model>
46
+ <sort_order>0</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </active>
51
+ <title translate="label">
52
+ <label>Title</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>1</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
+ </title>
59
+ <payment_action translate="label">
60
+ <label>Payment Action</label>
61
+ <frontend_type>select</frontend_type>
62
+ <source_model>upop/system_config_payment_paymentAction</source_model>
63
+ <sort_order>2</sort_order>
64
+ <show_in_default>1</show_in_default>
65
+ <show_in_website>1</show_in_website>
66
+ <show_in_store>1</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>3</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>1</show_in_store>
76
+ </order_status>
77
+ <currency translate="label">
78
+ <label>Native Currency</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>upop/system_config_payment_currency</source_model>
81
+ <sort_order>4</sort_order>
82
+ <show_in_default>1</show_in_default>
83
+ <show_in_website>1</show_in_website>
84
+ <show_in_store>1</show_in_store>
85
+ </currency>
86
+ <accepted_currencies translate="label">
87
+ <label>Accepted currency</label>
88
+ <frontend_type>multiselect</frontend_type>
89
+ <source_model>adminhtml/system_config_source_currency</source_model>
90
+ <sort_order>5</sort_order>
91
+ <show_in_default>1</show_in_default>
92
+ <show_in_website>1</show_in_website>
93
+ <show_in_store>0</show_in_store>
94
+ </accepted_currencies>
95
+ <service translate="label">
96
+ <label>Service</label>
97
+ <frontend_type>select</frontend_type>
98
+ <source_model>upop/system_config_payment_service</source_model>
99
+ <sort_order>6</sort_order>
100
+ <show_in_default>1</show_in_default>
101
+ <show_in_website>1</show_in_website>
102
+ <show_in_store>1</show_in_store>
103
+ <comment><![CDATA[
104
+ PYC: Used for single-currency Magento
105
+ installations allowing customers to pay in the
106
+ currency their credit card is registered in (only works with Visa and Mastercard).
107
+ <BR />MCP: Used for multi-currency Magento installations
108
+ requiring customers to pay in the currency
109
+ presented in the store with prices set by the Currency
110
+ Conversion function.]]>
111
+ </comment>
112
+ </service>
113
+ <logging translate="label">
114
+ <label>Logging</label>
115
+ <frontend_type>select</frontend_type>
116
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
117
+ <sort_order>9</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>1</show_in_store>
121
+ <comment>
122
+ Recommended. Disable to suppress logging of
123
+ payment processing transactions even if global
124
+ logging is enabled in General > Planet Payment UPOP
125
+ </comment>
126
+ </logging>
127
+ <allowspecific translate="label">
128
+ <label>Payment from Applicable Countries</label>
129
+ <frontend_type>allowspecific</frontend_type>
130
+ <sort_order>10</sort_order>
131
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>1</show_in_store>
135
+ </allowspecific>
136
+ <specificcountry translate="label">
137
+ <label>Payment from Specific Countries</label>
138
+ <frontend_type>multiselect</frontend_type>
139
+ <sort_order>11</sort_order>
140
+ <source_model>adminhtml/system_config_source_country</source_model>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>1</show_in_store>
144
+ </specificcountry>
145
+ <min_order_total translate="label">
146
+ <label>Minimum Order Total</label>
147
+ <frontend_type>text</frontend_type>
148
+ <sort_order>12</sort_order>
149
+ <show_in_default>1</show_in_default>
150
+ <show_in_website>1</show_in_website>
151
+ <show_in_store>1</show_in_store>
152
+ </min_order_total>
153
+ <max_order_total translate="label">
154
+ <label>Maximum Order Total</label>
155
+ <frontend_type>text</frontend_type>
156
+ <sort_order>13</sort_order>
157
+ <show_in_default>1</show_in_default>
158
+ <show_in_website>1</show_in_website>
159
+ <show_in_store>1</show_in_store>
160
+ </max_order_total>
161
+ </fields>
162
+ </upop>
163
+ </groups>
164
+ </payment>
165
+ <planet_payment_upop translate="label">
166
+ <label>Planet Payment UPOP</label>
167
+ <tab>general</tab>
168
+ <frontend_type>text</frontend_type>
169
+ <sort_order>95</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ <groups>
174
+ <upop_general translate="label">
175
+ <label>General</label>
176
+ <frontend_type>text</frontend_type>
177
+ <sort_order>0</sort_order>
178
+ <show_in_default>1</show_in_default>
179
+ <show_in_website>1</show_in_website>
180
+ <show_in_store>1</show_in_store>
181
+ <fields>
182
+ <url translate="label">
183
+ <label>URL</label>
184
+ <frontend_type>select</frontend_type>
185
+ <source_model>upop/system_config_general_mode</source_model>
186
+ <sort_order>0</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ </url>
191
+ <key translate="label">
192
+ <label>Company Key</label>
193
+ <frontend_type>text</frontend_type>
194
+ <validate>required-entry</validate>
195
+ <sort_order>1</sort_order>
196
+ <show_in_default>1</show_in_default>
197
+ <show_in_website>1</show_in_website>
198
+ <show_in_store>1</show_in_store>
199
+ <comment>Required.</comment>
200
+ </key>
201
+ <terminal_id translate="label">
202
+ <label>Terminal Id</label>
203
+ <frontend_type>text</frontend_type>
204
+ <validate>required-entry</validate>
205
+ <sort_order>1</sort_order>
206
+ <show_in_default>1</show_in_default>
207
+ <show_in_website>1</show_in_website>
208
+ <show_in_store>1</show_in_store>
209
+ <comment>Required.</comment>
210
+ </terminal_id>
211
+ <pin translate="label">
212
+ <label>PIN</label>
213
+ <frontend_type>text</frontend_type>
214
+ <sort_order>2</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>1</show_in_store>
218
+ <validate>validate-number</validate>
219
+ <!-- Commented Code, A conflicting info found in tech spec-->
220
+ <comment>4-digit numeric value required when Encryption is disabled</comment>
221
+ </pin>
222
+ <encryption translate="label">
223
+ <label>Encryption</label>
224
+ <frontend_type>select</frontend_type>
225
+ <source_model>upop/system_config_source_enabledisable</source_model>
226
+ <sort_order>3</sort_order>
227
+ <show_in_default>1</show_in_default>
228
+ <show_in_website>1</show_in_website>
229
+ <show_in_store>1</show_in_store>
230
+ <comment>Recommended.</comment>
231
+ </encryption>
232
+ <encryption_type translate="label">
233
+ <label>Encryption Type</label>
234
+ <frontend_type>select</frontend_type>
235
+ <source_model>upop/system_config_general_encryption</source_model>
236
+ <sort_order>4</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>1</show_in_store>
240
+ <depends>
241
+ <encryption>1</encryption>
242
+ </depends>
243
+ </encryption_type>
244
+ <encryption_key translate="label">
245
+ <label>Encryption Key</label>
246
+ <frontend_type>text</frontend_type>
247
+ <sort_order>5</sort_order>
248
+ <show_in_default>1</show_in_default>
249
+ <show_in_website>1</show_in_website>
250
+ <show_in_store>1</show_in_store>
251
+ <depends>
252
+ <encryption>1</encryption>
253
+ </depends>
254
+ </encryption_key>
255
+ <config_test translate="comment">
256
+ <label></label>
257
+ <frontend_model>upop/adminhtml_system_config_test</frontend_model>
258
+ <sort_order>6</sort_order>
259
+ <show_in_default>1</show_in_default>
260
+ <show_in_website>0</show_in_website>
261
+ <show_in_store>1</show_in_store>
262
+ </config_test>
263
+ </fields>
264
+ </upop_general>
265
+ <upop_logging translate="label">
266
+ <label>Logging</label>
267
+ <frontend_type>text</frontend_type>
268
+ <frontend_type>text</frontend_type>
269
+ <sort_order>1</sort_order>
270
+ <show_in_default>1</show_in_default>
271
+ <show_in_website>1</show_in_website>
272
+ <show_in_store>1</show_in_store>
273
+ <fields>
274
+ <mode translate="label">
275
+ <label>Log Mode</label>
276
+ <frontend_type>select</frontend_type>
277
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
278
+ <sort_order>0</sort_order>
279
+ <show_in_default>1</show_in_default>
280
+ <show_in_website>1</show_in_website>
281
+ <show_in_store>1</show_in_store>
282
+ <comment>
283
+ Recommended. Credit card numbers will be truncated
284
+ to the final four digits, and CVV numbers will be omitted.
285
+ </comment>
286
+ </mode>
287
+ <lifetime translate="label">
288
+ <label>Log Entry Lifetime</label>
289
+ <frontend_type>text</frontend_type>
290
+ <sort_order>1</sort_order>
291
+ <show_in_default>1</show_in_default>
292
+ <show_in_website>1</show_in_website>
293
+ <show_in_store>1</show_in_store>
294
+ <validate>required-entry</validate>
295
+ <comment>
296
+ Required. Smaller numbers recommended for high-traffic stores.
297
+ </comment>
298
+ </lifetime>
299
+ <export translate="comment">
300
+ <label></label>
301
+ <frontend_model>upop/adminhtml_system_config_export</frontend_model>
302
+ <sort_order>6</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>0</show_in_website>
305
+ <show_in_store>0</show_in_store>
306
+ </export>
307
+ </fields>
308
+ </upop_logging>
309
+ </groups>
310
+ </planet_payment_upop>
311
+ <currency>
312
+ <groups>
313
+ <upop translate="label">
314
+ <label>Planet payment Upop</label>
315
+ <frontend_type>text</frontend_type>
316
+ <frontend_type>text</frontend_type>
317
+ <sort_order>0</sort_order>
318
+ <show_in_default>1</show_in_default>
319
+ <show_in_website>1</show_in_website>
320
+ <show_in_store>1</show_in_store>
321
+ <fields>
322
+ <logging translate="label">
323
+ <label>Logging</label>
324
+ <frontend_type>select</frontend_type>
325
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
326
+ <sort_order>0</sort_order>
327
+ <show_in_default>1</show_in_default>
328
+ <show_in_website>1</show_in_website>
329
+ <show_in_store>1</show_in_store>
330
+ <comment>
331
+ Recommended. Disable to suppress logging of
332
+ payment processing transactions even if global
333
+ logging is enabled in General > Planet Payment UPOP
334
+ </comment>
335
+ </logging>
336
+ </fields>
337
+ </upop>
338
+ </groups>
339
+ </currency>
340
+ </sections>
341
+ <currency_convertor>
342
+
343
+ </currency_convertor>
344
+ </config>
app/code/community/PlanetPayment/Upop/sql/upop_setup/install-1.0.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Customer_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ // Sales Quote & Order entities
9
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'upop_order_number', 'varchar(32)');
10
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'upop_exchange_rate', 'float(15,6)');
11
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'upop_order_number', 'varchar(32)');
12
+
13
+ // Sales Quote & Order Payment entities
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'upop_order_number', 'varchar(32)');
15
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'upop_currency_code', 'varchar(10)');
16
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_order_number', 'varchar(32)');
17
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_currency_code', 'varchar(10)');
18
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_exchange_rate', 'float(15,6)');
19
+
20
+ $installer->run("
21
+
22
+ DROP TABLE IF EXISTS `{$this->getTable('upop/currencyCodes')}`;
23
+ CREATE TABLE `{$this->getTable('upop/currencyCodes')}` (
24
+ `currency` varchar(10) NOT NULL,
25
+ `currency_code` varchar(5) NOT NULL,
26
+ PRIMARY KEY (`currency`)
27
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
28
+
29
+ DROP TABLE IF EXISTS `{$this->getTable('upop/log')}`;
30
+ CREATE TABLE `{$this->getTable('upop/log')}` (
31
+ `id` int(10) NOT NULL AUTO_INCREMENT,
32
+ `request` text NULL,
33
+ `response` text NULL,
34
+ `create_date` timestamp DEFAULT CURRENT_TIMESTAMP,
35
+ PRIMARY KEY (`id`)
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
37
+ ");
38
+ $installer->endSetup();
app/code/community/PlanetPayment/Upop/sql/upop_setup/install-1.0.1.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Customer_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ // Sales Quote & Order entities
9
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'upop_order_number', 'varchar(32)');
10
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'upop_exchange_rate', 'float(15,6)');
11
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'upop_order_number', 'varchar(32)');
12
+
13
+ // Sales Quote & Order Payment entities
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'upop_order_number', 'varchar(32)');
15
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'upop_currency_code', 'varchar(10)');
16
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_order_number', 'varchar(32)');
17
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_currency_code', 'varchar(10)');
18
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'upop_exchange_rate', 'float(15,6)');
19
+
20
+
21
+ $installer->run("
22
+
23
+ DROP TABLE IF EXISTS `{$this->getTable('upop/currencyCodes')}`;
24
+ CREATE TABLE `{$this->getTable('upop/currencyCodes')}` (
25
+ `currency` varchar(10) NOT NULL,
26
+ `currency_code` varchar(5) NOT NULL,
27
+ PRIMARY KEY (`currency`)
28
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
29
+
30
+ DROP TABLE IF EXISTS `{$this->getTable('upop/log')}`;
31
+ CREATE TABLE `{$this->getTable('upop/log')}` (
32
+ `id` int(10) NOT NULL AUTO_INCREMENT,
33
+ `request` text NULL,
34
+ `response` text NULL,
35
+ `create_date` timestamp DEFAULT CURRENT_TIMESTAMP,
36
+ PRIMARY KEY (`id`)
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
+ ");
39
+
40
+ $installer->endSetup();
app/code/community/PlanetPayment/Upop/sql/upop_setup/install-2.0.1.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ //Create the table for module
8
+ //This is optional
9
+ $installer->run("
10
+
11
+ $installer->getConnection()
12
+ ->addColumn($tableName, 'test', array(
13
+ 'nullable' => false,
14
+ 'length' => 9,
15
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
16
+ 'comment' => 'Test Field'
17
+ )
18
+ )
19
+
20
+ $installer->endSetup();
21
+ ?>
app/code/community/PlanetPayment/Upop/sql/upop_setup/upgrade-1.0.13-1.0.17.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ $installer->startSetup();
5
+
6
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'dbt_status',
7
+ 'tinyint DEFAULT NULL');
8
+
9
+ $installer->endSetup();
app/code/community/PlanetPayment/Upop/sql/upop_setup/upgrade-1.0.17-1.0.18.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $installer->startSetup();
4
+
5
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'first_pass',
6
+ 'longtext');
7
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote'), 'second_pass',
8
+ 'longtext');
9
+
10
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/upop.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+
4
+ </layout>
app/design/adminhtml/default/default/template/upop/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/upop/checkout/currency_selector.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <div id="checkout-currency_selector-load">
30
+ <fieldset>
31
+ <?php if ($this->hasOptions()): ?>
32
+ <dl>
33
+ <dt>
34
+ <div>Select One Currency for your payment:</div>
35
+ </dt>
36
+ <?php
37
+ $_options = $this->getCurrencyOptions();
38
+ foreach ($_options as $key => $value):
39
+ ?>
40
+ <dd>
41
+ <input type="radio" name="payment[selected_currency]" class="validate-one-required-by-name currencies" value="<?php echo $key; ?>"/> <?php echo $value; ?>
42
+ </dd>
43
+ <?php endforeach; ?>
44
+ </dl>
45
+ <?php endif; ?>
46
+ </fieldset>
47
+ <script type="text/javascript">
48
+ //<![CDATA[
49
+ $$('.currencies').each(function(e){
50
+ Event.observe(e, 'click', updateCurrency.bind(this));
51
+ });
52
+
53
+ function updateCurrency(obj) {
54
+ $("loading-mask").show();
55
+ new Ajax.Request('<?php echo Mage::helper("adminhtml")->getUrl('upopadmin/adminhtml_checkout/updateCurrency');?>', {
56
+ parameters: $('edit_form').serialize(true),
57
+ method:'post',
58
+ onSuccess: function(transport) {
59
+
60
+ }.bind(this)
61
+ });
62
+ }
63
+ //]]>
64
+ </script>
65
+ </div>
app/design/adminhtml/default/default/template/upop/customer/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/upop/customer/tab/upop.phtml ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+
29
+ $upopProfileId = $this->getUpopProfileId();
30
+ if (!$upopProfileId) {
31
+ $upopProfileId = $this->__('Not registered with Planet Payment');
32
+ }
33
+ ?>
34
+ <div class="entry-edit">
35
+ <div class="entry-edit-head"><h4 class="icon-head"><?php echo Mage::helper('upop')->__('Planet Payment Payment Profiles') ?></h4></div>
36
+ <fieldset>
37
+ <?php $profiles = $this->getCimPaymentProfiles() ?>
38
+ <?php if (count($profiles)) { ?>
39
+ <?php $count = 1; ?>
40
+ <?php foreach ($profiles as $profile) { ?>
41
+ <div class="<?php echo ($count % 2 == 1 ? 'box-left' : 'box-right') ?>">
42
+ <button type="button" style="float: right;" class="scalable delete" onclick="deleteConfirm('Are you sure?', '<?php echo $this->getUpopProfileDeleteUrl($profile) ?>')"><span><?php echo $this->__('Delete Payment Profile') ?></span></button>
43
+ <strong><?php echo $this->__('Upop Profile Client Id:') ?></strong> <?php echo $profile->getClientId() ?><br/>
44
+ <strong><?php echo $this->__('Upop Profile Account Id:') ?></strong> <?php echo $profile->getAccountId() ?>
45
+ <div style="margin-top: 5px;">
46
+ <?php echo $profile->toHtml(true, false) ?>
47
+ </div>
48
+ </div>
49
+ <?php if ($count % 2 == 0) { ?>
50
+ <div style="height: 10px; clear: both;"></div>
51
+ <?php } ?>
52
+ <?php $count++; ?>
53
+ <?php } ?>
54
+ <?php } else { ?>
55
+ <em><?php echo $this->__('No Planet Payment Profile registered.') ?></em>
56
+ <?php } ?>
57
+ </fieldset>
58
+ </div>
app/design/adminhtml/default/default/template/upop/payment/form.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+
app/design/adminhtml/default/default/template/upop/payment/info.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <address>
30
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?><br />
31
+ </address>
app/design/adminhtml/default/default/template/upop/system/.DS_Store ADDED
Binary file
app/design/adminhtml/default/default/template/upop/system/config/export.phtml ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <?php $htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
30
+ <button style="margin-bottom: 10px;" class="scalable" type="button" id="exportBtn<?php echo $htmlId ?>">
31
+ <span><?php echo Mage::helper('upop')->__('Export Logs'); ?></span>
32
+ </button>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ function redirectToPurge () {
36
+ if (confirm('<?php echo Mage::helper('upop')->__("Are you sure you want to continue?") ?>')) {
37
+ window.location.href = '<?php echo $this->getExportUrl() ?>';
38
+ var btn = $('exportBtn<?php echo $htmlId ?>');
39
+ }
40
+ }
41
+ $('exportBtn<?php echo $htmlId ?>').observe('click', redirectToPurge);
42
+ //]]>
43
+ </script>
app/design/adminhtml/default/default/template/upop/system/config/purge.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <?php $htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
30
+ <button style="margin-bottom: 10px;" class="scalable" type="button" id="purgeBtn<?php echo $htmlId ?>">
31
+ <span><?php echo Mage::helper('upop')->__('Clear Profiles'); ?></span>
32
+ </button>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ function redirectToPurge () {
36
+ if (confirm('<?php echo Mage::helper('upop')->__("This will purge all Payment Profiles from Planet Payment and magento.\\nAre you sure you want to continue?") ?>')) {
37
+ window.location.href = '<?php echo $this->getPurgeUrl() ?>';
38
+ var btn = $('purgeBtn<?php echo $htmlId ?>');
39
+ btn.disable().addClassName('disabled');
40
+ }
41
+ }
42
+ $('purgeBtn<?php echo $htmlId ?>').observe('click', redirectToPurge);
43
+ //]]>
44
+ </script>
app/design/adminhtml/default/default/template/upop/system/config/test.phtml ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <?php $htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
30
+ <button style="margin-bottom: 10px;" class="scalable" type="button" id="testBtn<?php echo $htmlId ?>">
31
+ <span><?php echo Mage::helper('upop')->__('Test Configuration Values'); ?></span>
32
+ </button>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ function redirectToPurge () {
36
+ window.location.href = '<?php echo $this->getTestUrl() ?>';
37
+ var btn = $('testBtn<?php echo $htmlId ?>');
38
+ btn.disable().addClassName('disabled');
39
+ }
40
+ $('testBtn<?php echo $htmlId ?>').observe('click', redirectToPurge);
41
+ //]]>
42
+ </script>
app/design/frontend/base/default/layout/upop.xml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ </layout>
app/design/frontend/base/default/template/upop/checkout/onepage/currency_selector.phtml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <div id="checkout-currency_selector-load">
30
+ <form id="co-currency-select-form" action="">
31
+ <fieldset>
32
+ <?php if ($this->hasOptions()): ?>
33
+ <dl>
34
+ <dt>
35
+ <div><em><?php echo $this->__("As a convenience to our international customers, your purchase can be completed in your home currency at today's exchange rate of ".$this->getExchangeRate()." (Wholesale Rate ".$this->getMarkUp()."%).");?></em></div>
36
+ <div><?php echo $this->__("Select One Currency for your payment:");?></div>
37
+ </dt>
38
+ <?php
39
+ $_options = $this->getCurrencyOptions();
40
+ foreach ($_options as $key => $value):
41
+ ?>
42
+ <dd>
43
+ <input type="radio" name="payment[selected_currency]" class="validate-one-required-by-name currencies" value="<?php echo $key; ?>"/> <?php echo $value; ?>
44
+ </dd>
45
+ <?php endforeach; ?>
46
+ </dl>
47
+ <?php endif; ?>
48
+ </fieldset>
49
+ </form>
50
+
51
+
52
+ <div id="currency_select-buttons-container" class="buttons-set" style="">
53
+ <p class="required">* Required Fields</p>
54
+ <p class="back-link"><a onclick="checkout.back(); return false;" href="#"><small><<</small>Back</a></p>
55
+ <button onclick="currencySelect.save()" class="button" type="button"><span><span>Continue</span></span></button>
56
+ <span style="display: none;" id="currency_select-please-wait" class="please-wait">
57
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" class="v-middle" alt="" /> &nbsp; <?php echo $this->__('Loading next step...') ?> &nbsp;
58
+ </span>
59
+ </div>
60
+
61
+
62
+ <script type="text/javascript">
63
+ //<![CDATA[
64
+
65
+ var CurrencySelect = Class.create();
66
+ CurrencySelect.prototype = {
67
+ initialize: function(form, saveUrl){
68
+ this.form = form;
69
+ if ($(this.form)) {
70
+ $(this.form).observe('submit', function(event){this.save();Event.stop(event);}.bind(this));
71
+ }
72
+ this.saveUrl = saveUrl;
73
+ this.onSave = this.nextStep.bindAsEventListener(this);
74
+ this.onComplete = this.resetLoadWaiting.bindAsEventListener(this);
75
+ },
76
+
77
+ save: function(){
78
+ if (checkout.loadWaiting!=false) return;
79
+
80
+ var validator = new Validation(this.form);
81
+ if (validator.validate()) {
82
+
83
+ checkout.setLoadWaiting('currency_select');
84
+
85
+
86
+ var request = new Ajax.Request(
87
+ this.saveUrl,
88
+ {
89
+ method: 'post',
90
+ onComplete: this.onComplete,
91
+ onSuccess: this.onSave,
92
+ onFailure: checkout.ajaxFailure.bind(checkout),
93
+ parameters: Form.serialize(this.form)
94
+ }
95
+ );
96
+ }
97
+ },
98
+
99
+ resetLoadWaiting: function(transport){
100
+ checkout.setLoadWaiting(false);
101
+ },
102
+
103
+ nextStep: function(transport){
104
+ if (transport && transport.responseText){
105
+ try{
106
+ response = eval('(' + transport.responseText + ')');
107
+ }
108
+ catch (e) {
109
+ response = {};
110
+ }
111
+ }
112
+
113
+ if (response.error){
114
+ if ((typeof response.message) == 'string') {
115
+ alert(response.message);
116
+ } else {
117
+ if (response.update_section) {
118
+ $('checkout-'+response.update_section.name+'-load').update(response.update_section.html);
119
+ }
120
+
121
+ if (response.goto_section) {
122
+ checkout.gotoSection(response.goto_section);
123
+ checkout.reloadProgressBlock();
124
+ return;
125
+ }
126
+ }
127
+
128
+ return false;
129
+ }
130
+
131
+ checkout.setStepResponse(response);
132
+ }
133
+ }
134
+
135
+ var currencySelect = new CurrencySelect('co-currency-select-form', '<?php echo $this->getUrl('checkout/onepage/saveCurrency') ?>');
136
+
137
+ //]]>
138
+ </script>
139
+ </div>
app/design/frontend/base/default/template/upop/payment/form.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <?php $_code = $this->getMethodCode(); ?>
30
+ <div class="form-list" id="payment_form_<?php echo $_code ?>" style="display: block;">
31
+ <?php echo $this->__('You will be redirected to the UnionPay website witin a few seconds.') ?>
32
+ </div>
app/design/frontend/base/default/template/upop/payment/info.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <address>
30
+ <b><?php echo $this->__('Upop Website Payments'); ?></b>
31
+ </address>
app/design/frontend/base/default/template/upop/payment/mark.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
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 codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_Upop
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_Upop
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+
29
+ ?>
30
+ <!-- UPOP Logo -->
31
+ <img src="<?php echo $this->escapeHtml($this->getPaymentAcceptanceMarkSrc())?>" class="v-middle" height="21"/>&nbsp;
32
+ <!-- UPOP Logo -->
app/etc/modules/PlanetPayment_Upop.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <PlanetPayment_Upop>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Adminhtml />
9
+ <Mage_Checkout />
10
+ <Mage_Customer />
11
+ <Mage_Payment />
12
+ </depends>
13
+ </PlanetPayment_Upop>
14
+ </modules>
15
+ </config>
app/locale/zh_CN/PlanetPayment_Upop.csv ADDED
@@ -0,0 +1 @@
 
1
+ "You will be redirected to the UnionPay website when you place an order.","当您下单时将会把您引到中国银联网站。"
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>UnionPay</name>
4
+ <version>1.0.18</version>
5
+ <stability>stable</stability>
6
+ <license>Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Planet Payment UPOP integration extension</summary>
10
+ <description>Planet Payment UPOP integration extension</description>
11
+ <notes>To Create Order Object In magneto After Gateway Approval</notes>
12
+ <authors><author><name>mohd shamim</name><user>mohd</user><email>mohds@chetu.com</email></author></authors>
13
+ <date>2014-03-10</date>
14
+ <time>16:53:00</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="PlanetPayment_Upop.xml" hash="ee6065d3bf1de7c2e814489a60821892"/></dir></target><target name="magecommunity"><dir name="PlanetPayment"><dir name="Upop"><dir name="Block"><dir name="Adminhtml"><dir name="Checkout"><file name="Upop.php" hash="f854a43c28328b1cd2797925e5246ae2"/></dir><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Upop.php" hash="f5d600684feba000e2f97bf003db6faf"/></dir><file name="Tabs.php" hash="12b8d2d42d341f5fdc1c8fd1a6c9b964"/></dir></dir><dir name="Payment"><file name="Form.php" hash="233b17dc6034c5f1df7ec7076987897b"/></dir><dir name="System"><dir name="Config"><file name="Export.php" hash="391d915565b810f438c4677b7e41ed9a"/><file name="Purge.php" hash="1a022bd1a634b0bed4b0e1a42f395553"/><file name="Test.php" hash="7df1c62c850830d50b82ad168534be5a"/></dir></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Totals.php" hash="a7c8b7c1197ea8a6dd5c9ce0c64cf660"/></dir><file name=".DS_Store" hash="34ee7ed8add9c5b997c4a0fa426f57cc"/></dir><dir name="Onepage"><file name="Upop.php" hash="b0486e2700b88d5ba3b4d42ab278383a"/></dir><file name="Onepage.php" hash="3e578942927cb2ca952c2fa5a089be09"/><dir name="Payment"><file name="Form.php" hash="88a9c5ffa9039f8b99b963d291f97c68"/><file name="Info.php" hash="aa8b85b94941a78e2308945c085b3369"/></dir><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="c404ae7b5e1b8532f3fb9b5614465de6"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="e222c2d3754b1d06164c5fc592629171"/><file name="Error.php" hash="8b1f6043b4e80bfb030d1854c0d4ec91"/></dir><dir name="Model"><file name="Checkout.php" hash="d6901c9237d4fe8dfde22042e98acd5e"/><dir name="Currency"><dir name="Import"><file name="Upop.php" hash="36fbf0cd46996d1fa973591f3bdf44a7"/></dir></dir><file name="CurrencyCode.php" hash="8ed2c6de53938680b299d52d021e025e"/><file name="Log.php" hash="45e8572ebd9188d08d4a1378a82bafbf"/><dir name="Observer"><file name="Abstract.php" hash="041c726d7b5695703eb554b9d2e87532"/><file name="Checkout.php" hash="5fd4cc1dd8485c1dc00a9ef4f014e2bb"/><file name="Log.php" hash="125e82e8de8f948d9c8c53c690f1d991"/></dir><file name="Observer.php" hash="7d54664037e0429f0af465c612943900"/><file name="Profile.php" hash="dad9ce129904f5ff20a75cbace8dfac6"/><dir name="Resource"><dir name="CurrencyCode"><file name="Collection.php" hash="98236c1dd8c9563fd2c0cb94ba71ad7a"/></dir><file name="CurrencyCode.php" hash="33b01a7fcf53907b88f500356d38eac9"/><dir name="Log"><file name="Collection.php" hash="ce91cecf8da4cdcd865b0ada87c4ac57"/></dir><file name="Log.php" hash="ea93412f7f65c8c0a4ff2a9c46ae9cfd"/><dir name="Profile"><file name="Collection.php" hash="3abe5c69a5ebad304e8f8ad998d399d1"/></dir><file name="Profile.php" hash="a5c5db31042194037e20132283f5676b"/></dir><file name="Session.php" hash="0e091e72f0804a591ad1e91597701c76"/><dir name="System"><dir name="Config"><dir name="General"><file name="Encryption.php" hash="2b9b7dfbb132d6cfeab8b16d988a57ce"/><file name="Mode.php" hash="c80323f78abbf310091d716a18f78aa2"/></dir><dir name="Payment"><file name="Cctype.php" hash="8d2ed40fd85a5b156648d87e9e8595d5"/><file name="Currency.php" hash="7cd56cedddbd08aa7063da469b9ced4f"/><file name="PaymentAction.php" hash="d692da5b3c99dba9332312b6d425c778"/><file name="Service.php" hash="70cd38ee3a86e9d114db965e171cf128"/></dir><dir name="Source"><file name="Enabledisable.php" hash="7f95203e8894fc1fe5a7870158ef0850"/></dir></dir></dir><dir name="Type"><file name="Onepage.php" hash="2022601692ebb4ff5108acffebb1730a"/></dir><file name="Upop.php" hash="0c0dbf83cd9fc17577a91c69b823a4c5"/><dir name="Xml"><file name="Abstract.php" hash="a1e45b4a19f1577bbe9ecad7559f6f6a"/><file name="Request.php" hash="9d7e9d887493664a083de2ca441db969"/><file name="Response.php" hash="87c3a60df74bf098174a9fca521254dc"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CheckoutController.php" hash="ddcf35785f5315feac695e18592b91f4"/><file name="CustomerController.php" hash="b49333ef445c551baa4e463f9875fb30"/><file name="OrderController.php" hash="39a017b0aa021bdd39a1292f915e4446"/><file name="SystemController.php" hash="aa47e874790d61231dac4dd66c6dd037"/></dir><file name="IndexController.php" hash="f5f089dbe4766afc6db26fb11e63bd0f"/><file name="OnepageController.php" hash="a746fc36421a3eda7088ec79528e0967"/><file name="ProfileController.php" hash="bcdea4d31c963e0bf3fcd52cd1738d33"/></dir><dir name="data"><dir name="upop_setup"><file name="data-install-1.0.0.php" hash="0c423cb08fe5a20fc62fd3deca20f1fd"/><file name="data-install-1.0.1.php" hash="4efb3065821efc357a42d95883c5357c"/><file name="data-upgrade-1.0.4-1.0.5.php" hash="e8683eb6fde0a7d02763d15ed6b5a644"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="d2367e1541581e3fcce69b797931d4c7"/><file name="config.xml" hash="6bd55e76ec47c0b231caecc7599c06ee"/><file name="system.xml" hash="bf17913a7dc53d65f4c577030999d2cc"/></dir><dir name="sql"><dir name="upop_setup"><file name="install-1.0.0.php" hash="2cd61caba8459ed0f67e160c2e9651cd"/><file name="install-1.0.1.php" hash="6b5597a5846658906860e84da7edbb3e"/><file name="install-2.0.1.php" hash="9f6e34a1548ab8af327c777f51c4e2f3"/><file name="upgrade-1.0.13-1.0.17.php" hash="16d404389e3ec3e48814de217da966b4"/><file name="upgrade-1.0.17-1.0.18.php" hash="e808afdd2d2e38a1c44f6317d80dece5"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="zh_CN"><file name="PlanetPayment_Upop.csv" hash="b1f1bb1b287658fc409056feba6b9419"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="upop.xml" hash="2370be1560e9a6296d6c5ed4d2d3d5ef"/></dir><dir name="template"><dir name="upop"><dir name="checkout"><file name="currency_selector.phtml" hash="48b9af6ddbcb6766d4af288f329f58d0"/></dir><dir name="customer"><dir name="tab"><file name="upop.phtml" hash="2104bde661ce7debc6dff0f45894c6a5"/></dir><file name=".DS_Store" hash="194577a7e20bdcc7afbb718f502c134c"/></dir><dir name="payment"><file name="form.phtml" hash="fcaae1d360b765eaaaa818f74828445e"/><file name="info.phtml" hash="89cfeecbdd2ba96020755726e788f295"/></dir><dir name="system"><dir name="config"><file name="export.phtml" hash="abc7c27d5d4881886275a36e08a93c91"/><file name="purge.phtml" hash="6f157635d0df1c095fca6a58c9211500"/><file name="test.phtml" hash="f22ce9b059e30680aecc875bc43887f6"/></dir><file name=".DS_Store" hash="40f65db350f06e1673e0561dadb5fefb"/></dir><file name=".DS_Store" hash="f2f9b7690dbbc143b1e5ead79e9a324d"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="upop.xml" hash="27179eee219a0a8c85b87b8d670ae9e1"/></dir><dir name="template"><dir name="upop"><dir name="checkout"><dir name="onepage"><file name="currency_selector.phtml" hash="0153c8a8d1cc449dc82256fbbc8f044d"/></dir></dir><dir name="payment"><file name="form.phtml" hash="4673b6c69e6c120a9689f2c5c346fea0"/><file name="info.phtml" hash="1a210404f5c37db9443c9ef3bb1527c4"/><file name="mark.phtml" hash="746db8a50c7cad2a9fc0750b75662a97"/></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="js"><dir name="upop"><file name="upop.js" hash="999f658f2461210eef0cf51c9ca96dc6"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.3</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/js/upop/upop.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * UPOP Admin JS.
3
+ */
4
+ upop = {};
5
+ upop.Payment = Class.create({
6
+ initialize: function (container, dropdown, radio, url) {
7
+ this.container = $(container);
8
+ if (!this.container) {
9
+ return;
10
+ }
11
+ this.dropdown = $(dropdown);
12
+ this.dropdown.observe('change', this.toggleForm.bind(this));
13
+ var obj = this;
14
+ this.url = url;
15
+ $$(".upop-payment").each(function(e){
16
+ Event.observe(e, 'change', obj.checkPaymentMethod.bind(obj))
17
+ });
18
+ this.radio = $(radio);
19
+ this.radio.observe('click', this.toggleForm.bind(this));
20
+ this.form = this.container.down('ul');
21
+ /**
22
+ * Kind of ghetto, but wait a bit until AdminOrder.setPaymentMethod() fires because that enables
23
+ * all the payment form fields.
24
+ */
25
+ setTimeout(function () {
26
+ this.toggleForm();
27
+ }.bind(this), 500);
28
+ },
29
+
30
+ toggleForm: function (evt) {
31
+ if (this.dropdown.value) {
32
+ this.form.hide();
33
+ Form.disable(this.form.identify());
34
+ //console.log('disabled');
35
+ }
36
+ else {
37
+ this.form.show();
38
+ Form.enable(this.form.identify());
39
+ //console.log('enabled');
40
+ }
41
+ },
42
+
43
+ checkPaymentMethod: function (evt) {
44
+ $("loading-mask").show();
45
+ new Ajax.Request(this.url, {
46
+ parameters: $('edit_form').serialize(true),
47
+ method:'post',
48
+ onSuccess: function(transport) {
49
+ var response = transport.responseText.evalJSON();
50
+ if(response.update_section) {
51
+ if(response.error){
52
+ if(response.message){
53
+ Element.update($(response.update_section.name), "<font color='red'>"+response.message+"</font>");
54
+ }
55
+ } else {
56
+ Element.update($(response.update_section.name), response.update_section.html);
57
+ }
58
+ }
59
+ }.bind(this)
60
+ });
61
+ }
62
+ });