planetpay_ipaygateway - Version 1.0.7

Version Notes

Fixed address and postal code length issue.

Download this release

Release Info

Developer Brad Seeley
Extension planetpay_ipaygateway
Version 1.0.7
Comparing to
See all releases


Version 1.0.7

Files changed (73) hide show
  1. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Checkout/Ipay.php +42 -0
  2. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Customer/Edit/Tab/Ipay.php +77 -0
  3. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Customer/Edit/Tabs.php +46 -0
  4. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Payment/Form.php +76 -0
  5. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/System/Config/Export.php +52 -0
  6. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/System/Config/Purge.php +54 -0
  7. app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/System/Config/Test.php +54 -0
  8. app/code/community/PlanetPayment/IpayGateway/Block/Checkout/Cart/Totals.php +78 -0
  9. app/code/community/PlanetPayment/IpayGateway/Block/Onepage.php +50 -0
  10. app/code/community/PlanetPayment/IpayGateway/Block/Onepage/Ipay.php +60 -0
  11. app/code/community/PlanetPayment/IpayGateway/Block/Payment/Form.php +150 -0
  12. app/code/community/PlanetPayment/IpayGateway/Block/Payment/Info.php +36 -0
  13. app/code/community/PlanetPayment/IpayGateway/Block/Profile.php +115 -0
  14. app/code/community/PlanetPayment/IpayGateway/Block/Profile/Edit.php +186 -0
  15. app/code/community/PlanetPayment/IpayGateway/Block/Profile/List.php +81 -0
  16. app/code/community/PlanetPayment/IpayGateway/Block/Sales/Order/Totals.php +135 -0
  17. app/code/community/PlanetPayment/IpayGateway/Helper/Data.php +127 -0
  18. app/code/community/PlanetPayment/IpayGateway/Helper/Error.php +160 -0
  19. app/code/community/PlanetPayment/IpayGateway/Model/Currency/Import/Ipay.php +85 -0
  20. app/code/community/PlanetPayment/IpayGateway/Model/CurrencyCode.php +36 -0
  21. app/code/community/PlanetPayment/IpayGateway/Model/Ipay.php +445 -0
  22. app/code/community/PlanetPayment/IpayGateway/Model/Log.php +36 -0
  23. app/code/community/PlanetPayment/IpayGateway/Model/Observer/Abstract.php +62 -0
  24. app/code/community/PlanetPayment/IpayGateway/Model/Observer/Checkout.php +87 -0
  25. app/code/community/PlanetPayment/IpayGateway/Model/Observer/Log.php +46 -0
  26. app/code/community/PlanetPayment/IpayGateway/Model/Profile.php +174 -0
  27. app/code/community/PlanetPayment/IpayGateway/Model/Resource/CurrencyCode.php +35 -0
  28. app/code/community/PlanetPayment/IpayGateway/Model/Resource/CurrencyCode/Collection.php +36 -0
  29. app/code/community/PlanetPayment/IpayGateway/Model/Resource/Log.php +35 -0
  30. app/code/community/PlanetPayment/IpayGateway/Model/Resource/Log/Collection.php +36 -0
  31. app/code/community/PlanetPayment/IpayGateway/Model/Resource/Profile.php +35 -0
  32. app/code/community/PlanetPayment/IpayGateway/Model/Resource/Profile/Collection.php +41 -0
  33. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/General/Encryption.php +40 -0
  34. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/General/Mode.php +44 -0
  35. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/Payment/Cctype.php +76 -0
  36. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/Payment/Currency.php +52 -0
  37. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/Payment/PaymentAction.php +44 -0
  38. app/code/community/PlanetPayment/IpayGateway/Model/System/Config/Payment/Service.php +43 -0
  39. app/code/community/PlanetPayment/IpayGateway/Model/Type/Onepage.php +63 -0
  40. app/code/community/PlanetPayment/IpayGateway/Model/Xml/Abstract.php +178 -0
  41. app/code/community/PlanetPayment/IpayGateway/Model/Xml/Request.php +825 -0
  42. app/code/community/PlanetPayment/IpayGateway/Model/Xml/Response.php +179 -0
  43. app/code/community/PlanetPayment/IpayGateway/controllers/Adminhtml/CheckoutController.php +111 -0
  44. app/code/community/PlanetPayment/IpayGateway/controllers/Adminhtml/CustomerController.php +110 -0
  45. app/code/community/PlanetPayment/IpayGateway/controllers/Adminhtml/SystemController.php +127 -0
  46. app/code/community/PlanetPayment/IpayGateway/controllers/OnepageController.php +180 -0
  47. app/code/community/PlanetPayment/IpayGateway/controllers/ProfileController.php +192 -0
  48. app/code/community/PlanetPayment/IpayGateway/data/ipay_setup/data-install-1.0.0.php +252 -0
  49. app/code/community/PlanetPayment/IpayGateway/etc/adminhtml.xml +50 -0
  50. app/code/community/PlanetPayment/IpayGateway/etc/config.xml +495 -0
  51. app/code/community/PlanetPayment/IpayGateway/etc/system.xml +386 -0
  52. app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/install-1.0.0.php +67 -0
  53. app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.0-1.0.1.php +12 -0
  54. app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.1-1.0.2.php +12 -0
  55. app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.2-1.0.5.php +10 -0
  56. app/design/adminhtml/default/default/layout/ipay.xml +14 -0
  57. app/design/adminhtml/default/default/template/ipay/checkout/currency_selector.phtml +65 -0
  58. app/design/adminhtml/default/default/template/ipay/customer/tab/ipay.phtml +58 -0
  59. app/design/adminhtml/default/default/template/ipay/payment/form.phtml +102 -0
  60. app/design/adminhtml/default/default/template/ipay/payment/info.phtml +39 -0
  61. app/design/adminhtml/default/default/template/ipay/system/config/export.phtml +48 -0
  62. app/design/adminhtml/default/default/template/ipay/system/config/purge.phtml +44 -0
  63. app/design/adminhtml/default/default/template/ipay/system/config/test.phtml +47 -0
  64. app/design/frontend/base/default/layout/ipay.xml +44 -0
  65. app/design/frontend/base/default/template/ipay/checkout/onepage/currency_selector.phtml +139 -0
  66. app/design/frontend/base/default/template/ipay/payment/form.phtml +118 -0
  67. app/design/frontend/base/default/template/ipay/payment/info.phtml +36 -0
  68. app/design/frontend/base/default/template/ipay/profile/edit.phtml +195 -0
  69. app/design/frontend/base/default/template/ipay/profile/list.phtml +82 -0
  70. app/etc/modules/PlanetPayment_IpayGateway.xml +15 -0
  71. package.xml +18 -0
  72. skin/adminhtml/default/default/js/ipay/ipay.js +62 -0
  73. skin/frontend/base/default/js/ipay/validation.js +19 -0
app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Checkout/Ipay.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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Adminhtml_Checkout_Ipay 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/IpayGateway/Block/Adminhtml/Customer/Edit/Tab/Ipay.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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Adminhtml_Customer_Edit_Tab_Ipay extends Mage_Adminhtml_Block_Template {
29
+
30
+ protected function _construct() {
31
+ parent::_construct();
32
+ $this->setTemplate('ipay/customer/tab/ipay.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_IpayGateway_Model_Resource_PaymentProfile_Collection
48
+ */
49
+ public function getCimPaymentProfiles() {
50
+ return Mage::getModel('ipay/profile')->getCollection()
51
+ ->addCustomerFilter($this->getCustomer());
52
+ }
53
+
54
+ /**
55
+ * URL to create/recreate Ipay profile.
56
+ *
57
+ * @return string
58
+ */
59
+ public function getCimRegisterUrl() {
60
+ return $this->getUrl('ipayadmin/adminhtml_customer/register', array('customer_id' => $this->getCustomer()->getId()));
61
+ }
62
+
63
+ /**
64
+ * URL to delete a Ipay payment profile.
65
+ *
66
+ * @param PlanetPayment_IpayGateway_Model_PaymentProfile $profile
67
+ * @return string
68
+ */
69
+ public function getIpayProfileDeleteUrl(PlanetPayment_IpayGateway_Model_Profile $profile) {
70
+ $params = array(
71
+ 'customer_id' => $this->getCustomer()->getId(),
72
+ 'profile_id' => $profile->getId()
73
+ );
74
+ return $this->getUrl('ipayadmin/adminhtml_customer/deletePaymentProfile', $params);
75
+ }
76
+
77
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Adminhtml_Customer_Edit_Tabs extends Mage_Adminhtml_Block_Customer_Edit_Tabs {
29
+
30
+ /**
31
+ * Insert the CIM tab.
32
+ *
33
+ * @return PlanetPayment_IpayGateway_Block_Adminhtml_Customer_Edit_Tabs
34
+ */
35
+ protected function _beforeToHtml() {
36
+ if (Mage::registry('current_customer')->getId() && Mage::getStoreConfig('payment/ipay/tokenize')) {
37
+ $this->addTab('ipay', array(
38
+ 'label' => Mage::helper('ipay')->__('Planet Payment'),
39
+ 'content' => $this->getLayout()->createBlock('ipay/adminhtml_customer_edit_tab_ipay')->toHtml(),
40
+ 'after' => 'tags'
41
+ ));
42
+ }
43
+ return parent::_beforeToHtml();
44
+ }
45
+
46
+ }
app/code/community/PlanetPayment/IpayGateway/Block/Adminhtml/Payment/Form.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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Adminhtml_Payment_Form extends PlanetPayment_IpayGateway_Block_Payment_Form {
29
+
30
+ /**
31
+ * Returns an array of payment profiles.
32
+ *
33
+ * @return array
34
+ */
35
+ public function getPaymentProfiles() {
36
+
37
+ if (!$this->hasData('payment_profiles')) {
38
+ $profilesArray = array();
39
+ $profiles = Mage::getModel('ipay/profile')->getCollection()
40
+ ->addCustomerFilter($this->getCustomer());
41
+ foreach ($profiles as $profile) { // include all profiles regardless of visibility
42
+ $profilesArray[] = $profile;
43
+ }
44
+
45
+ $this->setPaymentProfiles($profilesArray);
46
+ }
47
+ return $this->getData('payment_profiles');
48
+ }
49
+
50
+ /**
51
+ * Returns an empty profile or the one chosen with the last request.
52
+ *
53
+ * @return PlanetPayment_IpayGateway_Model_Profile
54
+ */
55
+ public function getDefaultPaymentProfile() {
56
+ if ($this->getMethod()->getInfoInstance()->getIpayProfileId()) {
57
+ return $this->getSelectedProfile();
58
+ }
59
+ return Mage::getModel('ipay/profile');
60
+ }
61
+
62
+ /**
63
+ * Returns the profile set in the method instance.
64
+ *
65
+ * @return PlanetPayment_IpayGateway_Model_Profile
66
+ */
67
+ public function getSelectedProfile() {
68
+ $profile = Mage::getModel('ipay/profile');
69
+ $profileId = $this->getMethod()->getInfoInstance()->getIpayProfileId();
70
+ if ($profileId) {
71
+ $profile->loadByPaymentProfileId($profileId);
72
+ }
73
+ return $profile;
74
+ }
75
+
76
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
25
+ * @author One Pica Codemaster <codemaster@onepica.com>
26
+ */
27
+ class PlanetPayment_IpayGateway_Block_Adminhtml_System_Config_Export extends Mage_Adminhtml_Block_System_Config_Form_Field {
28
+
29
+ protected function _construct() {
30
+ parent::_construct();
31
+ $this->setTemplate('ipay/system/config/export.phtml');
32
+ }
33
+
34
+ /**
35
+ * @return string
36
+ */
37
+ public function getExportUrl() {
38
+ return $this->getUrl('ipay/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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Block_Adminhtml_System_Config_Purge extends Mage_Adminhtml_Block_System_Config_Form_Field {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('ipay/system/config/purge.phtml');
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getPurgeUrl() {
40
+ return $this->getUrl('ipay/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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Block_Adminhtml_System_Config_Test extends Mage_Adminhtml_Block_System_Config_Form_Field {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('ipay/system/config/test.phtml');
34
+ }
35
+
36
+ /**
37
+ * @return string
38
+ */
39
+ public function getTestUrl() {
40
+ return $this->getUrl('ipay/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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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()->getIpayCurrencyCode())) {
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->getIpayExchangeRate();
55
+ if ($this->_isPyc() && $exchangeRate) {
56
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
57
+ $currency = Mage::app()->getLocale()->currency($quote->getPayment()->getIpayCurrencyCode())->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('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC;
72
+ }
73
+
74
+ protected function _isMcp() {
75
+ return Mage::getmodel('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP;
76
+ }
77
+
78
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
25
+ * @author One Pica Codemaster <codemaster@onepica.com>
26
+ */
27
+
28
+ class PlanetPayment_IpayGateway_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('ipay')->isEnabled()) {
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/IpayGateway/Block/Onepage/Ipay.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Block_Onepage_Ipay extends Mage_Checkout_Block_Onepage_Abstract {
30
+
31
+ protected function _construct() {
32
+ $this->getCheckout()->setStepData('currency_selector', array(
33
+ 'label' => Mage::helper('ipay')->__('Payment Currency (Planet Payment)'),
34
+ 'is_show' => true
35
+ ));
36
+
37
+ parent::_construct();
38
+ }
39
+
40
+ public function getCurrencyOptions() {
41
+ return $this->getResponse()->getPycCurrencyOptions();
42
+ }
43
+
44
+ public function getExchangeRate() {
45
+ return $this->getResponse()->getExchangeRate();
46
+ }
47
+
48
+ public function getMarkUp() {
49
+ return $this->getResponse()->getMarkUp();
50
+ }
51
+
52
+ public function hasOptions() {
53
+ if ($this->getResponse()) {
54
+ return true;
55
+ }
56
+
57
+ return false;
58
+ }
59
+
60
+ }
app/code/community/PlanetPayment/IpayGateway/Block/Payment/Form.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Block_Payment_Form extends Mage_Payment_Block_Form_Cc {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('ipay/payment/form.phtml');
34
+ }
35
+
36
+ /**
37
+ * Returns true if it's guest checkout.
38
+ *
39
+ * @return bool
40
+ */
41
+ public function isGuestCheckout() {
42
+ return Mage::helper('ipay')->isGuestCheckout();
43
+ }
44
+
45
+ /**
46
+ * Returns the logged in user.
47
+ *
48
+ * @return Mage_Customer_Model_Customer
49
+ */
50
+ public function getCustomer() {
51
+ return Mage::helper('ipay')->getCustomer();
52
+ }
53
+
54
+ /**
55
+ * Returns an array of payment profiles.
56
+ *
57
+ * @return array
58
+ */
59
+ public function getPaymentProfiles() {
60
+ if (!$this->hasData('payment_profiles')) {
61
+ $profilesArray = array();
62
+ $profiles = Mage::getModel('ipay/profile')->getCollection()
63
+ ->addCustomerFilter($this->getCustomer());
64
+ foreach ($profiles as $profile) {
65
+ if ($profile->getIsVisible()) { // don't display on frontend
66
+ $profilesArray[] = $profile;
67
+ }
68
+ }
69
+ $this->setPaymentProfiles($profilesArray);
70
+ }
71
+ return $this->getData('payment_profiles');
72
+ }
73
+
74
+ /**
75
+ * @return bool
76
+ */
77
+ public function hasPaymentProfiles() {
78
+ return count($this->getPaymentProfiles()) > 0;
79
+ }
80
+
81
+ /**
82
+ * Renders a select dropdown of payment profiles.
83
+ *
84
+ * @return string
85
+ */
86
+ public function getPaymentProfileSelectHtml() {
87
+ $options = array();
88
+ if (Mage::app()->getStore()->isAdmin()) {
89
+ $options['0'] = $this->__('Select one profile');
90
+ }
91
+ foreach ($this->getPaymentProfiles() as $profile) {
92
+ $options[$profile->getId()] = $profile->format('oneline');
93
+ }
94
+ $options[''] = $this->__('New Card');
95
+
96
+ $select = Mage::app()->getLayout()->createBlock('core/html_select')
97
+ ->setName('payment[ipay_profile_id]')
98
+ ->setId($this->getMethodCode() . '_payment_profile_id')
99
+ ->setClass('ipay-payment')
100
+ ->setOptions($options);
101
+
102
+ return $select->getHtml();
103
+ }
104
+
105
+ /**
106
+ * Returns the default payment profile.
107
+ *
108
+ * @return PlanetPayment_IpayGateway_Model_PaymentProfile
109
+ */
110
+ public function getDefaultPaymentProfile() {
111
+ $profiles = $this->getPaymentProfiles();
112
+ foreach ($profiles as $profile) {
113
+ if ($profile->getIsDefault()) {
114
+ return $profile;
115
+ }
116
+ }
117
+ return end($profiles); // no default yet?
118
+ }
119
+
120
+ /**
121
+ * Returns all availale CC types
122
+ * @return type
123
+ */
124
+ public function getCcAvailableTypes() {
125
+ $types = $this->_getConfig()->getCcTypes();
126
+ $additionalCcTypes = Mage::getModel('ipay/system_config_payment_cctype')->getAdditionalCcTypes();
127
+ $types = array_merge($types, $additionalCcTypes);
128
+ if ($method = $this->getMethod()) {
129
+ $availableTypes = $method->getConfigData('cctypes');
130
+ if ($availableTypes) {
131
+ $availableTypes = explode(',', $availableTypes);
132
+ foreach ($types as $code => $name) {
133
+ if (!in_array($code, $availableTypes)) {
134
+ unset($types[$code]);
135
+ }
136
+ }
137
+ }
138
+ }
139
+ return $types;
140
+ }
141
+
142
+ /**
143
+ * Checking wether tokenie is enabbled
144
+ * @return type bool
145
+ */
146
+ public function isPaymentProfileEnabled() {
147
+ return (bool) Mage::getStoreConfig("payment/ipay/tokenize");
148
+ }
149
+
150
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Block_Payment_Info extends Mage_Payment_Block_Info_Cc {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->setTemplate('ipay/payment/info.phtml');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/IpayGateway/Block/Profile.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Profile extends Mage_Core_Block_Abstract {
29
+
30
+ /**
31
+ * @var array
32
+ */
33
+ protected $_params = array();
34
+
35
+ /**
36
+ * Renders the block.
37
+ *
38
+ * @return string
39
+ */
40
+ protected function _toHtml() {
41
+ if ($this->getPaymentProfile() && $this->getType()) {
42
+ switch ($this->getType()) {
43
+ case 'oneline':
44
+ return $this->_getOneline();
45
+ case 'html':
46
+ return $this->_getHtml();
47
+ }
48
+ }
49
+ return '';
50
+ }
51
+
52
+ /**
53
+ * Sets rendering params.
54
+ *
55
+ * Supported params:
56
+ * show_exp_date
57
+ * show_address
58
+ * container_tag
59
+ *
60
+ * @param array $params
61
+ * @return PlanetPayment_IpayGateway_Block_PaymentProfile
62
+ */
63
+ public function setParams(array $params) {
64
+ $this->_params = $params;
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Param getter.
70
+ *
71
+ * @param string $param
72
+ * @return mixed
73
+ */
74
+ public function getParam($param) {
75
+ return isset($this->_params[$param]) ? $this->_params[$param] : false;
76
+ }
77
+
78
+ /**
79
+ * @return string
80
+ */
81
+ protected function _getOneline() {
82
+ $profile = $this->getPaymentProfile();
83
+ $str = Mage::helper('ipay')->__(
84
+ 'Card Type: %s, xxxx-%s, Exp: %s/%s', $profile->getCardTypeName(), $profile->getCardNumberLast4(), $profile->getExpirationMonth(), $profile->getExpirationYear()
85
+ );
86
+ return $str;
87
+ }
88
+
89
+ /**
90
+ * @return string
91
+ */
92
+ protected function _getHtml() {
93
+ $profile = $this->getPaymentProfile();
94
+ $tag = $this->getParam('container_tag') ? $this->getParam('container_tag') : 'address';
95
+
96
+ $str = '<' . $tag . '>';
97
+ if ($profile->getCardType()) {
98
+ $str .= Mage::helper('ipay')->__('Card Type: %s<br />', $profile->getCardTypeName());
99
+ }
100
+ $str .= Mage::helper('ipay')->__('Card Number: XXXX-%s<br />', $profile->getCardNumberLast4());
101
+
102
+ if ($this->getParam('show_exp_date')) {
103
+ $str .= Mage::helper('ipay')->__('Expiration: %s/%s<br />', $profile->getExpirationMonth(), $profile->getExpirationYear());
104
+ }
105
+ if ($this->getParam('ipay')) {
106
+ $address = Mage::getModel('customer/address');
107
+ $profile->exportAddress($address);
108
+ $str .= $address->format('html');
109
+ }
110
+ $str = $str . '</' . $tag . '>';
111
+
112
+ return $str;
113
+ }
114
+
115
+ }
app/code/community/PlanetPayment/IpayGateway/Block/Profile/Edit.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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Profile_Edit extends Mage_Directory_Block_Data {
29
+
30
+ /**
31
+ * The payment profile being edited.
32
+ *
33
+ * @var PlanetPayment_IpayGateway_Model_PaymentProfile
34
+ */
35
+ protected $_paymentProfile = null;
36
+
37
+ /**
38
+ * Returns the payment profile being edited.
39
+ *
40
+ * @return PlanetPayment_IpayGateway_Model_PaymentProfile
41
+ */
42
+ public function getIpayPaymentProfile() {
43
+ return $this->_paymentProfile;
44
+ }
45
+
46
+ /**
47
+ * Retrieve customer session object
48
+ *
49
+ * @return Mage_Customer_Model_Session
50
+ */
51
+ public function getSession() {
52
+ return Mage::getSingleton('customer/session');
53
+ }
54
+
55
+ /**
56
+ * Retrieve customer model
57
+ *
58
+ * @return Mage_Customer_Model_Customer
59
+ */
60
+ public function getCustomer() {
61
+ return $this->getSession()->getCustomer();
62
+ }
63
+
64
+ protected function _prepareLayout() {
65
+ parent::_prepareLayout();
66
+
67
+ $this->_paymentProfile = Mage::getModel('ipay/profile');
68
+ $profileId = $this->getRequest()->getParam('profile_id');
69
+ if ($profileId) {
70
+ $this->_paymentProfile->load($profileId);
71
+ if ($this->_paymentProfile->getIpayProfileId() != $this->getCustomer()->getIpayProfileId()) {
72
+ $this->_paymentProfile->setData(array());
73
+ }
74
+ } else if ($this->getSession()->getProfileFormData()) {
75
+ $this->_paymentProfile->addData($this->getSession()->getProfileFormData(true));
76
+ }
77
+
78
+ $title = $this->_paymentProfile->getId() ? 'Edit Store Credit Card Profile' : 'Add New Store Credit Card Profile';
79
+ $this->setTitle($this->__($title));
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Returns a payment form block to access CC methods.
86
+ *
87
+ * @return PlanetPayment_IpayGateway_Block_Payment_Form
88
+ */
89
+ public function getPaymentBlock() {
90
+ if (!$this->hasPaymentBlock()) {
91
+ $method = Mage::getModel('ipay/ipay')->setIpayPaymentProfile($this->getIpayPaymentProfile());
92
+ $block = $this->getLayout()->createBlock('ipay/payment_form')
93
+ ->setIpayPaymentProfile($this->getIpayPaymentProfile())
94
+ ->setMethod($method);
95
+ $this->setPaymentBlock($block);
96
+ }
97
+ return $this->getData('payment_block');
98
+ }
99
+
100
+ /**
101
+ * @return array
102
+ */
103
+ public function getCcAvailableTypes() {
104
+ return $this->getPaymentBlock()->getCcAvailableTypes();
105
+ }
106
+
107
+ /**
108
+ * @return array
109
+ */
110
+ public function getCcYears() {
111
+ return $this->getPaymentBlock()->getCcYears();
112
+ }
113
+
114
+ /**
115
+ * @return array
116
+ */
117
+ public function getCcMonths() {
118
+ return $this->getPaymentBlock()->getCcMonths();
119
+ }
120
+
121
+ /**
122
+ * @return bool
123
+ */
124
+ public function hasVerification() {
125
+ return $this->getPaymentBlock()->hasVerification();
126
+ }
127
+
128
+ /**
129
+ * @return string
130
+ */
131
+ public function getBackUrl() {
132
+ return $this->getUrl('*/*/index');
133
+ }
134
+
135
+ /**
136
+ * @return string
137
+ */
138
+ public function getPostUrl() {
139
+ return $this->getUrl('*/*/editPost');
140
+ }
141
+
142
+ /**
143
+ * @return string
144
+ */
145
+ public function getSuccessUrl() {
146
+ return $this->getUrl('*/*/index');
147
+ }
148
+
149
+ /**
150
+ * @return string
151
+ */
152
+ public function getErrorUrl() {
153
+ return $this->getUrl('*/*/*');
154
+ }
155
+
156
+ /**
157
+ * Use region codes instead of region IDs.
158
+ *
159
+ * @return string
160
+ */
161
+ public function getRegionsJs() {
162
+ $regionsJs = $this->getData('regions_js');
163
+ if (!$regionsJs) {
164
+ $countryIds = array();
165
+ foreach ($this->getCountryCollection() as $country) {
166
+ $countryIds[] = $country->getCountryId();
167
+ }
168
+ $collection = Mage::getModel('directory/region')->getResourceCollection()
169
+ ->addCountryFilter($countryIds)
170
+ ->load();
171
+ $regions = array();
172
+ foreach ($collection as $region) {
173
+ if (!$region->getRegionId()) {
174
+ continue;
175
+ }
176
+ $regions[$region->getCountryId()][$region->getCode()] = array(
177
+ 'code' => $region->getCode(),
178
+ 'name' => $region->getName()
179
+ );
180
+ }
181
+ $regionsJs = Mage::helper('core')->jsonEncode($regions);
182
+ }
183
+ return $regionsJs;
184
+ }
185
+
186
+ }
app/code/community/PlanetPayment/IpayGateway/Block/Profile/List.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_Block_Profile_List extends Mage_Core_Block_Template {
29
+
30
+ /**
31
+ * Retrieve customer model
32
+ *
33
+ * @return Mage_Customer_Model_Customer
34
+ */
35
+ public function getCustomer() {
36
+ return Mage::getSingleton('customer/session')->getCustomer();
37
+ }
38
+
39
+ /**
40
+ * Returns an array of payment profiles.
41
+ *
42
+ * @return array
43
+ */
44
+ public function getPaymentProfiles() {
45
+ if (!$this->hasData('payment_profiles')) {
46
+ $profilesArray = array();
47
+ $profiles = Mage::getModel('ipay/profile')->getCollection()
48
+ ->addCustomerFilter($this->getCustomer());
49
+ foreach ($profiles as $profile) {
50
+ if ($profile->getIsVisible()) { // don't display on frontend
51
+ $profilesArray[] = $profile;
52
+ }
53
+ }
54
+ }
55
+ $this->setPaymentProfiles($profilesArray);
56
+ return $this->getData('payment_profiles');
57
+ }
58
+
59
+ /**
60
+ * @return string
61
+ */
62
+ public function getDeleteUrl() {
63
+ return $this->getUrl('*/*/delete');
64
+ }
65
+
66
+ /**
67
+ * @return string
68
+ */
69
+ public function getAddUrl() {
70
+ return $this->getUrl('*/*/new');
71
+ }
72
+
73
+ /**
74
+ * @param PlanetPayment_IpayGateway_Model_PaymentProfile $profile
75
+ * @return string
76
+ */
77
+ public function getEditUrl(PlanetPayment_IpayGateway_Model_PaymentProfile $profile) {
78
+ return $this->getUrl('*/*/edit', array('profile_id' => $profile->getId()));
79
+ }
80
+
81
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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->getIpayExchangeRate();
92
+ if ($this->_isPyc() && $exchangeRate) {
93
+ $total = $source->getBaseGrandTotal();
94
+ $currency = Mage::app()->getLocale()->currency($this->getOrder()->getPayment()->getIpayCurrencyCode())->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()->getIpayCurrencyCode())) {
122
+ return true;
123
+ }
124
+ return false;
125
+ }
126
+
127
+ protected function _isPyc() {
128
+ return Mage::getModel('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC;
129
+ }
130
+
131
+ protected function _isMcp() {
132
+ return Mage::getModel('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP;
133
+ }
134
+
135
+ }
app/code/community/PlanetPayment/IpayGateway/Helper/Data.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_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/ipay_logging/mode');
45
+ $method = $this->getConfigData('logging');
46
+ $currencyConvertor = Mage::getStoreConfig('currency/ipay/logging');
47
+ $logModel = Mage::getModel('ipay/log');
48
+ if ($global) {
49
+ if (!$currency && $method) {
50
+ $logModel->setRequest($request)
51
+ ->setResponse($response)
52
+ ->save();
53
+ } else if($currency && $currencyConvertor) {
54
+ $logModel->setRequest($request)
55
+ ->setResponse($response)
56
+ ->save();
57
+ }
58
+ }
59
+
60
+ return $logModel;
61
+ }
62
+
63
+ /**
64
+ * Returns data from the store config.
65
+ *
66
+ * @param string $key
67
+ * @return string
68
+ */
69
+ public function getConfigData($key) {
70
+ $path = 'payment/ipay/' . $key;
71
+ return Mage::getStoreConfig($path);
72
+ }
73
+
74
+ /**
75
+ * Returns the checkout session.
76
+ *
77
+ * @return Mage_Core_Model_Session_Abstract
78
+ */
79
+ public function getCheckout() {
80
+ if (Mage::app()->getStore()->isAdmin()) {
81
+ return Mage::getSingleton('adminhtml/session_quote');
82
+ } else {
83
+ return Mage::getSingleton('checkout/session');
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Returns the quote.
89
+ *
90
+ * @return Mage_Sales_Model_Quote
91
+ */
92
+ public function getQuote() {
93
+ return $this->getCheckout()->getQuote();
94
+ }
95
+
96
+ /**
97
+ * Returns the logged in user.
98
+ *
99
+ * @return Mage_Customer_Model_Customer
100
+ */
101
+ public function getCustomer() {
102
+ return $this->getQuote()->getCustomer();
103
+ }
104
+
105
+ /**
106
+ * Returns true if it's guest checkout.
107
+ *
108
+ * @return bool
109
+ */
110
+ public function isGuestCheckout() {
111
+ if (Mage::app()->getStore()->isAdmin()) {
112
+ return!$this->getCheckout()->getCustomerId();
113
+ } else {
114
+ return $this->getQuote()->getCheckoutMethod() == Mage_Checkout_Model_Type_Onepage::METHOD_GUEST;
115
+ }
116
+ }
117
+
118
+ /**
119
+ * Is the payment method enabled?
120
+ *
121
+ * @return bool
122
+ */
123
+ public function isEnabled() {
124
+ return (bool) $this->getConfigData('active');
125
+ }
126
+
127
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ class PlanetPayment_IpayGateway_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/IpayGateway/Model/Currency/Import/Ipay.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Currency_Import_Ipay extends Mage_Directory_Model_Currency_Import_Abstract {
30
+
31
+ protected $_messages = array();
32
+ protected $_rates = array();
33
+
34
+ public function __construct() {
35
+ $request = $this->_getRequestModel()
36
+ ->generateCurrencyRateLookUpRequest()
37
+ ->send();
38
+ if ($request->getResponse()->isSuccess()) {
39
+ $this->_rates = $this->_formatConvertionXml($request->getResponse());
40
+ } else {
41
+ Mage::throwException("Communication Error! Please try later");
42
+ }
43
+ }
44
+
45
+ protected function _convert($currencyFrom, $currencyTo, $retry=0) {
46
+ if (count($this->_rates)) {
47
+ try {
48
+ $nativeCurrency = $this->_getRequestModel()->getNativeCurrency();
49
+ if ($currencyFrom != $nativeCurrency) {
50
+ $this->_messages[] = Mage::helper('ipay')->__('Ipay Native currency is different from store base currency');
51
+ } else if (isset($this->_rates[$currencyTo])){
52
+ return $this->_rates[$currencyTo];
53
+ } else {
54
+ $this->_messages[] = Mage::helper('ipay')->__("Unable to retrieve the conversion rate from %s to %s",$currencyFrom, $currencyTo);
55
+ }
56
+ } catch (Exception $e) {
57
+ if ($retry == 0) {
58
+ $this->_convert($currencyFrom, $currencyTo, 1);
59
+ } else {
60
+ $this->_messages[] = Mage::helper('ipay')->__('Cannot retrieve rate from Ipay');
61
+ }
62
+ }
63
+ } else {
64
+ $this->_messages[] = Mage::helper('ipay')->__("Unable to retrieve the conversion rate from %s to %s",$currencyFrom, $currencyTo);
65
+ }
66
+ }
67
+
68
+ protected function _formatConvertionXml($response) {
69
+ $responsexml = $response->getXmlContent();
70
+ $currencyRates = array();
71
+ if ($responsexml) {
72
+ $rates = $responsexml->FIELDS->RATES;
73
+ foreach ($rates->RATE as $rate) {
74
+ $attributes = $rate->CURRENCY_CODE->Attributes();
75
+ $currencyRates[(string) $attributes['ALPHA']] = 1 / (float) $rate->EXCHANGE_RATE;
76
+ }
77
+ }
78
+ return $currencyRates;
79
+ }
80
+
81
+ protected function _getRequestModel() {
82
+ return Mage::getSingleton('ipay/xml_request');
83
+ }
84
+
85
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_CurrencyCode extends Mage_Core_Model_Abstract {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->_init('ipay/currencyCode');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/IpayGateway/Model/Ipay.php ADDED
@@ -0,0 +1,445 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Ipay extends Mage_Payment_Model_Method_Cc {
30
+ const GATEWAY_URL_PRODUCTION = 'https://prd.txngw.com';
31
+ const GATEWAY_URL_TESTING = 'https://uap.txngw.com';
32
+ const PAYMENT_ACTION_AUTHORIZE = "authorize";
33
+ const PAYMENT_ACTION_AUTHORIZE_CAPTURE = "authorize_capture";
34
+ const PAYMENT_SERVICE_PYC = "pyc";
35
+ const PAYMENT_SERVICE_MCP = "mcp";
36
+ const PAYMENT_SERVICE_NORMAL = "normal";
37
+
38
+ const VALIDATE_EXISTING = 1;
39
+ const VALIDATE_NEW = 2;
40
+ const METHOD_CODE = 'ipay';
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 = 'ipay_log.txt';
47
+
48
+ protected $_code = self::METHOD_CODE;
49
+ protected $_formBlockType = 'ipay/payment_form';
50
+ protected $_formBlockTypeAdmin = 'ipay/adminhtml_payment_form';
51
+ protected $_infoBlockType = 'ipay/payment_info';
52
+ protected $_isGateway = true;
53
+ protected $_canAuthorize = true;
54
+ protected $_canCapture = true;
55
+ protected $_canCapturePartial = false;
56
+ protected $_canRefund = true;
57
+ protected $_canRefundInvoicePartial = true;
58
+ protected $_canVoid = true;
59
+ protected $_canUseInternal = true; // enables admin use
60
+ protected $_canUseCheckout = true; // enables frontend use
61
+ protected $_canUseForMultishipping = true;
62
+ protected $_canSaveCc = true;
63
+
64
+ /**
65
+ * Assigning data
66
+ * @param type $data
67
+ * @return PlanetPayment_IpayGateway_Model_Ipay
68
+ */
69
+ public function assignData($data) {
70
+ if (!($data instanceof Varien_Object)) {
71
+ $data = new Varien_Object($data);
72
+ }
73
+ if ($data->getIpayProfileId()) { // use existing profile
74
+ $paymentProfile = Mage::getModel('ipay/profile')
75
+ ->load($data->getIpayProfileId())
76
+ ->exportPayment($this->getInfoInstance());
77
+ $this->setValidationMode(self::VALIDATE_EXISTING);
78
+ } else { // new profile
79
+ parent::assignData($data);
80
+ $this->getInfoInstance()
81
+ ->setIpayProfileId(null)
82
+ ->setIsVisible($data->getIsVisible());
83
+ $this->setValidationMode(self::VALIDATE_NEW);
84
+ }
85
+ return $this;
86
+ }
87
+
88
+ /**
89
+ * Capture previously athorized payment
90
+ * @param Varien_Object $payment
91
+ * @param type $amount
92
+ */
93
+ public function capture(Varien_Object $payment, $amount) {
94
+ try {
95
+ if(!$payment->getTransactionId() && $this->getConfigData('payment_action')== self::PAYMENT_ACTION_AUTHORIZE_CAPTURE)
96
+ {
97
+ return $this->sale($payment , $amount);
98
+ }
99
+ $payment->setAmount($amount);
100
+ $request = $this->_getRequest();
101
+ $request->setPayment($payment)
102
+ ->setAmount($amount)
103
+ ->setAmountInStoreCurrency(round($payment->getOrder()->getGrandTotal(), 2));
104
+
105
+ $request->generateRequestForCapture();
106
+ $request->send();
107
+
108
+ $response = $request->getResponse();
109
+
110
+ if ($response->isSuccess()) {
111
+ $result = $response->getXmlContent();
112
+ $payment->setStatus(self::STATUS_APPROVED);
113
+ //$payment->setCcTransId($result->getTransactionId());
114
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
115
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
116
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
117
+ }
118
+ } else {
119
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
120
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try again later or contact us"));
121
+ }
122
+ } catch (Exception $e) {
123
+ Mage::throwException(Mage::helper('ipay')->__($e->getMessage()));
124
+ }
125
+ }
126
+
127
+ /**
128
+ * Authorize and Capture
129
+ * @param Varien_Object $payment
130
+ * @param type $amount
131
+ */
132
+ public function sale(Varien_Object $payment, $amount) {
133
+ try {
134
+ $payment->setAmount($amount);
135
+ $request = $this->_getRequest();
136
+ $request->setPayment($payment)
137
+ ->setAmount($amount)
138
+ ->setAmountInStoreCurrency(round($payment->getOrder()->getGrandTotal(), 2));
139
+
140
+ $request->generateRequestForSale();
141
+ $request->send();
142
+
143
+ $response = $request->getResponse();
144
+
145
+ if ($response->isSuccess()) {
146
+ $result = $response->getXmlContent();
147
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1/$result->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('ipay')->getQuote()->getBaseToQuoteRate();
148
+ $payment->setStatus(self::STATUS_APPROVED);
149
+ $payment->setIpayExchangeRate($exchangeRate);
150
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
151
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
152
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
153
+ }
154
+ } else {
155
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
156
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try again later or contact us"));
157
+ }
158
+ } catch (Exception $e) {
159
+ Mage::throwException(Mage::helper('ipay')->__($e->getMessage()));
160
+ }
161
+ }
162
+
163
+ /**
164
+ * Authorizing payment
165
+ * @param Varien_Object $payment
166
+ * @param type $amount
167
+ * @return PlanetPayment_IpayGateway_Model_Ipay
168
+ */
169
+ public function authorize(Varien_Object $payment, $amount) {
170
+ if ($amount <= 0) {
171
+ Mage::throwException(Mage::helper('ipay')->__('Invalid amount for authorization.'));
172
+ }
173
+
174
+ $payment->setAmount($amount);
175
+ $request = $this->_getRequest();
176
+ $request->setTransactionType(self::PAYMENT_ACTION_AUTHORIZE)
177
+ ->setPayment($payment)
178
+ ->setAmount($amount);
179
+ $paymentType = $this->getPaymentType();
180
+ if ($paymentType == self::PAYMENT_SERVICE_PYC) {
181
+ $request->generateRequestForPycAuth();
182
+ } else if ($paymentType == self::PAYMENT_SERVICE_MCP) {
183
+ $request->setAmountInStoreCurrency(round(Mage::helper('ipay')->getQuote()->getGrandTotal(), 2));
184
+ $request->generateRequestForMcpAuth();
185
+ } else {
186
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try agin later."));
187
+ }
188
+ $request->send();
189
+
190
+ $response = $request->getResponse();
191
+
192
+ if ($response->isSuccess()) {
193
+ $result = $response->getXmlContent();
194
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1/$result->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('ipay')->getQuote()->getBaseToQuoteRate();
195
+ $payment->setCcApproval($result->FIELDS->APPROVAL_CODE)
196
+ ->setLastTransId($result->FIELDS->TRANSACTION_ID)
197
+ ->setTransactionId($result->FIELDS->TRANSACTION_ID)
198
+ ->setIpayExchangeRate($exchangeRate)
199
+ ->setIsTransactionClosed(0)
200
+ ->setCcTransId($result->FIELDS->P3DS_TRANSACTION_ID)
201
+ ->setStatus(self::STATUS_APPROVED);
202
+ } else {
203
+ //The last added log will be rolled back if error occured. So if any
204
+ //exception occured, the xmls will be logged in var/log/ipay_log.txt
205
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
206
+ Mage::throwException(Mage::helper('ipay')->__('Payment authorization error.'));
207
+ }
208
+
209
+ return $this;
210
+ }
211
+
212
+ /**
213
+ * Void the payment through gateway
214
+ *
215
+ * @param Varien_Object $payment
216
+ * @return PlanetPayment_IpayGateway_Model_Ipay
217
+ */
218
+ public function void(Varien_Object $payment) {
219
+ /* @var $payment Mage_Sales_Model_Order_Payment */
220
+ if ($payment->getParentTransactionId()) {
221
+ $request = $this->_getRequest();
222
+ $request->setPayment($payment);
223
+
224
+ $request->generateRequestForVoid()
225
+ ->send();
226
+
227
+ $response = $request->getResponse();
228
+
229
+ if ($response->isSuccess()) {
230
+ $payment->setStatus(self::STATUS_SUCCESS);
231
+ return $this;
232
+ } else {
233
+ $payment->setStatus(self::STATUS_ERROR);
234
+ Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
235
+ }
236
+ } else {
237
+ $payment->setStatus(self::STATUS_ERROR);
238
+ Mage::throwException(Mage::helper('ipay')->__('Invalid transaction id'));
239
+ }
240
+ }
241
+
242
+ /**
243
+ * Refund the amount with transaction id
244
+ *
245
+ * @param Varien_Object $payment
246
+ * @param decimal $amount
247
+ * @return PlanetPayment_IpayGateway_Model_Ipay
248
+ */
249
+ public function refund(Varien_Object $payment, $amount) {
250
+ /* @var $payment Mage_Sales_Model_Order_Payment */
251
+ if ($payment->getRefundTransactionId() && $amount > 0) {
252
+ if($amount == $payment->getBaseAmountPaid()) {
253
+ //avoid a rounding error
254
+ $amountConverted = round($payment->getAmountPaid(), 2);
255
+ } else {
256
+ //calculate the amount based on the payment exchange rate
257
+ $amountConverted = round($amount * $payment->getIpayExchangeRate(), 2);
258
+ }
259
+ /*
260
+ if($amountConverted > $payment->getAmountPaid()) {
261
+ Mage::throwException(Mage::helper('ipay')->__('Unable to refund for more than the capture amount.'));
262
+ }
263
+ */
264
+ //Mage::throwException("Refund Amount:".$amountConverted);
265
+ $request = $this->_getRequest();
266
+ $request->setPayment($payment)
267
+ ->setAmount($amount)
268
+ ->setAmountInStoreCurrency($amountConverted);
269
+
270
+ $request->generateRequestForRefund()
271
+ ->send();
272
+
273
+ $response = $request->getResponse();
274
+
275
+ if ($response->isSuccess()) {
276
+ $payment->setStatus(self::STATUS_SUCCESS);
277
+ return $this;
278
+ } else {
279
+ $payment->setStatus(self::STATUS_ERROR);
280
+ Mage::throwException(Mage::helper('ipay')->__('Error in refunding the payment. Message:'.$response->getMessage()));
281
+ }
282
+ }
283
+ Mage::throwException(Mage::helper('ipay')->__('Error in refunding the payment'));
284
+ }
285
+
286
+ /**
287
+ * Identifying the payment type PYC or MCP
288
+ * @return type
289
+ */
290
+ public function getPaymentType() {
291
+ $typeConfig = $this->getConfigData("service");
292
+ $nativeCurrency = $this->getConfigData("currency");
293
+ $quoteCurrency = Mage::helper('ipay')->getQuote()->getQuoteCurrencyCode();
294
+ $acceptedCurrencies = explode(",", $this->getConfigData("accepted_currencies"));
295
+
296
+ if ($typeConfig == self::PAYMENT_SERVICE_PYC) {
297
+ if ($quoteCurrency == $nativeCurrency) {
298
+ return self::PAYMENT_SERVICE_PYC;
299
+ }
300
+ } else if (in_array($quoteCurrency, $acceptedCurrencies)) {
301
+ return self::PAYMENT_SERVICE_MCP;
302
+ }
303
+
304
+ return self::PAYMENT_SERVICE_NORMAL;
305
+ }
306
+
307
+ /**
308
+ * Retrieve block type for method form generation
309
+ *
310
+ * @return string
311
+ */
312
+ public function getFormBlockType() {
313
+ if (Mage::app()->getStore()->isAdmin()) {
314
+ return $this->_formBlockTypeAdmin;
315
+ } else {
316
+ return $this->_formBlockType;
317
+ }
318
+ }
319
+
320
+ /**
321
+ * returns the Xml request object
322
+ * @return object PlanetPayment_IpayGateway_Model_Xml_Request
323
+ */
324
+ protected function _getRequest() {
325
+ return Mage::getmodel('ipay/xml_request');
326
+ }
327
+
328
+ /**
329
+ * Returns checkout session
330
+ * @return type
331
+ */
332
+ protected function _getSession() {
333
+ return Mage::getSingleton('checkout/session');
334
+ }
335
+
336
+ /**
337
+ * Validate payment method information object
338
+ *
339
+ * @param Mage_Payment_Model_Info $info
340
+ * @return Mage_Payment_Model_Abstract
341
+ */
342
+ public function validate() {
343
+ /*
344
+ * calling parent validate function
345
+ */
346
+ if ($this->getValidationMode() == self::VALIDATE_NEW) {
347
+
348
+ $info = $this->getInfoInstance();
349
+ $errorMsg = false;
350
+ $availableTypes = explode(',', $this->getConfigData('cctypes'));
351
+
352
+ $ccNumber = $info->getCcNumber();
353
+
354
+ // remove credit card number delimiters such as "-" and space
355
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
356
+ $info->setCcNumber($ccNumber);
357
+
358
+ $ccType = '';
359
+
360
+ if (in_array($info->getCcType(), $availableTypes)) {
361
+ if ($this->validateCcNum($ccNumber)
362
+ // Other credit card type number validation
363
+ || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
364
+
365
+ $ccType = 'OT';
366
+ $ccTypeRegExpList = array(
367
+ //Solo, Switch or Maestro. International safe
368
+ //'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/', // Maestro / Solo
369
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/', // Solo only
370
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
371
+ 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', // Visa
372
+ 'MC' => '/^5[1-5][0-9]{14}$/', // Master Card
373
+ 'AE' => '/^3[47][0-9]{13}$/', // American Express
374
+ 'DI' => '/^6011[0-9]{12}$/', // Discovery
375
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', // JCB
376
+ 'DIN' => '/^(300[0-9]{11}|305[0-9]{11}|36[0-9]{12}|38[0-9]{12})$/', //DINERS
377
+ );
378
+
379
+ foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp) {
380
+ if (preg_match($ccTypeRegExp, $ccNumber)) {
381
+ $ccType = $ccTypeMatch;
382
+ break;
383
+ }
384
+ }
385
+
386
+ if (!$this->OtherCcType($info->getCcType()) && $ccType != $info->getCcType()) {
387
+ $errorCode = 'ccsave_cc_type,ccsave_cc_number';
388
+ $errorMsg = $this->_getHelper()->__('Credit card number mismatch with credit card type.');
389
+ }
390
+ } else {
391
+ $errorCode = 'ccsave_cc_number';
392
+ $errorMsg = $this->_getHelper()->__('Invalid Credit Card Number');
393
+ }
394
+ } else {
395
+ $errorCode = 'ccsave_cc_type';
396
+ $errorMsg = $this->_getHelper()->__('Credit card type is not allowed for this payment method.');
397
+ }
398
+
399
+ //validate credit card verification number
400
+ if ($errorMsg === false && $this->hasVerification()) {
401
+ $verifcationRegEx = $this->getVerificationRegEx();
402
+ $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
403
+ if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) {
404
+ $errorMsg = $this->_getHelper()->__('Please enter a valid credit card verification number.');
405
+ }
406
+ }
407
+
408
+ if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
409
+ $errorCode = 'ccsave_expiration,ccsave_expiration_yr';
410
+ $errorMsg = $this->_getHelper()->__('Incorrect credit card expiration date.');
411
+ }
412
+
413
+ if ($errorMsg) {
414
+ Mage::throwException($errorMsg);
415
+ //throw Mage::exception('Mage_Payment', $errorMsg, $errorCode);
416
+ }
417
+
418
+ //This must be after all validation conditions
419
+ if ($this->getIsCentinelValidationEnabled()) {
420
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
421
+ }
422
+ } else {
423
+ Mage_Payment_Model_Method_Abstract::validate();
424
+ }
425
+
426
+ return $this;
427
+ }
428
+
429
+ public function getVerificationRegEx() {
430
+ $verificationExpList = array(
431
+ 'VI' => '/^[0-9]{3}$/', // Visa
432
+ 'MC' => '/^[0-9]{3}$/', // Master Card
433
+ 'AE' => '/^[0-9]{4}$/', // American Express
434
+ 'DI' => '/^[0-9]{3}$/', // Discovery
435
+ 'SS' => '/^[0-9]{3,4}$/',
436
+ 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
437
+ 'SO' => '/^[0-9]{3,4}$/', // Solo
438
+ 'OT' => '/^[0-9]{3,4}$/',
439
+ 'JCB' => '/^[0-9]{4}$/', //JCB
440
+ 'DIN' => '/^[0-9]{3}$/', //DINERS
441
+ );
442
+ return $verificationExpList;
443
+ }
444
+
445
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Log extends Mage_Core_Model_Abstract {
30
+
31
+ protected function _construct() {
32
+ parent::_construct();
33
+ $this->_init('ipay/log');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ abstract class PlanetPayment_IpayGateway_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('ipay')->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/IpayGateway/Model/Observer/Checkout.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Observer_Checkout extends PlanetPayment_IpayGateway_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
+ if (!$this->isEnabled()) {
39
+ return;
40
+ }
41
+ $order = $observer->getOrder();
42
+ /* @var $order Mage_Sales_Model_Order */
43
+ $payment = $order->getPayment();
44
+ if ($payment->getMethodInstance()->getCode() == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
45
+ if ($payment->getIsVisible() && !$order->getHasCcSaved()) {
46
+ /* @var $profile PlanetPayment_IpayGateway_Model_PaymentProfile */
47
+ $profile = Mage::getModel('ipay/profile');
48
+ Mage::helper('core')->copyFieldset('ipay_paymentprofile_savecc_payment', 'to_paymentprofile', $payment, $profile);
49
+ $customer = Mage::getModel('customer/customer')->load($order->getCustomerId());
50
+ if ($customer->getId()) {
51
+ $billingAddress = $customer->getDefaultBillingAddress();
52
+ Mage::helper('core')->copyFieldset('ipay_paymentprofile_savecc_address', 'to_paymentprofile', $billingAddress, $profile);
53
+ $streetAddress = $profile->getStreetAddress();
54
+ $address = '';
55
+ if ($streetAddress) {
56
+ if (is_array($streetAddress)) {
57
+ foreach ($streetAddress as $addressLine) {
58
+ $address .= ' ' . $addressLine;
59
+ }
60
+ }
61
+ }
62
+ $profile->setAddress($address);
63
+
64
+ $requestModel = Mage::getModel('ipay/xml_request')->setIpayPaymentProfile($profile)
65
+ ->setCustomer($customer);
66
+
67
+ $request = $requestModel->generateNewWalletProfileRequest()
68
+ ->send();
69
+
70
+ $response = $request->getResponse()
71
+ ->setPaymentProfile();
72
+
73
+ if ($response->isSuccess()) {
74
+ $profile = $response->getIpayPaymentProfile();
75
+ $profile->setIsVisible(true)
76
+ ->setCustomerId($customer->getId())
77
+ ->setCardNumberLast4($profile->getCardNumberLast4())
78
+ ->save();
79
+ $order->setHasCcSaved(true);
80
+ }
81
+ }
82
+ }
83
+ }
84
+ return;
85
+ }
86
+
87
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Observer_Log extends PlanetPayment_IpayGateway_Model_Observer_Abstract {
30
+
31
+ public function cleanLog() {
32
+ $logCleanConfig = Mage::getStoreConfig('planet_payment/ipay_logging/lifetime');
33
+
34
+ $daysBefore = strtotime("-$logCleanConfig days", time());
35
+ $formated = date('Y-m-d H:i:s', $daysBefore);
36
+ $logs = Mage::getModel('ipay/log')->getCollection()->addFieldToFilter('create_date', array('lt' => $formated));
37
+
38
+ if (count($logs)) {
39
+ foreach ($logs as $log) {
40
+ Mage::getModel('ipay/log')->load($log->getId())->delete();
41
+ }
42
+ }
43
+ return $this;
44
+ }
45
+
46
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Profile extends Mage_Core_Model_Abstract {
30
+
31
+ protected $_backupData = array();
32
+
33
+ protected function _construct() {
34
+ parent::_construct();
35
+ $this->_init('ipay/profile');
36
+ }
37
+
38
+ /**
39
+ * Loads the payment profile by payment profile id
40
+ * @param string $paymentProfileId
41
+ * @return PlanetPayment_IpayGateway_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_IpayGateway_Model_Profile
52
+ */
53
+ public function exportPayment(Varien_Object $payment) {
54
+ Mage::helper('core')->copyFieldset('ipay_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_IpayGateway_Model_Profile
64
+ */
65
+ public function exportAddress(Varien_Object $address) {
66
+ Mage::helper('core')->copyFieldset('ipay_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('ipay/profile');
78
+ /* @var $renderer PlanetPayment_IpayGateway_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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_CurrencyCode extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('ipay/currencyCodes', 'currency');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_CurrencyCode_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('ipay/currency');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_Log extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('ipay/log', 'id');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_Log_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('ipay/log');
34
+ }
35
+
36
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_Profile extends Mage_Core_Model_Resource_Db_Abstract {
30
+
31
+ public function _construct() {
32
+ $this->_init('ipay/paymentProfile', 'id');
33
+ }
34
+
35
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Resource_Profile_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract {
30
+
31
+ public function _construct() {
32
+ parent::_construct();
33
+ $this->_init('ipay/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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_System_Config_Payment_PaymentAction {
30
+
31
+ public function toOptionArray() {
32
+ return array(
33
+ array(
34
+ 'value' => PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_ACTION_AUTHORIZE,
35
+ 'label' => Mage::helper('ipay')->__('Authorize Only')
36
+ ),
37
+ array(
38
+ 'value' => PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_ACTION_AUTHORIZE_CAPTURE,
39
+ 'label' => Mage::helper('ipay')->__('Authorize and Capture')
40
+ )
41
+ );
42
+ }
43
+
44
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_System_Config_Payment_Service {
30
+
31
+ public function toOptionArray($isMultiSelect) {
32
+ return array(
33
+ array(
34
+ 'value' => PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC,
35
+ 'label' => Mage::helper('ipay')->__('PYC')
36
+ ),
37
+ array(
38
+ 'value' => PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP,
39
+ 'label' => Mage::helper('ipay')->__('MCP')
40
+ )
41
+ );
42
+ }
43
+ }
app/code/community/PlanetPayment/IpayGateway/Model/Type/Onepage.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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
+ if (Mage::helper('ipay')->isEnabled()) {
44
+ $checkout->setStepData('currency_selector', 'allow', true);
45
+ }
46
+
47
+
48
+ /*
49
+ * want to laod the correct customer information by assiging to address
50
+ * instead of just loading from sales/quote_address
51
+ */
52
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
53
+ if ($customer) {
54
+ $this->getQuote()->assignCustomer($customer);
55
+ }
56
+ if ($this->getQuote()->getIsMultiShipping()) {
57
+ $this->getQuote()->setIsMultiShipping(false);
58
+ $this->getQuote()->save();
59
+ }
60
+ return $this;
61
+ }
62
+
63
+ }
app/code/community/PlanetPayment/IpayGateway/Model/Xml/Abstract.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Xml_Abstract extends Mage_Core_Model_Abstract {
30
+
31
+ protected $_generalConfigPath = "planet_payment/ipay_general/";
32
+ protected $_paymentConfigPath = "payment/ipay/";
33
+ protected $_testKey = "123451234512345115432154321543214512345112345123";
34
+
35
+ const CONFIG_KEY = 'Magento';
36
+ const APP_NAME = 'PP_IpayGateway';
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);
50
+ }
51
+
52
+ public function getNativeCurrency() {
53
+ return $this->_getConfig('currency');
54
+ }
55
+
56
+ protected function _getCurrencyIsoCode($currency) {
57
+ $currencyCodeObject = Mage::getModel('ipay/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('ipay/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', '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', 'general') == 'production';
90
+ }
91
+
92
+ protected function _hasEncryption() {
93
+ return (bool) $this->_getConfig('encryption', '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', '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', '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 _getProfile($id, $field = null) {
125
+ return Mage::getModel('ipay/profile')->load($id, $field);
126
+ }
127
+
128
+ protected function _getPaymentType($payment) {
129
+ if ($payment) {
130
+ $typeConfig = $this->_getConfig("service");
131
+ $nativeCurrency = $this->_getConfig("currency");
132
+ $orderCurrency = $payment->getOrder()->getOrderCurrencyCode();
133
+ $acceptedCurrencies = explode(",", $this->_getConfig("accepted_currencies"));
134
+ if ($typeConfig == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
135
+ if ($orderCurrency == $nativeCurrency) {
136
+ return PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC;
137
+ }
138
+ } else if (in_array($orderCurrency, $acceptedCurrencies)) {
139
+ return PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP;
140
+ }
141
+
142
+ return PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_NORMAL;
143
+ }
144
+ }
145
+
146
+ /**
147
+ * Generates client name to pass with communications
148
+ *
149
+ * Parts:
150
+ * - MyERP: the ERP that this connector is for (not always applicable)
151
+ * - Majver: version info for the ERP (not always applicable)
152
+ * - MinVer: version info for the ERP (not always applicable)
153
+ * - MyConnector: Name of the OEM's connector AND the name of the OEM (company) *required*
154
+ * - Majver: OEM's connector version *required*
155
+ * - MinVer: OEM's connector version *required*
156
+ *
157
+ * @example Magento,1.4,.0.1,IPay by Planet Payment,2,0.1
158
+ * @return string
159
+ */
160
+ protected function _getClientName() {
161
+ //return "TEST STRING";
162
+ $mageVersion = Mage::getVersion();
163
+ $mageVerParts = explode('.', $mageVersion, 2);
164
+
165
+ $opVersion = Mage::getResourceModel('core/resource')->getDbVersion('ipay_setup');
166
+ $opVerParts = explode('.', $opVersion, 2);
167
+
168
+ $part = array();
169
+ $part[] = self::CONFIG_KEY;
170
+ $part[] = $mageVerParts[0];
171
+ $part[] = $mageVerParts[1];
172
+ $part[] = self::APP_NAME;
173
+ $part[] = $opVerParts[0];
174
+ $part[] = $opVerParts[1];
175
+ return implode(',', $part);
176
+ }
177
+
178
+ }
app/code/community/PlanetPayment/IpayGateway/Model/Xml/Request.php ADDED
@@ -0,0 +1,825 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Xml_Request extends PlanetPayment_IpayGateway_Model_Xml_Abstract {
30
+
31
+ /**
32
+ * Returns CC Expiration date in Palnet Payment's Format
33
+ */
34
+ protected function _getCcExpiration($month, $year) {
35
+ if (strlen($month) == 1) {
36
+ $month = '0' . $month;
37
+ }
38
+
39
+ return (string) $month . substr($year, -2);
40
+ }
41
+
42
+ /**
43
+ * Returns the response model object
44
+ * @return object PlanetPayment_IpayGateway_Model_Xml_Response
45
+ */
46
+ protected function _getResponseModel() {
47
+ return Mage::getModel('ipay/xml_response');
48
+ }
49
+
50
+ /**
51
+ * Returns the root node. Two options here, either get a simple xml root node
52
+ * as a varien_simplexml object or get the complete encrypted request wrapped in
53
+ * root node.
54
+ * @param bool $afterEncrypt
55
+ * @param string $encryptedXml
56
+ * @return Varien_Simplexml_Element
57
+ */
58
+ protected function _getRootNode($afterEncrypt = false, $encryptedXml = false) {
59
+ $hasEncryption = $this->_hasEncryption();
60
+
61
+ $key = $this->_getConfig('key', 'general');
62
+ $encryption = $hasEncryption ? '1' : '0';
63
+
64
+ if ($afterEncrypt) {
65
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1">' . $encryptedXml . '</REQUEST>';
66
+ } else {
67
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1"/>';
68
+ }
69
+ return new Varien_Simplexml_Element($rootNodeString);
70
+ }
71
+
72
+ /**
73
+ * Condition the address text passed in to be limited to 30 characters
74
+ *
75
+ * @param type $address
76
+ */
77
+ protected function _conditionAddress($text) {
78
+ if(!$text || $text=="" || strlen($text) <= 30) {
79
+ return $text;
80
+ }
81
+
82
+ /**
83
+ * Two instances of calls in this file used to call htmlentities on the
84
+ * value, which I don't think we actually want. HTML Encoding will only
85
+ * make the values longer...
86
+ */
87
+ //htmlentities($profile->getAddress(), ENT_QUOTES);
88
+ return substr($text, 0, 30);
89
+ }
90
+
91
+ /**
92
+ * If postal code is longer than 9 characters, strip to the first five. This
93
+ * handles U.S. formatted postal codes inserted with a hyphen (i.e. 12345-6789)
94
+ *
95
+ * In that case, 12345 will be returned. Any text shorter than 9 characters
96
+ * passed to this function will be returned unchanged.
97
+ * @param type $text
98
+ * @return type
99
+ */
100
+ protected function _conditionPostalCode($text) {
101
+ if(!$text || $text=="" || strlen($text) <= 9) {
102
+ return $text;
103
+ }
104
+
105
+ return substr($text, 0, 5);
106
+ }
107
+
108
+ /**
109
+ * Generates the Transaction Xml for authorization
110
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
111
+ */
112
+ public function generateRequestForPycAuth() {
113
+ try {
114
+ $payment = $this->getPayment();
115
+
116
+ $profile = $this->_getProfile($payment->getIpayProfileId());
117
+ $quote = Mage::helper('ipay')->getQuote();
118
+
119
+ $billingAddress = $quote->getBillingAddress();
120
+
121
+ $hasEncryption = $this->_hasEncryption();
122
+
123
+ $key = $this->_getConfig('key', 'general');
124
+ $encryption = $hasEncryption ? '1' : '0';
125
+
126
+ $request = $this->_getRootNode();
127
+ $transaction = $request->addChild('TRANSACTION');
128
+ $fields = $transaction->addChild('FIELDS');
129
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
130
+ $fields->addChild('SERVICE', 'CC');
131
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
132
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
133
+ $fields->addChild('SERVICE_FORMAT', '1010');
134
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
135
+ //If a profile selected by customer
136
+ if ($profile->getAccountId()) {
137
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
138
+ } else {
139
+ $fields->addChild('ACCOUNT_NUMBER', $payment->getCcNumber());
140
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($payment->getCcExpMonth(), $payment->getCcExpYear()));
141
+ $fields->addChild('CVV', $payment->getCcCid());
142
+ $fields->addChild('FIRST_NAME', $billingAddress->getFirstname());
143
+ $fields->addChild('LAST_NAME', $billingAddress->getLastname());
144
+ $fields->addChild('ADDRESS', $this->_conditionAddress($billingAddress->getStreet(1)));
145
+ $fields->addChild('STATE', $billingAddress->getRegionCode());
146
+ $fields->addChild('CITY', $billingAddress->getCity());
147
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($billingAddress->getPostcode()));
148
+ }
149
+
150
+ $fields->addChild('AMOUNT', $this->getAmount());
151
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
152
+ //If a different currecy is selected by the customer
153
+ if ($payment->getId() && $payment->getIpayCurrencyCode()) {
154
+ if ($payment->getIpayCurrencyCode() == $this->getNativeCurrency()) {
155
+ $fields->addChild('CURRENCY_INDICATOR', '0');
156
+ } else {
157
+ $fields->addChild('CURRENCY_INDICATOR', '2');
158
+ }
159
+ } else {
160
+ $fields->addChild('CURRENCY_INDICATOR', '0');
161
+ }
162
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
163
+ $fields->addChild('FESP_IND', '9');
164
+ $fields->addChild('USER_DATA_0', $this->_getClientName());
165
+
166
+ $this->setTransactionForLog($request);
167
+
168
+
169
+ if ($hasEncryption) {
170
+ $this->_encryptRequest($request);
171
+ }
172
+ $this->setTransaction($request);
173
+ } catch (Exception $e) {
174
+ Mage::throwException($e->getmessage());
175
+ }
176
+
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * Generates the Transaction Xml for authorization
182
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
183
+ */
184
+ public function generateRequestForMcpAuth() {
185
+ try {
186
+ $payment = $this->getPayment();
187
+
188
+ $profile = $this->_getProfile($payment->getIpayProfileId());
189
+ $quote = Mage::helper('ipay')->getQuote();
190
+ $quoteCurrency = $quote->getQuoteCurrencyCode();
191
+ $billingAddress = $quote->getBillingAddress();
192
+ $hasEncryption = $this->_hasEncryption();
193
+
194
+ $key = $this->_getConfig('key', 'general');
195
+ $encryption = $hasEncryption ? '1' : '0';
196
+
197
+ $request = $this->_getRootNode();
198
+ $transaction = $request->addChild('TRANSACTION');
199
+ $fields = $transaction->addChild('FIELDS');
200
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
201
+ $fields->addChild('SERVICE', 'CC');
202
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
203
+ $fields->addChild('SERVICE_SUBTYPE', 'AUTH');
204
+ $fields->addChild('SERVICE_FORMAT', '1010');
205
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
206
+ //If a profile selected by customer
207
+ if ($profile->getAccountId()) {
208
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
209
+ } else {
210
+ $fields->addChild('ACCOUNT_NUMBER', $payment->getCcNumber());
211
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($payment->getCcExpMonth(), $payment->getCcExpYear()));
212
+ $fields->addChild('CVV', $payment->getCcCid());
213
+ $fields->addChild('FIRST_NAME', $billingAddress->getFirstname());
214
+ $fields->addChild('LAST_NAME', $billingAddress->getLastname());
215
+ $fields->addChild('ADDRESS', $this->_conditionAddress($billingAddress->getStreet(1)));
216
+ $fields->addChild('STATE', $billingAddress->getRegionCode());
217
+ $fields->addChild('CITY', $billingAddress->getCity());
218
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($billingAddress->getPostcode()));
219
+ }
220
+
221
+ $fields->addChild('AMOUNT', $this->getAmountInStoreCurrency());
222
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($quoteCurrency));
223
+ if ($quoteCurrency != $this->getNativeCurrency()) {
224
+ $fields->addChild('CURRENCY_INDICATOR', '1');
225
+ } else {
226
+ $fields->addChild('CURRENCY_INDICATOR', '0');
227
+ }
228
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
229
+ $fields->addChild('FESP_IND', '9');
230
+ $fields->addChild('USER_DATA_0', $this->_getClientName());
231
+
232
+ $this->setTransactionForLog($request);
233
+
234
+
235
+ if ($hasEncryption) {
236
+ $this->_encryptRequest($request);
237
+ }
238
+ $this->setTransaction($request);
239
+ } catch (Exception $e) {
240
+ Mage::throwException($e->getmessage());
241
+ }
242
+
243
+ return $this;
244
+ }
245
+
246
+ /**
247
+ * Generates the Transaction Xml Fo Pyc Currency rate query
248
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
249
+ */
250
+ public function generatePycCurrencyRateQueryRequest() {
251
+ try {
252
+ $payment = $this->getPayment();
253
+ $profile = $this->_getProfile($payment->getIpayProfileId());
254
+ $quote = $this->getQuote();
255
+ $currencyCode = $this->_getCurrencyIsoCode($quote->getQuoteCurrencyCode());
256
+ $hasEncryption = $this->_hasEncryption();
257
+
258
+ $key = $this->_getConfig('key', 'general');
259
+ $encryption = $hasEncryption ? '1' : '0';
260
+
261
+ $request = $this->_getRootNode();
262
+ $transaction = $request->addChild('TRANSACTION');
263
+ $fields = $transaction->addChild('FIELDS');
264
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
265
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
266
+ $fields->addChild('SERVICE_FORMAT', '0000');
267
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
268
+ $fields->addChild('CURRENCY_INDICATOR', '2');
269
+ $fields->addChild('SERVICE', 'CURRENCY');
270
+ $fields->addChild('SERVICE_TYPE', 'RATE');
271
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
272
+ $fields->addChild('AMOUNT', $this->getAmount());
273
+ if ($profile->getAccountId()) {
274
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
275
+ } else {
276
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($payment->getCcExpMonth(), $payment->getCcExpYear()));
277
+ $fields->addChild('ACCOUNT_NUMBER', $payment->getCcNumber());
278
+ }
279
+ $fields->addChild('QUERY_TYPE', '0');
280
+ $fields->addChild('FESP_IND', '9');
281
+
282
+ $this->setTransactionForLog($request);
283
+
284
+
285
+ if ($hasEncryption) {
286
+ $this->_encryptRequest($request);
287
+ }
288
+
289
+ $this->setTransaction($request);
290
+ } catch (Exception $e) {
291
+ Mage::throwException($e->getmessage());
292
+ }
293
+
294
+ return $this;
295
+ }
296
+
297
+ /**
298
+ * Transaction request for currency rate look up for mcp
299
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
300
+ */
301
+ public function generateCurrencyRateLookUpRequest() {
302
+ try {
303
+ $hasEncryption = $this->_hasEncryption();
304
+
305
+ $key = $this->_getConfig('key', 'general');
306
+ $encryption = $hasEncryption ? '1' : '0';
307
+ $request = $this->_getRootNode();
308
+ $transaction = $request->addChild('TRANSACTION');
309
+ $fields = $transaction->addChild('FIELDS');
310
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
311
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
312
+ $fields->addChild('SERVICE_FORMAT', '0000');
313
+ $fields->addChild('CURRENCY_INDICATOR', '1');
314
+ $fields->addChild('SERVICE', 'CURRENCY');
315
+ $fields->addChild('SERVICE_TYPE', 'RATE');
316
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
317
+ $fields->addChild('QUERY_TYPE', '1');
318
+ $fields->addChild('FESP_IND', '9');
319
+
320
+ $this->setTransactionForLog($request);
321
+ $this->setCurrencyRate(true);
322
+
323
+ if ($hasEncryption) {
324
+ $this->_encryptRequest($request);
325
+ }
326
+
327
+ $this->setTransaction($request);
328
+ } catch (Exception $e) {
329
+ Mage::throwException($e->getmessage());
330
+ }
331
+
332
+ return $this;
333
+ }
334
+
335
+ /**
336
+ * Generating transaction request for adding a new Client Profille
337
+ * @return type
338
+ */
339
+ public function generateNewWalletProfileRequest() {
340
+ try {
341
+ $profile = $this->getIpayPaymentProfile();
342
+ if ($profile) {
343
+ $hasEncryption = $this->_hasEncryption();
344
+
345
+ $key = $this->_getConfig('key', 'general');
346
+ $encryption = $hasEncryption ? '1' : '0';
347
+ $request = $this->_getRootNode();
348
+ $transaction = $request->addChild('TRANSACTION');
349
+ $fields = $transaction->addChild('FIELDS');
350
+ $fields->addChild('SERVICE', 'WALLET');
351
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
352
+ $fields->addChild('SERVICE_SUBTYPE', 'INSERT');
353
+ $fields->addChild('SERVICE_FORMAT', '1010');
354
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
355
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
356
+ $fields->addChild('FIRST_NAME', htmlentities($profile->getFirstName(), ENT_QUOTES));
357
+ $fields->addChild('LAST_NAME', htmlentities($profile->getLastName(), ENT_QUOTES));
358
+ $fields->addChild('ADDRESS', $this->_conditionAddress($profile->getAddress()));
359
+ $fields->addChild('CITY', htmlentities($profile->getCity(), ENT_QUOTES));
360
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($profile->getZip()));
361
+ $fields->addChild('STATE', htmlentities($profile->getState(), ENT_QUOTES));
362
+ $fields->addChild('COUNTRY', htmlentities($profile->getCountry(), ENT_QUOTES));
363
+ $fields->addChild('ACCOUNT', 'CC');
364
+ $fields->addChild('ACCOUNT_NUMBER', $profile->getCardNumber());
365
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
366
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($profile->getExpirationMonth(), $profile->getExpirationYear()));
367
+ $fields->addChild('CVV', $profile->getCardCode());
368
+ $fields->addChild('BILLING_TRANSACTION', '2');
369
+ $fields->addChild('FESP_IND', '9');
370
+
371
+ $this->setTransactionForLog($request);
372
+
373
+
374
+ if ($hasEncryption) {
375
+ $this->_encryptRequest($request);
376
+ }
377
+
378
+ $this->setTransaction($request);
379
+ } else {
380
+ Mage::throwException("failed to create payment profile");
381
+ }
382
+ } catch (Exception $e) {
383
+ Mage::throwException($e->getmessage());
384
+ }
385
+
386
+ return $this;
387
+ }
388
+
389
+ /**
390
+ * Generate Xml request for updating customer profile
391
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
392
+ */
393
+ public function generateUpdateClientRequest() {
394
+ try {
395
+ $profile = $this->getIpayPaymentProfile();
396
+ if ($profile) {
397
+ $hasEncryption = $this->_hasEncryption();
398
+
399
+ $key = $this->_getConfig('key', 'general');
400
+ $encryption = $hasEncryption ? '1' : '0';
401
+ $request = $this->_getRootNode();
402
+ $transaction = $request->addChild('TRANSACTION');
403
+ $fields = $transaction->addChild('FIELDS');
404
+ $fields->addChild('SERVICE', 'WALLET');
405
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
406
+ $fields->addChild('SERVICE_SUBTYPE', 'MODIFY');
407
+ $fields->addChild('SERVICE_FORMAT', '1010');
408
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
409
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
410
+ $fields->addChild('CLIENT_ID', $profile->getClientId());
411
+ $fields->addChild('FIRST_NAME', htmlentities($profile->getFirstName(), ENT_QUOTES));
412
+ $fields->addChild('LAST_NAME', htmlentities($profile->getLastName(), ENT_QUOTES));
413
+ $fields->addChild('ADDRESS', $this->_conditionAddress($profile->getAddress()));
414
+ $fields->addChild('CITY', htmlentities($profile->getCity(), ENT_QUOTES));
415
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($profile->getZip()));
416
+ $fields->addChild('STATE', htmlentities($profile->getState(), ENT_QUOTES));
417
+ $fields->addChild('COUNTRY', htmlentities($profile->getCountry(), ENT_QUOTES));
418
+ $fields->addChild('FESP_IND', '9');
419
+
420
+ $this->setTransactionForLog($request);
421
+
422
+
423
+ if ($hasEncryption) {
424
+ $this->_encryptRequest($request);
425
+ }
426
+
427
+ $this->setTransaction($request);
428
+ } else {
429
+ Mage::throwException("failed to Update payment profile");
430
+ }
431
+ } catch (Exception $e) {
432
+ Mage::throwException($e->getmessage());
433
+ }
434
+
435
+ return $this;
436
+ }
437
+
438
+ /**
439
+ * Generating the xml reauest for updating customer card details
440
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
441
+ */
442
+ public function generateUpdateAccountRequest() {
443
+ try {
444
+ $profile = $this->getIpayPaymentProfile();
445
+ if ($profile) {
446
+ $hasEncryption = $this->_hasEncryption();
447
+
448
+ $key = $this->_getConfig('key', 'general');
449
+ $encryption = $hasEncryption ? '1' : '0';
450
+ $request = $this->_getRootNode();
451
+ $transaction = $request->addChild('TRANSACTION');
452
+ $fields = $transaction->addChild('FIELDS');
453
+ $fields->addChild('SERVICE', 'WALLET');
454
+ $fields->addChild('SERVICE_TYPE', 'ACCOUNT');
455
+ $fields->addChild('SERVICE_SUBTYPE', 'MODIFY');
456
+ $fields->addChild('SERVICE_FORMAT', '1010');
457
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
458
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
459
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
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('FESP_IND', '9');
465
+
466
+ $this->setTransactionForLog($request);
467
+
468
+
469
+ if ($hasEncryption) {
470
+ $this->_encryptRequest($request);
471
+ } else {
472
+ $fields->addChild('PIN', $this->_getConfig('terminal_id', 'pin'));
473
+ }
474
+
475
+ $this->setTransaction($request);
476
+ } else {
477
+ Mage::throwException("failed to update payment profile");
478
+ }
479
+ } catch (Exception $e) {
480
+ Mage::throwException($e->getmessage());
481
+ }
482
+
483
+ return $this;
484
+ }
485
+
486
+ /**
487
+ * Deleting Customer profile from Planet payment
488
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
489
+ */
490
+ public function generateDeleteClientRequest() {
491
+ try {
492
+ $profile = $this->getIpayPaymentProfile();
493
+ if ($profile) {
494
+ $hasEncryption = $this->_hasEncryption();
495
+
496
+ $key = $this->_getConfig('key', 'general');
497
+ $encryption = $hasEncryption ? '1' : '0';
498
+ $request = $this->_getRootNode();
499
+ $transaction = $request->addChild('TRANSACTION');
500
+ $fields = $transaction->addChild('FIELDS');
501
+ $fields->addChild('SERVICE', 'WALLET');
502
+ $fields->addChild('SERVICE_TYPE', 'CLIENT');
503
+ $fields->addChild('SERVICE_SUBTYPE', 'DELETE');
504
+ $fields->addChild('SERVICE_FORMAT', '1010');
505
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
506
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
507
+ $fields->addChild('CLIENT_ID', $profile->getClientId());
508
+ $fields->addChild('FESP_IND', '9');
509
+
510
+ $this->setTransactionForLog($request);
511
+
512
+ if ($hasEncryption) {
513
+ $this->_encryptRequest($request);
514
+ }
515
+
516
+ $this->setTransaction($request);
517
+ } else {
518
+ Mage::throwException("failed to delete payment profile");
519
+ }
520
+ } catch (Exception $e) {
521
+ Mage::throwException($e->getmessage());
522
+ }
523
+
524
+ return $this;
525
+ }
526
+
527
+ /**
528
+ * Test configurations
529
+ */
530
+ public function generateTestConfigurationRequest() {
531
+ try {
532
+ $hasEncryption = $this->_hasEncryption();
533
+
534
+ $key = $this->_getConfig('key', 'general');
535
+ $encryption = $hasEncryption ? '1' : '0';
536
+ $request = $this->_getRootNode();
537
+ $transaction = $request->addChild('TRANSACTION');
538
+ $fields = $transaction->addChild('FIELDS');
539
+ $fields->addChild('SERVICE', 'NETWORK');
540
+ $fields->addChild('SERVICE_TYPE', 'STATUS');
541
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
542
+ $fields->addChild('SERVICE_FORMAT', '0000');
543
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
544
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
545
+ $fields->addChild('FESP_IND', '9');
546
+
547
+ $this->setTransactionForLog($request);
548
+
549
+ if ($hasEncryption) {
550
+ $this->_encryptRequest($request);
551
+ }
552
+
553
+ $this->setTransaction($request);
554
+ } catch (Exception $e) {
555
+ Mage::throwException($e->getmessage());
556
+ }
557
+
558
+ return $this;
559
+ }
560
+
561
+ public function generateRequestForCapture() {
562
+ try {
563
+ $payment = $this->getPayment();
564
+ if ($payment) {
565
+ $hasEncryption = $this->_hasEncryption();
566
+ $billingAddress = $payment->getOrder()->getBillingAddress();
567
+ $key = $this->_getConfig('key', 'general');
568
+ $encryption = $hasEncryption ? '1' : '0';
569
+ $request = $this->_getRootNode();
570
+ $transaction = $request->addChild('TRANSACTION');
571
+ $fields = $transaction->addChild('FIELDS');
572
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
573
+ $fields->addChild('SERVICE_FORMAT', '1010');
574
+ $paymentType = $this->_getPaymentType($payment);
575
+
576
+ if ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
577
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
578
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
579
+ $fields->addChild('CURRENCY_INDICATOR', '2');
580
+ } else {
581
+ $fields->addChild('CURRENCY_INDICATOR', '0');
582
+ }
583
+ } elseif ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP) {
584
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
585
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
586
+ $fields->addChild('CURRENCY_INDICATOR', '1');
587
+ } else {
588
+ $fields->addChild('CURRENCY_INDICATOR', '0');
589
+ }
590
+ }
591
+
592
+ $fields->addChild('TRANSACTION_ID', $payment->getLastTransId());
593
+ $fields->addChild('SERVICE', 'CC');
594
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
595
+ $fields->addChild('SERVICE_SUBTYPE', 'CAPTURE');
596
+ $fields->addChild('AMOUNT', $this->getAmountInStoreCurrency());
597
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
598
+ $fields->addChild('FESP_IND', '9');
599
+
600
+ $this->setTransactionForLog($request);
601
+
602
+ if ($hasEncryption) {
603
+ $this->_encryptRequest($request);
604
+ }
605
+
606
+ $this->setTransaction($request);
607
+ } else {
608
+ Mage::throwException("Unable to capture");
609
+ }
610
+ } catch (Exception $e) {
611
+ Mage::throwException($e->getmessage());
612
+ }
613
+
614
+ return $this;
615
+ }
616
+
617
+ public function generateRequestForSale() {
618
+ try {
619
+ $payment = $this->getPayment();
620
+ $quote = Mage::helper('ipay')->getQuote();
621
+ $billingAddress = $quote->getBillingAddress();
622
+
623
+ $profile = $this->_getProfile($payment->getIpayProfileId());
624
+
625
+ $hasEncryption = $this->_hasEncryption();
626
+
627
+ $key = $this->_getConfig('key', 'general');
628
+ $encryption = $hasEncryption ? '1' : '0';
629
+
630
+ $request = $this->_getRootNode();
631
+ $transaction = $request->addChild('TRANSACTION');
632
+ $fields = $transaction->addChild('FIELDS');
633
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
634
+ $fields->addChild('SERVICE', 'CC');
635
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
636
+ $fields->addChild('SERVICE_SUBTYPE', 'SALE');
637
+ $fields->addChild('SERVICE_FORMAT', '1010');
638
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
639
+ //If a profile selected by customer
640
+ if ($profile->getAccountId()) {
641
+ $fields->addChild('ACCOUNT_ID', $profile->getAccountId());
642
+ } else {
643
+ $fields->addChild('ACCOUNT_NUMBER', $payment->getCcNumber());
644
+ $fields->addChild('EXPIRATION', $this->_getCcExpiration($payment->getCcExpMonth(), $payment->getCcExpYear()));
645
+ $fields->addChild('CVV', $payment->getCcCid());
646
+ $fields->addChild('FIRST_NAME', $billingAddress->getFirstname());
647
+ $fields->addChild('LAST_NAME', $billingAddress->getLastname());
648
+ $fields->addChild('ADDRESS', $this->_conditionAddress($billingAddress->getStreet(1)));
649
+ $fields->addChild('STATE', $billingAddress->getRegionCode());
650
+ $fields->addChild('CITY', $billingAddress->getCity());
651
+ $fields->addChild('POSTAL_CODE', $this->_conditionPostalCode($billingAddress->getPostcode()));
652
+ }
653
+
654
+ $fields->addChild('AMOUNT', round($quote->getGrandTotal(),2));
655
+
656
+ $paymentType = $this->_getPaymentType($payment);
657
+ if ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
658
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
659
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
660
+ $fields->addChild('CURRENCY_INDICATOR', '2');
661
+ } else {
662
+ $fields->addChild('CURRENCY_INDICATOR', '0');
663
+ }
664
+ } elseif ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP) {
665
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
666
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
667
+ $fields->addChild('CURRENCY_INDICATOR', '1');
668
+ } else {
669
+ $fields->addChild('CURRENCY_INDICATOR', '0');
670
+ }
671
+ }
672
+ $fields->addChild('ENTRY_MODE', '3');
673
+ $fields->addChild('TRANSACTION_INDICATOR', '7');
674
+ $fields->addChild('FESP_IND', '9');
675
+ $fields->addChild('USER_DATA_0', $this->_getClientName());
676
+
677
+ $this->setTransactionForLog($request);
678
+
679
+ if ($hasEncryption) {
680
+ $this->_encryptRequest($request);
681
+ }
682
+ $this->setTransaction($request);
683
+ } catch (Exception $e) {
684
+ Mage::throwException($e->getmessage());
685
+ }
686
+
687
+ return $this;
688
+ }
689
+
690
+ public function generateRequestForVoid() {
691
+ try {
692
+ $payment = $this->getPayment();
693
+ if ($payment) {
694
+ $hasEncryption = $this->_hasEncryption();
695
+
696
+ $key = $this->_getConfig('key', 'general');
697
+ $encryption = $hasEncryption ? '1' : '0';
698
+ $request = $this->_getRootNode();
699
+ $transaction = $request->addChild('TRANSACTION');
700
+ $fields = $transaction->addChild('FIELDS');
701
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
702
+ $fields->addChild('SERVICE_FORMAT', '1010');
703
+ $fields->addChild('TRANSACTION_ID', $payment->getLastTransId());
704
+ $fields->addChild('SERVICE', 'CC');
705
+ $fields->addChild('SERVICE_TYPE', 'DEBIT');
706
+ $fields->addChild('SERVICE_SUBTYPE', 'VOID');
707
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
708
+ $fields->addChild('FESP_IND', '9');
709
+
710
+ $this->setTransactionForLog($request);
711
+
712
+ if ($hasEncryption) {
713
+ $this->_encryptRequest($request);
714
+ }
715
+
716
+ $this->setTransaction($request);
717
+ } else {
718
+ Mage::throwException("Unable to Void");
719
+ }
720
+ } catch (Exception $e) {
721
+ Mage::throwException($e->getmessage());
722
+ }
723
+
724
+ return $this;
725
+ }
726
+
727
+ public function generateRequestForRefund() {
728
+ try {
729
+ $payment = $this->getPayment();
730
+ if ($payment) {
731
+ $hasEncryption = $this->_hasEncryption();
732
+
733
+ $key = $this->_getConfig('key', 'general');
734
+ $encryption = $hasEncryption ? '1' : '0';
735
+ $request = $this->_getRootNode();
736
+ $transaction = $request->addChild('TRANSACTION');
737
+ $fields = $transaction->addChild('FIELDS');
738
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'general'));
739
+ $fields->addChild('SERVICE_FORMAT', '1010');
740
+ $paymentType = $this->_getPaymentType($payment);
741
+
742
+ if ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
743
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($this->getNativeCurrency()));
744
+ if ($this->getNativeCurrency() != $payment->getOrder()->getOrderCurrencyCode()) {
745
+ $fields->addChild('CURRENCY_INDICATOR', '2');
746
+ } else {
747
+ $fields->addChild('CURRENCY_INDICATOR', '0');
748
+ }
749
+ $fields->addChild('AMOUNT', $this->getAmount());
750
+ } elseif ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP) {
751
+ $fields->addChild('CURRENCY_CODE', $this->_getCurrencyIsoCode($payment->getOrder()->getOrderCurrencyCode()));
752
+ if ($payment->getOrder()->getOrderCurrencyCode() != $this->getNativeCurrency()) {
753
+ $fields->addChild('CURRENCY_INDICATOR', '1');
754
+ } else {
755
+ $fields->addChild('CURRENCY_INDICATOR', '0');
756
+ }
757
+ $fields->addChild('AMOUNT', $this->getAmountInStoreCurrency()); //refund in the currency of the charge
758
+ }
759
+
760
+ $fields->addChild('TRANSACTION_ID', $payment->getRefundTransactionId());
761
+ $fields->addChild('SERVICE', 'CC');
762
+ $fields->addChild('SERVICE_TYPE', 'CREDIT');
763
+ $fields->addChild('SERVICE_SUBTYPE', 'REFUND');
764
+ $fields->addChild('PIN', $this->_getConfig('pin', 'general'));
765
+ $fields->addChild('FESP_IND', '9');
766
+
767
+ $this->setTransactionForLog($request);
768
+
769
+ if ($hasEncryption) {
770
+ $this->_encryptRequest($request);
771
+ }
772
+
773
+ $this->setTransaction($request);
774
+ } else {
775
+ Mage::throwException("Unable to Refund");
776
+ }
777
+ } catch (Exception $e) {
778
+ Mage::throwException($e->getmessage());
779
+ }
780
+
781
+ return $this;
782
+ }
783
+
784
+ /**
785
+ * Sending the request to Planet Payment
786
+ * @return PlanetPayment_IpayGateway_Model_Xml_Request
787
+ */
788
+ public function send() {
789
+ $transaction = $this->getTransaction();
790
+ if ($transaction) {
791
+ try {
792
+ $isProduction = $this->_isProductionMode();
793
+ if ($isProduction) {
794
+ $url = PlanetPayment_IpayGateway_Model_Ipay::GATEWAY_URL_PRODUCTION;
795
+ } else {
796
+ $url = PlanetPayment_IpayGateway_Model_Ipay::GATEWAY_URL_TESTING;
797
+ }
798
+ //Selecting port based on the url
799
+ $port = 86;
800
+ if (strstr($url, 'https://')) {
801
+ $port = 443;
802
+ }
803
+
804
+ $client = new Zend_Http_Client($url, array('keepalive' => true, 'timeout' => 60));
805
+ $client->getUri()->setPort($port);
806
+ $client->setRawData($transaction->asXML(), 'text/xml');
807
+ $client->setMethod(Zend_Http_Client::POST);
808
+ $response = $client->request()->getBody();
809
+
810
+ //Setting response to response model object
811
+ $responseModel = $this->_getResponseModel();
812
+ $responseModel->setIpayRequest($this);
813
+ $responseModel->setIpayResponse($response);
814
+ $this->setResponse($responseModel);
815
+ } catch (Exception $e) {
816
+ Mage::throwException($e->getmessage());
817
+ }
818
+
819
+ return $this;
820
+ } else {
821
+ Mage::throwException('invalid Transaction');
822
+ }
823
+ }
824
+
825
+ }
app/code/community/PlanetPayment/IpayGateway/Model/Xml/Response.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Xml_Response extends PlanetPayment_IpayGateway_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->getIpayResponse();
39
+
40
+ if ($response) {
41
+ $xmlResponse = simplexml_load_string($response);
42
+ if ($xmlResponse instanceof SimpleXMLElement) {
43
+
44
+ if ($this->_hasEncryption()) {
45
+ $this->_responseXml = simplexml_load_string($this->_decryptResponse($xmlResponse[0]));
46
+ } else {
47
+ $this->_responseXml = $xmlResponse->RESPONSE;
48
+ }
49
+
50
+ //Logging
51
+ $requestXml = $this->_getRequestObject()->getTransactionForLog()->asXML();
52
+ $requestXml = preg_replace("/<ACCOUNT_NUMBER>[0-9]+([0-9]{4})/", '<ACCOUNT_NUMBER>************$1', $requestXml);
53
+ $requestXml = preg_replace("/<CVV>([0-9]+)<\/CVV>/", '<CVV>***</CVV>', $requestXml);
54
+ $loggedInfo = Mage::helper('ipay')->log($requestXml, $this->_responseXml->asXML(), $this->_getRequestObject()->getCurrencyRate());
55
+ //This will be saved in log file if any error occured while Auth.
56
+ //The database transaction will be rolled back if error.
57
+ $this->setlogInfo("\n \t Request:" . $loggedInfo->getRequest() . "\n \t Response:" . $loggedInfo->getResponse());
58
+ } else {
59
+ Mage::throwException('Invalid response');
60
+ }
61
+ } else {
62
+ Mage::throwException('Invalid response');
63
+ }
64
+
65
+ return $this->_responseXml;
66
+ }
67
+
68
+ /**
69
+ * Checking whether the request was successful
70
+ * @return bool
71
+ */
72
+ public function isSuccess() {
73
+ $responseXml = $this->_getResponse();
74
+ if ($responseXml->FIELDS->ARC) {
75
+ if ($responseXml->FIELDS->ARC == '00' && $responseXml->FIELDS->MRC == '00') {
76
+ return true;
77
+ } else {
78
+ $errorHelper = Mage::helper('ipay/error');
79
+ $arcMsg = $errorHelper->getErrorMessage((string)$responseXml->FIELDS->ARC, 'arc');
80
+ $mrcMsg = $errorHelper->getErrorMessage((string)$responseXml->FIELDS->MRC, 'mrc');
81
+ $this->setMessage("<i> (".$arcMsg.", ".$mrcMsg.")</i><br/>RESPONSE TEXT:".$responseXml->FIELDS->RESPONSE_TEXT);
82
+ }
83
+ }
84
+
85
+ return false;
86
+ }
87
+
88
+ /**
89
+ * Returns the Xml content of response
90
+ * @return type
91
+ */
92
+ public function getXmlContent() {
93
+ if (!$this->_responseXml) {
94
+ $this->_getResponse();
95
+ }
96
+
97
+ return $this->_responseXml;
98
+ }
99
+
100
+ /**
101
+ * Setting the payment profile
102
+ * @return PlanetPayment_IpayGateway_Model_Xml_Response
103
+ */
104
+ public function setPaymentProfile() {
105
+ if ($this->isSuccess()) {
106
+ $profile = $this->_getRequestObject()->getIpayPaymentProfile();
107
+ $profile->setClientId((string) $this->getXmlContent()->FIELDS->CLIENT_ID)
108
+ ->setAccountId((string) $this->getXmlContent()->FIELDS->ACCOUNT_ID);
109
+ $this->setIpayPaymentProfile($profile);
110
+ }
111
+
112
+ return $this;
113
+ }
114
+
115
+ /**
116
+ * Setting the payment profile after updation of profile
117
+ * @return PlanetPayment_IpayGateway_Model_Xml_Response
118
+ */
119
+ public function setUpdatedPaymentProfile() {
120
+ if ($this->isSuccess()) {
121
+ $profile = $this->_getRequestObject()->getIpayPaymentProfile();
122
+ $this->setIpayPaymentProfile($profile);
123
+ }
124
+
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Returs the currecny options retured from Planet payment for PYC
130
+ * @return type Array
131
+ */
132
+ public function getPycCurrencyOptions() {
133
+ $response = $this->getXmlContent();
134
+ $pycCurrencyAmount = $response->FIELDS->CARDHOLDER_AMOUNT;
135
+ $baseCurrencyAmount = $response->FIELDS->AMOUNT;
136
+ $pycCurrency = $response->FIELDS->CARDHOLDER_CURRENCY_CODE;
137
+ $nativeCurrencyCode = $this->getNativeCurrency();
138
+ $pycCurrencyCode = $this->_getCurrencyFromIsoCode($pycCurrency);
139
+
140
+ return array((string) $pycCurrencyCode => $pycCurrencyCode . ' ' . $pycCurrencyAmount,
141
+ (string) $nativeCurrencyCode => $nativeCurrencyCode . ' ' . $baseCurrencyAmount);
142
+ }
143
+
144
+ /**
145
+ * Returns PYC exchange rate
146
+ * @return type
147
+ */
148
+ public function getExchangeRate() {
149
+ $response = $this->getXmlContent();
150
+ return (string)$response->FIELDS->PYC_EXCHANGE_RATE;
151
+ }
152
+
153
+ /**
154
+ * Returns PYC mark up
155
+ * @return type
156
+ */
157
+ public function getMarkUp() {
158
+ $response = $this->getXmlContent();
159
+ return (string)$response->FIELDS->PYC_MARKUP;
160
+ }
161
+
162
+ /**
163
+ * Returning the request object of this response
164
+ * @return type
165
+ */
166
+ protected function _getRequestObject() {
167
+ return $this->getIpayRequest();
168
+ }
169
+
170
+ /**
171
+ * Returning the Pyc Exchange rate
172
+ * @return type
173
+ */
174
+ public function getPycExchangeRate() {
175
+ $response = $this->getXmlContent();
176
+ return (string)$response->FIELDS->PYC_EXCHANGE_RATE;
177
+ }
178
+
179
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Adminhtml_CheckoutController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ public function getIpayCurrenciesAction() {
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('ipay')->getQuote();
43
+ $payment = $quote->getPayment();
44
+ $payment->importData($postData);
45
+
46
+ $quote->save();
47
+ if (isset($postData['method']) && $postData['method'] == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
48
+ try {
49
+ $method = $payment->getMethodInstance();
50
+ $paymentType = $method->getPaymentType();
51
+ if ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
52
+ // //Preparing & Sending request for PYC Rate Query
53
+ $quote->setIpayProfileId($payment->getIpayProfileId());
54
+ $request = $this->_getIpayRequestModel()
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('ipayadmin_adminhtml_checkout_getIpayCurrencies');
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'] = "Ipay 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('ipay')->getQuote();
96
+ $payment = $quote->getPayment();
97
+ $payment->setIpayCurrencyCode($postData['selected_currency']);
98
+ $quote->save();
99
+ }
100
+ }
101
+ }
102
+
103
+ protected function _getIpayRequestModel() {
104
+ return Mage::getModel('ipay/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/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_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_IpayGateway_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('ipay/profile')->load($profileId);
76
+ if ($profile->getId()) {
77
+ try {
78
+ $requestModel = Mage::getModel('ipay/xml_request')->setIpayPaymentProfile($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 Ipay. 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('ipay')->__('Payment Profile not found.'));
93
+ }
94
+ $this->_redirect('adminhtml/customer/edit', array('id' => $customer->getId(), 'tab' => 'ipay'));
95
+ return;
96
+ }
97
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ipay')->__('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/IpayGateway/controllers/Adminhtml/SystemController.php ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Adminhtml_SystemController extends Mage_Adminhtml_Controller_Action {
30
+
31
+ /**
32
+ * Purges all Ipay customer and profile data from Magento.
33
+ * Typically this is run after switching from a test account to a production account.
34
+ */
35
+ public function purgeAction() {
36
+ $profiles = Mage::getModel('ipay/profile')->getCollection();
37
+ /* @var $resource PlanetPayment_IpayGateway_Model_Profile */
38
+ try {
39
+ $errors = array();
40
+ if (count($profiles)) {
41
+ foreach ($profiles as $profile) {
42
+ $requestModel = Mage::getModel('ipay/xml_request')->setIpayPaymentProfile($profile)
43
+ ->generateDeleteClientRequest()
44
+ ->send();
45
+ $response = $requestModel->getResponse();
46
+ if ($response->isSuccess()) {
47
+ $profile->delete();
48
+ } else {
49
+ $errors[$profile->getClientId()] = $response->getMessage();
50
+ }
51
+ }
52
+
53
+ if (count($errors)) {
54
+ $message = "Some of the profiles couldn't delete.<br/>";
55
+ foreach ($errors as $accountId => $reason) {
56
+ $message .= "Account ID: $accountId, Message: $reason <br/>";
57
+ }
58
+ Mage::getSingleton('adminhtml/session')->addError($message);
59
+ } else {
60
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ipay')->__('Ipay Profiles has been successfully purged.'));
61
+ }
62
+ } else {
63
+ Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('ipay')->__('No Profiles Found.'));
64
+ }
65
+ } catch (Exception $e) {
66
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
67
+ }
68
+ $this->_redirectReferer();
69
+ }
70
+
71
+ /**
72
+ * Exports the logs into a text file
73
+ */
74
+ public function exportAction() {
75
+ try {
76
+ $logModel = Mage::getmodel('ipay/log');
77
+ $logs = $logModel->getCollection();
78
+ if (count($logs)) {
79
+ $content = "CREATE TABLE IF NOT EXISTS `" . $logModel->getResource()->getTable('ipay/log') . "`
80
+ (
81
+ `id` int(10) NOT NULL AUTO_INCREMENT,
82
+ `request` text NULL,
83
+ `response` text NULL,
84
+ `create_date` timestamp DEFAULT CURRENT_TIMESTAMP,
85
+ PRIMARY KEY (`id`)
86
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;";
87
+ $content .= "INSERT INTO `" . $logModel->getResource()->getTable('ipay/log') . "` (`request`, `response` , `create_date`) VALUES ";
88
+ $i = 0;
89
+ foreach ($logs as $log) {
90
+ $content .= $i != 0 ? ", " : "";
91
+ $content .= "('" . addslashes($log->getRequest()) . "','" . addslashes($log->getResponse()) . "','" . $log->getCreateDate() . "')";
92
+ $i++;
93
+ }
94
+ $this->_prepareDownloadResponse("LogExport.sql", $content);
95
+ return;
96
+ } else {
97
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ipay')->__('Log is empty'));
98
+ }
99
+ } catch (Exception $e) {
100
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
101
+ }
102
+ $this->_redirectReferer();
103
+ }
104
+
105
+ public function testAction() {
106
+ $requestModel = Mage::getModel('ipay/xml_request')->generateTestConfigurationRequest()
107
+ ->send();
108
+ $response = $requestModel->getResponse();
109
+ if ($response->isSuccess()) {
110
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('ipay')->__('Configurations tested successfully.'));
111
+ } else {
112
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('ipay')->__('Error in configuration.</br> Message:'.$response->getMessage()));
113
+ }
114
+ $this->_redirectReferer();
115
+ }
116
+
117
+ /**
118
+ * ACL check.
119
+ *
120
+ * @return bool
121
+ */
122
+ protected function _isAllowed() {
123
+ $actionName = $this->getRequest()->getActionName();
124
+ return Mage::getSingleton('admin/session')->isAllowed('ipay/system/' . $actionName);
125
+ }
126
+
127
+ }
app/code/community/PlanetPayment/IpayGateway/controllers/OnepageController.php ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ require_once 'Mage/Checkout/controllers/OnepageController.php';
30
+
31
+ class PlanetPayment_IpayGateway_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
+
40
+ if ($this->_expireAjax()) {
41
+ return;
42
+ }
43
+ try {
44
+ if (!$this->getRequest()->isPost()) {
45
+ $this->_ajaxRedirectResponse();
46
+ return;
47
+ }
48
+
49
+ // set payment to quote
50
+ $result = array();
51
+ $data = $this->getRequest()->getPost('payment', array());
52
+ $result = $this->getOnepage()->savePayment($data);
53
+
54
+ // get section and redirect data
55
+ $redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
56
+ if (empty($result['error']) && !$redirectUrl) {
57
+ if (isset($data['method']) && $data['method'] == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
58
+ try {
59
+ //Getting the Quote Object
60
+ $quote = $this->getOnepage()->getQuote();
61
+ $payment = $quote->getPayment();
62
+ $method = $payment->getMethodInstance();
63
+
64
+ $paymentType = $method->getPaymentType();
65
+
66
+ if ($paymentType == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC) {
67
+ // //Preparing & Sending request for PYC Rate Query
68
+ $quote->setIpayProfileId($payment->getIpayProfileId());
69
+ $request = $this->_getIpayRequestModel()
70
+ ->setPayment($payment)
71
+ ->setQuote($quote)
72
+ ->setAmount($quote->getGrandTotal());
73
+
74
+ $request->generatePycCurrencyRateQueryRequest()
75
+ ->send();
76
+
77
+ //Getting Response Object
78
+ $response = $request->getResponse();
79
+ //Checking whether the request succeed
80
+ if ($response->isSuccess()) {
81
+ $quote->setIpayExchangeRate($response->getPycExchangeRate())
82
+ ->save();
83
+ //Loading Currency section if request succeed
84
+ $this->loadLayout('checkout_onepage_ipay');
85
+ $result['goto_section'] = 'currency_selector';
86
+ $result['update_section'] = array(
87
+ 'name' => 'currency_selector',
88
+ 'html' => $this->_getCurrencySelectorHtml($response)
89
+ );
90
+ } else {
91
+ //Throwing an error to load the review section
92
+ Mage::throwException("Ipay Request Failed");
93
+ }
94
+ } else {
95
+ //Throwing an error to load the review section
96
+ Mage::throwException("Payment service is set to MCP.");
97
+ }
98
+ } catch (Exception $e) {
99
+ $quote->setIpayExchangeRate(null)
100
+ ->save();
101
+ $this->loadLayout('checkout_onepage_review');
102
+ $result['goto_section'] = 'review';
103
+ $result['update_section'] = array(
104
+ 'name' => 'review',
105
+ 'html' => $this->_getReviewHtml()
106
+ );
107
+ }
108
+ } else {
109
+ $this->loadLayout('checkout_onepage_review');
110
+ $result['goto_section'] = 'review';
111
+ $result['update_section'] = array(
112
+ 'name' => 'review',
113
+ 'html' => $this->_getReviewHtml()
114
+ );
115
+ }
116
+ }
117
+ if ($redirectUrl) {
118
+ $result['redirect'] = $redirectUrl;
119
+ }
120
+ } catch (Mage_Payment_Exception $e) {
121
+ if ($e->getFields()) {
122
+ $result['fields'] = $e->getFields();
123
+ }
124
+ $result['error'] = $e->getMessage();
125
+ } catch (Mage_Core_Exception $e) {
126
+ $result['error'] = $e->getMessage();
127
+ } catch (Exception $e) {
128
+ Mage::logException($e);
129
+ $result['error'] = $this->__('Unable to set Payment Method.');
130
+ }
131
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
132
+ }
133
+
134
+ /**
135
+ * Save the selected currency to the Payment for PYC
136
+ */
137
+ public function saveCurrencyAction() {
138
+ $this->_expireAjax();
139
+ if ($this->getRequest()->isPost()) {
140
+ // get section and redirect data
141
+ $data = $this->getRequest()->getPost('payment',array());
142
+ if(!isset($data['selected_currency'])) {
143
+ $result['error'] = true;
144
+ $result['message'] = 'Please select a currency';
145
+ $this->getOnepage()->getQuote()->setIpayCurrencyCode(null)->save();
146
+ } else {
147
+ $quote = $this->getOnepage()->getQuote();
148
+ $quote->getPayment()->setIpayCurrencyCode($data['selected_currency']);
149
+ $quote->save();
150
+ }
151
+ $redirectUrl = $this->getOnepage()->getQuote()->getPayment()->getCheckoutRedirectUrl();
152
+ if (empty($result['error']) && !$redirectUrl) {
153
+ $this->loadLayout('checkout_onepage_review');
154
+ $result['goto_section'] = 'review';
155
+ $result['update_section'] = array(
156
+ 'name' => 'review',
157
+ 'html' => $this->_getReviewHtml()
158
+ );
159
+ }
160
+ if ($redirectUrl) {
161
+ $result['redirect'] = $redirectUrl;
162
+ }
163
+ }
164
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
165
+ }
166
+
167
+ protected function _getIpayRequestModel() {
168
+ return Mage::getModel('ipay/xml_request');
169
+ }
170
+
171
+ /**
172
+ * Get order review step html
173
+ *
174
+ * @return string
175
+ */
176
+ protected function _getCurrencySelectorHtml($response) {
177
+ return $this->getLayout()->getBlock('root')->setResponse($response)->toHtml();
178
+ }
179
+
180
+ }
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_ProfileController extends Mage_Core_Controller_Front_Action {
30
+
31
+ public function preDispatch() {
32
+ parent::preDispatch();
33
+ if (!$this->_getSession()->authenticate($this) || !Mage::helper('ipay')->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('ipay/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_IpayGateway_Model_PaymentProfile */
78
+ $profile = Mage::getModel('ipay/profile');
79
+ if ($profileId) {
80
+ $profile = Mage::getModel('ipay/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('ipay_paymentprofile_form', 'to_paymentprofile', $this->getRequest()->getPost(), $profile);
89
+ $profile->setCardNumberLast4(substr($profile->getCardNumber(), -4))
90
+ ->setCustomerId($customer->getId());
91
+ $requestModel = Mage::getModel('ipay/xml_request')->setIpayPaymentProfile($profile)
92
+ ->setCustomer($customer);
93
+ // post to Ipay
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->getIpayPaymentProfile();
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->getIpayPaymentProfile();
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('ipay/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('ipay/xml_request')->setIpayPaymentProfile($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 Ipay. 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/IpayGateway/data/ipay_setup/data-install-1.0.0.php ADDED
@@ -0,0 +1,252 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ //Adding Ipay 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('ipay/currencyCodes'), $data);
app/code/community/PlanetPayment/IpayGateway/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_IpayGateway
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_IpayGateway
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 translate="title" module="cms">
40
+ <title>Planet Payment</title>
41
+ </planet_payment>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/community/PlanetPayment/IpayGateway/etc/config.xml ADDED
@@ -0,0 +1,495 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <modules>
32
+ <PlanetPayment_IpayGateway>
33
+ <version>1.0.7</version>
34
+ </PlanetPayment_IpayGateway>
35
+ </modules>
36
+ <global>
37
+ <currency>
38
+ <import>
39
+ <services>
40
+ <ipay>
41
+ <name>Planet Payment</name>
42
+ <model>ipay/currency_import_ipay</model>
43
+ </ipay>
44
+ </services>
45
+ </import>
46
+ </currency>
47
+ <models>
48
+ <ipay>
49
+ <class>PlanetPayment_IpayGateway_Model</class>
50
+ <resourceModel>ipay_resource</resourceModel>
51
+ </ipay>
52
+ <checkout>
53
+ <rewrite>
54
+ <type_onepage>PlanetPayment_IpayGateway_Model_Type_Onepage</type_onepage>
55
+ </rewrite>
56
+ </checkout>
57
+ <ipay_resource>
58
+ <class>PlanetPayment_IpayGateway_Model_Resource</class>
59
+ <entities>
60
+ <paymentProfile>
61
+ <table>planet_payment_profile</table>
62
+ </paymentProfile>
63
+ <currencyCodes>
64
+ <table>planet_payment_currency_codes</table>
65
+ </currencyCodes>
66
+ <log>
67
+ <table>planet_payment_log</table>
68
+ </log>
69
+ </entities>
70
+ </ipay_resource>
71
+ </models>
72
+ <blocks>
73
+ <adminhtml>
74
+ <rewrite>
75
+ <customer_edit_tabs>PlanetPayment_IpayGateway_Block_Adminhtml_Customer_Edit_Tabs</customer_edit_tabs>
76
+ </rewrite>
77
+ </adminhtml>
78
+ <ipay>
79
+ <class>PlanetPayment_IpayGateway_Block</class>
80
+ </ipay>
81
+ <checkout>
82
+ <rewrite>
83
+ <cart_totals>PlanetPayment_IpayGateway_Block_Checkout_cart_Totals</cart_totals>
84
+ <onepage>PlanetPayment_IpayGateway_Block_Onepage</onepage>
85
+ </rewrite>
86
+ </checkout>
87
+ <sales>
88
+ <rewrite>
89
+ <order_totals>PlanetPayment_IpayGateway_Block_Sales_Order_Totals</order_totals>
90
+ </rewrite>
91
+ </sales>
92
+ </blocks>
93
+ <helpers>
94
+ <ipay>
95
+ <class>PlanetPayment_IpayGateway_Helper</class>
96
+ </ipay>
97
+ </helpers>
98
+ <rewrite>
99
+ <ipay_onepage>
100
+ <from><![CDATA[#^/checkout/onepage/#]]>
101
+ </from>
102
+ <to>/ipay/onepage/</to>
103
+ </ipay_onepage>
104
+ </rewrite>
105
+ <resources>
106
+ <ipay_setup>
107
+ <setup>
108
+ <module>PlanetPayment_IpayGateway</module>
109
+ <class>Mage_Customer_Model_Entity_Setup</class>
110
+ </setup>
111
+ </ipay_setup>
112
+ </resources>
113
+ <fieldsets>
114
+ <!-- Quote to Order (create) -->
115
+ <sales_convert_quote>
116
+ <customer_ipay_profile_id>
117
+ <to_order>*</to_order>
118
+ </customer_ipay_profile_id>
119
+ </sales_convert_quote>
120
+ <sales_convert_quote_payment>
121
+ <ipay_profile_id>
122
+ <to_order_payment>*</to_order_payment>
123
+ </ipay_profile_id>
124
+ <ipay_currency_code>
125
+ <to_order_payment>*</to_order_payment>
126
+ </ipay_currency_code>
127
+ <is_visible>
128
+ <to_order_payment>*</to_order_payment>
129
+ </is_visible>
130
+ <ipay_exchange_rate>
131
+ <to_order_payment>*</to_order_payment>
132
+ </ipay_exchange_rate>
133
+ </sales_convert_quote_payment>
134
+
135
+ <!-- Order to Order (edit) -->
136
+ <sales_copy_order>
137
+ <customer_ipay_profile_id>
138
+ <to_edit>*</to_edit>
139
+ </customer_ipay_profile_id>
140
+ </sales_copy_order>
141
+
142
+ <customer_account>
143
+ <ipay_profile_id>
144
+ <to_quote>customer_ipay_profile_id</to_quote>
145
+ </ipay_profile_id>
146
+ </customer_account>
147
+
148
+ <ipay_payment_paymentprofile>
149
+ <ipay_profile_id>
150
+ <to_paymentprofile>*</to_paymentprofile>
151
+ </ipay_profile_id>
152
+ <ipay_payment_profile_id>
153
+ <to_paymentprofile>*</to_paymentprofile>
154
+ </ipay_payment_profile_id>
155
+ <cc_number>
156
+ <to_paymentprofile>card_number</to_paymentprofile>
157
+ </cc_number>
158
+ <cc_type>
159
+ <to_paymentprofile>card_type</to_paymentprofile>
160
+ </cc_type>
161
+ <cc_last4>
162
+ <to_paymentprofile>card_number_last4</to_paymentprofile>
163
+ </cc_last4>
164
+ <cc_exp_year>
165
+ <to_paymentprofile>expiration_year</to_paymentprofile>
166
+ </cc_exp_year>
167
+ <cc_exp_month>
168
+ <to_paymentprofile>expiration_month</to_paymentprofile>
169
+ </cc_exp_month>
170
+ <cc_cid>
171
+ <to_paymentprofile>card_code</to_paymentprofile>
172
+ </cc_cid>
173
+ <is_visible>
174
+ <to_paymentprofile>*</to_paymentprofile>
175
+ </is_visible>
176
+ </ipay_payment_paymentprofile>
177
+ <ipay_paymentprofile_payment>
178
+ <id>
179
+ <to_payment>ipay_profile_id</to_payment>
180
+ </id>
181
+ <!--card_number><to_payment>cc_num</to_payment></card_number-->
182
+ <card_type>
183
+ <to_payment>cc_type</to_payment>
184
+ </card_type>
185
+ <card_number_last4>
186
+ <to_payment>cc_last4</to_payment>
187
+ </card_number_last4>
188
+ <expiration_year>
189
+ <to_payment>cc_exp_year</to_payment>
190
+ </expiration_year>
191
+ <expiration_month>
192
+ <to_payment>cc_exp_month</to_payment>
193
+ </expiration_month>
194
+ <card_code>
195
+ <to_payment>cc_cid</to_payment>
196
+ </card_code>
197
+ <cc_save>
198
+ <to_payment>*</to_payment>
199
+ </cc_save>
200
+ </ipay_paymentprofile_payment>
201
+ <ipay_payment_form>
202
+ <selected_currency>
203
+ <to_payment>ipay_currency_code</to_payment>
204
+ </selected_currency>
205
+ <cc_type>
206
+ <to_payment>*</to_payment>
207
+ </cc_type>
208
+ <cc_number>
209
+ <to_payment>*</to_payment>
210
+ </cc_number>
211
+ <cc_exp_year>
212
+ <to_payment>*</to_payment>
213
+ </cc_exp_year>
214
+ <cc_exp_month>
215
+ <to_payment>*</to_payment>
216
+ </cc_exp_month>
217
+ <cc_id>
218
+ <to_payment>*</to_payment>
219
+ </cc_id>
220
+
221
+ </ipay_payment_form>
222
+ <ipay_address_paymentprofile>
223
+ <ipay_payment_profile_id>
224
+ <to_paymentprofile>*</to_paymentprofile>
225
+ </ipay_payment_profile_id>
226
+ <firstname>
227
+ <to_paymentprofile>first_name</to_paymentprofile>
228
+ </firstname>
229
+ <lastname>
230
+ <to_paymentprofile>last_name</to_paymentprofile>
231
+ </lastname>
232
+ <company>
233
+ <to_paymentprofile>*</to_paymentprofile>
234
+ </company>
235
+ <street>
236
+ <to_paymentprofile>address</to_paymentprofile>
237
+ </street>
238
+ <city>
239
+ <to_paymentprofile>*</to_paymentprofile>
240
+ </city>
241
+ <region_code>
242
+ <to_paymentprofile>state</to_paymentprofile>
243
+ </region_code>
244
+ <postcode>
245
+ <to_paymentprofile>zip</to_paymentprofile>
246
+ </postcode>
247
+ <country_id>
248
+ <to_paymentprofile>country</to_paymentprofile>
249
+ </country_id>
250
+ <telephone>
251
+ <to_paymentprofile>phone_number</to_paymentprofile>
252
+ </telephone>
253
+ <fax>
254
+ <to_paymentprofile>fax_number</to_paymentprofile>
255
+ </fax>
256
+ </ipay_address_paymentprofile>
257
+ <ipay_paymentprofile_address>
258
+ <ipay_payment_profile_id>
259
+ <to_address>*</to_address>
260
+ </ipay_payment_profile_id>
261
+ <first_name>
262
+ <to_address>firstname</to_address>
263
+ </first_name>
264
+ <last_name>
265
+ <to_address>lastname</to_address>
266
+ </last_name>
267
+ <company>
268
+ <to_address>*</to_address>
269
+ </company>
270
+ <address>
271
+ <to_address>street</to_address>
272
+ </address>
273
+ <city>
274
+ <to_address>*</to_address>
275
+ </city>
276
+ <state>
277
+ <to_address>region_code</to_address>
278
+ </state>
279
+ <zip>
280
+ <to_address>postcode</to_address>
281
+ </zip>
282
+ <country>
283
+ <to_address>country_id</to_address>
284
+ </country>
285
+ <telephone>
286
+ <to_address>phone_number</to_address>
287
+ </telephone>
288
+ <fax>
289
+ <to_address>fax_number</to_address>
290
+ </fax>
291
+ </ipay_paymentprofile_address>
292
+ <ipay_paymentprofile_form>
293
+ <first_name>
294
+ <to_paymentprofile>*</to_paymentprofile>
295
+ </first_name>
296
+ <last_name>
297
+ <to_paymentprofile>*</to_paymentprofile>
298
+ </last_name>
299
+ <client_id>
300
+ <to_paymentprofile>*</to_paymentprofile>
301
+ </client_id>
302
+ <account_id>
303
+ <to_paymentprofile>*</to_paymentprofile>
304
+ </account_id>
305
+ <company>
306
+ <to_paymentprofile>*</to_paymentprofile>
307
+ </company>
308
+ <phone_number>
309
+ <to_paymentprofile>*</to_paymentprofile>
310
+ </phone_number>
311
+ <fax_number>
312
+ <to_paymentprofile>*</to_paymentprofile>
313
+ </fax_number>
314
+ <address>
315
+ <to_paymentprofile>*</to_paymentprofile>
316
+ </address>
317
+ <city>
318
+ <to_paymentprofile>*</to_paymentprofile>
319
+ </city>
320
+ <state>
321
+ <to_paymentprofile>*</to_paymentprofile>
322
+ </state>
323
+ <country>
324
+ <to_paymentprofile>*</to_paymentprofile>
325
+ </country>
326
+ <zip>
327
+ <to_paymentprofile>*</to_paymentprofile>
328
+ </zip>
329
+ <card_type>
330
+ <to_paymentprofile>*</to_paymentprofile>
331
+ </card_type>
332
+ <card_number>
333
+ <to_paymentprofile>*</to_paymentprofile>
334
+ </card_number>
335
+ <expiration_year>
336
+ <to_paymentprofile>*</to_paymentprofile>
337
+ </expiration_year>
338
+ <expiration_month>
339
+ <to_paymentprofile>*</to_paymentprofile>
340
+ </expiration_month>
341
+ <card_code>
342
+ <to_paymentprofile>*</to_paymentprofile>
343
+ </card_code>
344
+ </ipay_paymentprofile_form>
345
+ <ipay_paymentprofile_savecc_payment>
346
+ <cc_type>
347
+ <to_paymentprofile>card_type</to_paymentprofile>
348
+ </cc_type>
349
+ <cc_number>
350
+ <to_paymentprofile>card_number</to_paymentprofile>
351
+ </cc_number>
352
+ <cc_exp_year>
353
+ <to_paymentprofile>expiration_year</to_paymentprofile>
354
+ </cc_exp_year>
355
+ <cc_exp_month>
356
+ <to_paymentprofile>expiration_month</to_paymentprofile>
357
+ </cc_exp_month>
358
+ <cc_cid>
359
+ <to_paymentprofile>card_code</to_paymentprofile>
360
+ </cc_cid>
361
+ </ipay_paymentprofile_savecc_payment>
362
+ <ipay_paymentprofile_savecc_address>
363
+ <firstname>
364
+ <to_paymentprofile>first_name</to_paymentprofile>
365
+ </firstname>
366
+ <lastname>
367
+ <to_paymentprofile>last_name</to_paymentprofile>
368
+ </lastname>
369
+ <company>
370
+ <to_paymentprofile>*</to_paymentprofile>
371
+ </company>
372
+ <telephone>
373
+ <to_paymentprofile>phone_number</to_paymentprofile>
374
+ </telephone>
375
+ <fax_number>
376
+ <to_paymentprofile>*</to_paymentprofile>
377
+ </fax_number>
378
+ <street>
379
+ <to_paymentprofile>street_address</to_paymentprofile>
380
+ </street>
381
+ <city>
382
+ <to_paymentprofile>*</to_paymentprofile>
383
+ </city>
384
+ <state>
385
+ <to_paymentprofile>*</to_paymentprofile>
386
+ </state>
387
+ <country_id>
388
+ <to_paymentprofile>country</to_paymentprofile>
389
+ </country_id>
390
+ <postcode>
391
+ <to_paymentprofile>zip</to_paymentprofile>
392
+ </postcode>
393
+ </ipay_paymentprofile_savecc_address>
394
+ </fieldsets>
395
+ <events>
396
+ <sales_order_place_before>
397
+ <observers>
398
+ <ipay_order_payment_place_after>
399
+ <class>ipay/observer_checkout</class>
400
+ <method>placeOrderAfter</method>
401
+ <type>singleton</type>
402
+ </ipay_order_payment_place_after>
403
+ </observers>
404
+ </sales_order_place_before>
405
+ </events>
406
+ </global>
407
+ <frontend>
408
+ <layout>
409
+ <updates>
410
+ <ipay>
411
+ <file>ipay.xml</file>
412
+ </ipay>
413
+ </updates>
414
+ </layout>
415
+ <routers>
416
+ <ipay>
417
+ <use>standard</use>
418
+ <args>
419
+ <module>PlanetPayment_IpayGateway</module>
420
+ <frontName>ipay</frontName>
421
+ </args>
422
+ </ipay>
423
+ </routers>
424
+ <secure_url>
425
+ <uspslabel_order>/ipay/customer/</uspslabel_order>
426
+ </secure_url>
427
+ </frontend>
428
+ <crontab>
429
+ <jobs>
430
+ <ipay_log_clean>
431
+ <schedule>
432
+ <cron_expr>*/5 * * * *</cron_expr>
433
+ </schedule>
434
+ <run>
435
+ <model>ipay/observer_log::cleanLog</model>
436
+ </run>
437
+ </ipay_log_clean>
438
+ </jobs>
439
+ </crontab>
440
+ <admin>
441
+ <routers>
442
+ <ipayadmin>
443
+ <use>admin</use>
444
+ <args>
445
+ <module>PlanetPayment_IpayGateway</module>
446
+ <frontName>ipayadmin</frontName>
447
+ </args>
448
+ </ipayadmin>
449
+ </routers>
450
+ </admin>
451
+
452
+ <adminhtml>
453
+ <layout>
454
+ <updates>
455
+ <ipay>
456
+ <file>ipay.xml</file>
457
+ </ipay>
458
+ </updates>
459
+ </layout>
460
+ </adminhtml>
461
+ <default>
462
+ <payment>
463
+ <ipay>
464
+ <active>1</active>
465
+ <model>ipay/ipay</model>
466
+ <title>Credit Card (Planet Payment)</title>
467
+ <payment_action>authorize</payment_action>
468
+ <order_status>processing</order_status>
469
+ <currency>USD</currency>
470
+ <accepted_currencies>USD</accepted_currencies>
471
+ <service>pyc</service>
472
+ <cctypes>AE,VI,MC,DI,DIN,JCB</cctypes>
473
+ <tokenize>0</tokenize>
474
+ <logging>1</logging>
475
+ <validation_mode>none</validation_mode>
476
+ <debug>0</debug>
477
+ </ipay>
478
+ </payment>
479
+ <planet_payment>
480
+ <ipay_general>
481
+ <url>production</url>
482
+ <encryption>0</encryption>
483
+ </ipay_general>
484
+ <ipay_logging>
485
+ <mode>1</mode>
486
+ <lifetime>14</lifetime>
487
+ </ipay_logging>
488
+ </planet_payment>
489
+ <currency>
490
+ <ipay>
491
+ <logging>1</logging>
492
+ </ipay>
493
+ </currency>
494
+ </default>
495
+ </config>
app/code/community/PlanetPayment/IpayGateway/etc/system.xml ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <sections>
32
+ <payment>
33
+ <groups>
34
+ <ipay translate="label">
35
+ <label>Planet Payment iPAY Gateway</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>0</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>0</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>ipay/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>0</show_in_store>
67
+ </payment_action>
68
+ <order_status translate="label">
69
+ <label>New order status</label>
70
+ <frontend_type>select</frontend_type>
71
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
72
+ <sort_order>3</sort_order>
73
+ <show_in_default>1</show_in_default>
74
+ <show_in_website>1</show_in_website>
75
+ <show_in_store>0</show_in_store>
76
+ </order_status>
77
+ <currency translate="label">
78
+ <label>Native Currency</label>
79
+ <frontend_type>select</frontend_type>
80
+ <source_model>ipay/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>0</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>ipay/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>0</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
+ <cctypes translate="label">
114
+ <label>Credit Card Types</label>
115
+ <frontend_type>multiselect</frontend_type>
116
+ <source_model>ipay/system_config_payment_cctype</source_model>
117
+ <sort_order>7</sort_order>
118
+ <show_in_default>1</show_in_default>
119
+ <show_in_website>1</show_in_website>
120
+ <show_in_store>0</show_in_store>
121
+ </cctypes>
122
+ <tokenize translate="label">
123
+ <label>Store/Tokenize Credit Cards</label>
124
+ <frontend_type>select</frontend_type>
125
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
126
+ <sort_order>8</sort_order>
127
+ <show_in_default>1</show_in_default>
128
+ <show_in_website>1</show_in_website>
129
+ <show_in_store>0</show_in_store>
130
+ <comment>
131
+ Recommended. Allows customers to securely store
132
+ cards for future use and enables admin post-order
133
+ edits without re-collecting credit cards.
134
+ </comment>
135
+ </tokenize>
136
+ <logging translate="label">
137
+ <label>Logging</label>
138
+ <frontend_type>select</frontend_type>
139
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
140
+ <sort_order>9</sort_order>
141
+ <show_in_default>1</show_in_default>
142
+ <show_in_website>1</show_in_website>
143
+ <show_in_store>0</show_in_store>
144
+ <comment>
145
+ Recommended. Disable to suppress logging of
146
+ payment processing transactions even if global
147
+ logging is enabled in General > Planet Payment
148
+ </comment>
149
+ </logging>
150
+ <allowspecific translate="label">
151
+ <label>Payment from Applicable Countries</label>
152
+ <frontend_type>allowspecific</frontend_type>
153
+ <sort_order>10</sort_order>
154
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ </allowspecific>
159
+ <specificcountry translate="label">
160
+ <label>Payment from Specific Countries</label>
161
+ <frontend_type>multiselect</frontend_type>
162
+ <sort_order>11</sort_order>
163
+ <source_model>adminhtml/system_config_source_country</source_model>
164
+ <show_in_default>1</show_in_default>
165
+ <show_in_website>1</show_in_website>
166
+ <show_in_store>0</show_in_store>
167
+ </specificcountry>
168
+ <min_order_total translate="label">
169
+ <label>Minimum Order Total</label>
170
+ <frontend_type>text</frontend_type>
171
+ <sort_order>12</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>0</show_in_store>
175
+ </min_order_total>
176
+ <max_order_total translate="label">
177
+ <label>Maximum Order Total</label>
178
+ <frontend_type>text</frontend_type>
179
+ <sort_order>13</sort_order>
180
+ <show_in_default>1</show_in_default>
181
+ <show_in_website>1</show_in_website>
182
+ <show_in_store>0</show_in_store>
183
+ </max_order_total>
184
+ <system_purge translate="comment">
185
+ <label></label>
186
+ <frontend_model>ipay/adminhtml_system_config_purge</frontend_model>
187
+ <sort_order>200</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>0</show_in_website>
190
+ <show_in_store>0</show_in_store>
191
+ <comment>
192
+ <![CDATA[<strong style="color: red;">WARNING:
193
+ </strong> This will purge all payment
194
+ profiles and Planet Payment customer
195
+ data from Magento. Typically this is run
196
+ after switching from a test account to a
197
+ production account. This action cannot be
198
+ undone.]]>
199
+ </comment>
200
+ </system_purge>
201
+ </fields>
202
+ </ipay>
203
+ </groups>
204
+ </payment>
205
+ <planet_payment translate="label">
206
+ <label>Planet Payment</label>
207
+ <tab>general</tab>
208
+ <frontend_type>text</frontend_type>
209
+ <sort_order>100</sort_order>
210
+ <show_in_default>1</show_in_default>
211
+ <show_in_website>1</show_in_website>
212
+ <show_in_store>1</show_in_store>
213
+ <groups>
214
+ <ipay_general translate="label">
215
+ <label>General</label>
216
+ <frontend_type>text</frontend_type>
217
+ <frontend_type>text</frontend_type>
218
+ <sort_order>0</sort_order>
219
+ <show_in_default>1</show_in_default>
220
+ <show_in_website>1</show_in_website>
221
+ <show_in_store>1</show_in_store>
222
+ <fields>
223
+ <url translate="label">
224
+ <label>URL</label>
225
+ <frontend_type>select</frontend_type>
226
+ <source_model>ipay/system_config_general_mode</source_model>
227
+ <sort_order>0</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>0</show_in_store>
231
+ </url>
232
+ <key translate="label">
233
+ <label>Company Key</label>
234
+ <frontend_type>text</frontend_type>
235
+ <validate>required-entry</validate>
236
+ <sort_order>1</sort_order>
237
+ <show_in_default>1</show_in_default>
238
+ <show_in_website>1</show_in_website>
239
+ <show_in_store>0</show_in_store>
240
+ <comment>Required.</comment>
241
+ </key>
242
+ <terminal_id translate="label">
243
+ <label>Terminal Id</label>
244
+ <frontend_type>text</frontend_type>
245
+ <validate>required-entry</validate>
246
+ <sort_order>1</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>1</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ <comment>Required.</comment>
251
+ </terminal_id>
252
+ <pin translate="label">
253
+ <label>PIN</label>
254
+ <frontend_type>text</frontend_type>
255
+ <sort_order>2</sort_order>
256
+ <show_in_default>1</show_in_default>
257
+ <show_in_website>1</show_in_website>
258
+ <show_in_store>0</show_in_store>
259
+ <validate>validate-number</validate>
260
+ <!-- Commented Code, A conflicting info found in tech spec-->
261
+ <comment>4-digit numeric value required when Encryption is disabled</comment>
262
+ </pin>
263
+ <encryption translate="label">
264
+ <label>Encryption</label>
265
+ <frontend_type>select</frontend_type>
266
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
267
+ <sort_order>3</sort_order>
268
+ <show_in_default>1</show_in_default>
269
+ <show_in_website>1</show_in_website>
270
+ <show_in_store>0</show_in_store>
271
+ <comment>Recommended.</comment>
272
+ </encryption>
273
+ <encryption_type translate="label">
274
+ <label>Encryption Type</label>
275
+ <frontend_type>select</frontend_type>
276
+ <source_model>ipay/system_config_general_encryption</source_model>
277
+ <sort_order>4</sort_order>
278
+ <show_in_default>1</show_in_default>
279
+ <show_in_website>1</show_in_website>
280
+ <show_in_store>0</show_in_store>
281
+ <depends>
282
+ <encryption>1</encryption>
283
+ </depends>
284
+ </encryption_type>
285
+ <encryption_key translate="label">
286
+ <label>Encryption Key</label>
287
+ <frontend_type>text</frontend_type>
288
+ <sort_order>5</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>0</show_in_store>
292
+ <depends>
293
+ <encryption>1</encryption>
294
+ </depends>
295
+ </encryption_key>
296
+ <!--config_test translate="comment">
297
+ <label></label>
298
+ <frontend_model>ipay/adminhtml_system_config_test</frontend_model>
299
+ <sort_order>6</sort_order>
300
+ <show_in_default>1</show_in_default>
301
+ <show_in_website>0</show_in_website>
302
+ <show_in_store>0</show_in_store>
303
+ </config_test-->
304
+ </fields>
305
+ </ipay_general>
306
+ <ipay_logging translate="label">
307
+ <label>Logging</label>
308
+ <frontend_type>text</frontend_type>
309
+ <frontend_type>text</frontend_type>
310
+ <sort_order>1</sort_order>
311
+ <show_in_default>1</show_in_default>
312
+ <show_in_website>1</show_in_website>
313
+ <show_in_store>1</show_in_store>
314
+ <fields>
315
+ <mode translate="label">
316
+ <label>Log Mode</label>
317
+ <frontend_type>select</frontend_type>
318
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
319
+ <sort_order>0</sort_order>
320
+ <show_in_default>1</show_in_default>
321
+ <show_in_website>1</show_in_website>
322
+ <show_in_store>0</show_in_store>
323
+ <comment>
324
+ Recommended. Credit card numbers will be truncated
325
+ to the final four digits, and CVV numbers will be omitted.
326
+ </comment>
327
+ </mode>
328
+ <lifetime translate="label">
329
+ <label>Log Entry Lifetime</label>
330
+ <frontend_type>text</frontend_type>
331
+ <sort_order>1</sort_order>
332
+ <show_in_default>1</show_in_default>
333
+ <show_in_website>1</show_in_website>
334
+ <show_in_store>0</show_in_store>
335
+ <validate>required-entry</validate>
336
+ <comment>
337
+ Required. Days before entries are autopurged.
338
+ Smaller numbers recommended for high-traffic stores.
339
+ </comment>
340
+ </lifetime>
341
+ <export translate="comment">
342
+ <label></label>
343
+ <frontend_model>ipay/adminhtml_system_config_export</frontend_model>
344
+ <sort_order>6</sort_order>
345
+ <show_in_default>1</show_in_default>
346
+ <show_in_website>0</show_in_website>
347
+ <show_in_store>0</show_in_store>
348
+ </export>
349
+ </fields>
350
+ </ipay_logging>
351
+ </groups>
352
+ </planet_payment>
353
+ <currency>
354
+ <groups>
355
+ <ipay translate="label">
356
+ <label>Planet payment</label>
357
+ <frontend_type>text</frontend_type>
358
+ <frontend_type>text</frontend_type>
359
+ <sort_order>0</sort_order>
360
+ <show_in_default>1</show_in_default>
361
+ <show_in_website>1</show_in_website>
362
+ <show_in_store>1</show_in_store>
363
+ <fields>
364
+ <logging translate="label">
365
+ <label>Logging</label>
366
+ <frontend_type>select</frontend_type>
367
+ <source_model>adminhtml/system_config_source_enabledisable</source_model>
368
+ <sort_order>0</sort_order>
369
+ <show_in_default>1</show_in_default>
370
+ <show_in_website>1</show_in_website>
371
+ <show_in_store>0</show_in_store>
372
+ <comment>
373
+ Recommended. Disable to suppress logging of
374
+ payment processing transactions even if global
375
+ logging is enabled in General > Planet Payment
376
+ </comment>
377
+ </logging>
378
+ </fields>
379
+ </ipay>
380
+ </groups>
381
+ </currency>
382
+ </sections>
383
+ <currency_convertor>
384
+
385
+ </currency_convertor>
386
+ </config>
app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/install-1.0.0.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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'), 'ipay_profile_id', 'int(10)');
10
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'ipay_profile_id', 'int(10)');
11
+
12
+ // Sales Quote & Order Payment entities
13
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'ipay_profile_id', 'int(10)');
14
+ $installer->getConnection()->addColumn($installer->getTable('sales/quote_payment'), 'ipay_currency_code', 'varchar(10)');
15
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'ipay_profile_id', 'int(10)');
16
+ $installer->getConnection()->addColumn($installer->getTable('sales/order_payment'), 'ipay_currency_code', 'varchar(10)');
17
+
18
+ // Payment Profile
19
+ $installer->run("
20
+
21
+ DROP TABLE IF EXISTS `{$this->getTable('ipay/paymentProfile')}`;
22
+ CREATE TABLE `{$this->getTable('ipay/paymentProfile')}` (
23
+ `id` int(10) unsigned NOT NULL auto_increment,
24
+ `customer_id` int(10) unsigned NOT NULL,
25
+ `client_id` varchar(50),
26
+ `account_id` varchar(50),
27
+ `is_visible` tinyint(1) default 1,
28
+ `is_default` tinyint(1) default 0,
29
+ `card_type` varchar(255),
30
+ `card_number_last4` varchar(25),
31
+ `expiration_year` smallint(4),
32
+ `expiration_month` tinyint(2),
33
+ `first_name` varchar(50),
34
+ `last_name` varchar(50),
35
+ `company` varchar(50),
36
+ `address` varchar(60),
37
+ `city` varchar(40),
38
+ `state` varchar(40),
39
+ `zip` varchar(20),
40
+ `country` varchar(60),
41
+ `phone_number` varchar(25),
42
+ `fax_number` varchar(25),
43
+ `created` datetime,
44
+ `modified` datetime,
45
+
46
+ PRIMARY KEY (`id`)
47
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
48
+
49
+
50
+ DROP TABLE IF EXISTS `{$this->getTable('ipay/currencyCodes')}`;
51
+ CREATE TABLE `{$this->getTable('ipay/currencyCodes')}` (
52
+ `currency` varchar(10) NOT NULL,
53
+ `currency_code` varchar(5) NOT NULL,
54
+ PRIMARY KEY (`currency`)
55
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
56
+
57
+ DROP TABLE IF EXISTS `{$this->getTable('ipay/log')}`;
58
+ CREATE TABLE `{$this->getTable('ipay/log')}` (
59
+ `id` int(10) NOT NULL AUTO_INCREMENT,
60
+ `request` text NULL,
61
+ `response` text NULL,
62
+ `create_date` timestamp DEFAULT CURRENT_TIMESTAMP,
63
+ PRIMARY KEY (`id`)
64
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
65
+ ");
66
+
67
+ $installer->endSetup();
app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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/order_payment'), 'ipay_exchange_rate', 'float(15,6)');
10
+
11
+
12
+ $installer->endSetup();
app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.1-1.0.2.php ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
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'), 'ipay_exchange_rate', 'float(15,6)');
10
+
11
+
12
+ $installer->endSetup();
app/code/community/PlanetPayment/IpayGateway/sql/ipay_setup/mysql4-upgrade-1.0.2-1.0.5.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+ /* @var $installer Mage_Customer_Model_Entity_Setup */
5
+
6
+ $installer->startSetup();
7
+
8
+ //empty, but present to boost the version number in the db to 1.0.5
9
+
10
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/ipay.xml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <layout version="0.1.0">
3
+ <adminhtml_sales_order_create_index>
4
+ <reference name="head">
5
+ <action method="addItem">
6
+ <type>skin_js</type>
7
+ <name>js/ipay/ipay.js</name>
8
+ </action>
9
+ </reference>
10
+ </adminhtml_sales_order_create_index>
11
+ <ipayadmin_adminhtml_checkout_getIpayCurrencies>
12
+ <block type="ipay/adminhtml_checkout_ipay" name="root" output="toHtml" template="ipay/checkout/currency_selector.phtml"/>
13
+ </ipayadmin_adminhtml_checkout_getIpayCurrencies>
14
+ </layout>
app/design/adminhtml/default/default/template/ipay/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_IpayGateway
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_IpayGateway
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('ipayadmin/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/ipay/customer/tab/ipay.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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+
29
+ $ipayProfileId = $this->getIpayProfileId();
30
+ if (!$ipayProfileId) {
31
+ $ipayProfileId = $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('ipay')->__('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->getIpayProfileDeleteUrl($profile) ?>')"><span><?php echo $this->__('Delete Payment Profile') ?></span></button>
43
+ <strong><?php echo $this->__('Ipay Profile Client Id:') ?></strong> <?php echo $profile->getClientId() ?><br/>
44
+ <strong><?php echo $this->__('Ipay 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/ipay/payment/form.phtml ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
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: none;">
31
+ <?php if ($this->hasPaymentProfiles()) { ?>
32
+ <label for="<?php echo $_code ?>_payment_profile_id"><?php echo $this->__('Store Credit Cards') ?></label>
33
+ <div class="input-box" style="margin-bottom: 10px;">
34
+ <?php echo $this->getPaymentProfileSelectHtml() ?>
35
+ </div>
36
+ <?php } ?>
37
+ <?php $selectedProfile = $this->getSelectedProfile() ?>
38
+ <ul<?php if ($this->hasPaymentProfiles() && $selectedProfile->getId()) { ?> style="display: none;"<?php } ?>>
39
+ <li>
40
+ <label for="<?php echo $_code ?>_cc_type"><?php echo $this->__('Credit Card Type') ?> <span>*</span></label>
41
+ <div class="input-box">
42
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select ipay-payment">
43
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
44
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
45
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
46
+ <option value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
47
+ <?php endforeach ?>
48
+ </select>
49
+ </div>
50
+ </li>
51
+ <li>
52
+ <label for="<?php echo $_code ?>_cc_number"><?php echo $this->__('Credit Card Number') ?> <span class="required">*</span></label>
53
+ <div class="input-box">
54
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type ipay-payment" value="<?php echo $this->getInfoData('cc_number') ?>" />
55
+ </div>
56
+ </li>
57
+ <li id="<?php echo $_code ?>_cc_type_exp_div">
58
+ <label for="<?php echo $_code ?>_expiration"><?php echo $this->__('Expiration Date') ?> <span class="required">*</span></label>
59
+ <div class="input-box">
60
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry ipay-payment">
61
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
62
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
63
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
64
+ <?php endforeach ?>
65
+ </select>
66
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
67
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry ipay-payment">
68
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
69
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
70
+ <?php endforeach ?>
71
+ </select>
72
+ </div>
73
+ </li>
74
+ <?php echo $this->getChildHtml() ?>
75
+ <?php if ($this->hasVerification()): ?>
76
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
77
+ <label for="<?php echo $_code ?>_cc_cid"><?php echo $this->__('Card Verification Number') ?> <span class="required">*</span></label>
78
+ <div class="input-box">
79
+ <div class="v-fix">
80
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn ipay-payment" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="<?php echo $this->getInfoData('cc_cid') ?>" />
81
+ </div>
82
+ </div>
83
+ </li>
84
+ <?php endif; ?>
85
+ </ul>
86
+ <input type="hidden" name="payment[is_visible]" value="<?php echo $this->isGuestCheckout() ? '0' : '1' ?>" />
87
+
88
+ <div class="clearer"></div>
89
+ <?php if ($this->hasPaymentProfiles()) { ?>
90
+ <script type="text/javascript">
91
+ //<![CDATA[
92
+ var ipayPayment = new ipay.Payment(
93
+ 'payment_form_<?php echo $_code ?>',
94
+ '<?php echo $_code ?>_payment_profile_id',
95
+ 'p_method_<?php echo $_code ?>',
96
+ '<?php echo Mage::helper("adminhtml")->getUrl('ipayadmin/adminhtml_checkout/getIpayCurrencies'); ?>'
97
+ );
98
+ //]]>
99
+ </script>
100
+ <?php } ?>
101
+ <div id="currency_selector"></div>
102
+ </div>
app/design/adminhtml/default/default/template/ipay/payment/info.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * @see OnePica_IpayGateWay_Block_Info
30
+ */
31
+ ?>
32
+ <address>
33
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?><br />
34
+ <?php echo $this->__('Card Type: %s', $this->getCcTypeName()); ?><br />
35
+ <?php echo $this->__('Card Number: XXXX-%s', $this->getInfo()->getCcLast4()); ?><br />
36
+ <?php echo $this->__('Expiration: %s/%s', $this->getCcExpMonth(), $this->getInfo()->getCcExpYear()); ?><br />
37
+ <?php echo $this->__('Ipay Profile ID: %s', $this->getInfo()->getIpayProfileId()); ?><br />
38
+ <?php echo $this->__('Ipay Payment Currency: %s', $this->getInfo()->getIpayCurrencyCode()); ?>
39
+ </address>
app/design/adminhtml/default/default/template/ipay/system/config/export.phtml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * Export button template for the system config.
30
+ *
31
+ * @var $this OnePica_AuthnetCim_Block_Adminhtml_System_Config_Purge
32
+ */
33
+ ?>
34
+ <?php $htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
35
+ <button style="margin-bottom: 10px;" class="scalable" type="button" id="exportBtn<?php echo $htmlId ?>">
36
+ <span><?php echo Mage::helper('ipay')->__('Export Logs'); ?></span>
37
+ </button>
38
+ <script type="text/javascript">
39
+ //<![CDATA[
40
+ function redirectToPurge () {
41
+ if (confirm('<?php echo Mage::helper('ipay')->__("Are you sure you want to continue?") ?>')) {
42
+ window.location.href = '<?php echo $this->getExportUrl() ?>';
43
+ var btn = $('exportBtn<?php echo $htmlId ?>');
44
+ }
45
+ }
46
+ $('exportBtn<?php echo $htmlId ?>').observe('click', redirectToPurge);
47
+ //]]>
48
+ </script>
app/design/adminhtml/default/default/template/ipay/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_IpayGateway
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_IpayGateway
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('ipay')->__('Clear Profiles'); ?></span>
32
+ </button>
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ function redirectToPurge () {
36
+ if (confirm('<?php echo Mage::helper('ipay')->__("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/ipay/system/config/test.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * Purge buttont template for the system config.
30
+ *
31
+ * @var $this OnePica_AuthnetCim_Block_Adminhtml_System_Config_Purge
32
+ */
33
+ ?>
34
+ <?php $htmlId = $this->getHtmlId() ? $this->getHtmlId() : '_' . uniqid(); ?>
35
+ <button style="margin-bottom: 10px;" class="scalable" type="button" id="testBtn<?php echo $htmlId ?>">
36
+ <span><?php echo Mage::helper('ipay')->__('Test Configuration Values'); ?></span>
37
+ </button>
38
+ <script type="text/javascript">
39
+ //<![CDATA[
40
+ function redirectToPurge () {
41
+ window.location.href = '<?php echo $this->getTestUrl() ?>';
42
+ var btn = $('testBtn<?php echo $htmlId ?>');
43
+ btn.disable().addClassName('disabled');
44
+ }
45
+ $('testBtn<?php echo $htmlId ?>').observe('click', redirectToPurge);
46
+ //]]>
47
+ </script>
app/design/frontend/base/default/layout/ipay.xml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+
4
+ <!-- Customer Account handles -->
5
+ <customer_account>
6
+ <reference name="customer_account_navigation">
7
+ <action method="addLink" translate="label" module="ipay" ifconfig="payment/ipay/active">
8
+ <name>ipay_profile</name>
9
+ <path>ipay/profile</path>
10
+ <label>Stored Credit Card Profiles</label>
11
+ </action>
12
+ </reference>
13
+ </customer_account>
14
+
15
+ <ipay_profile_index>
16
+ <update handle="customer_account" />
17
+ <reference name="my.account.wrapper">
18
+ <block type="ipay/profile_list" name="ipay.profile.list" template="ipay/profile/list.phtml" />
19
+ </reference>
20
+ </ipay_profile_index>
21
+
22
+ <ipay_profile_edit>
23
+ <update handle="customer_account" />
24
+ <reference name="my.account.wrapper">
25
+ <block type="ipay/profile_edit" name="ipay.profile.edit" template="ipay/profile/edit.phtml" />
26
+ </reference>
27
+ </ipay_profile_edit>
28
+ <checkout_onepage_index>
29
+ <reference name="head">
30
+ <action method="addItem">
31
+ <type>skin_js</type>
32
+ <name>js/ipay/validation.js</name>
33
+ </action>
34
+ </reference>
35
+ <reference name="checkout.onepage">
36
+ <block type="ipay/onepage_ipay" name="checkout.onepage.ipay.currency.selector" as="currency_selector" after="checkout.onepage.payment" template="ipay/checkout/onepage/currency_selector.phtml"/>
37
+ </reference>
38
+ </checkout_onepage_index>
39
+ <checkout_onepage_ipay>
40
+ <remove name="right"/>
41
+ <remove name="left"/>
42
+ <block type="ipay/onepage_ipay" name="root" output="toHtml" template="ipay/checkout/onepage/currency_selector.phtml"/>
43
+ </checkout_onepage_ipay>
44
+ </layout>
app/design/frontend/base/default/template/ipay/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_IpayGateway
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_IpayGateway
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/ipay/payment/form.phtml ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
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: none;">
31
+ <?php if ($this->hasPaymentProfiles() && $this->isPaymentProfileEnabled()) { ?>
32
+ <label for="<?php echo $_code ?>_payment_profile_id"><?php echo $this->__('Stored Credit Cards') ?></label>
33
+ <div class="input-box" style="margin-bottom: 10px;">
34
+ <?php echo $this->getPaymentProfileSelectHtml() ?>
35
+ </div>
36
+ <?php } ?>
37
+ <ul<?php if ($this->hasPaymentProfiles() && $this->isPaymentProfileEnabled()) { ?> style="display: none;"<?php } ?>>
38
+ <li>
39
+ <label for="<?php echo $_code ?>_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
40
+ <div class="input-box">
41
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]" class="required-entry validate-cc-type-select">
42
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
43
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
44
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
45
+ <option value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
46
+ <?php endforeach ?>
47
+ </select>
48
+ </div>
49
+ </li>
50
+ <li>
51
+ <label for="<?php echo $_code ?>_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
52
+ <div class="input-box">
53
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="" />
54
+ </div>
55
+ </li>
56
+ <li id="<?php echo $_code ?>_cc_type_exp_div">
57
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
58
+ <div class="input-box">
59
+ <div class="v-fix">
60
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]" class="month validate-cc-exp required-entry">
61
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
62
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
63
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
64
+ <?php endforeach ?>
65
+ </select>
66
+ </div>
67
+ <div class="v-fix">
68
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
69
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]" class="year required-entry">
70
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
71
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
72
+ <?php endforeach ?>
73
+ </select>
74
+ </div>
75
+ </div>
76
+ </li>
77
+ <?php echo $this->getChildHtml() ?>
78
+ <?php if ($this->hasVerification()): ?>
79
+ <li id="<?php echo $_code ?>_cc_type_cvv_div">
80
+ <label for="<?php echo $_code ?>_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
81
+ <div class="input-box">
82
+ <div class="v-fix">
83
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid" name="payment[cc_cid]" value="" />
84
+ </div>
85
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
86
+ </div>
87
+ </li>
88
+ <?php endif; ?>
89
+
90
+ <?php if (!$this->isGuestCheckout() && $this->isPaymentProfileEnabled()) { ?>
91
+ <li class="control">
92
+ <div class="input-box" style="margin-left:0px;">
93
+ <input type="checkbox" name="payment[is_visible]" id="<?php echo $_code ?>_cc_save" value="1" title="<?php echo $this->__('Save this card') ?>" checked="checked" class="checkbox" />
94
+ <label for="<?php echo $_code ?>_cc_save"><?php echo $this->__('Save this card') ?></label>
95
+ </div>
96
+ </li>
97
+ <?php } ?>
98
+ </ul>
99
+ <?php if ($this->isGuestCheckout()) { ?>
100
+ <input type="hidden" name="payment[is_visible]" value="0" />
101
+ <?php } ?>
102
+ <div class="clearer"></div>
103
+ <?php if ($this->hasPaymentProfiles()) { ?>
104
+ <script type="text/javascript">
105
+ //<![CDATA[
106
+ $('<?php echo $_code ?>_payment_profile_id').observe('change', function () {
107
+ var list = $('payment_form_<?php echo $_code ?>').down('ul');
108
+ this.value ? list.hide() : list.show();
109
+ });
110
+ //]]>
111
+ </script>
112
+ <?php } ?>
113
+ <style type="text/css">
114
+ #payment_form_<?php echo $_code ?> ul { clear: left; }
115
+ #payment_form_<?php echo $_code ?> .control .input-box { float: left; margin-left: 170px; }
116
+ #payment_form_<?php echo $_code ?> .control label { float: none; display: inline; }
117
+ </style>
118
+ </div>
app/design/frontend/base/default/template/ipay/payment/info.phtml ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * @see OnePica_AuthnetCim_Block_Payment_Info
30
+ */
31
+ ?>
32
+ <address>
33
+ <?php echo $this->__('Card Type: %s', $this->getCcTypeName()); ?><br />
34
+ <?php echo $this->__('Card Number: XXXX-%s', $this->getInfo()->getCcLast4()); ?><br />
35
+ <?php echo $this->__('Expiration: %s/%s', $this->getCcExpMonth(), $this->getInfo()->getCcExpYear()); ?>
36
+ </address>
app/design/frontend/base/default/template/ipay/profile/edit.phtml ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * @see OnePica_IpayGateWay_Block_PaymentProfile_Edit
30
+ */
31
+ ?>
32
+ <?php $profile = $this->getIpayPaymentProfile() ?>
33
+ <?php if ($this->getTitle()): ?>
34
+ <div class="page-title">
35
+ <h1><?php echo $this->getTitle() ?></h1>
36
+ </div>
37
+ <?php endif; ?>
38
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
39
+ <form action="<?php echo $this->getPostUrl() ?>" method="post" id="form-validate">
40
+ <div class="fieldset">
41
+ <?php echo $this->getBlockHtml('formkey') ?>
42
+ <input type="hidden" name="profile_id" value="<?php echo $profile->getId() ?>" />
43
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
44
+ <input type="hidden" name="client_id" value="<?php echo $profile->getClientId() ?>" />
45
+ <input type="hidden" name="account_id" value="<?php echo $profile->getAccountId() ?>" />
46
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
47
+ <input type="hidden" name="payment[payment_profile_id]" value="<?php echo $profile->getId() ?>" />
48
+ <input type="hidden" name="payment[is_visible]" value="1" />
49
+
50
+ <h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
51
+ <ul class="form-list">
52
+ <li>
53
+ <label for="first_name" class="required"><em>*</em><?php echo $this->__('First Name') ?></label>
54
+ <div class="input-box">
55
+ <input type="text" name="first_name" id="first_name" title="<?php echo $this->__('First Name') ?>" value="<?php echo $this->htmlEscape($profile->getFirstName()) ?>" class="input-text required-entry" />
56
+ </div>
57
+ </li>
58
+ <li>
59
+ <label for="last_name" class="required"><em>*</em><?php echo $this->__('Last Name') ?></label>
60
+ <div class="input-box">
61
+ <input type="text" name="last_name" id="last_name" title="<?php echo $this->__('Last Name') ?>" value="<?php echo $this->htmlEscape($profile->getLastName()) ?>" class="input-text required-entry" />
62
+ </div>
63
+ </li>
64
+ <li>
65
+ <label for="company"><?php echo $this->__('Company') ?></label>
66
+ <div class="input-box">
67
+ <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($profile->getCompany()) ?>" class="input-text" />
68
+ </div>
69
+ </li>
70
+ <li>
71
+ <label for="phone_number" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
72
+ <div class="input-box">
73
+ <input type="text" name="phone_number" value="<?php echo $this->htmlEscape($profile->getPhoneNumber()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" id="phone_number" />
74
+ </div>
75
+ </li>
76
+ <?php /*
77
+ <li>
78
+ <label for="fax_number"><?php echo $this->__('Fax') ?></label>
79
+ <div class="input-box">
80
+ <input type="text" name="fax_number" id="fax_number" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" class="input-text" />
81
+ </div>
82
+ </li>
83
+ */ ?>
84
+ </ul>
85
+ </div>
86
+ <div class="fieldset">
87
+ <h2 class="legend"><?php echo $this->__('Payment Information') ?></h2>
88
+ <ul class="form-list">
89
+ <li>
90
+ <label for="ipay_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
91
+ <div class="input-box">
92
+ <select id="ipay_cc_type" name="card_type" class="required-entry validate-cc-type-select">
93
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
94
+ <?php $_ccType = $profile->getData('card_type') ?>
95
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
96
+ <option value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
97
+ <?php endforeach ?>
98
+ </select>
99
+ </div>
100
+ </li>
101
+ <li>
102
+ <label for="ipay_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
103
+ <div class="input-box">
104
+ <?php $cardNum = $profile->getCardNumberLast4() ? 'XXXX' . $profile->getCardNumberLast4() : '' ?>
105
+ <input type="text" id="ipay_cc_number" name="card_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="<?php echo $cardNum ?>" />
106
+ </div>
107
+ </li>
108
+ <li>
109
+ <label for="ipay_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
110
+ <div class="input-box">
111
+ <div class="v-fix">
112
+ <?php $_ccExpMonth = $profile->getExpirationMonth() ?>
113
+ <select id="ipay_expiration" name="expiration_month" class="month validate-cc-exp required-entry" style="width: auto;">
114
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
115
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
116
+ <?php endforeach ?>
117
+ </select>
118
+ </div>
119
+ <div class="v-fix" style="margin-left: 5px;">
120
+ <?php $_ccExpYear = $profile->getExpirationYear() ?>
121
+ <select id="ipay_expiration_yr" name="expiration_year" class="year required-entry" style="width: auto;">
122
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
123
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
124
+ <?php endforeach ?>
125
+ </select>
126
+ </div>
127
+ </div>
128
+ </li>
129
+ <?php if ($this->hasVerification()): ?>
130
+ <li>
131
+ <label for="ipay_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
132
+ <div class="input-box">
133
+ <div class="v-fix">
134
+ <?php $_ccCid = $profile->getId() ? 'XXX' : '' ?>
135
+ <input type="text" id="ipay_cc_cid" name="card_code" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" value="<?php echo $_ccCid ?>" />
136
+ </div>
137
+ </div>
138
+ </li>
139
+ <?php endif; ?>
140
+ </ul>
141
+ </div>
142
+ <div class="fieldset">
143
+ <h2 class="legend"><?php echo $this->__('Address') ?></h2>
144
+ <ul class="form-list">
145
+ <li>
146
+ <label for="address" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
147
+ <div class="input-box">
148
+ <input type="text" name="address" value="<?php echo $this->htmlEscape($profile->getAddress()) ?>" title="<?php echo $this->__(' Address') ?>" id="address" class="input-text required-entry" />
149
+ </div>
150
+ </li>
151
+ <li>
152
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
153
+ <div class="input-box">
154
+ <input type="text" name="city" value="<?php echo $this->htmlEscape($profile->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text required-entry" id="city" />
155
+ </div>
156
+ </li>
157
+ <li>
158
+ <label for="state" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
159
+ <div class="input-box">
160
+ <select id="state" name="state" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
161
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
162
+ </select>
163
+ <script type="text/javascript">
164
+ //<![CDATA[
165
+ $('state').setAttribute('defaultValue', "<?php echo $profile->getState() ?>");
166
+ //]]>
167
+ </script>
168
+ <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($profile->getState()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
169
+ </div>
170
+ </li>
171
+ <li>
172
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
173
+ <div class="input-box">
174
+ <input type="text" name="zip" value="<?php echo $this->htmlEscape($profile->getZip()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
175
+ </div>
176
+ </li>
177
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
178
+ <div class="input-box">
179
+ <?php echo $this->getCountryHtmlSelect($profile->getCountry(), 'country') ?>
180
+ </div>
181
+ </li>
182
+ </ul>
183
+ </div>
184
+ <div class="buttons-set">
185
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
186
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
187
+ <button type="submit" title="<?php echo $this->__('Save Stored Credit Card') ?>" class="button"><span><span><?php echo $this->__('Save Stored Credit Card') ?></span></span></button>
188
+ </div>
189
+ </form>
190
+ <script type="text/javascript">
191
+ //<![CDATA[
192
+ var dataForm = new VarienForm('form-validate', true);
193
+ new RegionUpdater('country', 'region', 'state', <?php echo $this->getRegionsJs() ?>, undefined, 'zip');
194
+ //]]>
195
+ </script>
app/design/frontend/base/default/template/ipay/profile/list.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_IpayGateway
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_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <div class="page-title title-buttons">
30
+ <h1><?php echo $this->__('Stored Credit Card Profiles') ?></h1>
31
+ <button type="button" class="button" onclick="location.href='<?php echo $this->getAddUrl() ?>';" title="<?php echo $this->__('Add New Credit Card Profile') ?>"><span><span><?php echo $this->__('Add New Credit Card Profile') ?></span></span></button>
32
+ </div>
33
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
34
+ <ul>
35
+ <?php $profiles = $this->getPaymentProfiles() ?>
36
+ <?php if (count($profiles)): ?>
37
+ <?php foreach ($profiles as $profile): ?>
38
+ <li class="info-box">
39
+ <dl>
40
+ <dt><?php echo $this->__('Name'); ?>:</dt>
41
+ <dd><?php echo $profile->getName(); ?></dd>
42
+ <?php if ($profile) { ?>
43
+ <dt><?php echo $this->__('Card Type'); ?>:</dt>
44
+ <dd><?php echo $profile->getCardTypeName(); ?></dd>
45
+ <dt><?php echo $this->__('Card Number'); ?>:</dt>
46
+ <dd><?php echo $this->__('Ends in') . ' ' . $profile->getCardNumberLast4(); ?></dd>
47
+ <?php } ?>
48
+ <dt><?php echo $this->__('Address'); ?>:</dt>
49
+ <dd><?php echo $profile->getAddress(); ?>, <?php echo $profile->getCity(); ?>, <?php echo $profile->getState(); ?> <?php echo $profile->getZip(); ?>, <?php echo $profile->getCountry(); ?></dd>
50
+ <dt><?php echo $this->__('Phone'); ?>:</dt>
51
+ <dd><?php echo $profile->getPhoneNumber(); ?></dd>
52
+ </dl>
53
+ <p class="actions">
54
+ <a style="margin-left: 0;" href="<?php echo $this->getEditUrl($profile) ?>"><?php echo $this->__('Edit') ?></a>
55
+ <a class="btn-blank" href="#" onclick="return deleteProfile('<?php echo $profile->getId() ?>');"><?php echo $this->__('Delete') ?></a>
56
+ </p>
57
+ </li>
58
+ <?php endforeach; ?>
59
+ <?php else: ?>
60
+ <li class="item empty">
61
+ <p><?php echo $this->__('You have no stored credit card profiles.') ?></p>
62
+ </li>
63
+ <?php endif ?>
64
+ </ul>
65
+ <script type="text/javascript">
66
+ //<![CDATA[
67
+ function deleteProfile (profileId) {
68
+ if (confirm('<?php echo $this->__('Are you sure you want to delete this profile?') ?>')) {
69
+ window.location='<?php echo $this->getDeleteUrl() ?>profile_id/' + profileId;
70
+ }
71
+ return false;
72
+ }
73
+ //]]>
74
+ </script>
75
+ <style type="text/css">
76
+ .info-box { float: left; width: 44%; margin-right: 2%; }
77
+ .info-box:nth-child(even) { float: right; margin-right: 0; }
78
+ .info-box dl { margin: 10px 17px 17px; }
79
+ .info-box dt { float: left; clear: left; width: 30%; margin-right: 5%; font-weight: bold; }
80
+ .info-box dd { float: left; width: 65%; }
81
+ p.actions { clear: both; padding: 10px 17px 17px; }
82
+ </style>
app/etc/modules/PlanetPayment_IpayGateway.xml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <PlanetPayment_IpayGateway>
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_IpayGateway>
14
+ </modules>
15
+ </config>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>planetpay_ipaygateway</name>
4
+ <version>1.0.7</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://www.opensource.org/licenses/osl-3.0.php">OSL v3.0</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Magento Payment Method and Currency Conversion extension to use service provided by Planet Payment.</summary>
10
+ <description>This extension connects Magento with Planet Payment's services for credit card authorization, capture, and tokenization as well as currency conversion. These services work in conjunction with the Planet Payment Pay In Your Own Currency offering.</description>
11
+ <notes>Fixed address and postal code length issue.</notes>
12
+ <authors><author><name>Brad Seeley</name><user>Planet_Payment</user><email>bseeley@planetpayment.com</email></author></authors>
13
+ <date>2013-02-15</date>
14
+ <time>19:52:41</time>
15
+ <contents><target name="magecommunity"><dir name="PlanetPayment"><dir name="IpayGateway"><dir name="Block"><dir name="Adminhtml"><dir name="Checkout"><file name="Ipay.php" hash="182c17e0d5e09414d3cf27376589b7ab"/></dir><dir name="Customer"><dir name="Edit"><dir name="Tab"><file name="Ipay.php" hash="956b006975c076cb2081f0752c8ec399"/></dir><file name="Tabs.php" hash="78aaf15df7948911e0a9431559d32cb0"/></dir></dir><dir name="Payment"><file name="Form.php" hash="dbf9dd9bebd9f66f664d98b63899fa95"/></dir><dir name="System"><dir name="Config"><file name="Export.php" hash="ddde70d886ea489ef912320ea294ee09"/><file name="Purge.php" hash="1b99e08eb0b8bbc953a97e21f984c202"/><file name="Test.php" hash="682ca2dbda014b99c63a3f1a110e14f1"/></dir></dir></dir><dir name="Checkout"><dir name="Cart"><file name="Totals.php" hash="b866dc528f5f3c658ffa0d7d9c6f6207"/></dir></dir><dir name="Onepage"><file name="Ipay.php" hash="022b9028c7d9dcdc9dfa7fd98f40e9f6"/></dir><file name="Onepage.php" hash="78f28311bd320c5ee380c1acedff59b8"/><dir name="Payment"><file name="Form.php" hash="3f59b6e03ef0b15ee9fb8884315937ef"/><file name="Info.php" hash="eb7656f7be047200aebb3f4041e5faaf"/></dir><dir name="Profile"><file name="Edit.php" hash="38a4a49c65c3b745429264451a7635c9"/><file name="List.php" hash="5c8dc5c49692aa3ad89efb416d3a4178"/></dir><file name="Profile.php" hash="c133c7d0a209a43157036039ba651ea6"/><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="2faceacdec03fda02db9e6adc93646d3"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="eaf6d87444ff75f0165a388fa0e1ff31"/><file name="Error.php" hash="bd89f38d7c0f40b9e5535ecbb43517a8"/></dir><dir name="Model"><dir name="Currency"><dir name="Import"><file name="Ipay.php" hash="7e0d6d080b5edcee3a859ce12e49fbce"/></dir></dir><file name="CurrencyCode.php" hash="be0b3c08579dbc12b8151bee2606701a"/><file name="Ipay.php" hash="125c93e620889f438a431408efb68fcb"/><file name="Log.php" hash="82988227a911bb94cd588b09b730f2c8"/><dir name="Observer"><file name="Abstract.php" hash="0b5664ea3ea368c765f96e48685293b4"/><file name="Checkout.php" hash="36b9158c4926dcf80046d3f3b0e95167"/><file name="Log.php" hash="593b418cb3b809912f704147c1f25764"/></dir><file name="Profile.php" hash="441a84fa0a8f5fabd5880b8f65301eb0"/><dir name="Resource"><dir name="CurrencyCode"><file name="Collection.php" hash="e9b7479f9861f7aa174d285f18ac61eb"/></dir><file name="CurrencyCode.php" hash="646ddf0e769a7b147d28314c832b478f"/><dir name="Log"><file name="Collection.php" hash="32a4ba8f218fc8d9f687b17b583c24ca"/></dir><file name="Log.php" hash="0059c5c9aa3e4461d02bf0bbf84d15b9"/><dir name="Profile"><file name="Collection.php" hash="d7d48eaddd9d7b6c628003676be5803a"/></dir><file name="Profile.php" hash="879fc6ab6e9129f2cd6fd820c1fef5ce"/></dir><dir name="System"><dir name="Config"><dir name="General"><file name="Encryption.php" hash="7984d196b3df8b6282e268df1016b1ed"/><file name="Mode.php" hash="db81d615ece105a7c563db50c8fd0904"/></dir><dir name="Payment"><file name="Cctype.php" hash="8f1058b3773e1ad28543f59d060ae896"/><file name="Currency.php" hash="0e2c8da05e96be6e47eed02703c1b0b2"/><file name="PaymentAction.php" hash="9f1a3a23f652ed719d3c44e32c8bce69"/><file name="Service.php" hash="5185f6f870978c3e49ead5a0226db564"/></dir></dir></dir><dir name="Type"><file name="Onepage.php" hash="4f4fa44c01a3001a110acac9f1bb8e65"/></dir><dir name="Xml"><file name="Abstract.php" hash="8fb9dee63f8d79461daf9b72466466e1"/><file name="Request.php" hash="29ffe9d3c58ea6da64567df66fb0227a"/><file name="Response.php" hash="dece576da81d92cfbc7aa93b0ebd3ee7"/></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="CheckoutController.php" hash="07d4f69bf5b076303812419386cb1a0b"/><file name="CustomerController.php" hash="0eea07ffbe04f45106ae13f22fc19107"/><file name="SystemController.php" hash="7542ac227ed6f2782351af1fdbff1e5c"/></dir><file name="OnepageController.php" hash="e1722c00f0baf28d6a2c505f5fbbdf5e"/><file name="ProfileController.php" hash="228ab8a66766b16b3c4fcaf0de669139"/></dir><dir name="data"><dir name="ipay_setup"><file name="data-install-1.0.0.php" hash="7dbf220ae77fc5daef6c90b5582a2be9"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="3400db9ec7a24b043b56d7a543ddeb8d"/><file name="config.xml" hash="da67b27cbcf8a572e1752e60651cfa54"/><file name="system.xml" hash="8cf956dd5409f3553e26c4b7d7ae4f6e"/></dir><dir name="sql"><dir name="ipay_setup"><file name="install-1.0.0.php" hash="1fe6875dca481be13d6f41659b74361f"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="7e3e98f72a28f9baeecfe983801477bc"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="91e00b2c24990e050a107bb14bc9ee29"/><file name="mysql4-upgrade-1.0.2-1.0.5.php" hash="9c7f23c309223b49c6ec94aadb814c69"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="ipay.xml" hash="7cc8bb7b73bb991486506173362bf3b7"/></dir><dir name="template"><dir name="ipay"><dir name="checkout"><file name="currency_selector.phtml" hash="ff26d9cf9d30e1e067c3f1694c0e8406"/></dir><dir name="customer"><dir name="tab"><file name="ipay.phtml" hash="6fcf00a1f2c8d2c558df47e523f6e70a"/></dir></dir><dir name="payment"><file name="form.phtml" hash="dfbc4f7a4974bcdea1df0451d46be9f3"/><file name="info.phtml" hash="f35c97559c914938a6346ab9d6b10157"/></dir><dir name="system"><dir name="config"><file name="export.phtml" hash="bf1d91b675c4b0373031319b33e7ff61"/><file name="purge.phtml" hash="27229f19017c26cae2b7b31e78217ded"/><file name="test.phtml" hash="afe3c4c241d731ef1f0e7c095ec47848"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><file name="ipay.xml" hash="845907b9121a40b3d28ba48cb31b07ab"/></dir><dir name="template"><dir name="ipay"><dir name="checkout"><dir name="onepage"><file name="currency_selector.phtml" hash="687c6584b51608fed2dc7dce8b865501"/></dir></dir><dir name="payment"><file name="form.phtml" hash="d9ff34b69b6494a1bd8201a8590c05f1"/><file name="info.phtml" hash="2709ff680077b76063d0d9ccc6071d05"/></dir><dir name="profile"><file name="edit.phtml" hash="db5e50dc2b954ed0f99d2c1430c5b992"/><file name="list.phtml" hash="826df04a5ae8d130394821df29397c24"/></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="PlanetPayment_IpayGateway.xml" hash="5cd7961acfa1306ae6fb5857c0ec3bdd"/></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="js"><dir name="ipay"><file name="ipay.js" hash="f565c7ae5dca369de75c3780a7920800"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="js"><dir name="ipay"><file name="validation.js" hash="3807a0a3cccb159013a690697c107f08"/></dir></dir></dir></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><package><name>Mage_Adminhtml</name><channel>core</channel><min></min><max></max></package><package><name>Mage_Checkout</name><channel>core</channel><min></min><max></max></package><package><name>Mage_Customer</name><channel>core</channel><min></min><max></max></package><package><name>Mage_Payment</name><channel>core</channel><min></min><max></max></package></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/js/ipay/ipay.js ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * IPAY Admin JS.
3
+ */
4
+ ipay = {};
5
+ ipay.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
+ $$(".ipay-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
+ });
skin/frontend/base/default/js/ipay/validation.js ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Hash with credit card types wich can be simply extended in payment modules
3
+ * 0 - regexp for card number
4
+ * 1 - regexp for cvn
5
+ * 2 - check or not credit card number trough Luhn algorithm by
6
+ * function validateCreditCard wich you can find above in this file
7
+ */
8
+ Validation.creditCartTypes = $H({
9
+ // 'SS': [new RegExp('^((6759[0-9]{12})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(6333[0-9]{12})|(6334[0-4]\d{11})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
10
+ 'SO': [new RegExp('^(6334[5-9]([0-9]{11}|[0-9]{13,14}))|(6767([0-9]{12}|[0-9]{14,15}))$'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
11
+ 'SM': [new RegExp('(^(5[0678])[0-9]{11,18}$)|(^(6[^05])[0-9]{11,18}$)|(^(601)[^1][0-9]{9,16}$)|(^(6011)[0-9]{9,11}$)|(^(6011)[0-9]{13,16}$)|(^(65)[0-9]{11,13}$)|(^(65)[0-9]{15,18}$)|(^(49030)[2-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49033)[5-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49110)[1-2]([0-9]{10}$|[0-9]{12,13}$))|(^(49117)[4-9]([0-9]{10}$|[0-9]{12,13}$))|(^(49118)[0-2]([0-9]{10}$|[0-9]{12,13}$))|(^(4936)([0-9]{12}$|[0-9]{14,15}$))'), new RegExp('^([0-9]{3}|[0-9]{4})?$'), true],
12
+ 'VI': [new RegExp('^4[0-9]{12}([0-9]{3})?$'), new RegExp('^[0-9]{3}$'), true],
13
+ 'MC': [new RegExp('^5[1-5][0-9]{14}$'), new RegExp('^[0-9]{3}$'), true],
14
+ 'AE': [new RegExp('^3[47][0-9]{13}$'), new RegExp('^[0-9]{4}$'), true],
15
+ 'DI': [new RegExp('^6011[0-9]{12}$'), new RegExp('^[0-9]{3}$'), true],
16
+ 'JCB': [new RegExp('^(3[0-9]{15}|(2131|1800)[0-9]{11})$'), new RegExp('^[0-9]{4}$'), true],
17
+ 'OT': [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), false],
18
+ 'DIN': [new RegExp('^(300[0-9]{11}|305[0-9]{11}|36[0-9]{12}|38[0-9]{12})$'), new RegExp('^[0-9]{3}$'), true]
19
+ });