CDev_XPaymentsConnector - Version 1.8.0

Version Notes

What's new?

1) Magento admin back-end
- Major improvement and revamp of connection and configuration - instead of multiple configuration pages admin user can do whole X-Payments connection and configuration on the same page now.
- Now you can configure up to 3 payment gateways supported by X-Payments in your Magento checkout.
- Admin user can save credit cards into customer profiles on behalf of customers.
- Admin can enter a new credit card to pay for a new order created in Magento back-end.
- “Saving credit card” setup is now available to Magento admin user.
- “X-Payments Order State” page redesigned. This page allows to do partial refunds/voids and capture authorized funds.
- Now the access to the X-Payments Connector features can be partially or completely restricted with the help of the Magento’s Roles and Permissions.
- Added support of the Developer Mode (Use HTTP protocol) for the. testing/development environment which do not have valid SSL certificate.

2) Customer front-end
- Checkout can have up to three X-Payments payment methods.
- Saving credit cards by customers has been revamped and improved.
- Support of the One step Checkout module by Ahead Works (beta).
- Automatically unset used coupon for the declined payments.
- Corrected free shipping calculation for the FireCheckout extension.
- Increased speed of the callback requests processing, which makes checkout. faster.
- Corrected store operation if the extension is switched off.

3) Code re-factoring (for the developers who extend the module features)
- Decomposed common extension helper. Now the different features such as API communication, preparing cart data, address processing and the module settings are separated by the different sequestered helpers.
- Reworked functionality which was handled by the observer. Instead it was changed according to the MVC design. E.g. request to charge the card again is executed by special API request from the certain controller.
- Corrected and simplified the inheritance tree. Internal quote model is used to transport data during the payment processing, and it doesn’t affect the quote class extensions made by other modules.
- Removed the unused legacy code. Code-style is improved
- Corrected version in the internal config file.
- Other minor bug-fixes and improvements.

Download this release

Release Info

Developer Alexander Mulin
Extension CDev_XPaymentsConnector
Version 1.8.0
Comparing to
See all releases


Code changes from version 1.7.1 to 1.8.0

Files changed (157) hide show
  1. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardnumber.php +2 -2
  2. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardtype.php +15 -9
  3. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Txnid.php +21 -11
  4. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Tab/Usercards.php +15 -7
  5. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/Pay.php +76 -0
  6. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View.php +54 -30
  7. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php +395 -78
  8. app/code/community/Cdev/XPaymentsConnector/Block/{Failure.php → Adminhtml/Settings/Help.php} +13 -19
  9. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab.php +98 -0
  10. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/Connection.php +125 -0
  11. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/PaymentMethods.php +322 -0
  12. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/Welcome.php +102 -0
  13. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/ZeroAuth.php +122 -0
  14. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tabs.php +89 -0
  15. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Xpc.php +72 -153
  16. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/System/Config/Form/Subselect.php +0 -101
  17. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Add.php +281 -0
  18. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php +62 -13
  19. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Iframe.php +143 -0
  20. app/code/community/Cdev/XPaymentsConnector/Block/Beforesuccess.php +0 -72
  21. app/code/community/Cdev/XPaymentsConnector/Block/Cancel.php +0 -59
  22. app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Orderdetail.php +2 -2
  23. app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/{Settings.php → Review/Cc.php} +15 -16
  24. app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Success.php +39 -74
  25. app/code/community/Cdev/XPaymentsConnector/Block/{Redirect.php → Checkout/Redirect.php} +29 -41
  26. app/code/community/Cdev/XPaymentsConnector/Block/{Return.php → Checkout/Return.php} +4 -8
  27. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php +0 -113
  28. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards.php +0 -112
  29. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/Add.php +179 -0
  30. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/Iframe.php +142 -0
  31. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/List.php +185 -0
  32. app/code/community/Cdev/XPaymentsConnector/Block/Form/Cc.php +5 -6
  33. app/code/community/Cdev/XPaymentsConnector/Block/Form/Prepaidpayments.php +0 -52
  34. app/code/community/Cdev/XPaymentsConnector/Block/Form/Savedcards.php +2 -2
  35. app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php +2 -2
  36. app/code/community/Cdev/XPaymentsConnector/Block/Info/Prepaidpayments.php +2 -2
  37. app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php +2 -2
  38. app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php +2 -2
  39. app/code/community/Cdev/XPaymentsConnector/Block/Success.php +0 -59
  40. app/code/community/Cdev/XPaymentsConnector/Helper/Abstract.php +74 -0
  41. app/code/community/Cdev/XPaymentsConnector/Helper/Address/Data.php +204 -0
  42. app/code/community/Cdev/XPaymentsConnector/Helper/Api/Data.php +738 -0
  43. app/code/community/Cdev/XPaymentsConnector/Helper/Cart/Data.php +310 -0
  44. app/code/community/Cdev/XPaymentsConnector/Helper/Data.php +165 -1014
  45. app/code/community/Cdev/XPaymentsConnector/Helper/Settings/Data.php +891 -0
  46. app/code/community/Cdev/XPaymentsConnector/Model/Adminhtml/System/Config/Source/Placedisplay.php +3 -3
  47. app/code/community/Cdev/XPaymentsConnector/Model/Fraudcheckdata.php +2 -2
  48. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Coupon/Usage.php +98 -0
  49. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Fraudcheckdata.php +2 -2
  50. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Fraudcheckdata/Collection.php +2 -2
  51. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration.php +2 -2
  52. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration/Collection.php +2 -2
  53. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Quote/Xpcdata.php +2 -2
  54. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Quote/Xpcdata/Collection.php +2 -2
  55. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards.php +2 -2
  56. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards/Collection.php +2 -2
  57. app/code/community/Cdev/XPaymentsConnector/Model/Observer.php +67 -410
  58. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Abstract.php +272 -0
  59. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php +92 -1769
  60. app/code/community/Cdev/XPaymentsConnector/{Block/Form/Container.php → Model/Payment/Cc1.php} +11 -11
  61. app/code/community/Cdev/XPaymentsConnector/{Block/Customer/Success.php → Model/Payment/Cc2.php} +9 -14
  62. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc3.php +32 -0
  63. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Prepaidpayments.php +0 -89
  64. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Recurring/Profile.php +6 -4
  65. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php +137 -158
  66. app/code/community/Cdev/XPaymentsConnector/Model/Paymentconfiguration.php +2 -2
  67. app/code/community/Cdev/XPaymentsConnector/Model/Quote.php +262 -25
  68. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php +5 -6
  69. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Discount.php +2 -2
  70. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Initialfee/Tax.php +2 -2
  71. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Xpcdata.php +18 -2
  72. app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php +169 -136
  73. app/code/community/Cdev/XPaymentsConnector/Model/Source/Paymentconfiguration.php +2 -2
  74. app/code/community/Cdev/XPaymentsConnector/Model/Usercards.php +96 -11
  75. app/code/community/Cdev/XPaymentsConnector/Transport/ApiResponse.php +92 -0
  76. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/AddnewcardController.php +203 -0
  77. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/CustomerController.php +49 -14
  78. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/CreateController.php +78 -0
  79. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/FraudController.php +0 -92
  80. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/PaymentController.php +370 -0
  81. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Settings/XpcController.php +573 -105
  82. app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php +154 -100
  83. app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php +482 -241
  84. app/code/community/Cdev/XPaymentsConnector/etc/adminhtml.xml +19 -13
  85. app/code/community/Cdev/XPaymentsConnector/etc/config.xml +65 -187
  86. app/code/community/Cdev/XPaymentsConnector/etc/system.xml +45 -217
  87. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-install-1.0.0.php +2 -2
  88. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.0-1.0.1.php +2 -2
  89. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.1-1.0.2.php +2 -2
  90. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.2-1.0.3.php +2 -2
  91. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.3-1.0.4.php +2 -2
  92. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.4-1.0.5.php +2 -2
  93. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.5-1.0.6.php +2 -2
  94. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.6-1.0.7.php +2 -2
  95. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.7-1.0.8.php +2 -2
  96. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.8-1.0.9.php +2 -2
  97. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.9-1.1.0.php +2 -2
  98. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.0-1.1.1.php +2 -2
  99. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.1-1.1.2.php +2 -2
  100. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.2-1.1.3.php +6 -6
  101. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.3-1.8.0.php +121 -0
  102. app/design/adminhtml/default/default/layout/xpaymentsconnector.xml +51 -7
  103. app/design/adminhtml/default/default/template/xpaymentsconnector/form/cc.phtml +30 -0
  104. app/design/adminhtml/default/default/template/xpaymentsconnector/form/prepaidpayments.phtml +3 -3
  105. app/design/adminhtml/default/default/template/xpaymentsconnector/form/savedcards.phtml +3 -4
  106. app/design/adminhtml/default/default/template/xpaymentsconnector/info.phtml +27 -9
  107. app/design/adminhtml/default/default/template/xpaymentsconnector/info/cc.phtml +2 -2
  108. app/design/adminhtml/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml +2 -2
  109. app/design/adminhtml/default/default/template/xpaymentsconnector/info/savedcards.phtml +2 -2
  110. app/design/adminhtml/default/default/template/xpaymentsconnector/order/pay.phtml +44 -0
  111. app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml +268 -253
  112. app/design/adminhtml/default/default/template/xpaymentsconnector/pdf/info.phtml +2 -2
  113. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/help.phtml +34 -0
  114. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/connection.phtml +139 -0
  115. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/payment_methods.phtml +157 -0
  116. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/welcome.phtml +90 -0
  117. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/zero_auth.phtml +86 -0
  118. app/design/adminhtml/default/default/template/xpaymentsconnector/settings/xpc.phtml +36 -143
  119. app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/add.phtml +82 -0
  120. app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/iframe.phtml +72 -0
  121. app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/tab/js.phtml +20 -5
  122. app/design/frontend/base/default/layout/xpaymentsconnector.xml +71 -55
  123. app/design/frontend/base/default/template/xpaymentsconnector/cancel.phtml +0 -49
  124. app/design/frontend/base/default/template/xpaymentsconnector/{blank.phtml → checkout/blank.phtml} +4 -3
  125. app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/beforesuccess.phtml +0 -94
  126. app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml +2 -2
  127. app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/review/button.phtml +2 -2
  128. app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/{xpayment-iframe.phtml → review/cc.phtml} +6 -9
  129. app/design/frontend/base/default/template/xpaymentsconnector/{redirectiframe.phtml → checkout/redirect.phtml} +4 -4
  130. app/design/frontend/base/default/template/xpaymentsconnector/{return.phtml → checkout/return.phtml} +8 -8
  131. app/design/frontend/base/default/template/xpaymentsconnector/checkout/success.phtml +48 -51
  132. app/design/frontend/base/default/template/xpaymentsconnector/{xpc_data.phtml → checkout/xpc_data.phtml} +3 -2
  133. app/design/frontend/base/default/template/xpaymentsconnector/customer/cardaddsuccess.phtml +0 -59
  134. app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/add.phtml +71 -0
  135. app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/cardadd.phtml +0 -139
  136. app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/iframe.phtml +72 -0
  137. app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/list.phtml +77 -85
  138. app/design/frontend/base/default/template/xpaymentsconnector/failure.phtml +0 -39
  139. app/design/frontend/base/default/template/xpaymentsconnector/form/cc.phtml +8 -13
  140. app/design/frontend/base/default/template/xpaymentsconnector/form/savedcards.phtml +3 -3
  141. app/design/frontend/base/default/template/xpaymentsconnector/info/cc.phtml +2 -2
  142. app/design/frontend/base/default/template/xpaymentsconnector/info/prepaidpayments.phtml +2 -2
  143. app/design/frontend/base/default/template/xpaymentsconnector/info/savedcards.phtml +2 -2
  144. app/design/frontend/base/default/template/xpaymentsconnector/redirect.phtml +0 -55
  145. app/etc/modules/Cdev_XPaymentsConnector.xml +1 -1
  146. app/locale/en_US/Cdev_XPaymentsConnector.csv +1 -2
  147. js/xpayment/add-new-card.css +36 -0
  148. js/xpayment/add-new-card.js +188 -0
  149. js/xpayment/backend-xpayment.js +36 -23
  150. js/xpayment/checkout-submit.js +204 -70
  151. js/xpayment/images/card_types.png +0 -0
  152. js/xpayment/images/pci_dss_compliance.png +0 -0
  153. js/xpayment/images/{atep-arrow.png → step-arrow.png} +0 -0
  154. js/xpayment/settings-xpc.css +98 -26
  155. js/xpayment/settings-xpc.js +218 -0
  156. js/xpayment/settings.css +52 -265
  157. package.xml +32 -30
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardnumber.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardtype.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,24 +13,29 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
- * Grid column rendering for'Card Type'
24
  */
25
-
26
- class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Renderer_Cardtype extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
27
  {
28
-
29
- public function render(Varien_Object $row){
30
-
 
 
 
 
 
 
31
  $cardType = $row->getData($this->getColumn()->getIndex());
32
 
33
- return '<span class="x-payment-card-logo-list '.strtolower($cardType).'"title="'.$cardType.'" ></span>';
34
  }
35
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * Grid column rendering for 'Card Type'
25
  */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Renderer_Cardtype extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
 
27
  {
28
+ /**
29
+ * Render row
30
+ *
31
+ * @param Varien_Object $row
32
+ *
33
+ * @return string
34
+ */
35
+ public function render(Varien_Object $row)
36
+ {
37
  $cardType = $row->getData($this->getColumn()->getIndex());
38
 
39
+ return '<span class="xpc-card-logo-list ' . strtolower($cardType) . '" title="' . $cardType . '"></span>';
40
  }
41
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Txnid.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,28 +13,37 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
  * Grid column rendering for'X-Payments order url'
24
  */
25
-
26
- class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Renderer_Txnid extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
27
  {
 
 
 
 
 
 
 
 
 
 
28
 
29
- public function render(Varien_Object $row){
 
 
 
30
 
31
- $txnid = $row->getData($this->getColumn()->getIndex());
32
- $xpayUrl = Mage::getModel('xpaymentsconnector/payment_cc')->getConfig('xpay_url').'admin.php?';
33
- $data = array('target'=>'payment', 'txnid'=>$txnid);
34
- $xpayQueryParam = http_build_query($data);
35
- $xpayQueryUrl = $xpayUrl.$xpayQueryParam;
36
 
37
- return '<a href="'. $xpayQueryUrl . '" target="_blank" >' . $txnid . '</a>';
38
  }
39
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Grid column rendering for'X-Payments order url'
25
  */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Renderer_Txnid extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
 
27
  {
28
+ /**
29
+ * Render row
30
+ *
31
+ * @param Varien_Object $row
32
+ *
33
+ * @return string
34
+ */
35
+ public function render(Varien_Object $row)
36
+ {
37
+ $txnid = $row->getData($this->getColumn()->getIndex());
38
 
39
+ $params = array(
40
+ 'target' => 'payment',
41
+ 'txnid' => $txnid,
42
+ );
43
 
44
+ $url = Mage::helper('settings_xpc')->getAdminUrl()
45
+ . http_build_query($params);
 
 
 
46
 
47
+ return '<a href="'. $url . '" target="_blank" >' . $txnid . '</a>';
48
  }
49
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Tab/Usercards.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,10 +13,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
@@ -28,7 +29,11 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Tab_Usercards
28
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
  {
30
 
31
-
 
 
 
 
32
  public function __construct()
33
  {
34
  parent::__construct();
@@ -66,19 +71,22 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Tab_Usercards
66
  }
67
 
68
  /**
69
- * Tab is hidden
70
  *
71
  * @return boolean
72
  */
73
  public function isHidden()
74
  {
75
- return false;
76
  }
77
 
 
 
 
 
 
78
  public function getGridUrl()
79
  {
80
  return $this->getUrl('*/*/usercards', array('_current'=> true));
81
  }
82
-
83
-
84
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
29
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
30
  {
31
 
32
+ /**
33
+ * Constructor
34
+ *
35
+ * @return void
36
+ */
37
  public function __construct()
38
  {
39
  parent::__construct();
71
  }
72
 
73
  /**
74
+ * Check if tab is hidden
75
  *
76
  * @return boolean
77
  */
78
  public function isHidden()
79
  {
80
+ return !Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/payment_cards');
81
  }
82
 
83
+ /**
84
+ * Get grid URL
85
+ *
86
+ * @return bool
87
+ */
88
  public function getGridUrl()
89
  {
90
  return $this->getUrl('*/*/usercards', array('_current'=> true));
91
  }
 
 
92
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/Pay.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Payment form block for the backend order
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_Pay extends Mage_Adminhtml_Block_Template
27
+ {
28
+ /**
29
+ * Payment form fields
30
+ */
31
+ private $fields = null;
32
+
33
+ /**
34
+ * Set fields for payment form
35
+ *
36
+ * @param array $fields Payment for fields
37
+ *
38
+ * @return Mage_Adminhtml_Block_Template
39
+ */
40
+ public function setFields($fields)
41
+ {
42
+ $this->fields = $fields;
43
+
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Get fields for payment form
49
+ *
50
+ * @return array
51
+ */
52
+ public function getFields()
53
+ {
54
+ return $this->fields;
55
+ }
56
+
57
+ /**
58
+ * Get form action (URL)
59
+ *
60
+ * @return string
61
+ */
62
+ public function getFormAction()
63
+ {
64
+ return Mage::helper('settings_xpc')->getPaymentUrl();
65
+ }
66
+
67
+ /**
68
+ * Constructor
69
+ *
70
+ * @return void
71
+ */
72
+ protected function _construct()
73
+ {
74
+ $this->setTemplate('xpaymentsconnector/order/pay.phtml');
75
+ }
76
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,55 +13,78 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
23
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
 
 
 
 
 
25
  public function __construct()
26
  {
27
-
28
  parent::__construct();
29
 
30
  $order = $this->getOrder();
31
  $txnid = $order->getData('xpc_txnid');
32
- list($transactionStatus, $transactionInfo)
33
- = Mage::getModel('xpaymentsconnector/payment_cc')->requestPaymentInfo($txnid, false, true);
34
 
35
- if ($transactionStatus) {
36
- if(isset($transactionInfo['payment']['isFraudStatus']) && $transactionInfo['payment']['isFraudStatus']){
37
- $admSession = Mage::getSingleton('adminhtml/session');
38
- $messageText = "This transaction has been identified as possibly fraudulent, press 'Accept'".
39
- " to confirm the acceptance of the transaction or 'Decline' to cancel it.";
40
- $message = $this->__($messageText);
41
- $admSession->addNotice($message);
42
 
43
- $activeMessage = Mage::helper('xpaymentsconnector')->__('Are you sure you want to accept this order transaction?');
44
- $this->_addButton('active', array(
45
- 'label' => Mage::helper('xpaymentsconnector')->__('Accept'),
46
- 'onclick' => "confirmSetLocation('{$activeMessage}', '{$this->getRequestFraudUrl('accept')}')",
47
- 'class' => 'fraud-button'
48
- ), -1);
49
 
50
- $cancelMessage = Mage::helper('xpaymentsconnector')->__('Are you sure you want to decline this order transaction?');
51
- $this->_addButton('decline', array(
52
- 'label' => Mage::helper('xpaymentsconnector')->__('Decline'),
53
- 'onclick' => "confirmSetLocation('{$cancelMessage}', '{$this->getRequestFraudUrl('decline')}')",
54
- 'class' => 'fraud-button'
55
- ), -1);
56
- }
57
 
58
- }
59
- }
60
 
 
 
 
 
 
 
 
 
 
61
 
62
- public function getRequestFraudUrl($action)
63
- {
64
- return $this->getUrl('*/sales_order_fraud/'.$action);
 
 
 
 
 
 
 
65
  }
66
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View extends Mage_Adminhtml_Block_Sales_Order_View
24
  {
25
+ /**
26
+ * Get code for the button's onclick
27
+ *
28
+ * @param string $action Action
29
+ * @param string $message Confirmation message
30
+ *
31
+ * @return string
32
+ */
33
+ private function getOnClick($action, $message)
34
+ {
35
+ $url = $this->getUrl('*/sales_order_payment/' . $action);
36
+
37
+ $message = Mage::helper('xpaymentsconnector')->__($message);
38
+
39
+ // Quotes here are important!
40
+ return 'confirmSetLocation(\'' . $message .'\', \'' . $url . '\');';
41
+ }
42
 
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @return void
47
+ */
48
  public function __construct()
49
  {
 
50
  parent::__construct();
51
 
52
  $order = $this->getOrder();
53
  $txnid = $order->getData('xpc_txnid');
 
 
54
 
55
+ $response = Mage::helper('api_xpc')->requestPaymentInfo($txnid, false, true);
 
 
 
 
 
 
56
 
57
+ if (
58
+ $response->getStatus()
59
+ && $response->getField('payment')['isFraudStatus']
60
+ ) {
 
 
61
 
62
+ $session = Mage::getSingleton('adminhtml/session');
63
+
64
+ $message = $this->__('This transaction has been identified as possibly fraudulent, press "Accept" '
65
+ . 'to confirm the acceptance of the transaction or "Decline" to cancel it.');
 
 
 
66
 
67
+ $session->addNotice($message);
 
68
 
69
+ $this->_addButton(
70
+ 'active',
71
+ array(
72
+ 'label' => Mage::helper('xpaymentsconnector')->__('Accept'),
73
+ 'onclick' => $this->getOnClick('accept', 'Are you sure you want to accept this order transaction?'),
74
+ 'class' => 'fraud-button',
75
+ ),
76
+ -1
77
+ );
78
 
79
+ $this->_addButton(
80
+ 'decline',
81
+ array(
82
+ 'label' => Mage::helper('xpaymentsconnector')->__('Decline'),
83
+ 'onclick' => $this->getOnClick('decline', 'Are you sure you want to decline this order transaction?'),
84
+ 'class' => 'fraud-button',
85
+ ),
86
+ -1
87
+ );
88
+ }
89
  }
90
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,10 +13,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
@@ -27,15 +28,143 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
27
  extends Mage_Adminhtml_Block_Sales_Order_Abstract
28
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
  {
30
- public $txnid;
31
- public $transactionStatus;
32
- public $transactionInfo;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  protected function _construct()
35
  {
36
- $this->txnid = $this->getOrder()->getData("xpc_txnid");
37
  $this->setTemplate('xpaymentsconnector/order/view/tab/xporderstate.phtml');
38
 
 
 
 
 
 
 
 
 
 
 
 
 
 
39
  }
40
 
41
  /**
@@ -59,103 +188,291 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
59
  }
60
 
61
  /**
62
- * ######################## TAB settings #################################
 
 
63
  */
64
- public function getTabLabel()
65
  {
66
- return Mage::helper('xpaymentsconnector')->__('X-Payment Order State');
67
  }
68
 
69
- public function getTabTitle()
 
 
 
 
 
70
  {
71
- return Mage::helper('xpaymentsconnector')->__('X-Payment Order State');
72
  }
73
 
74
- public function canShowTab()
 
 
 
 
 
75
  {
76
- return true;
77
  }
78
 
79
- public function getXpaymentsOrderInfo(){
80
- $result = array();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
81
 
82
- if (empty($this->txnid) && empty($this->transactionInfo)) {
83
- $orderBroken = Mage::helper('xpaymentsconnector')->__("This order has been broken. Parameter 'xpayments transaction id' is not available.");
84
- $result['success'] = false;
85
- $result['error_message'] = $orderBroken;
86
- return $result;
87
  }
88
 
89
- if (!$this->transactionStatus || empty($this->transactionInfo)) {
90
- $xpaymentsConnect = Mage::helper('xpaymentsconnector')->__("Can't get information about the order from X-Payments server. More information is available in log files.");
91
- $result['success'] = false;
92
- $result['error_message'] = $xpaymentsConnect;
93
- } else {
94
- $result['success'] = true;
95
- $result['info'] = $this->transactionInfo;
96
  }
97
 
98
- return $result;
99
  }
100
 
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- public function isHidden()
 
 
 
 
 
 
 
 
 
 
103
  {
 
 
 
 
104
 
105
- $currentOrder = $this->getOrder();
106
- $currentPaymentCode = $currentOrder->getPayment()->getMethodInstance()->getCode();
107
- $isXpaymentsMethod = Mage::helper('xpaymentsconnector')->isXpaymentsMethod($currentPaymentCode);
108
-
109
-
110
- if($isXpaymentsMethod){
111
- $xpPaymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
112
-
113
- if($this->txnid){
114
- list($this->transactionStatus, $this->transactionInfo[$currentOrder->getIncrementId()])
115
- = $xpPaymentCcModel->requestPaymentInfo($this->txnid,false,true);
116
- if($this->transactionStatus){
117
- $this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $this->txnid;
118
- }
119
- }
120
-
121
- while(!is_null($parentOrder = $currentOrder->getRelationParentId())){
122
- $currentOrder = Mage::getModel('sales/order')->load($parentOrder);
123
- if ($currentOrder) {
124
- $txnid = $currentOrder->getData('xpc_txnid');
125
- if($txnid){
126
- list($transactionStatus, $transactionInfo)
127
- = $xpPaymentCcModel->requestPaymentInfo($txnid, false, true);
128
- if ($transactionStatus) {
129
- $this->transactionInfo[$currentOrder->getIncrementId()] = $transactionInfo;
130
- $this->transactionInfo[$currentOrder->getIncrementId()]['payment']['xpc_txnid'] = $txnid;
131
- }
132
- }
133
- }
134
- }
135
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
136
 
137
- return !$isXpaymentsMethod;
 
 
 
 
 
 
 
 
 
138
 
 
139
  }
140
 
141
  /**
142
- * Calculate order action available amount
143
- * @param array $xpOrderStateData
144
- * @return float
 
 
145
  */
146
- public function getCurrentActionAmount($xpOrderStateData){
147
- $actionAmount = 0.00;
148
- switch (true) {
149
- case ($xpOrderStateData['capturedAmountAvail'] > 0 && $xpOrderStateData['refundedAmountAvail'] < 0.01):
150
- $actionAmount = $xpOrderStateData['capturedAmountAvailGateway'];
151
- break;
152
- case ($xpOrderStateData['refundedAmountAvail'] > 0 && $xpOrderStateData['capturedAmountAvail'] < 0.01):
153
- $actionAmount = $xpOrderStateData['refundedAmountAvail'];
154
- break;
155
- case ($actionAmount < 0.01 && $xpOrderStateData['chargedAmount'] > 0):
156
- $actionAmount = $xpOrderStateData['chargedAmount'];
157
- break;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
158
  }
159
- return $actionAmount;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
161
- }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
28
  extends Mage_Adminhtml_Block_Sales_Order_Abstract
29
  implements Mage_Adminhtml_Block_Widget_Tab_Interface
30
  {
31
+ /**
32
+ * Is it X-Payments payment method or not
33
+ */
34
+ private $isXpc = null;
35
+
36
+ /**
37
+ * List of payment transactions
38
+ */
39
+ private $transactions = array();
40
+
41
+ /**
42
+ * List of order/payment data
43
+ */
44
+ private $orderData = array();
45
+
46
+ /**
47
+ * Error message
48
+ */
49
+ private $error = '';
50
+
51
+ /**
52
+ * ######################## TAB settings #################################
53
+ */
54
+ public function getTabLabel()
55
+ {
56
+ return Mage::helper('xpaymentsconnector')->__('X-Payments Order State');
57
+ }
58
+
59
+ public function getTabTitle()
60
+ {
61
+ return Mage::helper('xpaymentsconnector')->__('X-Payments Order State');
62
+ }
63
+
64
+ public function canShowTab()
65
+ {
66
+ return true;
67
+ }
68
+
69
+ public function isHidden()
70
+ {
71
+ return !$this->isXpc();
72
+ }
73
+ /**
74
+ * ######################## /TAB settings #################################
75
+ */
76
+
77
+
78
+ /**
79
+ * Check method code. Is it X-Payments paymet method or not
80
+ *
81
+ * @return bool
82
+ */
83
+ private function isXpc()
84
+ {
85
+ if (is_null($this->isXpc)) {
86
+
87
+ $this->isXpc = false;
88
+
89
+ if (
90
+ $this->getOrder()->getPayment()
91
+ && $this->getOrder()->getPayment()->getMethodInstance()->getCode()
92
+ ) {
93
+ $this->isXpc = Mage::helper('settings_xpc')->isXpcMethod(
94
+ $this->getOrder()->getPayment()->getMethodInstance()->getCode()
95
+ );
96
+ }
97
+ }
98
+
99
+ return $this->isXpc;
100
+ }
101
+
102
+ /**
103
+ * Process payment info request and save data internally
104
+ *
105
+ * @param Mage_Sales_Model_Order $order Order
106
+ * @param bool $saveError Is it necessary to save the error message
107
+ *
108
+ * @return void
109
+ */
110
+ private function processPaymentInfoRequest(Mage_Sales_Model_Order $order, $saveError = true)
111
+ {
112
+ if (
113
+ empty($order->getId())
114
+ || empty($order->getData('xpc_txnid'))
115
+ ) {
116
+ return;
117
+ }
118
+
119
+ $orderId = $order->getIncrementId();
120
+ $txnId = $order->getData('xpc_txnid');
121
+
122
+ $response = Mage::helper('api_xpc')
123
+ ->requestPaymentInfo($txnId, false, true);
124
+
125
+ if (
126
+ !$response->getStatus()
127
+ && $saveError
128
+ ) {
129
+
130
+ $this->error = $response->getErrorMessage(
131
+ 'Can\'t get information about the order from X-Payments server. More information is available in the log files.'
132
+ );
133
+ }
134
 
135
+ if (!empty($response->getField('transactions'))) {
136
+ $this->transactions[$orderId] = $response->getField('transactions');
137
+ }
138
+
139
+ if (!empty($response->getField('payment'))) {
140
+ $this->orderData[$orderId] = $response->getField('payment');
141
+ $this->orderData[$orderId]['xpc_txnid'] = $order->getData('xpc_txnid');
142
+ }
143
+ }
144
+
145
+ /**
146
+ * Constructor
147
+ * Communicate with X-Payments and adjust properties
148
+ *
149
+ * @return void
150
+ */
151
  protected function _construct()
152
  {
 
153
  $this->setTemplate('xpaymentsconnector/order/view/tab/xporderstate.phtml');
154
 
155
+ if ($this->isXpc()) {
156
+
157
+ $this->processPaymentInfoRequest($this->getOrder());
158
+
159
+ $order = $this->getOrder();
160
+
161
+ while (!is_null($parentId = $order->getRelationParentId())) {
162
+
163
+ $order = Mage::getModel('sales/order')->load($parentId);
164
+
165
+ $this->processPaymentInfoRequest($order, false);
166
+ }
167
+ }
168
  }
169
 
170
  /**
188
  }
189
 
190
  /**
191
+ * Get transactions associated with order
192
+ *
193
+ * @return array
194
  */
195
+ public function getTransactions()
196
  {
197
+ return $this->transactions;
198
  }
199
 
200
+ /**
201
+ * Get Order/Payment data associated with order
202
+ *
203
+ * @return array
204
+ */
205
+ public function getOrderData()
206
  {
207
+ return $this->orderData;
208
  }
209
 
210
+ /**
211
+ * Get error message
212
+ *
213
+ * @return array
214
+ */
215
+ public function getError()
216
  {
217
+ return $this->error;
218
  }
219
 
220
+ /**
221
+ * Calculate order action available amount
222
+ *
223
+ * @param array $data Payment data
224
+ *
225
+ * @return float
226
+ */
227
+ public function getActionAmount($data)
228
+ {
229
+ // Legacy logic in calculation is used here, and it works.
230
+ // So let it be for now.
231
+
232
+ $amount = 0.00;
233
+
234
+ if (
235
+ $data['capturedAmountAvail'] > 0
236
+ && $data['refundedAmountAvail'] < 0.01
237
+ ) {
238
+
239
+ $amount = $data['capturedAmountAvailGateway'];
240
+
241
+ } elseif (
242
+ $data['refundedAmountAvail'] > 0
243
+ && $data['capturedAmountAvail'] < 0.01
244
+ ) {
245
 
246
+ $amount = $data['refundedAmountAvail'];
 
 
 
 
247
  }
248
 
249
+ if ($amount < 0.01 && $data['chargedAmount'] > 0) {
250
+
251
+ $amount = $data['chargedAmount'];
 
 
 
 
252
  }
253
 
254
+ return $amount;
255
  }
256
 
257
+ /**
258
+ * Return image SRC for arrow
259
+ *
260
+ * @param string $arrow Arrow, up or down
261
+ *
262
+ * @return string
263
+ */
264
+ public function getArrowImg($arrow)
265
+ {
266
+ if (!in_array($arrow, array('up', 'down'))) {
267
+ $arrow = 'up';
268
+ }
269
 
270
+ return Mage::getBaseUrl('js') . 'xpayment/images/arrow-' . $arrow . '.png';
271
+ }
272
+
273
+ /**
274
+ * Get CSS class for the row in transactions table.
275
+ *
276
+ * @param int $row Row number. By default it should be "odd", so default value is 1.
277
+ *
278
+ * @return string
279
+ */
280
+ public function getRowClass($row = 1)
281
  {
282
+ return ($row % 2 == 0)
283
+ ? 'even'
284
+ : 'odd';
285
+ }
286
 
287
+ /**
288
+ * Format transaction date and time
289
+ *
290
+ * @param array $data Transaction data
291
+ *
292
+ * @return string
293
+ */
294
+ public function getTransactionDateTime($data)
295
+ {
296
+ return date('F d, Y H:i:s e', $data['date']);
297
+ }
298
+
299
+ /**
300
+ * Format transaction date
301
+ *
302
+ * @param array $data Transaction data
303
+ *
304
+ * @return string
305
+ */
306
+ public function getTransactionDate($data)
307
+ {
308
+ return date('F d, Y', $data['date']);
309
+ }
310
+
311
+ /**
312
+ * Format transaction time
313
+ *
314
+ * @param array $data Transaction data
315
+ *
316
+ * @return string
317
+ */
318
+ public function getTransactionTime($data)
319
+ {
320
+ return date('H:i', $data['date']);
321
+ }
322
+
323
+ /**
324
+ * Get DOM form ID
325
+ *
326
+ * @param string $orderId Order ID
327
+ *
328
+ * @return string
329
+ */
330
+ public function getFormId($orderId)
331
+ {
332
+ return 'xp_fast_transactions_' . $orderId;
333
+ }
334
 
335
+ /**
336
+ * Get form action URL
337
+ *
338
+ * @return string
339
+ */
340
+ public function getFormUrl()
341
+ {
342
+ $params = array(
343
+ 'order_id' => $this->getOrder()->getEntityId(),
344
+ );
345
 
346
+ return $this->getUrl('adminhtml/sales_order_payment/secondary', $params);
347
  }
348
 
349
  /**
350
+ * Get JS validator name for the amount field
351
+ *
352
+ * @param string $orderId Order ID
353
+ *
354
+ * @return string
355
  */
356
+ public function getAmountValidatorName($orderId)
357
+ {
358
+ return 'validate-transaction-amount_' . $orderId;
359
+ }
360
+
361
+ /**
362
+ * Get JS required validator name for the amount field
363
+ *
364
+ * @param string $orderId Order ID
365
+ *
366
+ * @return string
367
+ */
368
+ public function getRequiredValidatorName($orderId)
369
+ {
370
+ return 'required-entry_' . $orderId;
371
+ }
372
+
373
+ /**
374
+ * Get CSS class name for the transaction amount input field
375
+ *
376
+ * @param string $orderId Order ID
377
+ *
378
+ * @return string
379
+ */
380
+ public function getAmountInputClass($orderId)
381
+ {
382
+ $class = array(
383
+ $this->getAmountValidatorName($orderId),
384
+ $this->getRequiredValidatorName($orderId),
385
+ 'input-text',
386
+ 'transaction-amount',
387
+ );
388
+
389
+ return implode(' ', $class);
390
+ }
391
+
392
+ /**
393
+ * Get onclick JS code for action button (Capture, Refund, Void)
394
+ *
395
+ * @param string $action Action
396
+ * @param string $orderId Order ID
397
+ * @param string $amount Amount
398
+ *
399
+ * @return string
400
+ */
401
+ public function getOnClick($action, $orderId, $amount = false)
402
+ {
403
+ $params = array(
404
+ $action,
405
+ $this->getFormId($orderId),
406
+ $this->getAmountValidatorName($orderId),
407
+ $this->getRequiredValidatorName($orderId),
408
+ );
409
+
410
+ if ($amount) {
411
+ $params[] = $amount;
412
  }
413
+
414
+ return 'submitXpcTransaction(\'' . implode("', '", $params) . '\')';
415
+ }
416
+
417
+ /**
418
+ * Get name for the Void button with amount
419
+ *
420
+ * @param array $data Order/Payment data
421
+ *
422
+ * @return string
423
+ */
424
+ public function getVoidValue($data)
425
+ {
426
+ return 'Void (' . Mage::helper('core')->currency($data['voidedAmountAvail'], true, false) . ')';
427
+ }
428
+
429
+ /**
430
+ * Get fraud check data for Order/Payment
431
+ *
432
+ * @return Cdev_XPaymentsConnector_Model_Fraudcheckdata
433
+ */
434
+ public function getFraudCheckData()
435
+ {
436
+ return Mage::getModel('xpaymentsconnector/fraudcheckdata')
437
+ ->getCollection()
438
+ ->addFieldToFilter('order_id', $this->getOrder()->getId());
439
+ }
440
+
441
+ /**
442
+ * Check if payment is required for the order created in the backend
443
+ *
444
+ * @return bool
445
+ */
446
+ public function isPaymentRequired()
447
+ {
448
+ // Order has no transactions and was created in the backend
449
+ // It's checked by the remote_ip field. Usual way in Magento.
450
+ $isOrderNotPaid = empty($this->transactions)
451
+ && empty($this->getOrder()->getRemoteIp())
452
+ && empty($this->error);
453
+
454
+ // Check if order created in the admin backend was declined
455
+ $isOrderDeclined = !empty($this->transactions)
456
+ && empty($this->getOrder()->getRemoteIp())
457
+ && (
458
+ Mage_Sales_Model_Order::STATE_CANCELED == $this->getOrder()->getState()
459
+ || Mage_Sales_Model_Order::STATE_NEW == $this->getOrder()->getState()
460
+ );
461
+
462
+ return $isOrderNotPaid || $isOrderDeclined;
463
+ }
464
+
465
+ /**
466
+ * Get URL to pay for the backend order
467
+ *
468
+ * @return string
469
+ */
470
+ public function getBackendPaymentUrl()
471
+ {
472
+ $params = array(
473
+ 'order_id' => $this->getOrder()->getEntityId(),
474
+ );
475
+
476
+ return $this->getUrl('adminhtml/sales_order_payment/pay', $params);
477
  }
478
+ }
app/code/community/Cdev/XPaymentsConnector/Block/{Failure.php → Adminhtml/Settings/Help.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,47 +13,40 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
- * Payment failure block
24
  *
25
  * @package Cdev_XPaymentsConnector
26
  * @see ____class_see____
27
  * @since 1.0.0
28
  */
29
- class Cdev_XPaymentsConnector_Block_Failure extends Mage_Core_Block_Template
30
  {
31
  /**
32
  * Constructor
33
- *
34
  * @return void
35
- * @access protected
36
- * @see ____func_see____
37
- * @since 1.0.0
38
  */
39
- protected function _construct()
40
  {
41
- parent::_construct();
42
- $this->setTemplate('xpaymentsconnector/failure.phtml');
43
  }
44
 
45
  /**
46
- * get Continue shopping link URL
47
- *
48
  * @return string
49
- * @access public
50
- * @see ____func_see____
51
- * @since 1.0.0
52
  */
53
- public function getContinueShoppingUrl()
54
  {
55
- return Mage::getUrl('checkout/cart', array('_nosid' => true));
56
  }
57
  }
58
-
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * X-Payments Connector help link on the left side
25
  *
26
  * @package Cdev_XPaymentsConnector
27
  * @see ____class_see____
28
  * @since 1.0.0
29
  */
30
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Help extends Mage_Adminhtml_Block_Template
31
  {
32
  /**
33
  * Constructor
34
+ *
35
  * @return void
 
 
 
36
  */
37
+ public function __construct()
38
  {
39
+ parent::__construct();
40
+ $this->setTemplate('xpaymentsconnector/settings/help.phtml');
41
  }
42
 
43
  /**
44
+ * Get Contact Us link
45
+ *
46
  * @return string
 
 
 
47
  */
48
+ public function getContactUsUrl()
49
  {
50
+ return 'http://www.x-payments.com/contact-us.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link';
51
  }
52
  }
 
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Connector tabs abstract class
25
+ */
26
+ abstract class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab extends Mage_Adminhtml_Block_Template
27
+ {
28
+ /**
29
+ * Current tab
30
+ */
31
+ protected $tab = null;
32
+
33
+ /**
34
+ * Check if it's welcome mode.
35
+ * I.e. module is not configured, payment methods are not imported, etc.
36
+ *
37
+ * @return bool
38
+ */
39
+ protected function isWelcomeMode()
40
+ {
41
+ return !Mage::helper('settings_xpc')->isConfigured();
42
+ }
43
+
44
+ /**
45
+ * Retrieve the label used for the tab relating to this block
46
+ *
47
+ * @return string
48
+ */
49
+ public function getTabLabel()
50
+ {
51
+ $tabs = Mage::helper('settings_xpc')->getTabs();
52
+
53
+ return $this->__($tabs[$this->tab]);
54
+ }
55
+
56
+ /**
57
+ * Retrieve the title used by this tab
58
+ *
59
+ * @return string
60
+ */
61
+ public function getTabTitle()
62
+ {
63
+ $tabs = Mage::helper('settings_xpc')->getTabs();
64
+
65
+ return $this->__($tabs[$this->tab]);
66
+ }
67
+
68
+ /**
69
+ * Determines whether to display the tab
70
+ * Add logic here to decide whether you want the tab to display
71
+ *
72
+ * @return bool
73
+ */
74
+ public function canShowTab()
75
+ {
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * Stops the tab being hidden
81
+ *
82
+ * @return bool
83
+ */
84
+ public function isHidden()
85
+ {
86
+ return !$this->canShowTab();
87
+ }
88
+
89
+ /**
90
+ * Check if at least one of the payment configurations can be used for saving cards
91
+ *
92
+ * @return bool
93
+ */
94
+ public function isCanSaveCards()
95
+ {
96
+ return Mage::helper('settings_xpc')->isCanSaveCards();
97
+ }
98
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/Connection.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Connector Connection settings tab
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_Connection
27
+ extends Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab
28
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
+ {
30
+ /**
31
+ * Current tab
32
+ */
33
+ protected $tab = Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_CONNECTION;
34
+
35
+ /**
36
+ * List of errors
37
+ */
38
+ private $errorList = null;
39
+
40
+ /**
41
+ * Determines whether to display the tab
42
+ * Add logic here to decide whether you want the tab to display
43
+ *
44
+ * @return bool
45
+ */
46
+ public function canShowTab()
47
+ {
48
+ return true;
49
+ }
50
+
51
+ /**
52
+ * Prepare layout
53
+ *
54
+ * @return void
55
+ */
56
+ protected function _prepareLayout()
57
+ {
58
+ parent::_prepareLayout();
59
+
60
+ $this->setChild(
61
+ 'deployButton',
62
+ $this->getLayout()->createBlock('adminhtml/widget_button')
63
+ ->setData(
64
+ array(
65
+ 'type' => 'submit',
66
+ 'label' => Mage::helper('adminhtml')->__('Deploy'),
67
+ 'class' => 'task'
68
+ )
69
+ )
70
+ );
71
+
72
+ $this->setChild(
73
+ 'updateButton',
74
+ $this->getLayout()->createBlock('adminhtml/widget_button')
75
+ ->setData(
76
+ array(
77
+ 'type' => 'submit',
78
+ 'label' => Mage::helper('adminhtml')->__('Update'),
79
+ 'class' => 'task'
80
+ )
81
+ )
82
+ );
83
+ }
84
+
85
+ /**
86
+ * Check if options for Iframe should be displayed
87
+ *
88
+ * @return bool
89
+ */
90
+ public function isDisplayIframeOptions()
91
+ {
92
+ return !Mage::helper('settings_xpc')->checkOscModuleEnabled()
93
+ && !Mage::helper('settings_xpc')->checkFirecheckoutModuleEnabled();
94
+ }
95
+
96
+ /**
97
+ * Get module configuration errors list
98
+ *
99
+ * @return array
100
+ */
101
+ public function getErrorList()
102
+ {
103
+ if (is_array($this->errorList)) {
104
+ return $this->errorList;
105
+ }
106
+
107
+ $settings = Mage::helper('settings_xpc');
108
+
109
+ if (!$settings->checkRequirements()) {
110
+
111
+ $this->errorList = $settings->getRequirementsErrors();
112
+
113
+ } elseif ($settings->getXpcConfig('xpay_conf_bundle')) {
114
+
115
+ $this->errorList = $settings->getConfigurationErrors(true);
116
+
117
+ } else {
118
+
119
+ // Do not display configuration errors if bundle is empty
120
+ $this->errorList = array();
121
+ }
122
+
123
+ return $this->errorList;
124
+ }
125
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/PaymentMethods.php ADDED
@@ -0,0 +1,322 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Connector Payment Methods tab
25
+ *
26
+ */
27
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_PaymentMethods
28
+ extends Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab
29
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
30
+ {
31
+ /**
32
+ * Current tab
33
+ */
34
+ protected $tab = Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_PAYMENT_METHODS;
35
+
36
+ /**
37
+ * Determines whether to display the tab
38
+ * Add logic here to decide whether you want the tab to display
39
+ *
40
+ * @return bool
41
+ */
42
+ public function canShowTab()
43
+ {
44
+ return !$this->isWelcomeMode();
45
+ }
46
+
47
+ /**
48
+ * Get data for payment method title input
49
+ *
50
+ * @param $pm Payment method data
51
+ *
52
+ * @return array
53
+ */
54
+ private function getTitleInput($pm)
55
+ {
56
+ return array(
57
+ 'name' => 'payment_method_data[' . $pm['confid'] . '][title]',
58
+ 'value' => $pm['payment_method_data']['title'],
59
+ );
60
+ }
61
+
62
+ /**
63
+ * Get data for payment method sort order input
64
+ *
65
+ * @param $pm Payment method data
66
+ *
67
+ * @return array
68
+ */
69
+ private function getSortOrderInput($pm)
70
+ {
71
+ return array(
72
+ 'name' => 'payment_method_data[' . $pm['confid'] . '][sort_order]',
73
+ 'value' => $pm['payment_method_data']['sort_order'],
74
+ );
75
+ }
76
+
77
+ /**
78
+ * Get data for list of specific countries selectbox
79
+ *
80
+ * @param array $pm Payment method data
81
+ *
82
+ * @return array
83
+ */
84
+ private function getSpecificCountriesSelectBox($pm)
85
+ {
86
+ $countries = Mage::getResourceModel('directory/country_collection')->loadData()->toOptionArray(false);
87
+
88
+ $result = array(
89
+ 'select' => array(
90
+ 'name' => 'payment_method_data[' . $pm['confid'] . '][specificcountry][]',
91
+ 'multiple' => 'multiple',
92
+ 'class' => 'select multiselect specificcountry',
93
+ 'size' => 10,
94
+ ),
95
+ 'options' => array(),
96
+ );
97
+
98
+ $selected = explode(',', $pm['payment_method_data']['specificcountry']);
99
+
100
+ foreach ($countries as $country) {
101
+
102
+ $code = $country['value'];
103
+
104
+ $result['options'][$code] = array(
105
+ 'title' => $country['label'],
106
+ 'value' => $code,
107
+ );
108
+
109
+ if (in_array($code, $selected)) {
110
+ $result['options'][$code]['selected'] = 'selected';
111
+ }
112
+ }
113
+
114
+ return $result;
115
+ }
116
+
117
+ /**
118
+ * Get data for Yes/No selectbox
119
+ *
120
+ * @param array $pm Payment method data
121
+ * @param string $name Element name
122
+ * @param bool $isYes Should be Yes selected by default
123
+ *
124
+ * @return array
125
+ */
126
+ private function getYesNoSelectBox($pm, $name, $isYes = false)
127
+ {
128
+ $result = array(
129
+ 'select' => array(
130
+ 'name' => 'payment_method_data[' . $pm['confid'] . '][' . $name . ']',
131
+ 'class' => $name,
132
+ ),
133
+ 'options' => array(
134
+ 1 => array(
135
+ 'title' => 'Yes',
136
+ 'value' => '1',
137
+ ),
138
+ 0 => array(
139
+ 'title' => 'No',
140
+ 'value' => '0',
141
+ ),
142
+ ),
143
+ );
144
+
145
+ if (isset($pm['payment_method_data'][$name])) {
146
+ $key = $pm['payment_method_data'][$name] ? 1 : 0;
147
+ } else {
148
+ $key = $isYes ? 1 : 0;
149
+ }
150
+
151
+ $result['options'][$key]['selected'] = 'selected';
152
+
153
+ return $result;
154
+ }
155
+
156
+ /**
157
+ * Get list of imported payment configurations
158
+ *
159
+ * @param bool $includeDisabled Include "disable all" fake payment method or not
160
+ *
161
+ * @return array
162
+ */
163
+ public function getPaymentMethods($includeDisabled = true)
164
+ {
165
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
166
+
167
+ $activeCount = 0;
168
+
169
+ $result = array();
170
+
171
+ if (!empty($list)) {
172
+
173
+ $count = 0;
174
+
175
+ foreach ($list as $k => $v) {
176
+
177
+ $v['payment_method_data'] = unserialize($v['payment_method_data']);
178
+
179
+ $result[$k] = $v;
180
+
181
+ // Enable/disable checkbox
182
+ $result[$k]['active_checkbox'] = array(
183
+ 'id' => 'active-checkbox-' . $v['confid'],
184
+ 'name' => 'payment_methods[active][' . $v['confid'] . ']',
185
+ 'value' => 'Y',
186
+ 'class' => 'pm-active pointer ' . ($count++ % 2 == 0 ? 'even' : 'odd'),
187
+ );
188
+
189
+ if (
190
+ 'Y' == $v['active']
191
+ && $activeCount < Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS
192
+ ) {
193
+ $result[$k]['active_checkbox'] += array('checked' => 'checked');
194
+ $activeCount++;
195
+ }
196
+
197
+ // Save cards checkbox
198
+ $result[$k]['savecard_checkbox'] = array(
199
+ 'id' => 'savecard-checkbox-' . $v['confid'],
200
+ 'name' => 'payment_methods[savecard][' . $v['confid'] . ']',
201
+ 'value' => 'Y',
202
+ 'class' => 'pm-savecard',
203
+ );
204
+
205
+ if ('Y' == $v['save_cards']) {
206
+ $result[$k]['savecard_checkbox'] += array('checked' => 'checked');
207
+ }
208
+
209
+
210
+ // Payment method block
211
+ $result[$k]['payment_method'] = array(
212
+ 'id' => 'payment-method-' . $v['confid'],
213
+ 'title' => $this->getTitleInput($v),
214
+ 'sort_order' => $this->getSortOrderInput($v),
215
+ 'allowspecific' => $this->getYesNoSelectBox($v, 'allowspecific'),
216
+ 'specificcountry' => $this->getSpecificCountriesSelectBox($v),
217
+ 'use_authorize' => $this->getYesNoSelectBox($v, 'use_authorize'),
218
+ 'use_initialfee_authorize' => $this->getYesNoSelectBox($v, 'use_initialfee_authorize'),
219
+ );
220
+
221
+ }
222
+ }
223
+
224
+ if ($includeDisabled) {
225
+
226
+ // Add the "disabled" row
227
+ $result[0] = array(
228
+ 'confid' => 0,
229
+ 'name' => $this->__('Disable X-Payments payment method'),
230
+ 'active_checkbox' => array(
231
+ 'id' => 'active-checkbox-0',
232
+ 'name' => 'payment_methods[active][0]',
233
+ 'value' => 'Y',
234
+ 'class' => 'pm-disable pointer ' . ($count++ % 2 == 0 ? 'even' : 'odd'),
235
+ ),
236
+ );
237
+
238
+ if (0 == $activeCount) {
239
+ $result[0]['active_checkbox']['checked'] = 'checked';
240
+ }
241
+ }
242
+
243
+ return $result;
244
+ }
245
+
246
+ /**
247
+ * Get attributes string
248
+ * param1="value1" param2="value2"...
249
+ *
250
+ * @param array $data Attributes list
251
+ *
252
+ * @return string
253
+ */
254
+ private function getAttributesStr($data)
255
+ {
256
+ $str = '';
257
+
258
+ foreach ($data as $k => $v) {
259
+ $str .= $k . '=' . '"' . $v . '" ';
260
+ }
261
+
262
+ return $str;
263
+ }
264
+
265
+ /**
266
+ * Print selectbox
267
+ *
268
+ * @param array $data Selectbox data
269
+ *
270
+ * @return void
271
+ */
272
+ public function printSelectbox($data)
273
+ {
274
+ $str = '<select '
275
+ . $this->getAttributesStr($data['select'])
276
+ . '>' . PHP_EOL;
277
+
278
+ foreach ($data['options'] as $option) {
279
+ $title = $option['title'];
280
+ unset($option['title']);
281
+ $str .= '<option ' . $this->getAttributesStr($option) . '>'
282
+ . $this->__($title)
283
+ . '</option>' . PHP_EOL;
284
+ }
285
+
286
+ $str .= '</select>';
287
+
288
+ echo $str;
289
+ }
290
+
291
+ /**
292
+ * Print checkbox
293
+ *
294
+ * @param array $data Checkbox data
295
+ *
296
+ * @return void
297
+ */
298
+ public function printCheckbox($data)
299
+ {
300
+ $str = '<input type="checkbox" '
301
+ . $this->getAttributesStr($data)
302
+ . '/>';
303
+
304
+ echo $str;
305
+ }
306
+
307
+ /**
308
+ * Print input text
309
+ *
310
+ * @param array $data Input data
311
+ *
312
+ * @return void
313
+ */
314
+ public function printInputText($data)
315
+ {
316
+ $str = '<input type="text" class="input-text" '
317
+ . $this->getAttributesStr($data)
318
+ . '/>';
319
+
320
+ echo $str;
321
+ }
322
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/Welcome.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Connector Welcome tab
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_Welcome
27
+ extends Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab
28
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
+ {
30
+ /**
31
+ * Current tab
32
+ */
33
+ protected $tab = Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_WELCOME;
34
+
35
+ /**
36
+ * Determines whether to display the tab
37
+ * Add logic here to decide whether you want the tab to display
38
+ *
39
+ * @return bool
40
+ */
41
+ public function canShowTab()
42
+ {
43
+ return $this->isWelcomeMode();
44
+ }
45
+
46
+ /**
47
+ * Get description
48
+ *
49
+ * @return string
50
+ */
51
+ public function getDescription()
52
+ {
53
+ $description = 'Give your customers – and yourself – peace of mind with this payment processing module
54
+ that guarantees compliance with PCI security mandates, significantly reduces the risk of
55
+ data breaches and ensures you won’t be hit with a fine of up to $500,000 for non-compliance.
56
+ Safely and conveniently store customers credit card information to use for new orders, reorders
57
+ or recurring payments.';
58
+
59
+ return $this->__($description);
60
+ }
61
+
62
+ /**
63
+ * Get System/X-Payments connector link
64
+ *
65
+ * @return string
66
+ */
67
+ public function getTrialDemoUrl()
68
+ {
69
+ return 'http://www.x-payments.com/trial-demo.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link';
70
+ }
71
+
72
+ /**
73
+ * Get User manual link for stores
74
+ *
75
+ * @return string
76
+ */
77
+ public function getUserManualMagentoUrl()
78
+ {
79
+ return 'https://www.x-payments.com/help/X-Payments:Using_X-Payments_with_Magento#Connecting_X-Payments_and_Magento';
80
+ }
81
+
82
+ /**
83
+ * Get User manual link for gateways
84
+ *
85
+ * @return string
86
+ */
87
+ public function getUserManualGatewaysUrl()
88
+ {
89
+ return 'https://www.x-payments.com/help/X-Payments:Payment_configurations';
90
+ }
91
+
92
+
93
+ /**
94
+ * Get video link
95
+ *
96
+ * @return string
97
+ */
98
+ public function getVideoUrl()
99
+ {
100
+ return 'https://www.youtube.com/embed/OVN8acj45ic';
101
+ }
102
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tab/ZeroAuth.php ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Connector Zero auth (card setup) tab
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_ZeroAuth
27
+ extends Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab
28
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
+ {
30
+ /**
31
+ * Current tab
32
+ */
33
+ protected $tab = Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_ZERO_AUTH;
34
+
35
+ /**
36
+ * Determines whether to display the tab
37
+ * Add logic here to decide whether you want the tab to display
38
+ *
39
+ * @return bool
40
+ */
41
+ public function canShowTab()
42
+ {
43
+ return !$this->isWelcomeMode()
44
+ && $this->isCanSaveCards();
45
+ }
46
+
47
+ /**
48
+ * Prepare layout
49
+ *
50
+ * @return void
51
+ */
52
+ protected function _prepareLayout()
53
+ {
54
+ parent::_prepareLayout();
55
+
56
+ $this->setChild(
57
+ 'updateButton',
58
+ $this->getLayout()->createBlock('adminhtml/widget_button')
59
+ ->setData(
60
+ array(
61
+ 'type' => 'submit',
62
+ 'label' => Mage::helper('adminhtml')->__('Update'),
63
+ 'class' => 'task'
64
+ )
65
+ )
66
+ );
67
+ }
68
+
69
+ /**
70
+ * Get list of payment methods which allow saving cards
71
+ *
72
+ * @return array
73
+ */
74
+ public function getPaymentMethodsList()
75
+ {
76
+ $settings = Mage::helper('settings_xpc');
77
+
78
+ $list = array(
79
+ $settings::ZERO_AUTH_DISABLED => Mage::helper('adminhtml')->__('Do not use Save credit card setup'),
80
+ );
81
+
82
+ for ($xpcSlot = 1; $xpcSlot <= $settings::MAX_SLOTS; $xpcSlot++) {
83
+
84
+ if ($settings->getPaymentConfig('active', $xpcSlot)) {
85
+
86
+ $confid = $settings->getPaymentConfig('confid', $xpcSlot);
87
+
88
+ $paymentConf = Mage::getModel('xpaymentsconnector/paymentconfiguration')->load($confid);
89
+
90
+ if ('Y' == $paymentConf->getData('save_cards')) {
91
+ $list[$confid] = $settings->getPaymentConfig('title', $xpcSlot);
92
+ }
93
+ }
94
+ }
95
+
96
+ return $list;
97
+ }
98
+
99
+ /**
100
+ * Check if this payment configuration is used for the Zero Auth
101
+ *
102
+ * @return bool
103
+ */
104
+ public function isZeroAuthConfId($confid)
105
+ {
106
+ return $confid == Mage::helper('settings_xpc')->getXpcConfig('xpay_zero_auth_confid');
107
+ }
108
+
109
+ /**
110
+ * Get amount
111
+ *
112
+ * @return string
113
+ */
114
+ protected function getAmount()
115
+ {
116
+ $settings = Mage::helper('settings_xpc');
117
+
118
+ return $settings->preparePrice(
119
+ $settings->getXpcConfig('xpay_zero_auth_amount')
120
+ );
121
+ }
122
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Tabs.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Tab widget for X-Payments Connector settings
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
27
+ {
28
+ /**
29
+ * List of tab IDs
30
+ */
31
+ private $tabIDs = array();
32
+
33
+ /**
34
+ * Convert Tab ID
35
+ *
36
+ * @param string $tabId
37
+ *
38
+ * @return string
39
+ */
40
+ private function convertTabId($tabId)
41
+ {
42
+ return 'settings_xpc_tabs_' . str_replace('_', '', $tabId) . '_section';
43
+ }
44
+
45
+ /**
46
+ * Constructor
47
+ *
48
+ * @return void
49
+ */
50
+ public function __construct()
51
+ {
52
+ parent::__construct();
53
+
54
+ $this->setId('settings_xpc_tabs');
55
+ $this->setDestElementId('settings_xpc');
56
+
57
+ foreach (Mage::helper('settings_xpc')->getTabs() as $tabId => $name) {
58
+ $this->tabIDs[$tabId] = $this->convertTabId($tabId);
59
+ }
60
+ }
61
+
62
+ /**
63
+ * Get active tab ID
64
+ *
65
+ * @return string
66
+ */
67
+ public function getActiveTabId()
68
+ {
69
+ $tabId = Mage::app()->getRequest()->getParam('tab');
70
+
71
+ if (
72
+ !empty($tabId)
73
+ && array_key_exists($tabId, $this->tabIDs)
74
+ ) {
75
+
76
+ $tabId = $this->tabIDs[$tabId];
77
+
78
+ } elseif (Mage::helper('settings_xpc')->isConfigured()) {
79
+
80
+ $tabId = $this->tabIDs[Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_PAYMENT_METHODS];
81
+
82
+ } else {
83
+
84
+ $tabId = $this->tabIDs[Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_WELCOME];
85
+ }
86
+
87
+ return $tabId;
88
+ }
89
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Settings/Xpc.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -29,11 +29,6 @@
29
  */
30
  class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc extends Mage_Adminhtml_Block_Template
31
  {
32
- /**
33
- * @var array
34
- */
35
- private $_configurationErrorList = array();
36
-
37
  /**
38
  * Constructor
39
  *
@@ -45,6 +40,23 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc extends Mage_Adminhtm
45
  $this->setTemplate('xpaymentsconnector/settings/xpc.phtml');
46
  }
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  /**
49
  * Prepare layout
50
  *
@@ -55,168 +67,82 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc extends Mage_Adminhtm
55
  parent::_prepareLayout();
56
 
57
  $this->setChild(
58
- 'requestButton',
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  $this->getLayout()->createBlock('adminhtml/widget_button')
60
  ->setData(
61
- array(
62
- 'type' => 'submit',
63
- 'label' => Mage::helper('adminhtml')->__('Import payment methods from X-Payments'),
64
- 'class' => 'task'
65
- )
66
  )
67
  );
68
 
69
  $this->setChild(
70
- 'clearButton',
71
  $this->getLayout()->createBlock('adminhtml/widget_button')
72
  ->setData(
73
- array(
74
- 'type' => 'submit',
75
- 'label' => Mage::helper('adminhtml')->__('Clear'),
76
- 'class' => 'task'
77
- )
78
  )
79
  );
80
  }
81
 
82
  /**
83
- * Check - payment configuration is requested or not
84
- *
85
- * @return boolean
86
- */
87
- public function isMethodsRequested()
88
- {
89
- return 0 < count($this->getPaymentMethods());
90
- }
91
-
92
- /**
93
- * Get requested payment configurations
94
- *
95
- * @return array
96
- */
97
- public function getPaymentMethods()
98
- {
99
- $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
100
-
101
- return !empty($list) ? $list : array();
102
- }
103
-
104
- /**
105
- * Check - is payment configurations are already imported into DB or not
106
- *
107
- * @return boolean
108
- */
109
- public function isMethodsAlreadyImported()
110
- {
111
- // TODO: Same as isMethodsRequested()
112
- return 0 < count($this->getPaymentMethods());
113
- }
114
-
115
- /**
116
- * Get system requiremenets errors list
117
- *
118
- * @return array
119
- */
120
- public function getRequiremenetsErrors()
121
- {
122
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
123
-
124
- $result = $api->checkRequirements();
125
-
126
- $list = array();
127
- if ($result & $api::REQ_CURL) {
128
- $list[] = 'PHP extension cURL is not installed on your server';
129
- }
130
-
131
- if ($result & $api::REQ_OPENSSL) {
132
- $list[] = 'PHP extension OpenSSL is not installed on your server';
133
- }
134
-
135
- if ($result & $api::REQ_DOM) {
136
- $list[] = 'PHP extension DOM is not installed on your server';
137
- }
138
-
139
- return $list;
140
- }
141
-
142
- /**
143
- * Get module configuration errors list
144
- *
145
- * @return array
146
- */
147
- public function getConfigurationErrors()
148
- {
149
- if (empty($this->_configurationErrorList)) {
150
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
151
-
152
- $result = $api->getConfigurationErrors();
153
-
154
- $list = array();
155
-
156
- if ($result & $api::CONF_CART_ID) {
157
- $list[] = 'Store ID is empty or has an incorrect value';
158
- }
159
-
160
- if ($result & $api::CONF_URL) {
161
- $list[] = 'X-Payments URL is empty or has an incorrect value';
162
- }
163
-
164
- if ($result & $api::CONF_PUBLIC_KEY) {
165
- $list[] = 'Public key is empty';
166
- }
167
-
168
- if ($result & $api::CONF_PRIVATE_KEY) {
169
- $list[] = 'Private key is empty';
170
- }
171
-
172
- if ($result & $api::CONF_PRIVATE_KEY_PASS) {
173
- $list[] = 'Private key password is empty';
174
- }
175
-
176
- $this->_configurationErrorList = $list;
177
- }
178
-
179
- return $this->_configurationErrorList;
180
- }
181
-
182
- /**
183
- * Get System/X-Payments connector link
184
  *
185
- * @return string
186
  */
187
- public function getSystemConfigXpcUrl()
188
  {
189
- return $this->getUrl('adminhtml/system_config/edit/section/xpaymentsconnector/');
190
  }
191
 
192
  /**
193
- * Get System/X-Payments connector link
194
  *
195
- * @return string
196
  */
197
- public function getTrialDemoUrl()
198
  {
199
- return 'http://www.x-payments.com/trial-demo.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link';
200
  }
201
 
202
  /**
203
- * Get User manual link
204
  *
205
- * @return string
206
  */
207
- public function getUserManualUrl()
208
  {
209
- return 'http://help.x-cart.com/index.php?title=X-Payments:User_manual#Online_Stores';
210
- }
211
-
212
- /**
213
- * Get video link
214
- *
215
- * @return string
216
- */
217
- public function getVideoUrl()
218
- {
219
- return 'https://www.youtube.com/embed/2VRR0JW23qc';
220
  }
221
 
222
  /**
@@ -229,21 +155,14 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc extends Mage_Adminhtm
229
  return 'http://www.x-payments.com/contact-us.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link';
230
  }
231
 
232
-
233
  /**
234
- * Get description
235
  *
236
- * @return string
237
  */
238
- public function getDescription()
239
  {
240
- $description = 'Give your customers – and yourself – peace of mind with this payment processing module
241
- that guarantees compliance with PCI security mandates, significantly reduces the risk of
242
- data breaches and ensures you won’t be hit with a fine of up to $500,000 for non-compliance.
243
- Safely and conveniently store customers credit card information to use for new orders, reorders
244
- or recurring payments.';
245
-
246
- return $this->__($description);
247
  }
248
-
249
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
29
  */
30
  class Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc extends Mage_Adminhtml_Block_Template
31
  {
 
 
 
 
 
32
  /**
33
  * Constructor
34
  *
40
  $this->setTemplate('xpaymentsconnector/settings/xpc.phtml');
41
  }
42
 
43
+ /**
44
+ * Get button data
45
+ *
46
+ * @return array
47
+ */
48
+ private function getButtonData($name, $mode, $class = 'task')
49
+ {
50
+ return array(
51
+ 'type' => 'submit',
52
+ 'element_name' => 'mode',
53
+ 'value' => $mode,
54
+ 'label' => Mage::helper('adminhtml')->__($name),
55
+ 'class' => $class,
56
+ 'onclick' => 'javascript: submitPaymentMethodsForm(this);',
57
+ );
58
+ }
59
+
60
  /**
61
  * Prepare layout
62
  *
67
  parent::_prepareLayout();
68
 
69
  $this->setChild(
70
+ 'welcomeSection',
71
+ $this->getLayout()
72
+ ->createBlock('xpaymentsconnector/adminhtml_settings_tab_welcome')
73
+ ->setTemplate('xpaymentsconnector/settings/tabs/welcome.phtml')
74
+ );
75
+
76
+ $this->setChild(
77
+ 'connectionSection',
78
+ $this->getLayout()
79
+ ->createBlock('xpaymentsconnector/adminhtml_settings_tab_connection')
80
+ ->setTemplate('xpaymentsconnector/settings/tabs/connection.phtml')
81
+ );
82
+
83
+ $this->setChild(
84
+ 'paymentMethodsSection',
85
+ $this->getLayout()
86
+ ->createBlock('xpaymentsconnector/adminhtml_settings_tab_paymentMethods')
87
+ ->setTemplate('xpaymentsconnector/settings/tabs/payment_methods.phtml')
88
+ );
89
+
90
+ $this->setChild(
91
+ 'zeroAuthSection',
92
+ $this->getLayout()
93
+ ->createBlock('xpaymentsconnector/adminhtml_settings_tab_zeroAuth')
94
+ ->setTemplate('xpaymentsconnector/settings/tabs/zero_auth.phtml')
95
+ );
96
+
97
+ $this->setChild(
98
+ 'updateButton',
99
  $this->getLayout()->createBlock('adminhtml/widget_button')
100
  ->setData(
101
+ $this->getButtonData('Save config', 'update', 'save')
 
 
 
 
102
  )
103
  );
104
 
105
  $this->setChild(
106
+ 'importButton',
107
  $this->getLayout()->createBlock('adminhtml/widget_button')
108
  ->setData(
109
+ $this->getButtonData('Re-import payment methods', 'import', 'gray')
 
 
 
 
110
  )
111
  );
112
  }
113
 
114
  /**
115
+ * Check if it's welcome mode.
116
+ * I.e. module is not configured, payment methods are not imported, etc.
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  *
118
+ * @return bool
119
  */
120
+ protected function isWelcomeMode()
121
  {
122
+ return !Mage::helper('settings_xpc')->isConfigured();
123
  }
124
 
125
  /**
126
+ * Check if at least one of the payment configurations can be used for saving cards
127
  *
128
+ * @return bool
129
  */
130
+ public function isCanSaveCards()
131
  {
132
+ return Mage::helper('settings_xpc')->isCanSaveCards();
133
  }
134
 
135
  /**
136
+ * Check if sticky panel should be shown initially
137
  *
138
+ * @return bool
139
  */
140
+ public function isShowStickyPanel()
141
  {
142
+ $tabId = Mage::app()->getRequest()->getParam('tab');
143
+
144
+ return $tabId != Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_CONNECTION
145
+ && $tabId != Cdev_XPaymentsConnector_Helper_Settings_Data::TAB_ZERO_AUTH;
 
 
 
 
 
 
 
146
  }
147
 
148
  /**
155
  return 'http://www.x-payments.com/contact-us.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link';
156
  }
157
 
 
158
  /**
159
+ * Get Add new payment method URL
160
  *
161
+ * @return array
162
  */
163
+ public function getAddNewPaymentMethodUrl()
164
  {
165
+ return Mage::helper('settings_xpc')->getAdminUrl()
166
+ . '?target=payment_confs';
 
 
 
 
 
167
  }
 
168
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/System/Config/Form/Subselect.php DELETED
@@ -1,101 +0,0 @@
1
- <?php
2
- // vim: set ts=4 sw=4 sts=4 et:
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * @author Qualiteam Software info@qtmsoft.com
17
- * @category Cdev
18
- * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
- */
22
-
23
-
24
- class Cdev_XPaymentsConnector_Block_Adminhtml_System_Config_Form_Subselect extends Mage_Adminhtml_Block_System_Config_Form_Field
25
- {
26
- /**
27
- * Get the button and scripts contents
28
- *
29
- * @param Varien_Data_Form_Element_Abstract $element
30
- *
31
- * @return string
32
- */
33
- protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
34
- {
35
- // Check if Onestep Checkout or Firecheckout module is enabed
36
- $checkoutModuleEnabled = Mage::helper('xpaymentsconnector')->checkOscModuleEnabled()
37
- || Mage::helper('xpaymentsconnector')->checkFirecheckoutModuleEnabled();
38
-
39
- $html = parent::_getElementHtml($element);
40
- $js = $this->getElementJsEvents($checkoutModuleEnabled);
41
- $html = $html.$js;
42
-
43
- return $html;
44
- }
45
-
46
-
47
- /**
48
- * Get Events for settings select boxes
49
- *
50
- * @param bool $hidden If the payment form place selector should always be hidden
51
- *
52
- * @return string
53
- */
54
- public function getElementJsEvents($hidden = false)
55
- {
56
- if ($hidden) {
57
-
58
- $js = <<<EndHTML
59
- <script type="text/javascript">
60
- document.observe("dom:loaded", function() {
61
-
62
- $('row_payment_xpayments_placedisplay').hide();
63
- $('payment_xpayments_placedisplay').value = "payment";
64
-
65
- $('row_payment_xpayments_use_iframe').hide();
66
- $('payment_xpayments_use_iframe').value = "1";
67
- });
68
- </script>
69
- EndHTML;
70
-
71
-
72
- } else {
73
-
74
- $js = <<<EndHTML
75
- <script type="text/javascript">
76
- document.observe("dom:loaded", function() {
77
- var useIframe = $('payment_xpayments_use_iframe');
78
- var placeDisplaySelect = $('row_payment_xpayments_placedisplay');
79
- if(useIframe.value == 0){
80
- placeDisplaySelect.hide();
81
- }
82
- Event.observe(useIframe, 'change', checkPlaceDisplayAccess.bind(this));
83
- function checkPlaceDisplayAccess(event)
84
- {
85
- var conditionNameElement = Event.element(event);
86
- if(conditionNameElement.value == 1){
87
- placeDisplaySelect.show();
88
- }else{
89
- placeDisplaySelect.hide();
90
- }
91
-
92
- }
93
- });
94
- </script>
95
- EndHTML;
96
-
97
- }
98
-
99
- return $js;
100
- }
101
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Add.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Add new card block
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Add extends Mage_Adminhtml_Block_Template
27
+ {
28
+ /**
29
+ * Current customer profile
30
+ */
31
+ private $customer = null;
32
+
33
+ /**
34
+ * Error message
35
+ */
36
+ private $error = null;
37
+
38
+ /**
39
+ * Current address ID
40
+ */
41
+ private $addressId = null;
42
+
43
+ /**
44
+ * Address list
45
+ */
46
+ private $addressList = null;
47
+
48
+ /**
49
+ * Set current customer profile
50
+ *
51
+ * @param Mage_Customer_Model_Customer
52
+ *
53
+ * @return void
54
+ */
55
+ public function setCustomer($customer)
56
+ {
57
+ $this->customer = $customer;
58
+ }
59
+
60
+ /**
61
+ * Get current customer profile
62
+ *
63
+ * @return Mage_Customer_Model_Customer
64
+ */
65
+ public function getCustomer()
66
+ {
67
+ return $this->customer;
68
+ }
69
+
70
+ /**
71
+ * Set error message
72
+ *
73
+ * @param string $error Error message
74
+ *
75
+ * @return void
76
+ */
77
+ public function setError($error)
78
+ {
79
+ $this->error = $error;
80
+ }
81
+
82
+ /**
83
+ * Get error message
84
+ *
85
+ * @return string
86
+ */
87
+ public function getError()
88
+ {
89
+ return $this->error;
90
+ }
91
+
92
+ /**
93
+ * Set current customer profile
94
+ *
95
+ * @param int $addressId Billing address ID
96
+ *
97
+ * @return void
98
+ */
99
+ public function setAddressId($addressId)
100
+ {
101
+ if (!$this->isEmptyAddressList()) {
102
+
103
+ if (!in_array($addressId, array_keys($this->getAddressList()))) {
104
+ $addressId = key($this->getAddressList());
105
+ }
106
+
107
+ $this->addressId = $addressId;
108
+ }
109
+ }
110
+
111
+ /**
112
+ * Get current address ID
113
+ *
114
+ * @return int
115
+ */
116
+ public function getAddressId()
117
+ {
118
+ return $this->addressId;
119
+ }
120
+
121
+ /**
122
+ * Check if there is no addresses in customer's profile
123
+ *
124
+ * @return bool
125
+ */
126
+ public function isEmptyAddressList()
127
+ {
128
+ return empty($this->getAddressList());
129
+ }
130
+
131
+ /**
132
+ * Check if there is only one address in customer's profile
133
+ *
134
+ * @return bool
135
+ */
136
+ public function isSingleAddress()
137
+ {
138
+ return 1 == count($this->getAddressList());
139
+ }
140
+
141
+ /**
142
+ * Get single address from the customer's profile
143
+ *
144
+ * @return string
145
+ */
146
+ public function getSingleAddress()
147
+ {
148
+ $addresses = $this->getAddressList();
149
+
150
+ return array_shift($addresses);
151
+ }
152
+
153
+ /**
154
+ * Get list of all addresses from the customer's profile
155
+ *
156
+ * @return array
157
+ */
158
+ public function getAddressList()
159
+ {
160
+ if (!is_null($this->addressList)) {
161
+ return $this->addressList;
162
+ }
163
+
164
+ $this->addressList = array();
165
+
166
+ foreach ($this->getCustomer()->getAddresses() as $address) {
167
+
168
+ $item = array(
169
+ $address->getData('firstname') . ' ' . $address->getData('lastname'),
170
+ $address->getData('postcode') . ' '. $address->getData('street') . ' ' . $address->getData('city'),
171
+ $address->getData('region'),
172
+ Mage::getModel('directory/country')->load($address->getData('country_id'))->getName()
173
+ );
174
+
175
+ $this->addressList[$address->getEntityId()] = implode(', ', $item);
176
+ }
177
+
178
+ return $this->addressList;
179
+ }
180
+
181
+ /**
182
+ * Check if this address ID used currently
183
+ *
184
+ * @param int $addressId Address ID
185
+ *
186
+ * @return bool
187
+ */
188
+ public function isCurrentAddress($addressId)
189
+ {
190
+ return $this->getAddressId() == $addressId;
191
+ }
192
+
193
+ /**
194
+ * Get URL of the address book
195
+ *
196
+ * @return string
197
+ */
198
+ public function getAddressBookUrl()
199
+ {
200
+ $params = array(
201
+ 'id' => $this->getCustomer()->getId(),
202
+ 'tab' => 'customer_info_tabs_addresses',
203
+ );
204
+
205
+ return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', $params);
206
+ }
207
+
208
+ /**
209
+ * Get change address URL
210
+ *
211
+ * @return string
212
+ */
213
+ public function getChangeAddressUrl()
214
+ {
215
+ $params = array(
216
+ 'customer_id' => $this->getCustomer()->getId(),
217
+ 'address_id' => 'ADDRESSID',
218
+ );
219
+
220
+ return Mage::helper('adminhtml')->getUrl('adminhtml/addnewcard/index', $params);
221
+ }
222
+
223
+ /**
224
+ * Get iframe URL
225
+ *
226
+ * @return string
227
+ */
228
+ public function getIframeUrl()
229
+ {
230
+ $params = array(
231
+ 'customer_id' => $this->getCustomer()->getId(),
232
+ 'address_id' => $this->getAddressId(),
233
+ );
234
+
235
+ return Mage::helper('adminhtml')->getUrl('adminhtml/addnewcard/iframe', $params);
236
+ }
237
+
238
+ /**
239
+ * Get URL for payment cards tab in the profile
240
+ *
241
+ * @return string
242
+ */
243
+ public function getPaymentCardsUrl()
244
+ {
245
+ $params = array(
246
+ 'id' => $this->getRequest()->getParam('customer_id'),
247
+ 'tab' => 'customer_edit_tab_usercards',
248
+ );
249
+
250
+ return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', $params);
251
+ }
252
+
253
+ /**
254
+ * Get JSON data for X-Payments iframe
255
+ *
256
+ * @return string
257
+ */
258
+ public function getXpcData()
259
+ {
260
+ $data = array(
261
+ 'url' => array(
262
+ 'redirect' => $this->getIframeUrl(),
263
+ 'changeAddress' => $this->getChangeAddressUrl(),
264
+ 'paymentCards' => $this->getPaymentCardsUrl(),
265
+ ),
266
+ 'origins' => Mage::helper('settings_xpc')->getAllowedOrigins(),
267
+ );
268
+
269
+ return json_encode($data, JSON_FORCE_OBJECT);
270
+ }
271
+
272
+ /**
273
+ * Constructor
274
+ *
275
+ * @return void
276
+ */
277
+ protected function _construct()
278
+ {
279
+ $this->setTemplate('xpaymentsconnector/usercards/add.phtml');
280
+ }
281
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,36 +13,47 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
  * Adminhtml customer X-Payments 'Payment cards' tab
24
  */
25
-
26
  class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
-
 
 
 
 
29
  protected function _prepareCollection()
30
  {
31
  $collection = Mage::getResourceModel('xpaymentsconnector/usercards_collection')
32
  ->addFieldToFilter('user_id', $this->getRequest()->getParam('id'));
 
33
  $this->setCollection($collection);
 
34
  return parent::_prepareCollection();
35
  }
36
 
37
- public function __construct(){
 
 
 
 
 
 
38
  parent::__construct();
 
39
  $this->setId('xp_card_id');
40
  $this->setDefaultSort('xp_card_id', 'desc');
41
  $this->setUseAjax(true);
42
  }
43
 
44
-
45
  /**
46
  * Configure grid mass actions
47
  *
@@ -54,12 +66,15 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminh
54
  $this->getMassactionBlock()->setUseAjax(true);
55
  $this->getMassactionBlock()->setHideFormElement(true);
56
 
57
- $this->getMassactionBlock()->addItem('delete', array(
58
- 'label'=> Mage::helper('adminhtml')->__('Delete'),
59
- 'url' => $this->getUrl('*/*/cardsMassDelete', array('_current' => true)),
60
- 'confirm' => Mage::helper('salesrule')->__('Are you sure you want to delete the selected card(s)?'),
61
- 'complete' => 'refreshUsercardsGrid'
62
- ));
 
 
 
63
 
64
  return $this;
65
  }
@@ -69,7 +84,6 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminh
69
  *
70
  * @return Mage_Adminhtml_Block_Widget_Grid
71
  */
72
-
73
  protected function _prepareColumns()
74
  {
75
  $collection = Mage::getModel('xpaymentsconnector/usercards')->getCollection()->addFieldToSelect('card_type')->distinct(true);
@@ -130,5 +144,40 @@ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminh
130
  return parent::_prepareColumns();
131
  }
132
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Adminhtml customer X-Payments 'Payment cards' tab
25
  */
 
26
  class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid extends Mage_Adminhtml_Block_Widget_Grid
27
  {
28
+ /**
29
+ * Prepare collection
30
+ *
31
+ * @return Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Tab_Usercards
32
+ */
33
  protected function _prepareCollection()
34
  {
35
  $collection = Mage::getResourceModel('xpaymentsconnector/usercards_collection')
36
  ->addFieldToFilter('user_id', $this->getRequest()->getParam('id'));
37
+
38
  $this->setCollection($collection);
39
+
40
  return parent::_prepareCollection();
41
  }
42
 
43
+ /**
44
+ * Constructor
45
+ *
46
+ * @return void
47
+ */
48
+ public function __construct()
49
+ {
50
  parent::__construct();
51
+
52
  $this->setId('xp_card_id');
53
  $this->setDefaultSort('xp_card_id', 'desc');
54
  $this->setUseAjax(true);
55
  }
56
 
 
57
  /**
58
  * Configure grid mass actions
59
  *
66
  $this->getMassactionBlock()->setUseAjax(true);
67
  $this->getMassactionBlock()->setHideFormElement(true);
68
 
69
+ $this->getMassactionBlock()->addItem(
70
+ 'delete',
71
+ array(
72
+ 'label' => Mage::helper('adminhtml')->__('Delete'),
73
+ 'url' => $this->getUrl('*/*/cardsMassDelete', array('_current' => true)),
74
+ 'confirm' => Mage::helper('salesrule')->__('Are you sure you want to delete the selected card(s)?'),
75
+ 'complete' => 'refreshUsercardsGrid'
76
+ )
77
+ );
78
 
79
  return $this;
80
  }
84
  *
85
  * @return Mage_Adminhtml_Block_Widget_Grid
86
  */
 
87
  protected function _prepareColumns()
88
  {
89
  $collection = Mage::getModel('xpaymentsconnector/usercards')->getCollection()->addFieldToSelect('card_type')->distinct(true);
144
  return parent::_prepareColumns();
145
  }
146
 
147
+ /**
148
+ * Prepare layout
149
+ *
150
+ * @return void
151
+ */
152
+ protected function _prepareLayout()
153
+ {
154
+ if (Mage::helper('settings_xpc')->isZeroAuthMethodConfigured()) {
155
+
156
+ $addNewButton = $this->getLayout()->createBlock('adminhtml/widget_button')->setData(
157
+ array(
158
+ 'label' => Mage::helper('adminhtml')->__('Add new'),
159
+ 'onclick' => $this->getJsObjectName() . '.doAddNew()',
160
+ 'class' => 'task'
161
+ )
162
+ );
163
+
164
+ $this->setChild('addnew_button', $addNewButton);
165
+ }
166
+
167
+ return parent::_prepareLayout();
168
+ }
169
 
170
+ /**
171
+ * Get buttons HTML code
172
+ *
173
+ * @return string
174
+ */
175
+ public function getMainButtonsHtml()
176
+ {
177
+ $html = parent::getMainButtonsHtml();
178
+
179
+ $html .= $this->getChildHtml('addnew_button');
180
+
181
+ return $html;
182
+ }
183
  }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Iframe.php ADDED
@@ -0,0 +1,143 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Block for add new card iframe
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Iframe extends Mage_Adminhtml_Block_Template
27
+ {
28
+ /**
29
+ * Payment form fields
30
+ */
31
+ private $fields = null;
32
+
33
+ /**
34
+ * Error message
35
+ */
36
+ private $error = null;
37
+
38
+ /**
39
+ * Return flag
40
+ */
41
+ private $returnFlag = false;
42
+
43
+ /**
44
+ * Set fields for payment form
45
+ *
46
+ * @param array $fields Payment for fields
47
+ *
48
+ * @return void
49
+ */
50
+ public function setFields($fields)
51
+ {
52
+ $this->fields = $fields;
53
+ }
54
+
55
+ /**
56
+ * Get fields for payment form
57
+ *
58
+ * @return array
59
+ */
60
+ public function getFields()
61
+ {
62
+ return $this->fields;
63
+ }
64
+
65
+ /**
66
+ * Set error message
67
+ *
68
+ * @param string $error Error message
69
+ *
70
+ * @return void
71
+ */
72
+ public function setError($error)
73
+ {
74
+ $this->error = $error;
75
+ }
76
+
77
+ /**
78
+ * Get error message
79
+ *
80
+ * @return string
81
+ */
82
+ public function getError()
83
+ {
84
+ return $this->error;
85
+ }
86
+
87
+ /**
88
+ * Set return flag
89
+ *
90
+ * @param bool $returnFlag Return flag
91
+ *
92
+ * @return void
93
+ */
94
+ public function setReturnFlag($returnFlag)
95
+ {
96
+ $this->returnFlag = $returnFlag;
97
+ }
98
+
99
+ /**
100
+ * Is it return from X-Payments
101
+ *
102
+ * @return bool
103
+ */
104
+ public function isReturn()
105
+ {
106
+ return $this->returnFlag;
107
+ }
108
+
109
+ /**
110
+ * Get form action (URL)
111
+ *
112
+ * @return string
113
+ */
114
+ public function getFormAction()
115
+ {
116
+ return Mage::helper('settings_xpc')->getPaymentUrl();
117
+ }
118
+
119
+ /**
120
+ * Get URL for payment cards tab in the profile
121
+ *
122
+ * @return string
123
+ */
124
+ public function getPaymentCardsUrl()
125
+ {
126
+ $params = array(
127
+ 'id' => $this->getRequest()->getParam('customer_id'),
128
+ 'tab' => 'customer_edit_tab_usercards',
129
+ );
130
+
131
+ return Mage::helper('adminhtml')->getUrl('adminhtml/customer/edit', $params);
132
+ }
133
+
134
+ /**
135
+ * Constructor
136
+ *
137
+ * @return void
138
+ */
139
+ protected function _construct()
140
+ {
141
+ $this->setTemplate('xpaymentsconnector/usercards/iframe.phtml');
142
+ }
143
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Beforesuccess.php DELETED
@@ -1,72 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * Payemnt successs block
24
- *
25
- * @package Cdev_XPaymentsConnector
26
- * @see ____class_see____
27
- * @since 1.0.0
28
- */
29
- class Cdev_XPaymentsConnector_Block_Beforesuccess extends Mage_Core_Block_Template
30
- {
31
- protected $_agreements = array();
32
- /**
33
- * Get block contecnt as HTML
34
- *
35
- * @return string
36
- * @access protected
37
- * @see ____func_see____
38
- * @since 1.0.0
39
- */
40
- protected function _construct()
41
- {
42
- parent::_construct();
43
-
44
- $this->setTemplate('xpaymentsconnector/checkout/onepage/beforesuccess.phtml');
45
- }
46
-
47
- public function getSaveOrderUrl(){
48
- return Mage::getUrl('checkout/onepage/saveorder');
49
- }
50
-
51
- public function getCheckoutSuccessUrl(){
52
- return Mage::getUrl('checkout/onepage/success');
53
- }
54
-
55
- public function getXpaymentsCode(){
56
- $xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
57
- return $xpaymentPaymentCode;
58
- }
59
-
60
- public function getAgreements(){
61
- if(empty($this->_agreements)){
62
- if (Mage::getStoreConfigFlag('checkout/options/enable_agreements')) {
63
- $agreements = Mage::getModel('checkout/agreement')->getCollection()
64
- ->addStoreFilter(Mage::app()->getStore()->getId())
65
- ->addFieldToFilter('is_active', 1);
66
- $this->_agreements = $agreements;
67
- }
68
- }
69
- return $this->_agreements;
70
- }
71
-
72
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Cancel.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * Payment cancel block (frontend)
24
- *
25
- * @package Cdev_XPaymentsConnector
26
- * @see ____class_see____
27
- * @since 1.0.0
28
- */
29
- class Cdev_XPaymentsConnector_Block_Cancel extends Mage_Core_Block_Template
30
- {
31
- /**
32
- * Constructor
33
- *
34
- * @return void
35
- * @access protected
36
- * @see ____func_see____
37
- * @since 1.0.0
38
- */
39
- protected function _construct()
40
- {
41
- parent::_construct();
42
-
43
- $this->setTemplate('xpaymentsconnector/cancel.phtml');
44
- }
45
-
46
- /**
47
- * Get Continue shopping link URL
48
- *
49
- * @return string
50
- * @access public
51
- * @see ____func_see____
52
- * @since 1.0.0
53
- */
54
- public function getContinueShoppingUrl()
55
- {
56
- return Mage::getUrl('*/*/cancel', array('_nosid' => true));
57
- }
58
-
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Orderdetail.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/{Settings.php → Review/Cc.php} RENAMED
@@ -13,40 +13,39 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
- * Additional settings for "IFrame" variant of payment method (frontend)
25
  */
26
- class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Settings extends Mage_Core_Block_Template
27
  {
28
  /**
29
- * Check if X-Payments payment method was selected on the payment step
30
- *
31
  * @return bool
32
  */
33
- private function isXpcMethod()
34
  {
35
- $code = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
36
- $xpcCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
37
 
38
- return $code == $xpcCode;
 
 
39
  }
40
 
41
  /**
42
- * Display iframe on the review step (after payment) or not
43
  *
44
- * @return bool
45
  */
46
- protected function isVisible()
47
  {
48
- return $this->isXpcMethod()
49
- && Mage::helper('xpaymentsconnector')->isUseIframe()
50
- && 'review' == Mage::helper('xpaymentsconnector')->getIframePlaceDisplay();
51
  }
52
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * Iframe block at checkout on the review step
25
  */
26
+ class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Review_Cc extends Mage_Core_Block_Template
27
  {
28
  /**
29
+ * Display iframe on the review step (after payment) or not
30
+ *
31
  * @return bool
32
  */
33
+ protected function isVisible()
34
  {
35
+ $settings = Mage::helper('settings_xpc');
 
36
 
37
+ return $settings->isXpcMethod($this->getMethodCode(), false)
38
+ && $settings->isUseIframe()
39
+ && 'review' == $settings->getIframePlace();
40
  }
41
 
42
  /**
43
+ * Get payment method code
44
  *
45
+ * @return string
46
  */
47
+ protected function getMethodCode()
48
  {
49
+ return Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
 
 
50
  }
51
  }
app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Success.php CHANGED
@@ -13,98 +13,63 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
- * Rewrite for success block for failed order transaction.
25
- */
26
-
27
  class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success extends Mage_Checkout_Block_Onepage_Success
28
  {
29
-
30
- protected function _prepareLastOrder()
31
- {
32
- $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
33
- if ($orderId) {
34
- $order = Mage::getModel('sales/order')->load($orderId);
35
- if ($order->getId()) {
36
- $isVisible = !in_array($order->getState(),
37
- Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates());
38
- $this->addData(array(
39
- 'is_order_visible' => $isVisible,
40
- 'view_order_id' => $this->getUrl('sales/order/view/', array('order_id' => $orderId)),
41
- 'print_url' => $this->getUrl('sales/order/print', array('order_id'=> $orderId)),
42
- 'can_print_order' => $isVisible,
43
- 'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
44
- 'order_id' => $order->getIncrementId(),
45
- 'order_status'=> $order->getStatus(),
46
- 'order_entity_id' => $orderId
47
- ));
48
- }
49
- }
50
- }
51
-
52
  /**
53
- * This function check (Is the order was successful?)
54
- * @return bool
 
55
  */
56
- public function checkOrderSuccess()
57
  {
58
- if (Mage_Sales_Model_Order::STATE_CANCELED == $this->_getData('order_status')) {
59
- return false;
60
- }
61
- return true;
62
 
63
- }
64
 
65
- /**
66
- * @return string
67
- */
68
- public function getButtonUrl()
69
- {
70
- if ($this->getOrderId()) {
71
- if (!$this->checkOrderSuccess()) {
72
- return $this->getUrl('sales/order/reorder',
73
- array('order_id' => $this->getData('order_entity_id'), '_secure' => true));
74
- }
75
- }
76
- return $this->getUrl();
77
- }
78
 
79
- /**
80
- * @return string
81
- */
82
- public function getButtonLabel()
83
- {
84
- if ($this->checkOrderSuccess()) {
85
- return $this->__('Continue Shopping');
86
- } else {
87
- return $this->__('Return to checkout');
88
- }
89
- }
90
 
91
- /**
92
- * Get recurring profiles
93
- *
94
- * @return array
95
- */
96
- public function getRecurringProfiles()
97
- {
98
- $order = Mage::getModel('sales/order')->load($this->getData('order_entity_id'));
99
 
100
- $profile = Mage::helper('xpaymentsconnector')->getOrderRecurringProfile($order);
 
 
 
 
 
 
 
 
 
 
 
 
101
 
102
- if ($profile) {
103
- $profile = array($profile);
104
  } else {
105
- $profile = false;
 
 
106
  }
107
-
108
- return $profile;
109
  }
110
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * Success page after order is placed
25
+ */
 
26
  class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success extends Mage_Checkout_Block_Onepage_Success
27
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
  /**
29
+ * Prepare last order
30
+ *
31
+ * @return void
32
  */
33
+ protected function _prepareLastOrder()
34
  {
35
+ $order = Mage::getModel('sales/order')->load(
36
+ Mage::getSingleton('checkout/session')->getLastOrderId()
37
+ );
 
38
 
39
+ if ($order->getId()) {
40
 
41
+ $orderId = $order->getEntityId();
42
+
43
+ $isVisible = !in_array(
44
+ $order->getState(),
45
+ Mage::getSingleton('sales/order_config')->getInvisibleOnFrontStates()
46
+ );
 
 
 
 
 
 
 
47
 
48
+ $recurringProfile = Mage::helper('xpaymentsconnector')->getOrderRecurringProfile($order);
 
 
 
 
 
 
 
 
 
 
49
 
50
+ $params = array(
51
+ 'order_id' => $orderId,
52
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
53
+ );
 
 
 
 
54
 
55
+ $data = array(
56
+ 'is_order_visible' => $isVisible,
57
+ 'view_order_id' => $this->getUrl('sales/order/view/', $params),
58
+ 'print_url' => $this->getUrl('sales/order/print', $params),
59
+ 'can_print_order' => $isVisible,
60
+ 'can_view_order' => Mage::getSingleton('customer/session')->isLoggedIn() && $isVisible,
61
+ 'order_id' => $order->getIncrementId(),
62
+ 'order_status' => $order->getStatus(),
63
+ 'order_entity_id' => $orderId,
64
+ 'recurring_profile' => $recurringProfile,
65
+ );
66
+
67
+ $this->addData($data);
68
 
 
 
69
  } else {
70
+
71
+ // This should not happen at the success page, but add error just in case
72
+ Mage::getSingleton('core/session')->addError('Order was lost');
73
  }
 
 
74
  }
75
  }
app/code/community/Cdev/XPaymentsConnector/Block/{Redirect.php → Checkout/Redirect.php} RENAMED
@@ -13,71 +13,59 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Redirect to X-Payments block
25
- *
26
- * @package Cdev_XPaymentsConnector
27
- * @see ____class_see____
28
- * @since 1.0.0
29
  */
30
- class Cdev_XPaymentsConnector_Block_Redirect extends Mage_Core_Block_Template
31
  {
32
  /**
33
- * Get checkout session object
34
- *
35
- * @return object
36
- * @access protected
37
- * @see ____func_see____
38
- * @since 1.0.0
39
  */
40
- public $paymentMethod = Null;
41
- protected function _getCheckout()
42
- {
43
- return Mage::getSingleton('checkout/session');
44
- }
45
 
46
  /**
47
- * Get order
48
- *
49
- * @return Mage_Sales_Model_Order or null
50
- * @access protected
51
- * @see ____func_see____
52
- * @since 1.0.0
53
  */
54
- protected function _getOrder()
55
- {
56
- $order = null;
57
 
58
- if ($this->getOrder()) {
59
- $order = $this->getOrder();
 
 
 
 
 
 
60
 
61
- } else {
62
- $orderIncrementId = $this->_getCheckout()->getLastRealOrderId();
63
- if ($orderIncrementId) {
64
- $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
65
- }
66
 
 
 
67
  }
68
 
69
- return $order;
70
  }
71
 
72
  /**
73
  * Get payment method model
74
  *
75
- * @return
76
  */
77
  protected function getPaymentMethod()
78
  {
79
  if (is_null($this->paymentMethod)) {
80
- $this->paymentMethod = Mage::getModel('xpaymentsconnector/payment_cc');
 
 
 
81
  }
82
 
83
  return $this->paymentMethod;
@@ -90,7 +78,7 @@ class Cdev_XPaymentsConnector_Block_Redirect extends Mage_Core_Block_Template
90
  */
91
  public function getFormAction()
92
  {
93
- return $this->getPaymentMethod()->getUrl();
94
  }
95
 
96
  /**
@@ -100,7 +88,7 @@ class Cdev_XPaymentsConnector_Block_Redirect extends Mage_Core_Block_Template
100
  */
101
  public function getFormData()
102
  {
103
- return $this->getPaymentMethod()->getFormFields();
104
  }
105
 
106
  /**
@@ -108,8 +96,8 @@ class Cdev_XPaymentsConnector_Block_Redirect extends Mage_Core_Block_Template
108
  *
109
  * @return bool
110
  */
111
- public function checkToken()
112
  {
113
- return $this->getPaymentMethod()->checkToken();
114
  }
115
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Redirect to X-Payments block
 
 
 
 
25
  */
26
+ class Cdev_XPaymentsConnector_Block_Checkout_Redirect extends Mage_Core_Block_Template
27
  {
28
  /**
29
+ * Quote model
 
 
 
 
 
30
  */
31
+ private $quote = null;
 
 
 
 
32
 
33
  /**
34
+ * Payment method object
 
 
 
 
 
35
  */
36
+ private $paymentMethod = null;
 
 
37
 
38
+ /**
39
+ * Get checkout quote
40
+ *
41
+ * @return Mage_Sales_Model_quote
42
+ */
43
+ private function getQuote()
44
+ {
45
+ if (is_null($this->quote)) {
46
 
47
+ $quoteId = Mage::getSingleton('checkout/session')->getQuoteId();
48
+ $xpcSlot = $this->getPaymentMethod()->getXpcSlot();
 
 
 
49
 
50
+ $this->quote = Mage::getModel('xpaymentsconnector/quote')->load($quoteId)
51
+ ->setXpcSlot($xpcSlot);
52
  }
53
 
54
+ return $this->quote;
55
  }
56
 
57
  /**
58
  * Get payment method model
59
  *
60
+ * @return Cdev_XPaymentsConnector_Model_Payment_Cc
61
  */
62
  protected function getPaymentMethod()
63
  {
64
  if (is_null($this->paymentMethod)) {
65
+
66
+ $xpcSlot = intval(Mage::app()->getRequest()->getParam('xpc_slot'));
67
+
68
+ $this->paymentMethod = Mage::getModel('xpaymentsconnector/payment_cc' . $xpcSlot);
69
  }
70
 
71
  return $this->paymentMethod;
78
  */
79
  public function getFormAction()
80
  {
81
+ return Mage::helper('settings_xpc')->getPaymentUrl();
82
  }
83
 
84
  /**
88
  */
89
  public function getFormData()
90
  {
91
+ return $this->getPaymentMethod()->getFormFields($this->getQuote());
92
  }
93
 
94
  /**
96
  *
97
  * @return bool
98
  */
99
+ public function prepareToken()
100
  {
101
+ return $this->getPaymentMethod()->prepareToken($this->getQuote());
102
  }
103
  }
app/code/community/Cdev/XPaymentsConnector/Block/{Return.php → Checkout/Return.php} RENAMED
@@ -13,24 +13,20 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Return from X-Payments block
25
- *
26
- * @package Cdev_XPaymentsConnector
27
- * @see ____class_see____
28
- * @since 1.0.0
29
  */
30
- class Cdev_XPaymentsConnector_Block_Return extends Mage_Core_Block_Template
31
  {
32
  /**
33
- * Get succcess URL
34
  *
35
  * @return string
36
  */
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Return from X-Payments block
 
 
 
 
25
  */
26
+ class Cdev_XPaymentsConnector_Block_Checkout_Return extends Mage_Core_Block_Template
27
  {
28
  /**
29
+ * Get redirect URL
30
  *
31
  * @return string
32
  */
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php DELETED
@@ -1,113 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * Block to add new cards to the list (frontend)
24
- */
25
-
26
- class Cdev_XPaymentsConnector_Block_Customer_Cardadd extends Mage_Core_Block_Template
27
- {
28
- protected $_customerSession = null;
29
- protected $_defaultBillingAddress = null;
30
-
31
-
32
-
33
- /**
34
- * Internal constructor, that is called from real constructor
35
- *
36
- */
37
- protected function _construct()
38
- {
39
- parent::_construct();
40
- $this->_customerSession = Mage::getSingleton('customer/session');
41
- $customer = $this->_customerSession->getCustomer();
42
- $this->_defaultBillingAddress = $customer->getDefaultBillingAddress();
43
-
44
- }
45
-
46
- /**
47
- * Enter description here...
48
- *
49
- * @return string
50
- */
51
- public function getBackUrl()
52
- {
53
- if ($this->getRefererUrl()) {
54
- return $this->getRefererUrl();
55
- }
56
- return $this->getUrl('customer/account/usercards/');
57
- }
58
-
59
- /**
60
- * @return string (url)
61
- */
62
- public function getAuthorizeIframeUrl(){
63
-
64
- // update standart iframe handshake request
65
- $refId = 'authorization';
66
- $updateSendData = array();
67
-
68
- $customerId = $this->_customerSession->getId();
69
-
70
- $updateSendData['returnUrl'] = Mage::getUrl('xpaymentsconnector/customer/cardadd',
71
- array('order_refid' => $refId,'customer_id' => $customerId,'_secure' => true));
72
- $updateSendData['callbackUrl'] = Mage::getUrl('xpaymentsconnector/processing/callback',
73
- array('order_refid' => $refId,'customer_id' => $customerId,'_secure' => true));
74
- $updateSendData['refId'] = $refId;
75
- $updateSendData['template'] = 'magento_iframe';
76
-
77
- $xpaymentFormData = Mage::helper('payment')->getMethodInstance('xpayments')->getFormFields();
78
- $xpaymentFormUrl = Mage::helper('payment')->getMethodInstance('xpayments')->getUrl();
79
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
80
-
81
- $result = $api->sendIframeHandshakeRequest(true);
82
- if($result['success']){
83
- $iframeUrlDataArray = array('target' => $xpaymentFormData['target'], 'token' => $result['response']['token']);
84
- $iframeUrl = $xpaymentFormUrl . '?' . http_build_query($iframeUrlDataArray);
85
- $result['iframe_url'] = $iframeUrl;
86
- }
87
-
88
- return $result;
89
- }
90
-
91
- /**
92
- * @return string (url)
93
- */
94
- public function getXpayUrl(){
95
- $xpayUrlMas = parse_url(Mage::getModel('xpaymentsconnector/payment_cc')->getConfig('xpay_url'));
96
- $xpayUrl = $xpayUrlMas["scheme"]."://".$xpayUrlMas["host"];
97
- return $xpayUrl;
98
- }
99
-
100
- public function getDefaultAddressHtml(){
101
- return ($this->_defaultBillingAddress) ? $this->_defaultBillingAddress->format('html') : "";
102
- }
103
-
104
- public function getAddressEditUrl()
105
- {
106
- if (!empty($this->getDefaultAddressHtml())) {
107
- return $this->getUrl('customer/address/edit', array('_secure' => true, 'id' => $this->_defaultBillingAddress->getId()));
108
- }
109
- return $this->getUrl('customer/address/edit');
110
- }
111
-
112
-
113
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards.php DELETED
@@ -1,112 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * Block for customer payment cards list (frontend)
24
- * Customer account page, "My Payment Cards" tab
25
- */
26
-
27
- class Cdev_XPaymentsConnector_Block_Customer_Usercards extends Mage_Core_Block_Template
28
- {
29
- public function getUserCreditCardsList(){
30
- if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
31
- $customerData = Mage::getSingleton('customer/session')->getCustomer();
32
- $customerId = $customerData->getId();
33
- $userCardsCollection = Mage::getModel('xpaymentsconnector/usercards')
34
- ->getCollection()
35
- ->addFilter('user_id',$customerId)
36
- ->addFilter('usage_type',Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD);
37
- return $userCardsCollection;
38
- }else{
39
- return array();
40
- }
41
-
42
- }
43
-
44
- /**
45
- * Class constructor
46
- */
47
- public function __construct()
48
- {
49
- parent::__construct();
50
- $session = Mage::getSingleton('customer/session');
51
- $purchased = Mage::getResourceModel('xpaymentsconnector/usercards_collection')
52
- ->addFieldToFilter('user_id', $session->getCustomerId())
53
- ->addFieldToFilter('usage_type', array('in' =>
54
- array(
55
- Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD,
56
- Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD
57
- )
58
- )
59
- )
60
- ->addOrder('xp_card_id', 'desc');
61
- $this->setPurchased($purchased);
62
- $this->setItems($purchased);
63
-
64
- }
65
-
66
- /**
67
- * Enter description here...
68
- *
69
- * @return Mage_Downloadable_Block_Customer_Products_List
70
- */
71
- protected function _prepareLayout()
72
- {
73
- parent::_prepareLayout();
74
-
75
- $pager = $this->getLayout()->createBlock('page/html_pager', 'xpaymentsconnector.customer.cards.pager')
76
- ->setCollection($this->getItems());
77
- $this->setChild('pager', $pager);
78
- $this->getItems()->load();
79
- foreach ($this->getItems() as $item) {
80
- $item->setPurchased($this->getPurchased()->getItemById($item->getPurchasedId()));
81
- }
82
- return $this;
83
- }
84
-
85
-
86
- /**
87
- * Enter description here...
88
- *
89
- * @return string
90
- */
91
- public function getBackUrl()
92
- {
93
- if ($this->getRefererUrl()) {
94
- return $this->getRefererUrl();
95
- }
96
- return $this->getUrl('customer/account/');
97
- }
98
-
99
-
100
- public function getAddCardUrl(){
101
- return $this->getUrl('xpaymentsconnector/customer/cardadd');
102
- }
103
-
104
- /**
105
- * @return array
106
- */
107
- public function getCardsUsageOptions(){
108
- $cardUsageOptions = Mage::getModel("xpaymentsconnector/usercards")->getCardsUsageOptions();
109
- return $cardUsageOptions;
110
- }
111
-
112
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/Add.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Block to add new cards to the list (frontend)
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Customer_Usercards_Add extends Mage_Core_Block_Template
27
+ {
28
+ /**
29
+ * Error message
30
+ */
31
+ private $error = null;
32
+
33
+ /**
34
+ * Default billing address
35
+ */
36
+ private $defaultBillingAddress = null;
37
+
38
+ /**
39
+ * Get current customer profile
40
+ *
41
+ * @return Mage_Customer_Model_Customer
42
+ */
43
+ private function getCustomer()
44
+ {
45
+ return Mage::getSingleton('customer/session')->getCustomer();
46
+ }
47
+
48
+ /**
49
+ * Set error message
50
+ *
51
+ * @param string $error Error message
52
+ *
53
+ * @return void
54
+ */
55
+ public function setError($error)
56
+ {
57
+ $this->error = $error;
58
+ }
59
+
60
+ /**
61
+ * Get error message
62
+ *
63
+ * @return string
64
+ */
65
+ public function getError()
66
+ {
67
+ return $this->error;
68
+ }
69
+
70
+ /**
71
+ * Get default biling addrress
72
+ *
73
+ * @return
74
+ */
75
+ private function getDefaultBillingAddress()
76
+ {
77
+ if (is_null($this->defaultBillingAddress)) {
78
+ $this->defaultBillingAddress = $this->getCustomer()->getDefaultBillingAddress();
79
+ }
80
+
81
+ return $this->defaultBillingAddress;
82
+ }
83
+
84
+ /**
85
+ * Get default address HTML code
86
+ *
87
+ * @return string
88
+ */
89
+ public function getDefaultAddressHtml()
90
+ {
91
+ if ($this->getDefaultBillingAddress()) {
92
+ $address = $this->getDefaultBillingAddress()->format('html');
93
+ } else {
94
+ $address = '';
95
+ }
96
+
97
+ return $address;
98
+ }
99
+
100
+ /**
101
+ * Get iframe URL
102
+ *
103
+ * @return string
104
+ */
105
+ public function getIframeUrl()
106
+ {
107
+ $params = array(
108
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
109
+ );
110
+
111
+ return Mage::getUrl('xpaymentsconnector/customer/iframe', $params);
112
+ }
113
+
114
+ /**
115
+ * Get "Back" URL (payment cards page)
116
+ *
117
+ * @return string
118
+ */
119
+ public function getBackUrl()
120
+ {
121
+ if ($this->getRefererUrl()) {
122
+
123
+ $url = $this->getRefererUrl();
124
+
125
+ } else {
126
+
127
+ $params = array(
128
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
129
+ );
130
+
131
+ $url = Mage::getUrl('xpaymentsconnector/customer/usercards', $params);
132
+ }
133
+
134
+ return $url;
135
+ }
136
+
137
+ /**
138
+ * Get edit address URL
139
+ *
140
+ * @return string
141
+ */
142
+ public function getEditAddressUrl()
143
+ {
144
+ if ($this->getDefaultBillingAddress()) {
145
+
146
+ $params = array(
147
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
148
+ 'id' => $this->getDefaultBillingAddress()->getId(),
149
+ );
150
+
151
+ $url = Mage::getUrl('customer/address/edit', $params);
152
+
153
+ } else {
154
+
155
+ $url = Mage::getUrl('customer/address/edit');
156
+ }
157
+
158
+ return $url;
159
+ }
160
+
161
+ /**
162
+ * Get JSON data for X-Payments iframe
163
+ *
164
+ * @return string
165
+ */
166
+ public function getXpcData()
167
+ {
168
+ $data = array(
169
+ 'url' => array(
170
+ 'redirect' => $this->getIframeUrl(),
171
+ 'changeAddress' => $this->getEditAddressUrl(),
172
+ 'paymentCards' => $this->getBackUrl(),
173
+ ),
174
+ 'origins' => Mage::helper('settings_xpc')->getAllowedOrigins(),
175
+ );
176
+
177
+ return json_encode($data, JSON_FORCE_OBJECT);
178
+ }
179
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/Iframe.php ADDED
@@ -0,0 +1,142 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Block for add new card iframe (frontend)
25
+ */
26
+ class Cdev_XPaymentsConnector_Block_Customer_Usercards_Iframe extends Mage_Core_Block_Template
27
+ {
28
+ /**
29
+ * Payment form fields
30
+ */
31
+ private $fields = null;
32
+
33
+ /**
34
+ * Error message
35
+ */
36
+ private $error = null;
37
+
38
+ /**
39
+ * Return flag
40
+ */
41
+ private $returnFlag = false;
42
+
43
+ /**
44
+ * Set fields for payment form
45
+ *
46
+ * @param array $fields Payment for fields
47
+ *
48
+ * @return void
49
+ */
50
+ public function setFields($fields)
51
+ {
52
+ $this->fields = $fields;
53
+ }
54
+
55
+ /**
56
+ * Get fields for payment form
57
+ *
58
+ * @return array
59
+ */
60
+ public function getFields()
61
+ {
62
+ return $this->fields;
63
+ }
64
+
65
+ /**
66
+ * Set error message
67
+ *
68
+ * @param string $error Error message
69
+ *
70
+ * @return void
71
+ */
72
+ public function setError($error)
73
+ {
74
+ $this->error = $error;
75
+ }
76
+
77
+ /**
78
+ * Get error message
79
+ *
80
+ * @return string
81
+ */
82
+ public function getError()
83
+ {
84
+ return $this->error;
85
+ }
86
+
87
+ /**
88
+ * Set return flag
89
+ *
90
+ * @param bool $returnFlag Return flag
91
+ *
92
+ * @return void
93
+ */
94
+ public function setReturnFlag($returnFlag)
95
+ {
96
+ $this->returnFlag = $returnFlag;
97
+ }
98
+
99
+ /**
100
+ * Is it return from X-Payments
101
+ *
102
+ * @return bool
103
+ */
104
+ public function isReturn()
105
+ {
106
+ return $this->returnFlag;
107
+ }
108
+
109
+ /**
110
+ * Get form action (URL)
111
+ *
112
+ * @return string
113
+ */
114
+ public function getFormAction()
115
+ {
116
+ return Mage::helper('settings_xpc')->getPaymentUrl();
117
+ }
118
+
119
+ /**
120
+ * Get URL for payment cards tab in the profile
121
+ *
122
+ * @return string
123
+ */
124
+ public function getPaymentCardsUrl()
125
+ {
126
+ $params = array(
127
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
128
+ );
129
+
130
+ return Mage::getUrl('xpaymentsconnector/customer/usercards', $params);
131
+ }
132
+
133
+ /**
134
+ * Constructor
135
+ *
136
+ * @return void
137
+ */
138
+ protected function _construct()
139
+ {
140
+ $this->setTemplate('xpaymentsconnector/customer/usercards/iframe.phtml');
141
+ }
142
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards/List.php ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Block for customer payment cards list (frontend)
25
+ * Customer account page, "My Payment Cards" tab
26
+ */
27
+ class Cdev_XPaymentsConnector_Block_Customer_Usercards_List extends Mage_Core_Block_Template
28
+ {
29
+ /**
30
+ * List of cards
31
+ */
32
+ private $cards = null;
33
+
34
+ /**
35
+ * Card types/usage options
36
+ */
37
+ private $cardUsageTypes = array();
38
+
39
+ /**
40
+ * Get customer model
41
+ *
42
+ * @return Mage_Customer_Model_Customer
43
+ */
44
+ private function getCustomer()
45
+ {
46
+ return Mage::getSingleton('customer/session')->getCustomer();
47
+ }
48
+
49
+ /**
50
+ * Wrapper for getItems() method
51
+ *
52
+ * @return array
53
+ */
54
+ public function getCards()
55
+ {
56
+ if (is_null($this->cards)) {
57
+ $this->cards = $this->getItems();
58
+ }
59
+
60
+ return $this->cards;
61
+ }
62
+
63
+ /**
64
+ * Constructor. Prepare user cards list
65
+ *
66
+ * @return Mage_Core_Block_Template
67
+ */
68
+ public function __construct()
69
+ {
70
+ parent::__construct();
71
+
72
+ $usageTypeCondition = array(
73
+ 'in' => array(
74
+ Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD,
75
+ Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD
76
+ )
77
+ );
78
+
79
+ $items = Mage::getResourceModel('xpaymentsconnector/usercards_collection')
80
+ ->addFieldToFilter('user_id', $this->getCustomer()->getId())
81
+ ->addFieldToFilter('usage_type', $usageTypeCondition)
82
+ ->addOrder('xp_card_id', 'desc');
83
+
84
+ $this->setItems($items);
85
+
86
+ $this->cardUsageTypes = Mage::getModel("xpaymentsconnector/usercards")
87
+ ->getCardsUsageOptions();
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Prepare layout
94
+ *
95
+ * @return Mage_Core_Block_Template
96
+ */
97
+ protected function _prepareLayout()
98
+ {
99
+ parent::_prepareLayout();
100
+
101
+ $pager = $this->getLayout()->createBlock('page/html_pager', 'xpaymentsconnector.customer.cards.pager')
102
+ ->setCollection($this->getItems());
103
+
104
+ $this->setChild('pager', $pager);
105
+
106
+ $this->getItems()->load();
107
+
108
+ return $this;
109
+ }
110
+
111
+ /**
112
+ * Get form action URL
113
+ *
114
+ * @return string
115
+ */
116
+ public function getFormUrl()
117
+ {
118
+ $params = array(
119
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
120
+ );
121
+
122
+ return Mage::getUrl('xpaymentsconnector/customer/removecard', $params);
123
+ }
124
+
125
+ /**
126
+ * Get "Back" URL
127
+ *
128
+ * @return string
129
+ */
130
+ public function getBackUrl()
131
+ {
132
+ if ($this->getRefererUrl()) {
133
+
134
+ $url = $this->getRefererUrl();
135
+
136
+ } else {
137
+
138
+ $params = array(
139
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
140
+ );
141
+
142
+ $url = Mage::getUrl('customer/account/', $params);
143
+ }
144
+
145
+ return $url;
146
+ }
147
+
148
+ /**
149
+ * Get Add new card URL
150
+ *
151
+ * @return string
152
+ */
153
+ public function getAddCardUrl()
154
+ {
155
+ $params = array(
156
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
157
+ );
158
+
159
+ return Mage::getUrl('xpaymentsconnector/customer/cardadd', $params);
160
+ }
161
+
162
+ /**
163
+ * Get human-readable card string (type, number, expire date)
164
+ *
165
+ * @param $card Cdev_XPaymentsConnector_Model_Usercards Card model
166
+ *
167
+ * @return string
168
+ */
169
+ public function getCardString($card)
170
+ {
171
+ return Mage::helper('xpaymentsconnector')->prepareCardDataString($card->getData());
172
+ }
173
+
174
+ /**
175
+ * Get human-readable card usage type
176
+ *
177
+ * @param $card Cdev_XPaymentsConnector_Model_Usercards Card model
178
+ *
179
+ * @return string
180
+ */
181
+ public function getCardUsageType($card)
182
+ {
183
+ return $this->cardUsageTypes[$card->getUsageType()];
184
+ }
185
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Form/Cc.php CHANGED
@@ -14,17 +14,16 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
 
24
  /**
25
- * "Credit Card (X-Payments)" form block
26
  */
27
-
28
  class Cdev_XPaymentsConnector_Block_Form_Cc extends Mage_Payment_Block_Form
29
  {
30
  /**
@@ -45,7 +44,7 @@ class Cdev_XPaymentsConnector_Block_Form_Cc extends Mage_Payment_Block_Form
45
  */
46
  protected function isVisible()
47
  {
48
- return Mage::helper('xpaymentsconnector')->isUseIframe()
49
- && 'payment' == Mage::helper('xpaymentsconnector')->getIframePlaceDisplay();
50
  }
51
  }
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
 
24
  /**
25
+ * Iframe block at checkout on the payment step
26
  */
 
27
  class Cdev_XPaymentsConnector_Block_Form_Cc extends Mage_Payment_Block_Form
28
  {
29
  /**
44
  */
45
  protected function isVisible()
46
  {
47
+ return Mage::helper('settings_xpc')->isUseIframe()
48
+ && 'payment' == Mage::helper('settings_xpc')->getIframePlace();
49
  }
50
  }
app/code/community/Cdev/XPaymentsConnector/Block/Form/Prepaidpayments.php DELETED
@@ -1,52 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * "Prepaid Payments (X-Payments)" form block
24
- */
25
-
26
- class Cdev_XPaymentsConnector_Block_Form_Prepaidpayments extends Mage_Payment_Block_Form
27
- {
28
-
29
- protected function _construct()
30
- {
31
- parent::_construct();
32
- $this->setTemplate('xpaymentsconnector/form/prepaidpayments.phtml');
33
- }
34
-
35
- public function getAdminhtmlUserPrepaidCardsList(){
36
- $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
37
- $customerId = $quote->getData('customer_id');
38
- if($customerId){
39
- $userBalanceCardsCollection = Mage::getModel('xpaymentsconnector/usercards')
40
- ->getCollection()
41
- ->addFilter('user_id',$customerId)
42
- ->addFilter('usage_type',Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD);
43
- return $userBalanceCardsCollection;
44
- }
45
- else{
46
- return false;
47
- }
48
-
49
- }
50
-
51
-
52
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Block/Form/Savedcards.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Block/Info/Prepaidpayments.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Block/Success.php DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * Payment success block
24
- *
25
- * @package Cdev_XPaymentsConnector
26
- * @see ____class_see____
27
- * @since 1.0.0
28
- */
29
- class Cdev_XPaymentsConnector_Block_Success extends Mage_Core_Block_Abstract
30
- {
31
- /**
32
- * Get block contecnt as HTML
33
- *
34
- * @return string
35
- * @access protected
36
- * @see ____func_see____
37
- * @since 1.0.0
38
- */
39
- protected function _toHtml()
40
- {
41
- $styleUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_JS)."xpayment/settings.css";
42
-
43
- $successUrl = Mage::getUrl('*/*/success', array('_nosid' => true));
44
- $successUrlHtml = '<a href="'.$successUrl.'">'.$this->__('here').'</a>';
45
- return '<html>'
46
- . '<head>'
47
- ."<link href=".$styleUrl." type='text/css' rel='stylesheet'> "
48
- . '<meta http-equiv="refresh" content="0; URL=' . $successUrl . '" />'
49
- . '</head>'
50
- ."<div class='b-loader-wrap'><div id='ajax-loader'></div></div>"
51
- . '<body>'
52
- ."<div id='wait-message'>"
53
- . '<p><strong>' . $this->__('Your payment has been successfully processed by our shop system.') . '</strong></p>'
54
- . '<p>' . $this->__('Please click %s if you are not redirected automatically.',$successUrlHtml) . '</p>'
55
- ."</div>"
56
- . '</body>'
57
- . '</html>';
58
- }
59
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Helper/Abstract.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Abstract X-Payments helper
25
+ */
26
+
27
+ abstract class Cdev_XPaymentsConnector_Helper_Abstract extends Mage_Core_Helper_Abstract
28
+ {
29
+ /**
30
+ * Log file name
31
+ */
32
+ const XPAYMENTS_LOG_FILE = 'xpayments.log';
33
+
34
+ /**
35
+ * Format price in 1234.56 format
36
+ *
37
+ * @param mixed $price
38
+ *
39
+ * @return string
40
+ */
41
+ public function preparePrice($price)
42
+ {
43
+ return number_format($price, 2, '.', '');
44
+ }
45
+
46
+ /**
47
+ * Write log
48
+ *
49
+ * @param string $title Log title
50
+ * @param mixed $data Data to log
51
+ * @param bool $trace Include backtrace or not
52
+ *
53
+ * @return void
54
+ */
55
+ public function writeLog($title, $data = '', $trace = false)
56
+ {
57
+ if (!is_string($data)) {
58
+ $data = var_export($data, true);
59
+ }
60
+
61
+ $message = PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL
62
+ . $title . PHP_EOL
63
+ . $data . PHP_EOL
64
+ . Mage::helper('core/url')->getCurrentUrl() . PHP_EOL;
65
+
66
+ if ($trace) {
67
+ $message .= '--------------------------' . PHP_EOL
68
+ . Varien_Debug::backtrace(true, false, false)
69
+ . PHP_EOL;
70
+ }
71
+
72
+ Mage::log($message, null, self::XPAYMENTS_LOG_FILE, true);
73
+ }
74
+ }
app/code/community/Cdev/XPaymentsConnector/Helper/Address/Data.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Helper for addresses
25
+ */
26
+
27
+ class Cdev_XPaymentsConnector_Helper_Address_Data extends Cdev_XPaymentsConnector_Helper_Abstract
28
+ {
29
+ /**
30
+ * Placeholder for empty email (something which will pass X-Payments validation)
31
+ */
32
+ const EMPTY_USER_EMAIL = 'user@example.com';
33
+
34
+ /**
35
+ * Placeholder for not available cart data
36
+ */
37
+ const NOT_AVAILABLE = 'N/A';
38
+
39
+ /**
40
+ * Billing and shipping address names
41
+ */
42
+ const BILLING_ADDRESS = 'Billing';
43
+ const SHIPPING_ADDRESS = 'Shipping';
44
+
45
+ /**
46
+ * Prepare state
47
+ *
48
+ * @param array $data Address data
49
+ *
50
+ * @return string
51
+ */
52
+ private function prepareState($data)
53
+ {
54
+ $state = self::NOT_AVAILABLE;
55
+
56
+ if (!empty($data['region_id'])) {
57
+
58
+ $region = Mage::getModel('directory/region')->load($data['region_id']);
59
+
60
+ if (
61
+ $region
62
+ && $region->getCode()
63
+ ) {
64
+ $state = $region->getCode();
65
+ }
66
+ }
67
+
68
+ return $state;
69
+ }
70
+
71
+ /**
72
+ * Prepare street (Address lines 1 and 2)
73
+ *
74
+ * @param array $data Address data
75
+ *
76
+ * @return string
77
+ */
78
+ private function prepareStreet($data)
79
+ {
80
+ $street = self::NOT_AVAILABLE;
81
+
82
+ if (!empty($data['street'])) {
83
+
84
+ $street = $data['street'];
85
+
86
+ if (is_array($street)) {
87
+ $street = array_filter($street);
88
+ $street = implode("\n", $street);
89
+ }
90
+ }
91
+
92
+ return $street;
93
+ }
94
+
95
+ /**
96
+ * Prepare address for initial payment request (internal)
97
+ *
98
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote Quote
99
+ * @param Mage_Customer_Model_Customer $customer Customer
100
+ * @param $type Address type, Billing or Shipping
101
+ *
102
+ * @return array
103
+ */
104
+ private function prepareAddress(Cdev_XPaymentsConnector_Model_Quote $quote = null, Mage_Customer_Model_Customer $customer = null, $type = self::BILLING_ADDRESS)
105
+ {
106
+ $getAddress = 'get' . $type . 'Address';
107
+ $getDefaultAddress = 'getDefault' . $type . 'Address';
108
+
109
+ $customerAddress = $customerDefaultAddress = $quoteAddress = $orderAddress = array();
110
+
111
+ if ($quote) {
112
+
113
+ $customer = $quote->getCustomer();
114
+
115
+ if ($quote->$getAddress()) {
116
+ $quoteAddress = $quote->$getAddress()->getData();
117
+ }
118
+
119
+ if ($quote->isBackendOrderQuote()) {
120
+ $orderAddress = $quote->getBackendOrder()->$getAddress()->getData();
121
+ }
122
+ }
123
+
124
+ if ($customer) {
125
+
126
+ $customerAddress = $customer->getData();
127
+
128
+ if ($customer->$getDefaultAddress()) {
129
+ $customerDefaultAddress = $customer->$getDefaultAddress()->getData();
130
+ }
131
+ }
132
+
133
+ $data = array_merge(
134
+ array_filter($customerAddress),
135
+ array_filter($customerDefaultAddress),
136
+ array_filter($quoteAddress),
137
+ array_filter($orderAddress)
138
+ );
139
+
140
+ $result = array(
141
+ 'firstname' => !empty($data['firstname']) ? $data['firstname'] : self::NOT_AVAILABLE,
142
+ 'lastname' => !empty($data['lastname']) ? $data['lastname'] : self::NOT_AVAILABLE,
143
+ 'address' => $this->prepareStreet($data),
144
+ 'city' => !empty($data['city']) ? $data['city'] : self::NOT_AVAILABLE,
145
+ 'state' => $this->prepareState($data),
146
+ 'country' => !empty($data['country_id']) ? $data['country_id'] : 'XX', // WA fix for MySQL 5.7 with strict mode
147
+ 'zipcode' => !empty($data['postcode']) ? $data['postcode'] : self::NOT_AVAILABLE,
148
+ 'phone' => !empty($data['telephone']) ? $data['telephone'] : '',
149
+ 'fax' => '',
150
+ 'company' => '',
151
+ 'email' => !empty($data['email']) ? $data['email'] : self::EMPTY_USER_EMAIL,
152
+ );
153
+
154
+ return $result;
155
+ }
156
+
157
+ /**
158
+ * Prepare billing address from quote for initial payment request
159
+ *
160
+ * @param Mage_Sales_Model_Quote $quote Quote
161
+ *
162
+ * @return array
163
+ */
164
+ public function prepareQuoteBillingAddress(Cdev_XPaymentsConnector_Model_Quote $quote)
165
+ {
166
+ return $this->prepareAddress($quote, null, self::BILLING_ADDRESS);
167
+ }
168
+
169
+ /**
170
+ * Prepare shipping address from quote for initial payment request
171
+ *
172
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote Quote
173
+ *
174
+ * @return array
175
+ */
176
+ public function prepareQuoteShippingAddress(Cdev_XPaymentsConnector_Model_Quote $quote)
177
+ {
178
+ return $this->prepareAddress($quote, null, self::SHIPPING_ADDRESS);
179
+ }
180
+
181
+ /**
182
+ * Prepare billing address from customer for initial payment request
183
+ *
184
+ * @param Mage_Sales_Model_Customer $customer Customer
185
+ *
186
+ * @return array
187
+ */
188
+ public function prepareCustomerBillingAddress(Mage_Customer_Model_Customer $customer)
189
+ {
190
+ return $this->prepareAddress(null, $customer, self::BILLING_ADDRESS);
191
+ }
192
+
193
+ /**
194
+ * Prepare shipping address from customer for initial payment request
195
+ *
196
+ * @param Mage_Sales_Model_Customer $customer Customer
197
+ *
198
+ * @return array
199
+ */
200
+ public function prepareCustomerShippingAddress(Mage_Customer_Model_Customer $customer)
201
+ {
202
+ return $this->prepareAddress(null, $customer, self::SHIPPING_ADDRESS);
203
+ }
204
+ }
app/code/community/Cdev/XPaymentsConnector/Helper/Api/Data.php ADDED
@@ -0,0 +1,738 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Helper for API
25
+ */
26
+
27
+ class Cdev_XPaymentsConnector_Helper_Api_Data extends Cdev_XPaymentsConnector_Helper_Abstract
28
+ {
29
+ // Payment statuses
30
+ const NEW_STATUS = 1;
31
+ const AUTH_STATUS = 2;
32
+ const DECLINED_STATUS = 3;
33
+ const CHARGED_STATUS = 4;
34
+ const REFUNDED_STATUS = 5;
35
+ const PART_REFUNDED_STATUS = 6;
36
+
37
+ // Payment actions
38
+ const NEW_ACTION = 1;
39
+ const AUTH_ACTION = 2;
40
+ const CHARGED_ACTION = 3;
41
+ const DECLINED_ACTION = 4;
42
+ const REFUND_ACTION = 5;
43
+ const PART_REFUND_ACTION = 6;
44
+
45
+ // Salt block length
46
+ const SALT_LENGTH = 32;
47
+
48
+ // Salt generator start character code
49
+ const SALT_BEGIN = 33;
50
+
51
+ // Salt generator end character code
52
+ const SALT_END = 255;
53
+
54
+ // Encryption check length
55
+ const CHUNK_LENGTH = 128;
56
+
57
+ // Root-level tag for all XML messages
58
+ const TAG_ROOT = 'data';
59
+
60
+ // Value of the 'type' attribute for list items in XML
61
+ const TYPE_CELL = 'cell';
62
+
63
+ /**
64
+ * CURL headers collector callback
65
+ *
66
+ * @return mixed
67
+ */
68
+ protected function getCurlHeadersCollector()
69
+ {
70
+ static $headers = '';
71
+
72
+ $args = func_get_args();
73
+
74
+ if (count($args) == 1) {
75
+
76
+ $return = '';
77
+
78
+ if ($args[0] == true) {
79
+ $return = $headers;
80
+ }
81
+
82
+ $headers = '';
83
+
84
+ } else {
85
+
86
+ if (trim($args[1]) != '') {
87
+ $headers .= $args[1];
88
+ }
89
+ $return = strlen($args[1]);
90
+ }
91
+
92
+ return $return;
93
+ }
94
+
95
+ /**
96
+ * Request
97
+ *
98
+ * @param string $target Request target
99
+ * @param string $action Request action
100
+ * @param array $data Data
101
+ *
102
+ * @return array (Operation status & response array)
103
+ */
104
+ private function request($target, $action, array $data = array())
105
+ {
106
+ $settings = Mage::helper('settings_xpc');
107
+
108
+ $apiResponse = new Cdev_XPaymentsConnector_Transport_ApiResponse;
109
+
110
+ $data['target'] = $target;
111
+ $data['action'] = $action;
112
+
113
+ if (!isset($data['api_version'])) {
114
+ $data['api_version'] = $settings->getXpcConfig('xpay_api_version');
115
+ }
116
+
117
+ $log = 'URL: ' . $settings->getApiUrl() . PHP_EOL
118
+ . 'Data: ' . var_export($data, true) . PHP_EOL;
119
+
120
+ $this->writeLog('Request to X-Payments', $log);
121
+
122
+ try {
123
+
124
+ // Check configuration
125
+ if (!$settings->isConfigured()) {
126
+ throw new Exception('X-Payments Connector is not configured');
127
+ }
128
+
129
+ // Check requirements
130
+ if (!$settings->checkRequirements()) {
131
+ throw new Exception('Check module requirements is failed');
132
+ }
133
+
134
+ // Convert array to XML
135
+ $xml = $this->convertHash2XML($data);
136
+
137
+ if (!$xml) {
138
+ throw new Exception('Data is not valid');
139
+ }
140
+
141
+ // Encrypt
142
+ $xml = $this->encrypt($xml);
143
+ if (!$xml) {
144
+ throw new Exception('Data is not encrypted');
145
+ }
146
+
147
+ // HTTPS request
148
+ $post = array(
149
+ 'cart_id' => $settings->getXpcConfig('xpay_cart_id'),
150
+ 'request' => $xml
151
+ );
152
+
153
+ $this->getCurlHeadersCollector(false);
154
+
155
+ $ch = curl_init();
156
+
157
+ curl_setopt($ch, CURLOPT_URL, $settings->getApiUrl());
158
+ curl_setopt($ch, CURLOPT_HEADER, false);
159
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15000);
160
+ curl_setopt($ch, CURLOPT_POST, true);
161
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
162
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
163
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
164
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, array($this, 'getCurlHeadersCollector'));
165
+
166
+ $body = curl_exec($ch);
167
+ $errno = curl_errno($ch);
168
+ $error = curl_error($ch);
169
+ $headers = $this->getCurlHeadersCollector(true);
170
+
171
+ curl_close($ch);
172
+
173
+ // Check curl error
174
+ if (!empty($error) || 0 != $errno) {
175
+ throw new Exception('Communication error. Curl error #' . $errno . ': ' . $error);
176
+ }
177
+
178
+ $response = $this->decryptXml($body, $headers);
179
+
180
+ $apiResponse->setStatus(true);
181
+ $apiResponse->setResponse($response);
182
+
183
+ if (!empty($response['error'])) {
184
+ $apiResponse->setErrorCode($response['error']);
185
+ }
186
+
187
+ if (!empty($response['error_message'])) {
188
+ $apiResponse->setErrorMessage($response['error_message']);
189
+ }
190
+
191
+ } catch (Exception $e) {
192
+
193
+ $apiResponse->setStatus(false);
194
+ $apiResponse->setErrorMessage($e->getMessage());
195
+ }
196
+
197
+ $this->writeLog('Response from X-Payments', $apiResponse->getData());
198
+
199
+ return $apiResponse;
200
+ }
201
+
202
+ /**
203
+ * Decrypt separate XML block
204
+ *
205
+ * @param string $body Encrypted XML data
206
+ *
207
+ * @return array
208
+ */
209
+ public function decryptXml($body, $headers = null)
210
+ {
211
+ // Check raw data
212
+ if (substr($body, 0, 3) !== 'API') {
213
+
214
+ $error = array(
215
+ 'Response is not valid:',
216
+ $body,
217
+ );
218
+
219
+ if ($headers) {
220
+ $error += array(
221
+ 'Headers:',
222
+ $headers,
223
+ );
224
+ }
225
+
226
+ $error = implode(PHP_EOL, $error);
227
+
228
+ throw new Exception($error);
229
+ }
230
+
231
+ // Decrypt
232
+ list($responseStatus, $response) = $this->decrypt($body);
233
+
234
+ if (!$responseStatus) {
235
+ throw new Exception('Response is not decrypted (Error: ' . $response . ')');
236
+ }
237
+
238
+ // Convert XML to array
239
+ $response = $this->convertXML2Hash($response);
240
+
241
+ if (!is_array($response)) {
242
+ throw new Exception('Unable to convert response into XML');
243
+ }
244
+
245
+ // The 'Data' tag must be set in response
246
+ if (!isset($response[self::TAG_ROOT])) {
247
+ throw new Exception('Response does not contain any data');
248
+ }
249
+ return $response[self::TAG_ROOT];
250
+ }
251
+
252
+ /**
253
+ * Convert hash to XML
254
+ *
255
+ * @param array $data Hash
256
+ * @param integer $level Parentness level
257
+ *
258
+ * @return string
259
+ */
260
+ public function convertHash2Xml(array $data, $level = 0)
261
+ {
262
+ $xml = '';
263
+
264
+ foreach ($data as $name => $value) {
265
+
266
+ if ($this->isAnonymousArray($value)) {
267
+
268
+ foreach ($value as $item) {
269
+
270
+ $xml .= $this->writeXMLTag($item, $name, $level, self::TYPE_CELL);
271
+ }
272
+
273
+ } else {
274
+
275
+ $xml .= $this->writeXMLTag($value, $name, $level);
276
+ }
277
+ }
278
+
279
+ return $xml;
280
+ }
281
+
282
+ /**
283
+ * Check - argument is plain array or not
284
+ *
285
+ * @param array $data Array
286
+ *
287
+ * @return boolean
288
+ */
289
+ private function isAnonymousArray($data)
290
+ {
291
+ return is_array($data)
292
+ && 1 > count(preg_grep('/^\d+$/', array_keys($data), PREG_GREP_INVERT));
293
+ }
294
+
295
+ /**
296
+ * Write XML tag
297
+ *
298
+ * @param mixed $data Data
299
+ * @param string $name Tag name
300
+ * @param integer $level Parentness level
301
+ * @param string $type Tag type
302
+ *
303
+ * @return string
304
+ */
305
+ protected function writeXMLTag($data, $name, $level = 0, $type = '')
306
+ {
307
+ $xml = '';
308
+ $indent = str_repeat(' ', $level);
309
+
310
+ // Open tag
311
+ $xml .= $indent . '<' . $name . (empty($type) ? '' : ' type="' . $type . '"') . '>';
312
+
313
+ // Sublevel tags or tag value
314
+ if (is_array($data)) {
315
+ $xml .= "\n" . $this->convertHash2XML($data, $level + 1) . $indent;
316
+
317
+ } elseif (function_exists('iconv')) {
318
+ $trn = iconv('UTF-8', 'UTF-8//IGNORE', $data);
319
+ $data = false === $trn ? $data : $trn;
320
+ $data = str_replace(
321
+ array("\n", "\t", "\r", "\f",),
322
+ array(' ', ' ', '', '',),
323
+ $data
324
+ );
325
+ $xml .= $data;
326
+
327
+ } else {
328
+ $data = str_replace(
329
+ array("\n", "\t", "\r", "\f",),
330
+ array(' ', ' ', '', '',),
331
+ $data
332
+ );
333
+ $xml .= $data;
334
+ }
335
+
336
+ // Close tag
337
+ $xml .= '</' . $name . '>' . "\n";
338
+
339
+ return $xml;
340
+ }
341
+
342
+ /**
343
+ * Convert XML-to-hash
344
+ *
345
+ * @param string $xml XML string
346
+ *
347
+ * @return array or string
348
+ */
349
+ private function convertXml2Hash($xml)
350
+ {
351
+ $data = array();
352
+
353
+ while (
354
+ !empty($xml)
355
+ && preg_match('/<([\w\d]+)(?:\s*type=["\'](\w+)["\']\s*)?' . '>(.*)<\/\1>/Us', $xml, $matches)
356
+ ) {
357
+
358
+ // Sublevel tags or tag value
359
+ if (self::TYPE_CELL === $matches[2]) {
360
+
361
+ $data[$matches[1]][] = $this->convertXML2Hash($matches[3]);
362
+
363
+ } else {
364
+
365
+ $data[$matches[1]] = $this->convertXML2Hash($matches[3]);
366
+ }
367
+
368
+ // Exclude parsed part from XML
369
+ $xml = str_replace($matches[0], '', $xml);
370
+ }
371
+
372
+ return empty($data) ? $xml : $data;
373
+ }
374
+
375
+ /**
376
+ * Encrypt data
377
+ *
378
+ * @param string $data Data
379
+ *
380
+ * @return string
381
+ */
382
+ public function encrypt($data)
383
+ {
384
+ // Preprocess
385
+ srand(time());
386
+ $salt = '';
387
+ for ($i = 0; $i < self::SALT_LENGTH; $i++) {
388
+ $salt .= chr(rand(self::SALT_BEGIN, self::SALT_END));
389
+ }
390
+
391
+ $lenSalt = strlen($salt);
392
+
393
+ $crcType = 'MD5';
394
+ $crc = md5($data, true);
395
+
396
+ $crc = str_repeat(' ', 8 - strlen($crcType)) . $crcType . $crc;
397
+ $lenCRC = strlen($crc);
398
+
399
+ $lenData = strlen($data);
400
+
401
+ $data = str_repeat('0', 12 - strlen((string)$lenSalt)) . $lenSalt . $salt
402
+ . str_repeat('0', 12 - strlen((string)$lenCRC)) . $lenCRC . $crc
403
+ . str_repeat('0', 12 - strlen((string)$lenData)) . $lenData . $data;
404
+
405
+ // Encrypt
406
+ $key = openssl_pkey_get_public(Mage::helper('settings_xpc')->getXpcConfig('xpay_public_key'));
407
+ if (!$key) {
408
+ throw new Exception('Cannot initialize public key');
409
+ }
410
+
411
+ $data = str_split($data, self::CHUNK_LENGTH);
412
+ $crypttext = null;
413
+ foreach ($data as $k => $chunk) {
414
+ if (!openssl_public_encrypt($chunk, $crypttext, $key)) {
415
+ throw new Exception('Cannot enctypt chunk');
416
+ }
417
+
418
+ $data[$k] = $crypttext;
419
+ }
420
+
421
+ // Postprocess
422
+ $data = array_map('base64_encode', $data);
423
+
424
+ return 'API' . implode("\n", $data);
425
+ }
426
+
427
+ /**
428
+ * Decrypt
429
+ *
430
+ * @param string $data Encrypted data
431
+ *
432
+ * @return string
433
+ */
434
+ private function decrypt($data)
435
+ {
436
+ // Decrypt
437
+ $res = openssl_get_privatekey(
438
+ Mage::helper('settings_xpc')->getXpcConfig('xpay_private_key'),
439
+ Mage::helper('settings_xpc')->getXpcConfig('xpay_private_key_pass')
440
+ );
441
+ if (!$res) {
442
+ throw new Exception('Private key is not initialized');
443
+ }
444
+
445
+ $data = substr($data, 3);
446
+
447
+ $data = explode("\n", $data);
448
+ $data = array_map('base64_decode', $data);
449
+ foreach ($data as $k => $s) {
450
+ if (!openssl_private_decrypt($s, $newsource, $res)) {
451
+ throw new Exception('Can not decrypt chunk');
452
+ }
453
+
454
+ $data[$k] = $newsource;
455
+ }
456
+
457
+ openssl_free_key($res);
458
+
459
+ $data = implode('', $data);
460
+
461
+ // Postprocess
462
+ $lenSalt = substr($data, 0, 12);
463
+ if (!preg_match('/^\d+$/Ss', $lenSalt)) {
464
+ throw new Exception('Salt length prefix has wrong format');
465
+ }
466
+
467
+ $lenSalt = intval($lenSalt);
468
+ $data = substr($data, 12 + intval($lenSalt));
469
+
470
+ $lenCRC = substr($data, 0, 12);
471
+ if (!preg_match('/^\d+$/Ss', $lenCRC) || $lenCRC < 9) {
472
+ throw new Exception('CRC length prefix has wrong format');
473
+ }
474
+
475
+ $lenCRC = intval($lenCRC);
476
+ $crcType = trim(substr($data, 12, 8));
477
+ if ($crcType !== 'MD5') {
478
+ throw new Exception('CRC hash is not MD5');
479
+ }
480
+ $crc = substr($data, 20, $lenCRC - 8);
481
+
482
+ $data = substr($data, 12 + $lenCRC);
483
+
484
+ $lenData = substr($data, 0, 12);
485
+ if (!preg_match('/^\d+$/Ss', $lenData)) {
486
+ throw new Exception('Data block length prefix has wrong format');
487
+ }
488
+
489
+ $data = substr($data, 12, intval($lenData));
490
+
491
+ $currentCRC = md5($data, true);
492
+ if ($currentCRC !== $crc) {
493
+ throw new Exception('Original CRC and calculated CRC is not equal');
494
+ }
495
+
496
+ return array(true, $data);
497
+ }
498
+
499
+ /**
500
+ * Check if status is succesfull
501
+ *
502
+ * @param string $status Status
503
+ *
504
+ * @return bool
505
+ */
506
+ public function isSuccessStatus($status)
507
+ {
508
+ return self::AUTH_STATUS == $status
509
+ || self::CHARGED_STATUS == $status;
510
+ }
511
+
512
+ /**
513
+ * Process Connect Test request
514
+ *
515
+ * @param string $apiVersion API version
516
+ * @param string $error Error message (if any)
517
+ * @param string $code Error code (if any)
518
+ *
519
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
520
+ */
521
+ public function testConnection($apiVersion)
522
+ {
523
+ srand();
524
+
525
+ $hashCode = strval(rand(0, 1000000));
526
+
527
+ $params = array(
528
+ 'testCode' => $hashCode,
529
+ );
530
+
531
+ $params['api_version'] = $apiVersion;
532
+
533
+ // Send test request
534
+
535
+ $response = $this->request(
536
+ 'connect',
537
+ 'test',
538
+ $params
539
+ );
540
+
541
+ $result = $response->getStatus();
542
+
543
+ if (
544
+ $response->getStatus()
545
+ && md5($hashCode) != $response->getField('hashCode')
546
+ ) {
547
+ $response->setStatus(false);
548
+ $response->setErrorMessage('Connection with X-Payments is not verified');
549
+ }
550
+
551
+ return $response;
552
+ }
553
+
554
+ /**
555
+ * Send Get payment configurations request
556
+ *
557
+ * @return array Payment configurations list
558
+ */
559
+ public function requestPaymentMethods()
560
+ {
561
+ $result = array();
562
+
563
+ // Call the "api.php?target=payment_confs&action=get" URL
564
+ $response = $this->request(
565
+ 'payment_confs',
566
+ 'get',
567
+ array()
568
+ );
569
+
570
+ // Check status
571
+ if (
572
+ $response->getStatus()
573
+ && (is_array($response->getField('payment_module'))
574
+ )) {
575
+ $result = $response->getField('payment_module');
576
+ }
577
+
578
+ return $result;
579
+ }
580
+
581
+ /**
582
+ * Initialize payment
583
+ *
584
+ * @param array $data Request data
585
+ *
586
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
587
+ */
588
+ public function initPayment($data)
589
+ {
590
+ $response = $this->request('payment', 'init', $data);
591
+
592
+ if (
593
+ empty($response->getField('token'))
594
+ || empty($response->getField('txnId'))
595
+ ) {
596
+
597
+ $response->setStatus(false);
598
+ }
599
+
600
+ return $response;
601
+ }
602
+
603
+ /**
604
+ * Send Payment info request
605
+ *
606
+ * @param string $txnId X-Payments transaction id
607
+ * @param boolean $refresh Refresh data flag
608
+ * @param boolean $withAdditionalInfo Flag for additional info
609
+ *
610
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
611
+ */
612
+ public function requestPaymentInfo($txnId, $refresh = false, $withAdditionalInfo = false)
613
+ {
614
+ $data = array(
615
+ 'txnId' => $txnId,
616
+ );
617
+
618
+ if ($withAdditionalInfo) {
619
+
620
+ $action = 'get_additional_info';
621
+
622
+ } else {
623
+
624
+ $data['refresh'] = $refresh ? 1 : 0;
625
+
626
+ $action = 'get_info';
627
+ }
628
+
629
+ return $this->request('payment', $action, $data);
630
+ }
631
+
632
+ /**
633
+ * Send capture payment request
634
+ *
635
+ * @param string $txnId X-Payments transaction id
636
+ * @param float $amount Amount
637
+ *
638
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
639
+ */
640
+ public function requestPaymentCapture($txnId, $amount = false)
641
+ {
642
+ $data = array(
643
+ 'txnId' => $txnId,
644
+ );
645
+
646
+ if ($amount) {
647
+ $data['amount'] = $this->preparePrice($amount);
648
+ }
649
+
650
+ return $this->request('payment', 'capture', $data);
651
+ }
652
+
653
+ /**
654
+ * Send void payment request
655
+ *
656
+ * @param string $txnId X-Payments transaction id
657
+ * @param float $amount Amount
658
+ *
659
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
660
+ */
661
+ public function requestPaymentVoid($txnId, $amount = false)
662
+ {
663
+ $data = array(
664
+ 'txnId' => $txnId,
665
+ );
666
+
667
+ if ($amount) {
668
+ $data['amount'] = $this->preparePrice($amount);
669
+ }
670
+
671
+ return $this->request('payment', 'void', $data);
672
+ }
673
+
674
+ /**
675
+ * Send refund payment request
676
+ *
677
+ * @param string $txnId X-Payments transaction id
678
+ * @param float $amount Amount
679
+ *
680
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
681
+ */
682
+ public function requestPaymentRefund($txnId, $amount = false)
683
+ {
684
+ $data = array(
685
+ 'txnId' => $txnId,
686
+ );
687
+
688
+ if ($amount) {
689
+ $data['amount'] = $this->preparePrice($amount);
690
+ }
691
+
692
+ return $this->request('payment', 'refund', $data);
693
+ }
694
+
695
+ /**
696
+ * Send accept payment request
697
+ *
698
+ * @param string $txnId X-Payments transaction id
699
+ *
700
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
701
+ */
702
+ public function requestPaymentAccept($txnId)
703
+ {
704
+ $data = array(
705
+ 'txnId' => $txnId,
706
+ );
707
+
708
+ return $this->request('payment', 'accept', $data);
709
+ }
710
+
711
+ /**
712
+ * Send decline payment request
713
+ *
714
+ * @param string $txnId X-Payments transaction id
715
+ *
716
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
717
+ */
718
+ public function requestPaymentDecline($txnId)
719
+ {
720
+ $data = array(
721
+ 'txnId' => $txnId,
722
+ );
723
+
724
+ return $this->request('payment', 'decline', $data);
725
+ }
726
+
727
+ /**
728
+ * Send recharge payment request
729
+ *
730
+ * @param array $data Payment data
731
+ *
732
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
733
+ */
734
+ public function requestPaymentRecharge($data)
735
+ {
736
+ return $this->request('payment', 'recharge', $data);
737
+ }
738
+ }
app/code/community/Cdev/XPaymentsConnector/Helper/Cart/Data.php ADDED
@@ -0,0 +1,310 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Helper for cart
25
+ */
26
+
27
+ class Cdev_XPaymentsConnector_Helper_Cart_Data extends Cdev_XPaymentsConnector_Helper_Abstract
28
+ {
29
+ /**
30
+ * Prepare totals element: shipping, tax, discount
31
+ *
32
+ * @param array $totals Cart totals
33
+ * @param string $key Totals element key
34
+ *
35
+ * @return string
36
+ */
37
+ private function prepareTotalsElement($totals, $key)
38
+ {
39
+ $value = 0;
40
+
41
+ if (
42
+ isset($totals[$key])
43
+ && is_object($totals[$key])
44
+ && method_exists($totals[$key], 'getValue')
45
+ ) {
46
+ $value = abs($totals[$key]->getValue());
47
+ }
48
+
49
+ return $this->preparePrice($value);
50
+ }
51
+
52
+ /**
53
+ * Prepare simple items from quote for initial payment request
54
+ *
55
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
56
+ * @param array &$result
57
+ *
58
+ * @return void
59
+ */
60
+ protected function prepareSimpleItems(Cdev_XPaymentsConnector_Model_Quote $quote, &$result)
61
+ {
62
+ if ($quote->isBackendOrderQuote()) {
63
+
64
+ $order = $quote->getBackendOrder();
65
+
66
+ $result['totalCost'] = $this->preparePrice($order->getGrandTotal());
67
+ $result['shippingCost'] = $this->preparePrice($order->getShippingSmount());
68
+ $result['taxCost'] = $this->preparePrice($order->getTaxAmount());
69
+ $result['discount'] = $this->preparePrice($order->getDiscountAmount());
70
+
71
+ } else {
72
+
73
+ $quote->collectTotals();
74
+ $totals = $quote->getTotals();
75
+
76
+ $result['totalCost'] = $this->preparePrice($quote->getGrandTotal());
77
+ $result['shippingCost'] = $this->prepareTotalsElement($totals, 'shipping');
78
+ $result['taxCost'] = $this->prepareTotalsElement($totals, 'tax');
79
+ $result['discount'] = $this->prepareTotalsElement($totals, 'discount');
80
+ }
81
+
82
+ foreach ($quote->getAllVisibleItems() as $item) {
83
+
84
+ if ($item->getIsNominal()) {
85
+ continue;
86
+ }
87
+
88
+ $productId = $item->getProductId();
89
+ $product = Mage::getModel('catalog/product')->load($productId);
90
+
91
+ $qty = $item->getQty() ? $item->getQty() : $item->getQtyOrdered();
92
+
93
+ $result['items'][] = array(
94
+ 'sku' => $product->getData('sku'),
95
+ 'name' => $product->getData('name'),
96
+ 'price' => $this->preparePrice($product->getPrice()),
97
+ 'quantity' => intval($qty),
98
+ );
99
+ }
100
+ }
101
+
102
+ /**
103
+ * Prepare recurring item for initial payment request
104
+ *
105
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
106
+ * @param array &$result
107
+ *
108
+ * @return void
109
+ */
110
+ private function prepareRecurringItem(Cdev_XPaymentsConnector_Model_Quote $quote, &$result)
111
+ {
112
+ $item = $quote->getRecurringItem();
113
+ $product = $item->getProduct();
114
+ $recurringProfile = $product->getRecurringProfile();
115
+
116
+ $startDateParams = Mage::helper('xpaymentsconnector')->checkStartDateDataByProduct($product, $item);
117
+ $startDateParams = $startDateParams[$product->getId()];
118
+
119
+ $shipping = $item->getData('shipping_amount');
120
+ $discount = abs($item->getData('discount_amount'));
121
+
122
+ $quantity = $item->getQty();
123
+
124
+ if ($startDateParams['success']) {
125
+
126
+ $minimalPayment = $startDateParams['minimal_payment_amount'];
127
+
128
+ $tax = !empty($recurringProfile['init_amount'])
129
+ ? $item->getData('initialfee_tax_amount')
130
+ : 0;
131
+
132
+ $totalCost = $minimalPayment + $tax + $shipping - $discount;
133
+
134
+ } else {
135
+
136
+ $minimalPayment = 0;
137
+
138
+ $tax = $item->getData('initialfee_tax_amount') + $item->getData('tax_amount');
139
+
140
+ $totalCost = $item->getData('nominal_row_total');
141
+ }
142
+
143
+ $recurringPrice = $product->getPrice();
144
+
145
+ if (!empty($recurringProfile['init_amount'])) {
146
+ $recurringPrice += $item->getXpRecurringInitialFee() / $quantity;
147
+ }
148
+
149
+ $price = $minimalPayment
150
+ ? $minimalPayment / $quantity
151
+ : $recurringPrice;
152
+
153
+ $result['items'][] = array(
154
+ 'sku' => $product->getData('sku'),
155
+ 'name' => $product->getData('name'),
156
+ 'price' => $this->preparePrice($price),
157
+ 'quantity' => intval($quantity),
158
+ );
159
+
160
+ $result['totalCost'] = $this->preparePrice($price);
161
+ $result['shippingCost'] = $this->preparePrice($shipping);
162
+ $result['taxCost'] = $this->preparePrice($tax);
163
+ $result['discount'] = $this->preparePrice($discount);
164
+ }
165
+
166
+ /**
167
+ * Prepare items for initial payment request
168
+ *
169
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
170
+ * @param array &$result
171
+ *
172
+ * @return void
173
+ */
174
+ public function prepareItems(Cdev_XPaymentsConnector_Model_Quote $quote, &$result)
175
+ {
176
+ if ($quote->getRecurringItem()) {
177
+
178
+ // Actually, only one item per order.
179
+ // For checkout with subscription
180
+ $this->prepareRecurringItem($quote, $result);
181
+
182
+ } else {
183
+
184
+ // For checkout with regular items
185
+ $this->prepareSimpleItems($quote, $result);
186
+ }
187
+ }
188
+
189
+ /**
190
+ * Get forced transaction type
191
+ *
192
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
193
+ *
194
+ * @return string
195
+ */
196
+ private function getForcedTransactionType(Cdev_XPaymentsConnector_Model_Quote $quote)
197
+ {
198
+ $isRecurringItem = (bool)$quote->getRecurringItem();
199
+
200
+ $xpcSlot = $quote->getXpcSlot();
201
+
202
+ $settings = Mage::helper('settings_xpc');
203
+
204
+ if (
205
+ $isRecurringItem && $settings->getPaymentConfig('use_initialfee_authorize', $xpcSlot)
206
+ || !$isRecurringItem && $settings->getPaymentConfig('use_authorize', $xpcSlot)
207
+ ) {
208
+
209
+ $result = 'A';
210
+
211
+ } else {
212
+
213
+ $result = '';
214
+ }
215
+
216
+ return $result;
217
+ }
218
+
219
+ /**
220
+ * Prepare cart for initial payment request
221
+ *
222
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
223
+ * @param string $refId Reference to the order
224
+ *
225
+ * @return array
226
+ */
227
+ public function prepareCart(Cdev_XPaymentsConnector_Model_Quote $quote, $refId = false)
228
+ {
229
+ if ($refId) {
230
+ $description = 'Order #' . $refId;
231
+ } else {
232
+ $description = 'Quote #' . $quote->getId();
233
+ }
234
+
235
+ $customer = $quote->getCustomer();
236
+
237
+ if (
238
+ !$customer->getData('email')
239
+ || !$customer->getData('entity_id')
240
+ ) {
241
+ $login = 'Anonymous customer (' . $description . ')';
242
+ } else {
243
+ $login = $customer->getData('email') . ' (User ID #' . $customer->getData('entity_id') . ')';
244
+ }
245
+
246
+ $result = array(
247
+ 'login' => $login,
248
+ 'billingAddress' => Mage::helper('address_xpc')->prepareQuoteBillingAddress($quote),
249
+ 'shippingAddress' => Mage::helper('address_xpc')->prepareQuoteShippingAddress($quote),
250
+ 'items' => array(),
251
+ 'currency' => $quote->getCurrency(),
252
+ 'shippingCost' => 0.00,
253
+ 'taxCost' => 0.00,
254
+ 'discount' => 0.00,
255
+ 'totalCost' => 0.00,
256
+ 'description' => $description,
257
+ 'merchantEmail' => Mage::getStoreConfig('trans_email/ident_sales/email'),
258
+ 'forceTransactionType' => $this->getForcedTransactionType($quote),
259
+ );
260
+
261
+ $this->prepareItems($quote, $result);
262
+
263
+ return $result;
264
+ }
265
+
266
+ /**
267
+ * Prepare cart for initial payment request
268
+ *
269
+ * @param Mage_Customer_Model_Customer $customer Customer
270
+ *
271
+ * @return array
272
+ */
273
+ public function prepareFakeCart(Mage_Customer_Model_Customer $customer)
274
+ {
275
+ $settings = Mage::helper('settings_xpc');
276
+
277
+ $description = strval($settings->getXpcConfig('xpay_zero_auth_description'));
278
+ if (!$description) {
279
+ $description = 'Authorization';
280
+ }
281
+
282
+ $price = $this->preparePrice($settings->getXpcConfig('xpay_zero_auth_amount'));
283
+
284
+ $currency = $settings->getZeroAuthMethod()->getPaymentConfiguration()->getCurrency();
285
+
286
+ $result = array(
287
+ 'login' => $customer->getData('email') . ' (User ID #' . $customer->getData('entity_id') . ')',
288
+ 'billingAddress' => Mage::helper('address_xpc')->prepareCustomerBillingAddress($customer),
289
+ 'shippingAddress' => Mage::helper('address_xpc')->prepareCustomerShippingAddress($customer),
290
+ 'items' => array(
291
+ array(
292
+ 'sku' => 'CardSetup',
293
+ 'name' => 'CardSetup',
294
+ 'price' => $price,
295
+ 'quantity' => '1',
296
+ ),
297
+ ),
298
+ 'currency' => $currency,
299
+ 'shippingCost' => 0.00,
300
+ 'taxCost' => 0.00,
301
+ 'discount' => 0.00,
302
+ 'totalCost' => $price,
303
+ 'description' => $description,
304
+ 'merchantEmail' => Mage::getStoreConfig('trans_email/ident_sales/email'),
305
+ 'forceTransactionType' => 'A',
306
+ );
307
+
308
+ return $result;
309
+ }
310
+ }
app/code/community/Cdev/XPaymentsConnector/Helper/Data.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -28,51 +28,33 @@
28
  * @since 1.0.0
29
  */
30
 
31
- class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
32
  {
33
  const DAY_TIME_STAMP = 86400;
34
  const WEEK_TIME_STAMP = 604800;
35
  const SEMI_MONTH_TIME_STAMP = 1209600;
36
 
37
  /**
38
- * Order statuses. Constant values are left for the backwards compatibility
39
  */
40
  const STATUS_AUTHORIZED = 'xp_pending_payment';
41
  const STATUS_CHARGED = 'processing';
42
  const STATUS_FRAUD = 'fraud';
43
 
44
- const XPAYMENTS_LOG_FILE = 'xpayments.log';
45
  const RECURRING_ORDER_TYPE = 'recurring';
46
  const SIMPLE_ORDER_TYPE = 'simple';
47
 
48
- // TODO: change both names in the database!!!!!!!!
49
-
50
  /**
51
- * Attribute name to store temporary X-Payments data in Quote model
52
  */
53
  const XPC_DATA = 'xp_card_data';
54
 
55
- /**
56
- * Attribute name to store checkout data in Quote model
57
- */
58
- const CHECKOUT_DATA = 'xp_callback_approve';
59
-
60
- /**
61
- * Placeholder for empty email (something which will pass X-Payments validation)
62
- */
63
- const EMPTY_USER_EMAIL = 'user@example.com';
64
-
65
- /**
66
- * Placeholder for not available cart data
67
- */
68
- const NOT_AVAILABLE = 'N/A';
69
-
70
  /**
71
  * Checkout methods
72
  */
73
  const METHOD_LOGIN_IN = 'login_in';
74
  const METHOD_REGISTER = 'register';
75
-
76
  /**
77
  * save/update qty for createOrder function.
78
  * @var int
@@ -80,228 +62,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
80
  protected $itemsQty = null;
81
  public $payDeferredProfileId = null;
82
 
83
- /**
84
- * This function return 'IncrementId' for feature order.
85
- * Xpayment Prepare Order Mas(xpayment_prepare_order):
86
- * - prepare_order_id (int)
87
- * - xpayment_response
88
- * - token
89
- * return
90
- * @return bool or int
91
- */
92
- public function getOrderKey()
93
- {
94
- $xpaymentPrepareOrderData = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
95
- if ($xpaymentPrepareOrderData && isset($xpaymentPrepareOrderData['prepare_order_id'])) {
96
- return $xpaymentPrepareOrderData['prepare_order_id'];
97
- }
98
- return false;
99
- }
100
-
101
- /**
102
- * This function create 'IncrementId' for feature order.
103
- * Xpayment Prepare Order Mas(xpayment_prepare_order):
104
- * - prepare_order_id (int)
105
- * - xpayment_response
106
- * - token
107
- * return
108
- * @return bool or int
109
- */
110
- public function prepareOrderKey()
111
- {
112
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
113
- if(!isset($xpaymentPrepareOrder["prepare_order_id"])){
114
- $this->prepareSimpleOrderKey();
115
- }
116
-
117
- }
118
-
119
- public function updateRecurringMasKeys(Mage_Payment_Model_Recurring_Profile $recurringProfile)
120
- {
121
- $orderItemInfo = $recurringProfile->getData('order_item_info');
122
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
123
- $xpaymentPrepareOrder['recurring_mas'][$orderItemInfo['product_id']] = $this->getOrderKey();
124
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
125
- }
126
-
127
- public function getPrepareRecurringMasKey(Mage_Payment_Model_Recurring_Profile $recurringProfile)
128
- {
129
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
130
- if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['recurring_mas'])) {
131
- $orderItemInfo = $recurringProfile->getData('order_item_info');
132
- $prodId = $orderItemInfo['product_id'];
133
- if (isset($xpaymentPrepareOrder['recurring_mas'][$prodId])) {
134
- return $xpaymentPrepareOrder['recurring_mas'][$prodId];
135
- }
136
- }
137
- return false;
138
- }
139
-
140
-
141
- /**
142
- * @return mixed
143
- */
144
- public function prepareSimpleOrderKey()
145
- {
146
- $storeId = Mage::app()->getStore()->getStoreId();
147
- $prepareOrderId = Mage::getSingleton('eav/config')
148
- ->getEntityType('order')
149
- ->fetchNewIncrementId($storeId);
150
-
151
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
152
- $xpaymentPrepareOrder['prepare_order_id'] = $prepareOrderId;
153
-
154
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
155
- return $prepareOrderId;
156
-
157
- }
158
-
159
- /**
160
- * Check if Idev OneStepCheckout module is enablled and activated
161
- *
162
- * @return bool
163
- */
164
- public function checkOscModuleEnabled()
165
- {
166
- $modules = Mage::getConfig()->getNode('modules')->children();
167
- $modules = (array)$modules;
168
-
169
- $result = false;
170
-
171
- if (isset($modules['Idev_OneStepCheckout'])) {
172
-
173
- $module = $modules['Idev_OneStepCheckout'];
174
-
175
- if ($module->active) {
176
-
177
- $result = (bool)Mage::getStoreConfig(
178
- 'onestepcheckout/general/rewrite_checkout_links',
179
- Mage::app()->getStore()
180
- );
181
- }
182
-
183
- }
184
-
185
- return $result;
186
- }
187
-
188
- /**
189
- * Check if Firecheckout module is enablled and activated
190
- *
191
- * @return bool
192
- */
193
- public function checkFirecheckoutModuleEnabled()
194
- {
195
- $modules = Mage::getConfig()->getNode('modules')->children();
196
- $modules = (array)$modules;
197
-
198
- $result = false;
199
-
200
- if (isset($modules['TM_FireCheckout'])) {
201
-
202
- $module = $modules['TM_FireCheckout'];
203
-
204
- if ($module->active) {
205
-
206
- $result = (bool)Mage::getStoreConfig(
207
- 'firecheckout/general/enabled',
208
- Mage::app()->getStore()
209
- );
210
- }
211
-
212
- }
213
-
214
- return $result;
215
- }
216
-
217
-
218
- /**
219
- * Get place to display iframe. Review or payment step of checkout
220
- *
221
- * @return string "payment" or "review"
222
- */
223
- public function getIframePlaceDisplay()
224
- {
225
- $place = Mage::getStoreConfig('payment/xpayments/placedisplay');
226
-
227
- if (
228
- $this->checkOscModuleEnabled()
229
- || $this->checkFirecheckoutModuleEnabled()
230
- ) {
231
- $place = 'payment';
232
- } elseif (
233
- $place != 'payment'
234
- && $place != 'review'
235
- ) {
236
- $place = 'payment';
237
- }
238
-
239
- return $place;
240
- }
241
-
242
- /**
243
- * Check if iframe should be used or not
244
- *
245
- * @return bool
246
- */
247
- public function isUseIframe()
248
- {
249
- return $this->checkOscModuleEnabled()
250
- || $this->checkFirecheckoutModuleEnabled()
251
- || Mage::getStoreConfig('payment/xpayments/use_iframe');
252
- }
253
-
254
- /**
255
- * This function set 'place_display' flag for feature x-payment form.
256
- * Xpayment Prepare Order Mas(xpayment_prepare_order):
257
- * - prepare_order_id (int)
258
- * - xpayment_response
259
- * - token
260
- * - place_display
261
- * return
262
- * @return bool or int
263
- */
264
- public function setIframePlaceDisplaySettings()
265
- {
266
- if ($this->isUseIframe()) {
267
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
268
- $xpaymentPrepareOrder['place_display'] = $this->getIframePlaceDisplay();
269
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
270
- }
271
- }
272
-
273
- /**
274
- * check 'xpayment' config settigs
275
- * @return bool
276
- */
277
- public function isIframePaymentPlaceDisplay()
278
- {
279
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
280
- if (isset($xpaymentPrepareOrder['place_display']) && ($xpaymentPrepareOrder['place_display'] == 'payment')) {
281
- return true;
282
- }
283
- return false;
284
- }
285
-
286
- /**
287
- * This function return saved card data from X-Payments response.
288
- * @return bool or array
289
- */
290
- public function getXpCardData($quoteId = null)
291
- {
292
- if (is_null($quoteId)) {
293
- $currentCart = Mage::getModel('checkout/cart')->getQuote();
294
- $quoteId = $currentCart->getEntityId();
295
- }
296
- $cartModel = Mage::getModel('sales/quote')->load($quoteId);
297
- $cardData = $cartModel->getXpCardData();
298
- if (!empty($cardData)) {
299
- $cardData = unserialize($cardData);
300
- return $cardData;
301
- }
302
- return false;
303
- }
304
-
305
  /**
306
  * Save masked CC details to the order model
307
  *
@@ -319,145 +79,15 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
319
  }
320
 
321
  /**
322
- * This function sets a type for prepared order
323
- * Xpayment Prepare Order Mas(xpayment_prepare_order):
324
- * - prepare_order_id (int)
325
- * - xpayment_response
326
- * - type (string)
327
- * - is_recurring
328
- */
329
- public function setPrepareOrderType()
330
- {
331
- // TODO: Remove it? Or rework.
332
-
333
- $data = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
334
-
335
- if ($this->getRecurringQuoteItem()) {
336
- $data['type'] = self::RECURRING_ORDER_TYPE;
337
- } else {
338
- $data['type'] = self::SIMPLE_ORDER_TYPE;
339
- }
340
-
341
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $data);
342
- }
343
-
344
- /**
345
- * This function checks a type for prepared order
346
- * Xpayment Prepare Order Mas(xpayment_prepare_order):
347
- * - prepare_order_id (int)
348
- * - xpayment_response
349
- * - type (string)
350
- * - is_recurring
351
- * @return bool
352
- */
353
- public function checkIsRecurringPrepareOrderType()
354
- {
355
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
356
- if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['type']) && !empty($xpaymentPrepareOrder['type'])) {
357
- ($xpaymentPrepareOrder['type'] == self::RECURRING_ORDER_TYPE) ? true : false;
358
- return ($xpaymentPrepareOrder['type'] == self::RECURRING_ORDER_TYPE) ? true : false;
359
- } else {
360
- return false;
361
- }
362
- }
363
-
364
- /**
365
- * Unset prepare order params
366
- * @param array $unsetParams
367
- */
368
- public function unsetXpaymentPrepareOrder($unsetParams = array())
369
- {
370
- if (!empty($unsetParams)) {
371
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
372
- foreach ($unsetParams as $param) {
373
- if (is_array($xpaymentPrepareOrder) && isset($xpaymentPrepareOrder[$param])) {
374
- unset($xpaymentPrepareOrder[$param]);
375
- }
376
- }
377
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
378
- return;
379
- }
380
-
381
- Mage::getSingleton('checkout/session')->unsetData('xpayment_prepare_order');
382
- }
383
-
384
- /**
385
- * Save X-Payments response data after card data send.
386
- * - xpayment_response
387
- * @param array $responseData
388
- */
389
- public function savePaymentResponse($responseData)
390
- {
391
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
392
- $xpaymentPrepareOrder['xpayment_response'] = $responseData;
393
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
394
- }
395
-
396
- /**
397
- * Save all allowed payments for current checkout session in store.
398
- * - allowed_payments
399
- * @param array $methods
400
- */
401
- public function setAllowedPaymentsMethods($methodsInstances)
402
- {
403
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
404
- $xpaymentPrepareOrder['allowed_payments'] = $methodsInstances;
405
- $methods = array();
406
- foreach ($methodsInstances as $methodInstance) {
407
- $methods[]['method_code'] = $methodInstance->getCode();
408
- }
409
- $xpaymentPrepareOrder['allowed_payments'] = $methods;
410
- Mage::getSingleton('checkout/session')->setData('xpayment_prepare_order', $xpaymentPrepareOrder);
411
- }
412
-
413
- /**
414
- * get all allowed payments for current checkout session in store.
415
- * - allowed_payments
416
- */
417
- public function getAllowedPaymentsMethods()
418
- {
419
- $xpaymentPrepareOrder = Mage::getSingleton('checkout/session')->getData('xpayment_prepare_order');
420
- if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder['allowed_payments']) && !empty($xpaymentPrepareOrder['allowed_payments'])) {
421
- return $xpaymentPrepareOrder['allowed_payments'];
422
- }
423
- return false;
424
- }
425
-
426
- /**
427
- * @param $name
428
- * @param $block
429
- * @return string
430
- */
431
- public function getReviewButtonTemplate($name, $block)
432
- {
433
- $quote = Mage::getSingleton('checkout/session')->getQuote();
434
- $useIframe = $this->isUseIframe();
435
- $xpCcMethodCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
436
- if ($quote) {
437
- $payment = $quote->getPayment();
438
- if ($payment && $payment->getMethod() == $xpCcMethodCode && $useIframe) {
439
- return $name;
440
- }
441
- }
442
-
443
- if ($blockObject = Mage::getSingleton('core/layout')->getBlock($block)) {
444
- return $blockObject->getTemplate();
445
- }
446
-
447
- return '';
448
- }
449
-
450
- /**
451
- * @return bool
452
  */
453
- public function isNeedToSaveUserCard()
454
  {
455
- $result = (bool)Mage::getSingleton('checkout/session')->getData('user_card_save');
456
- return $result;
457
- }
458
-
459
- public function userCardSaved(){
460
- Mage::getSingleton('checkout/session')->setData('user_card_save',false);
461
  }
462
 
463
  /**
@@ -482,23 +112,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
482
  return $result;
483
  }
484
 
485
- /**
486
- * @param $currentPaymentCode
487
- * @return bool
488
- */
489
- public function isXpaymentsMethod($currentPaymentCode)
490
- {
491
- $xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
492
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
493
- $prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
494
- $usePaymetCodes = array($xpaymentPaymentCode, $saveCardsPaymentCode, $prepaidpayments);
495
- if (in_array($currentPaymentCode, $usePaymetCodes)) {
496
- return true;
497
- } else {
498
- return false;
499
- }
500
- }
501
-
502
  /**
503
  * This function prepare order keys for recurring orders
504
  * @return int
@@ -509,13 +122,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
509
  $this->itemsQty = $quote->getItemsCount();
510
  $orderItemInfo = $recurringProfile->getData('order_item_info');
511
  $quote->getItemById($orderItemInfo['item_id'])->isDeleted(true);
512
-
513
- if ($this->itemsQty > 1) {
514
- // update order key
515
- $unsetParams = array('prepare_order_id');
516
- $this->unsetXpaymentPrepareOrder($unsetParams);
517
- $this->prepareOrderKey();
518
- }
519
  }
520
 
521
  /**
@@ -592,9 +198,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
592
  }
593
  if ($orderKey) {
594
  $order->setIncrementId($orderKey);
595
- //unset order Key
596
- $unsetParams = array('prepare_order_id');
597
- $this->unsetXpaymentPrepareOrder($unsetParams);
598
  }
599
  }
600
  if(isset($orderAmountData['shipping_amount'])){
@@ -708,37 +311,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
708
  $recurringProfile->save();
709
  }
710
 
711
- /**
712
- * Get quote item for the recurring product from the current checkout session. If any.
713
- *
714
- * @param Mage_Sales_model_Quote $quote Quote. If omitted use quote from checkout session
715
- *
716
- * @return Mage_Sales_Model_Quote_Item or false
717
- */
718
- public function getRecurringQuoteItem($quote = false)
719
- {
720
- $result = false;
721
-
722
- if (!$quote) {
723
- $quote = Mage::getSingleton('checkout/session')->getQuote();
724
- }
725
-
726
- foreach ($quote->getAllItems() as $item) {
727
-
728
- if (
729
- $item
730
- && $item->getProduct()
731
- && $item->getProduct()->getIsRecurring()
732
- ) {
733
-
734
- $result = $item;
735
- break;
736
- }
737
- }
738
-
739
- return $result;
740
- }
741
-
742
  /**
743
  * update recurring profile for deferred pay.
744
  * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
@@ -765,7 +337,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
765
  $orderAmountData = $this->preparePayDeferredOrderAmountData($recurringProfile);
766
 
767
  if (!isset($orderItemInfo['recurring_initial_fee'])) {
768
- $orderAmountData['grand_total'] = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
769
  }
770
 
771
 
@@ -795,10 +367,10 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
795
  } else {
796
  $recurringProfile->setReferenceId($cardData['txnId']);
797
  //check transaction state
798
- list($status, $response) = $xpaymentCCModel->requestPaymentInfo($cardData['txnId']);
799
  if (
800
- $status
801
- && in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
802
  ) {
803
  if(!is_null($recurringProfile->getInitAmount())){
804
  //create order
@@ -807,8 +379,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
807
  $xpaymentCCModel->updateOrderByXpaymentResponse($orderId, $cardData['txnId']);
808
  }
809
 
810
- Mage::getSingleton('checkout/session')->setData('user_card_save', true);
811
- $xpaymentCCModel->saveUserCard($cardData, Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
812
  $recurringProfile->activate();
813
  } else {
814
  $this->addRecurringTransactionError($response);
@@ -918,7 +488,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
918
  $initAmount = $recurringProfileData['init_amount'];
919
  }
920
 
921
- $defaultMinimumPayment = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
922
  $minimumPaymentAmount = ($initAmount) ? $initAmount : $defaultMinimumPayment;
923
  $result[$product->getId()]['minimal_payment_amount'] = $minimumPaymentAmount;
924
 
@@ -944,7 +514,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
944
 
945
  public function addRecurringTransactionError($response = array())
946
  {
947
- $this->unsetXpaymentPrepareOrder();
948
  if (!empty($response)) {
949
  if (!empty($response['error_message'])) {
950
  $errorMessage = $this->__("%s. The subscription has been canceled.", $response['error_message']);
@@ -993,51 +562,6 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
993
  return false;
994
  }
995
 
996
- /**
997
- * Save custom calculating initial fee amount
998
- * @param Mage_Sales_Model_Quote_Item $product
999
- */
1000
- public function updateRecurringQuoteItem(Mage_Sales_Model_Quote_Item $quoteItem)
1001
- {
1002
- $product = $quoteItem->getProduct();
1003
- if ($product->getIsRecurring()) {
1004
- $recurringProfile = $product->getRecurringProfile();
1005
- $initAmount = $recurringProfile['init_amount'];
1006
- if(!is_null($initAmount)){
1007
- $qty = $quoteItem->getQty();
1008
- $totalInitAmount = $qty * $initAmount;
1009
-
1010
- if (isset($recurringProfile['init_amount']) &&
1011
- !empty($recurringProfile['init_amount']) &&
1012
- $recurringProfile['init_amount'] > 0
1013
- ) {
1014
-
1015
- $quoteItemData = $quoteItem->getData();
1016
- if(array_key_exists('xp_recurring_initial_fee',$quoteItemData)){
1017
- $quoteItem->setXpRecurringInitialFee($totalInitAmount);
1018
- $initialFeeTax = $this->calculateTaxForProductCustomPrice($product,$totalInitAmount);
1019
- if($initialFeeTax){
1020
- $quoteItem->setInitialfeeTaxAmount($initialFeeTax);
1021
- }
1022
-
1023
- $quoteItem->save();
1024
- }
1025
- }
1026
- }
1027
- }
1028
-
1029
- }
1030
-
1031
- public function updateAllRecurringQuoteItem()
1032
- {
1033
- $quote = Mage::getModel('checkout/cart')->getQuote();
1034
- $quoteItems = $quote->getAllVisibleItems();
1035
- foreach ($quoteItems as $quoteItem) {
1036
- $this->updateRecurringQuoteItem($quoteItem);
1037
- }
1038
-
1039
- }
1040
-
1041
  /**
1042
  * Add default settings for submitRecurringProfile function
1043
  * @param Mage_Payment_Model_Recurring_Profile $profile
@@ -1183,390 +707,24 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1183
  return $result;
1184
  }
1185
 
1186
- /**
1187
- * @param $name
1188
- * @param $block
1189
- * @return mixed
1190
- */
1191
- public function getCheckoutSuccessTemplate($name, $block)
1192
- {
1193
- if (Mage::helper('core')->isModuleEnabled('Vsourz_Ordersuccess')) {
1194
- if ($blockObject = Mage::getSingleton('core/layout')->getBlock($block)) {
1195
- return $blockObject->getTemplate();
1196
- }
1197
- } else {
1198
- return $name;
1199
- }
1200
- }
1201
-
1202
- /**
1203
- * Prepare state
1204
- *
1205
- * @param array $data Address data
1206
- *
1207
- * @return string
1208
- */
1209
- protected function prepareState($data)
1210
- {
1211
- $state = self::NOT_AVAILABLE;
1212
-
1213
- if (!empty($data['region_id'])) {
1214
-
1215
- $region = Mage::getModel('directory/region')->load($data['region_id']);
1216
-
1217
- if (
1218
- $region
1219
- && $region->getCode()
1220
- ) {
1221
- $state = $region->getCode();
1222
- }
1223
- }
1224
-
1225
- return $state;
1226
- }
1227
-
1228
- /**
1229
- * Prepare street (Address lines 1 and 2)
1230
- *
1231
- * @param array $data Address data
1232
- *
1233
- * @return string
1234
- */
1235
- protected function prepareStreet($data)
1236
- {
1237
- $street = self::NOT_AVAILABLE;
1238
-
1239
- if (!empty($data['street'])) {
1240
-
1241
- $street = $data['street'];
1242
-
1243
- if (is_array($street)) {
1244
- $street = array_filter($street);
1245
- $street = implode("\n", $street);
1246
- }
1247
- }
1248
-
1249
- return $street;
1250
- }
1251
-
1252
- /**
1253
- * Prepare address for initial payment request
1254
- *
1255
- * @param Mage_Sales_Model_Quote $quote Quote
1256
- * @param Mage_Customer_Model_Customer $customer Customer
1257
- * @param $type Address type, Billing or Shipping
1258
- *
1259
- * @return array
1260
- */
1261
- protected function prepareAddress(Mage_Sales_Model_Quote $quote = null, Mage_Customer_Model_Customer $customer = null, $type = 'Billing')
1262
- {
1263
- $getAddress = 'get' . $type . 'Address';
1264
- $getDefaultAddress = 'getDefault' . $type . 'Address';
1265
-
1266
- $customerAddress = $customerDefaultAddress = $quoteAddress = array();
1267
-
1268
- if ($quote) {
1269
-
1270
- $customer = $quote->getCustomer();
1271
-
1272
- if ($quote->$getAddress()) {
1273
- $quoteAddress = $quote->$getAddress()->getData();
1274
- }
1275
- }
1276
-
1277
- if ($customer) {
1278
-
1279
- $customerAddress = $customer->getData();
1280
-
1281
- if ($customer->$getDefaultAddress()) {
1282
- $customerDefaultAddress = $customer->$getDefaultAddress()->getData();
1283
- }
1284
- }
1285
-
1286
- $data = array_merge(
1287
- array_filter($customerAddress),
1288
- array_filter($customerDefaultAddress),
1289
- array_filter($quoteAddress)
1290
- );
1291
-
1292
- $result = array(
1293
- 'firstname' => !empty($data['firstname']) ? $data['firstname'] : self::NOT_AVAILABLE,
1294
- 'lastname' => !empty($data['lastname']) ? $data['lastname'] : self::NOT_AVAILABLE,
1295
- 'address' => $this->prepareStreet($data),
1296
- 'city' => !empty($data['city']) ? $data['city'] : self::NOT_AVAILABLE,
1297
- 'state' => $this->prepareState($data),
1298
- 'country' => !empty($data['country_id']) ? $data['country_id'] : 'XX', // WA fix for MySQL 5.7 with strict mode
1299
- 'zipcode' => !empty($data['postcode']) ? $data['postcode'] : self::NOT_AVAILABLE,
1300
- 'phone' => !empty($data['telephone']) ? $data['telephone'] : '',
1301
- 'fax' => '',
1302
- 'company' => '',
1303
- 'email' => !empty($data['email']) ? $data['email'] : self::EMPTY_USER_EMAIL,
1304
- );
1305
-
1306
- return $result;
1307
- }
1308
-
1309
- /**
1310
- * Format price in 1234.56 format
1311
- *
1312
- * @param mixed $price
1313
- *
1314
- * @return string
1315
- */
1316
- protected function preparePrice($price)
1317
- {
1318
- return number_format($price, 2, '.', '');
1319
- }
1320
-
1321
- /**
1322
- * Prepare totals item: shipping, tax, discount
1323
- *
1324
- * @param array $totals Cart totals
1325
- * @param string $key Totals item key
1326
- *
1327
- * @return string
1328
- */
1329
- protected function prepareTotalsItem($totals, $key)
1330
- {
1331
- $value = 0;
1332
-
1333
- if (
1334
- isset($totals[$key])
1335
- && is_object($totals[$key])
1336
- && method_exists($totals[$key], 'getValue')
1337
- ) {
1338
- $value = abs($totals[$key]->getValue());
1339
- }
1340
-
1341
- return $this->preparePrice($value);
1342
- }
1343
-
1344
-
1345
- /**
1346
- * Prepare simple items for initial payment request
1347
- *
1348
- * @param Mage_Sales_Model_Quote $quote
1349
- * @param array &$result
1350
- *
1351
- * @return void
1352
- */
1353
- protected function prepareSimpleItems(Mage_Sales_Model_Quote $quote, &$result)
1354
- {
1355
- $quote->collectTotals();
1356
- $totals = $quote->getTotals();
1357
-
1358
- $result['totalCost'] = $this->preparePrice($quote->getGrandTotal());
1359
- $result['shippingCost'] = $this->prepareTotalsItem($totals, 'shipping');
1360
- $result['taxCost'] = $this->prepareTotalsItem($totals, 'tax');
1361
- $result['discount'] = $this->prepareTotalsItem($totals, 'discount');
1362
-
1363
- $cartItems = $quote->getAllVisibleItems();
1364
-
1365
- foreach ($cartItems as $item) {
1366
-
1367
- if ($item->getIsNominal()) {
1368
- continue;
1369
- }
1370
-
1371
- $productId = $item->getProductId();
1372
- $product = Mage::getModel('catalog/product')->load($productId);
1373
-
1374
- $result['items'][] = array(
1375
- 'sku' => $product->getData('sku'),
1376
- 'name' => $product->getData('name'),
1377
- 'price' => $this->preparePrice($product->getPrice()),
1378
- 'quantity' => intval($item->getQty()),
1379
- );
1380
- }
1381
- }
1382
-
1383
- /**
1384
- * Prepare recurring items for initial payment request
1385
- *
1386
- * @param Mage_Sales_Model_Quote $quote
1387
- * @param array &$result
1388
- *
1389
- * @return void
1390
- */
1391
- protected function prepareRecurringItems(Mage_Sales_Model_Quote $quote, &$result)
1392
- {
1393
- $item = $this->getRecurringQuoteItem($quote);
1394
- $product = $item->getProduct();
1395
- $recurringProfile = $product->getRecurringProfile();
1396
-
1397
- $startDateParams = $this->checkStartDateDataByProduct($product, $item);
1398
- $startDateParams = $startDateParams[$product->getId()];
1399
-
1400
- $shipping = $item->getData('shipping_amount');
1401
- $discount = abs($item->getData('discount_amount'));
1402
-
1403
- $quantity = $item->getQty();
1404
-
1405
- if ($startDateParams['success']) {
1406
-
1407
- $minimalPayment = $startDateParams['minimal_payment_amount'];
1408
-
1409
- $tax = !empty($recurringProfile['init_amount'])
1410
- ? $item->getData('initialfee_tax_amount')
1411
- : 0;
1412
-
1413
- $totalCost = $minimalPayment + $tax + $shipping - $discount;
1414
-
1415
- } else {
1416
-
1417
- $minimalPayment = 0;
1418
-
1419
- $tax = $item->getData('initialfee_tax_amount') + $item->getData('tax_amount');
1420
-
1421
- $totalCost = $item->getData('nominal_row_total');
1422
- }
1423
-
1424
- $recurringPrice = $product->getPrice();
1425
-
1426
- if (!empty($recurringProfile['init_amount'])) {
1427
- $recurringPrice += $item->getXpRecurringInitialFee() / $quantity;
1428
- }
1429
-
1430
- $price = $minimalPayment
1431
- ? $minimalPayment / $quantity
1432
- : $recurringPrice;
1433
-
1434
- $result['items'][] = array(
1435
- 'sku' => $product->getData('sku'),
1436
- 'name' => $product->getData('name'),
1437
- 'price' => $this->preparePrice($price),
1438
- 'quantity' => intval($quantity),
1439
- );
1440
-
1441
-
1442
- $result['totalCost'] = $this->preparePrice($price);
1443
- $result['shippingCost'] = $this->preparePrice($shipping);
1444
- $result['taxCost'] = $this->preparePrice($tax);
1445
- $result['discount'] = $this->preparePrice($discount);
1446
- }
1447
-
1448
- /**
1449
- * Prepare items for initial payment request
1450
- *
1451
- * @param Mage_Sales_Model_Quote $quote
1452
- * @param array &$result
1453
- *
1454
- * @return void
1455
- */
1456
- protected function prepareItems(Mage_Sales_Model_Quote $quote, &$result)
1457
- {
1458
- if ($this->getRecurringQuoteItem($quote)) {
1459
- // Actually, only one item per order
1460
- $this->prepareRecurringItems($quote, $result);
1461
- } else {
1462
- $this->prepareSimpleItems($quote, $result);
1463
- }
1464
- }
1465
-
1466
- /**
1467
- * Prepare cart for initial payment request
1468
- *
1469
- * @param Mage_Sales_Model_Quote $quote
1470
- * @param string $refId Reference to the order
1471
- *
1472
- * @return array
1473
- */
1474
- public function prepareCart(Mage_Sales_Model_Quote $quote, $refId = false)
1475
- {
1476
- $customer = $quote->getCustomer();
1477
-
1478
- if (
1479
- !$customer->getData('email')
1480
- || !$customer->getData('entity_id')
1481
- ) {
1482
- $login = 'Anonymous customer (Quote ID #' . $quote->getId() . ')';
1483
- } else {
1484
- $login = $customer->getData('email') . ' (User ID #' . $customer->getData('entity_id') . ')';
1485
- }
1486
-
1487
- if ($refId) {
1488
- $description = 'Order #' . $refId;
1489
- } else {
1490
- $description = 'Quote #' . $quote->getId();
1491
- }
1492
-
1493
- $result = array(
1494
- 'login' => $login,
1495
- 'billingAddress' => $this->prepareAddress($quote, null, 'Billing'),
1496
- 'shippingAddress' => $this->prepareAddress($quote, null, 'Shipping'),
1497
- 'items' => array(),
1498
- 'currency' => $quote->getData('quote_currency_code'),
1499
- 'shippingCost' => 0.00,
1500
- 'taxCost' => 0.00,
1501
- 'discount' => 0.00,
1502
- 'totalCost' => 0.00,
1503
- 'description' => $description,
1504
- 'merchantEmail' => Mage::getStoreConfig('trans_email/ident_sales/email'),
1505
- 'forceTransactionType' => '',
1506
- );
1507
-
1508
- $this->prepareItems($quote, $result);
1509
-
1510
- return $result;
1511
- }
1512
-
1513
- /**
1514
- * Prepare cart for initial payment request
1515
- *
1516
- * Mage_Customer_Model_Customer $customer Customer
1517
- *
1518
- * @return array
1519
- */
1520
- public function prepareFakeCart(Mage_Customer_Model_Customer $customer)
1521
- {
1522
- $refId = 'authorization';
1523
-
1524
- $description = 'Authorization'; // TODO: add reference to customer?
1525
-
1526
- $price = $this->preparePrice(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount'));
1527
-
1528
- $result = array(
1529
- 'login' => $customer->getData('email') . ' (User ID #' . $customer->getData('entity_id') . ')',
1530
- 'billingAddress' => $this->prepareAddress(null, $customer, 'Billing'),
1531
- 'shippingAddress' => $this->prepareAddress(null, $customer, 'Shipping'),
1532
- 'items' => array(
1533
- array(
1534
- 'sku' => 'CardSetup',
1535
- 'name' => 'CardSetup',
1536
- 'price' => $price,
1537
- 'quantity' => '1',
1538
- ),
1539
- ),
1540
- 'currency' => Mage::getModel('xpaymentsconnector/payment_cc')->getCurrency(),
1541
- 'shippingCost' => 0.00,
1542
- 'taxCost' => 0.00,
1543
- 'discount' => 0.00,
1544
- 'totalCost' => $price,
1545
- 'description' => $description,
1546
- 'merchantEmail' => Mage::getStoreConfig('trans_email/ident_sales/email'),
1547
- 'forceTransactionType' => '',
1548
- );
1549
-
1550
- return $result;
1551
- }
1552
-
1553
  /**
1554
  * Get callback URL for initial payment request
1555
  *
1556
- * @param string $refId Reference ID
1557
- * @param string $entityId Quote ID or Cutomer ID
1558
- * @param bool $zeroAuth Is it zero auth request
1559
  *
1560
  * @return array
1561
  */
1562
- public function getCallbackUrl($refId, $entityId, $zeroAuth = false)
1563
  {
1564
  $params = array(
1565
- '_secure' => true,
1566
- '_nosid' => true,
 
1567
  );
1568
 
1569
- if ($zeroAuth) {
1570
 
1571
  $params['customer_id'] = $entityId;
1572
 
@@ -1583,30 +741,40 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1583
  /**
1584
  * Get return URL for initial payment request
1585
  *
1586
- * @param string $refId Reference ID
1587
- * @param string $entityId Quote ID or Cutomer ID
1588
- * @param bool $zeroAuth Is it zero auth request
 
1589
  *
1590
  * @return array
1591
  */
1592
- public function getReturnUrl($refId, $entityId, $zeroAuth = false)
1593
  {
1594
  $params = array(
1595
- '_secure' => true,
1596
- '_nosid' => true,
 
1597
  );
1598
 
1599
- if ($zeroAuth) {
1600
 
1601
  $params['customer_id'] = $entityId;
1602
 
1603
- $url = Mage::getUrl('xpaymentsconnector/customer/cardadd', $params);
 
 
 
 
1604
 
1605
  } else {
1606
 
1607
  $params['quote_id'] = $entityId;
1608
 
1609
- $url = Mage::getUrl('xpaymentsconnector/processing/return', $params);
 
 
 
 
1610
  }
1611
 
1612
  return $url;
@@ -1656,7 +824,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1656
  */
1657
  protected function getCheckoutAddressData($data, $type)
1658
  {
1659
- $result = array();
1660
 
1661
  $key = $type . '_address_id';
1662
 
@@ -1664,7 +832,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1664
 
1665
  // Address data from the address book
1666
  $address = Mage::getModel('customer/address')->load($data[$key]);
1667
- $result += array_filter($address->getData());
1668
  }
1669
 
1670
  if (isset($data[$type])) {
@@ -1681,54 +849,33 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1681
  }
1682
 
1683
  // Addrress data from checkout
1684
- $result += array_filter($data[$type]);
1685
  }
1686
 
1687
- return $result;
1688
- }
1689
-
1690
- /**
1691
- * Get Quote xpc data (just a wrapper)
1692
- *
1693
- * @param Mage_Sales_Model_Quote $quote
1694
- *
1695
- * @return Cdev_XPaymentsConnector_Model_Quote_XpcData
1696
- */
1697
- public function getQuoteXpcData(Mage_Sales_Model_Quote $quote, $methodCode = false)
1698
- {
1699
- $quoteId = $quote->getEntityId();
1700
-
1701
- if (!$methodCode) {
1702
- $methodCode = 'xpaymentsconnector/payment_cc';
1703
- }
1704
-
1705
- $model = Mage::getModel('xpaymentsconnector/quote_xpcdata')
1706
- ->getCollection()
1707
- ->addFieldToFilter('quote_id', $quoteId)
1708
- ->addFieldToFilter('payment_method_code', $methodCode)
1709
- ->getFirstItem();
1710
-
1711
- if (!$model->getQuoteId()) {
1712
- // Fill "primary key" for the new entity
1713
- $model->setQuoteId($quoteId)
1714
- ->setPaymentMethodCode($methodCode)
1715
- ->save();
1716
- }
1717
 
1718
- return $model;
1719
  }
1720
 
1721
  /**
1722
  * Process data saved at checkout
1723
  *
1724
- * @param Mage_Sales_Model_Quote $quote
1725
  *
1726
  * @return void
1727
  */
1728
- protected function processCheckoutData(Mage_Sales_Model_Quote $quote)
1729
  {
 
 
 
 
1730
  // Grab data saved at checkout
1731
- $data = unserialize($this->getQuoteXpcData($quote)->getData('checkout_data'));
1732
 
1733
  // Add billing address data from checkout
1734
  $quote->getBillingAddress()->addData($this->getCheckoutAddressData($data, 'billing'));
@@ -1742,7 +889,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1742
  $data['shipping'] = $data['billing'];
1743
 
1744
  if (
1745
- $this->checkOscModuleEnabled()
1746
  && !empty($data['billing_address_id'])
1747
  ) {
1748
  $shippingAddress = Mage::getModel('customer/address')->load($data['billing_address_id']);
@@ -1759,14 +906,19 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1759
  }
1760
 
1761
  // Add shipping address data from checkout
1762
- $quote->getShippingAddress()->addData($this->getCheckoutAddressData($data, 'shipping'));
1763
-
1764
- if (!$this->checkOscModuleEnabled()) {
1765
 
1766
- // TODO: Understand what's wrong with it for OSC.
1767
 
1768
  // Save shipping method
1769
  if (!empty($data['shipping_method'])) {
 
 
 
 
 
 
 
1770
  $quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates();
1771
  $quote->setShippingMethod($data['shipping_method']);
1772
  }
@@ -1792,11 +944,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1792
  /**
1793
  * Create customer and assign it to the quote
1794
  *
1795
- * @param Mage_Sales_Model_Quote $quote
1796
  *
1797
  * @return Mage_Customer_Model_Customer
1798
  */
1799
- protected function createNewCustomer(Mage_Sales_Model_Quote $quote)
1800
  {
1801
  $billing = $quote->getBillingAddress();
1802
 
@@ -1834,7 +986,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1834
  // One page checkout
1835
  $password = $customer->decryptPassword($quote->getPasswordHash());
1836
  } else {
1837
- $data = unserialize($this->getQuoteXpcData($quote)->getData('checkout_data'));
1838
  if (!empty($data['billing']['customer_password'])) {
1839
  // One step checkout
1840
  $password = $data['billing']['customer_password'];
@@ -1862,22 +1014,24 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1862
  *
1863
  * @return bool
1864
  */
1865
- public function isCreateNewCustomer(Mage_Sales_Model_Quote $quote, $includeLoginMethod = false)
1866
  {
1867
  $result = false;
1868
 
1869
- if ($this->checkOscModuleEnabled()) {
 
 
1870
 
1871
  // For One Step Checkout module
1872
- $data = unserialize($this->getQuoteXpcData($quote)->getData('checkout_data'));
1873
 
1874
  $result = isset($data['create_account'])
1875
  && (bool)$data['create_account'];
1876
 
1877
- } elseif ($this->checkFirecheckoutModuleEnabled()) {
1878
 
1879
  // For Firecheckout module
1880
- $data = unserialize($this->getQuoteXpcData($quote)->getData('checkout_data'));
1881
 
1882
  $result = isset($data['billing']['register_account'])
1883
  && (bool)$data['billing']['register_account'];
@@ -1897,11 +1051,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1897
  /**
1898
  * Convert quote to order
1899
  *
1900
- * @param Mage_Sales_Model_Quote $quote
1901
  *
1902
  * @return string
1903
  */
1904
- public function funcPlaceOrder(Mage_Sales_Model_Quote $quote)
1905
  {
1906
  $refId = false;
1907
 
@@ -1915,13 +1069,11 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1915
  // Create customer's profile who's registered at checkout
1916
  $this->createNewCustomer($quote);
1917
 
1918
- $this->getQuoteXpcData($quote)
1919
- ->setData('address_saved', true)
1920
- ->save();
1921
  }
1922
 
1923
  // Set payment method (maybe not necessary. Just in case)
1924
- $quote->collectTotals()->getPayment()->setMethod('xpayments');
1925
 
1926
  // Place order
1927
  $service = Mage::getModel('sales/service_quote', $quote);
@@ -1931,7 +1083,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1931
 
1932
  if (!$order) {
1933
 
1934
- $orderId = $this->getQuoteXpcData($quote)->getData('recurring_order_id');
1935
 
1936
  if ($orderId) {
1937
  $order = Mage::getModel('sales/order')->load($orderId);
@@ -1946,10 +1098,10 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1946
 
1947
  $quote->setIsActive(false)->save();
1948
 
1949
- $xpcData = $this->getQuoteXpcData($quote)->getData();
1950
  $order->setData(self::XPC_DATA, serialize($xpcData));
1951
 
1952
- $order->setData('xpc_txnid', $xpcData['txn_id'])->save();
1953
 
1954
  $refId = $order->getIncrementId();
1955
 
@@ -1960,7 +1112,7 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
1960
  $this->writeLog('Unable to create order: ' . $e->getMessage(), $e->getTraceAsString());
1961
 
1962
  // Save error message in quote
1963
- $this->getQuoteXpcData($quote)
1964
  ->setData('xpc_message', $e->getMessage())
1965
  ->save();
1966
  }
@@ -2035,13 +1187,38 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
2035
  protected function getXpcCheckoutUrl($path, $params = array())
2036
  {
2037
  $params += array(
2038
- '_nosid' => true,
2039
- '_secure' => true
2040
  );
2041
 
2042
  return Mage::getUrl($path, $params);
2043
  }
2044
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2045
  /**
2046
  * Get some JSON data for javascript at checkout
2047
  *
@@ -2049,116 +1226,90 @@ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
2049
  */
2050
  public function getXpcJsonData()
2051
  {
2052
- // Display iframe on the review step (after payment step) or not
2053
- $isDisplayOnReviewStep = 'review' == Mage::helper('xpaymentsconnector')->getIframePlaceDisplay();
2054
 
2055
- $xpOrigin = parse_url(Mage::getModel('xpaymentsconnector/payment_cc')->getConfig('xpay_url'));
2056
- $xpOrigin = $xpOrigin['scheme'] . '://' . $xpOrigin['host'];
2057
 
2058
  $data = array(
2059
- 'url' => array(
2060
-
2061
- 'redirectIframe' => $this->getXpcCheckoutUrl('xpaymentsconnector/processing/redirectiframe'),
2062
-
2063
- 'redirectIframeUnsetOrder' => $this->getXpcCheckoutUrl(
2064
- 'xpaymentsconnector/processing/redirectiframe',
2065
- array(
2066
- 'unset_xp_prepare_order' => 1
2067
- )
2068
- ),
2069
-
2070
- 'setMethodRegister' => $this->getXpcCheckoutUrl(
2071
- 'xpaymentsconnector/processing/redirectiframe',
2072
- array(
2073
- 'unset_xp_prepare_order' => 1,
2074
- 'checkout_method' => 'register'
2075
- )
2076
- ),
2077
-
2078
- 'setMethodGuest' => $this->getXpcCheckoutUrl(
2079
- 'xpaymentsconnector/processing/redirectiframe',
2080
- array(
2081
- 'unset_xp_prepare_order' => 1,
2082
- 'checkout_method' => 'guest'
2083
- )
2084
- ),
2085
-
2086
- 'saveCheckoutData' => $this->getXpcCheckoutUrl('xpaymentsconnector/processing/save_checkout_data'),
2087
-
2088
- 'changeMethod' => $this->getXpcCheckoutUrl('checkout/cart/'),
2089
-
2090
- 'checkAgreements' => $this->getXpcCheckoutUrl('xpaymentsconnector/processing/check_agreements'),
2091
- ),
2092
- 'xpOrigin' => $xpOrigin,
2093
  'displayOnReviewStep' => $isDisplayOnReviewStep,
2094
- 'useIframe' => $this->isUseIframe(),
2095
- 'isOneStepCheckout' => $this->checkOscModuleEnabled(),
2096
- 'isFirecheckout' => $this->checkFirecheckoutModuleEnabled(),
2097
  'height' => 0,
2098
  );
2099
 
 
 
 
 
 
 
 
 
 
 
 
 
2100
  return json_encode($data, JSON_FORCE_OBJECT);
2101
  }
2102
 
2103
  /**
2104
  * Clear init data and something about "unset prepared order"
2105
  *
 
 
2106
  * @return void
2107
  */
2108
- public function resetInitData($quote = null)
2109
  {
2110
- $unsetParams = array('token');
2111
- $this->unsetXpaymentPrepareOrder($unsetParams);
2112
-
2113
- if (!$quote) {
2114
- // Get quote from session
2115
- $quote = Mage::getSingleton('checkout/session')->getQuote();
2116
- }
2117
-
2118
- $this->getQuoteXpcData($quote)->clear();
2119
  }
2120
 
2121
  /**
2122
  * Find last order by X-Payments transaction ID
2123
  *
2124
  * @param string $txnId
 
2125
  *
2126
  * @return Mage_Sales_Model_Order
2127
  */
2128
- public function getOrderByTxnId($txnId)
2129
  {
2130
- return Mage::getModel('sales/order')->getCollection()
2131
  ->addAttributeToSelect('*')
2132
  ->addFieldToFilter('xpc_txnid', $txnId)
2133
  ->getLastItem();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2134
  }
2135
 
2136
  /**
2137
- * Write log
2138
  *
2139
- * @param string $title Log title
2140
- * @param mixed $data Data to log
2141
- * @param bool $trace Include backtrace or not
2142
  *
2143
- * @return void
2144
  */
2145
- public function writeLog($title, $data = '', $trace = false)
2146
  {
2147
- if (!is_string($data)) {
2148
- $data = var_export($data, true);
2149
- }
2150
-
2151
- $message = PHP_EOL . date('Y-m-d H:i:s') . PHP_EOL
2152
- . $title . PHP_EOL
2153
- . $data . PHP_EOL
2154
- . Mage::helper('core/url')->getCurrentUrl() . PHP_EOL;
2155
-
2156
- if ($trace) {
2157
- $message .= '--------------------------' . PHP_EOL
2158
- . Varien_Debug::backtrace(true, false, false)
2159
- . PHP_EOL;
2160
- }
2161
-
2162
- Mage::log($message, null, self::XPAYMENTS_LOG_FILE, true);
2163
  }
2164
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
28
  * @since 1.0.0
29
  */
30
 
31
+ class Cdev_XPaymentsConnector_Helper_Data extends Cdev_XPaymentsConnector_Helper_Abstract
32
  {
33
  const DAY_TIME_STAMP = 86400;
34
  const WEEK_TIME_STAMP = 604800;
35
  const SEMI_MONTH_TIME_STAMP = 1209600;
36
 
37
  /**
38
+ * Order statuses. Actual vaues left for the backwrds compatibility
39
  */
40
  const STATUS_AUTHORIZED = 'xp_pending_payment';
41
  const STATUS_CHARGED = 'processing';
42
  const STATUS_FRAUD = 'fraud';
43
 
 
44
  const RECURRING_ORDER_TYPE = 'recurring';
45
  const SIMPLE_ORDER_TYPE = 'simple';
46
 
 
 
47
  /**
48
+ * Column name for the serialized CC data in order model
49
  */
50
  const XPC_DATA = 'xp_card_data';
51
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
52
  /**
53
  * Checkout methods
54
  */
55
  const METHOD_LOGIN_IN = 'login_in';
56
  const METHOD_REGISTER = 'register';
57
+
58
  /**
59
  * save/update qty for createOrder function.
60
  * @var int
62
  protected $itemsQty = null;
63
  public $payDeferredProfileId = null;
64
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  /**
66
  * Save masked CC details to the order model
67
  *
79
  }
80
 
81
  /**
82
+ * Get saved CC details from the order model
83
+ *
84
+ * @param Mage_Sales_Model_Order $order
85
+ *
86
+ * @return array
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
  */
88
+ public function getOrderXpcCardData(Mage_Sales_Model_Order $order)
89
  {
90
+ return @unserialize($order->getData(self::XPC_DATA));
 
 
 
 
 
91
  }
92
 
93
  /**
112
  return $result;
113
  }
114
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
115
  /**
116
  * This function prepare order keys for recurring orders
117
  * @return int
122
  $this->itemsQty = $quote->getItemsCount();
123
  $orderItemInfo = $recurringProfile->getData('order_item_info');
124
  $quote->getItemById($orderItemInfo['item_id'])->isDeleted(true);
 
 
 
 
 
 
 
125
  }
126
 
127
  /**
198
  }
199
  if ($orderKey) {
200
  $order->setIncrementId($orderKey);
 
 
 
201
  }
202
  }
203
  if(isset($orderAmountData['shipping_amount'])){
311
  $recurringProfile->save();
312
  }
313
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
314
  /**
315
  * update recurring profile for deferred pay.
316
  * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
337
  $orderAmountData = $this->preparePayDeferredOrderAmountData($recurringProfile);
338
 
339
  if (!isset($orderItemInfo['recurring_initial_fee'])) {
340
+ $orderAmountData['grand_total'] = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_zero_auth_amount'));
341
  }
342
 
343
 
367
  } else {
368
  $recurringProfile->setReferenceId($cardData['txnId']);
369
  //check transaction state
370
+ $response = $xpaymentCCModel->requestPaymentInfo($cardData['txnId']);
371
  if (
372
+ $response->getStatus()
373
+ && in_array($response->getField('status'), array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
374
  ) {
375
  if(!is_null($recurringProfile->getInitAmount())){
376
  //create order
379
  $xpaymentCCModel->updateOrderByXpaymentResponse($orderId, $cardData['txnId']);
380
  }
381
 
 
 
382
  $recurringProfile->activate();
383
  } else {
384
  $this->addRecurringTransactionError($response);
488
  $initAmount = $recurringProfileData['init_amount'];
489
  }
490
 
491
+ $defaultMinimumPayment = floatval(Mage::getStoreConfig('xpaymentsconnector/settings/xpay_zero_auth_amount'));
492
  $minimumPaymentAmount = ($initAmount) ? $initAmount : $defaultMinimumPayment;
493
  $result[$product->getId()]['minimal_payment_amount'] = $minimumPaymentAmount;
494
 
514
 
515
  public function addRecurringTransactionError($response = array())
516
  {
 
517
  if (!empty($response)) {
518
  if (!empty($response['error_message'])) {
519
  $errorMessage = $this->__("%s. The subscription has been canceled.", $response['error_message']);
562
  return false;
563
  }
564
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
565
  /**
566
  * Add default settings for submitRecurringProfile function
567
  * @param Mage_Payment_Model_Recurring_Profile $profile
707
  return $result;
708
  }
709
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
710
  /**
711
  * Get callback URL for initial payment request
712
  *
713
+ * @param string $entityId Quote ID or Cutomer ID
714
+ * @param int $xpcSlot Slot index of the XPC payment method
715
+ * @param bool $isZeroAuth Is it zero auth request
716
  *
717
  * @return array
718
  */
719
+ public function getCallbackUrl($entityId, $xpcSlot, $isZeroAuth = false)
720
  {
721
  $params = array(
722
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
723
+ '_nosid' => true,
724
+ 'xpc_slot' => $xpcSlot,
725
  );
726
 
727
+ if ($isZeroAuth) {
728
 
729
  $params['customer_id'] = $entityId;
730
 
741
  /**
742
  * Get return URL for initial payment request
743
  *
744
+ * @param string $entityId Quote ID or Cutomer ID
745
+ * @param int $xpcSlot Slot index of the XPC payment method
746
+ * @param bool $isZeroAuth Is it zero auth request
747
+ * @param bool $isBackend Is it backend order or not
748
  *
749
  * @return array
750
  */
751
+ public function getReturnUrl($entityId, $xpcSlot, $isZeroAuth = false, $isBackend = false)
752
  {
753
  $params = array(
754
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
755
+ '_nosid' => true,
756
+ 'xpc_slot' => $xpcSlot,
757
  );
758
 
759
+ if ($isZeroAuth) {
760
 
761
  $params['customer_id'] = $entityId;
762
 
763
+ if ($isBackend) {
764
+ $url = Mage::helper('adminhtml')->getUrl('adminhtml/addnewcard/return', $params);
765
+ } else {
766
+ $url = Mage::getUrl('xpaymentsconnector/customer/return', $params);
767
+ }
768
 
769
  } else {
770
 
771
  $params['quote_id'] = $entityId;
772
 
773
+ if ($isBackend) {
774
+ $url = Mage::helper('adminhtml')->getUrl('adminhtml/sales_order_payment/return', $params);
775
+ } else {
776
+ $url = Mage::getUrl('xpaymentsconnector/processing/return', $params);
777
+ }
778
  }
779
 
780
  return $url;
824
  */
825
  protected function getCheckoutAddressData($data, $type)
826
  {
827
+ $addressBookData = $checkoutAddressData = array();
828
 
829
  $key = $type . '_address_id';
830
 
832
 
833
  // Address data from the address book
834
  $address = Mage::getModel('customer/address')->load($data[$key]);
835
+ $addressBookData = array_filter($address->getData());
836
  }
837
 
838
  if (isset($data[$type])) {
849
  }
850
 
851
  // Addrress data from checkout
852
+ $checkoutAddressData = array_filter($data[$type]);
853
  }
854
 
855
+ // Address data from checkout has a higher priority
856
+ $result = array_merge(
857
+ $addressBookData,
858
+ $checkoutAddressData
859
+ );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
860
 
861
+ return $result;
862
  }
863
 
864
  /**
865
  * Process data saved at checkout
866
  *
867
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
868
  *
869
  * @return void
870
  */
871
+ protected function processCheckoutData(Cdev_XPaymentsConnector_Model_Quote $quote)
872
  {
873
+ // Check if external checkout module is enabled
874
+ $isOscModuleEnabled = Mage::helper('settings_xpc')->checkOscModuleEnabled();
875
+ $isFirecheckoutModuleEnabled = Mage::helper('settings_xpc')->checkFirecheckoutModuleEnabled();
876
+
877
  // Grab data saved at checkout
878
+ $data = unserialize($quote->getXpcData()->getData('checkout_data'));
879
 
880
  // Add billing address data from checkout
881
  $quote->getBillingAddress()->addData($this->getCheckoutAddressData($data, 'billing'));
889
  $data['shipping'] = $data['billing'];
890
 
891
  if (
892
+ $isOscModuleEnabled
893
  && !empty($data['billing_address_id'])
894
  ) {
895
  $shippingAddress = Mage::getModel('customer/address')->load($data['billing_address_id']);
906
  }
907
 
908
  // Add shipping address data from checkout
909
+ $quote->getShippingAddress()->addData($this->getCheckoutAddressData($data, 'shipping'))->save();
 
 
910
 
911
+ if (!$isOscModuleEnabled) {
912
 
913
  // Save shipping method
914
  if (!empty($data['shipping_method'])) {
915
+
916
+ if ($isFirecheckoutModuleEnabled) {
917
+ // Necessary for the FC.
918
+ // See TM_FireCheckout_IndexController::saveShippingAction()
919
+ $quote->collectTotals();
920
+ }
921
+
922
  $quote->getShippingAddress()->setCollectShippingRates(true)->collectShippingRates();
923
  $quote->setShippingMethod($data['shipping_method']);
924
  }
944
  /**
945
  * Create customer and assign it to the quote
946
  *
947
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
948
  *
949
  * @return Mage_Customer_Model_Customer
950
  */
951
+ protected function createNewCustomer(Cdev_XPaymentsConnector_Model_Quote $quote)
952
  {
953
  $billing = $quote->getBillingAddress();
954
 
986
  // One page checkout
987
  $password = $customer->decryptPassword($quote->getPasswordHash());
988
  } else {
989
+ $data = unserialize($quote->getXpcData()->getData('checkout_data'));
990
  if (!empty($data['billing']['customer_password'])) {
991
  // One step checkout
992
  $password = $data['billing']['customer_password'];
1014
  *
1015
  * @return bool
1016
  */
1017
+ public function isCreateNewCustomer(Cdev_XPaymentsConnector_Model_Quote $quote, $includeLoginMethod = false)
1018
  {
1019
  $result = false;
1020
 
1021
+ $settings = Mage::helper('settings_xpc');
1022
+
1023
+ if ($settings->checkOscModuleEnabled()) {
1024
 
1025
  // For One Step Checkout module
1026
+ $data = unserialize($quote->getXpcData()->getData('checkout_data'));
1027
 
1028
  $result = isset($data['create_account'])
1029
  && (bool)$data['create_account'];
1030
 
1031
+ } elseif ($settings->checkFirecheckoutModuleEnabled()) {
1032
 
1033
  // For Firecheckout module
1034
+ $data = unserialize($quote->getXpcData()->getData('checkout_data'));
1035
 
1036
  $result = isset($data['billing']['register_account'])
1037
  && (bool)$data['billing']['register_account'];
1051
  /**
1052
  * Convert quote to order
1053
  *
1054
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
1055
  *
1056
  * @return string
1057
  */
1058
+ public function funcPlaceOrder(Cdev_XPaymentsConnector_Model_Quote $quote)
1059
  {
1060
  $refId = false;
1061
 
1069
  // Create customer's profile who's registered at checkout
1070
  $this->createNewCustomer($quote);
1071
 
1072
+ $quote->getXpcData()->setData('address_saved', true)->save();
 
 
1073
  }
1074
 
1075
  // Set payment method (maybe not necessary. Just in case)
1076
+ $quote->setTotalsCollectedFlag(false)->collectTotals()->getPayment()->setMethod('xpayments' . $quote->getXpcSlot());
1077
 
1078
  // Place order
1079
  $service = Mage::getModel('sales/service_quote', $quote);
1083
 
1084
  if (!$order) {
1085
 
1086
+ $orderId = $quote->getXpcData()->getData('recurring_order_id');
1087
 
1088
  if ($orderId) {
1089
  $order = Mage::getModel('sales/order')->load($orderId);
1098
 
1099
  $quote->setIsActive(false)->save();
1100
 
1101
+ $xpcData = $quote->getXpcData()->getData();
1102
  $order->setData(self::XPC_DATA, serialize($xpcData));
1103
 
1104
+ $order->setData('xpc_txnid', $quote->getXpcData()->getData('txn_id'))->save();
1105
 
1106
  $refId = $order->getIncrementId();
1107
 
1112
  $this->writeLog('Unable to create order: ' . $e->getMessage(), $e->getTraceAsString());
1113
 
1114
  // Save error message in quote
1115
+ $quote->getXpcData()
1116
  ->setData('xpc_message', $e->getMessage())
1117
  ->save();
1118
  }
1187
  protected function getXpcCheckoutUrl($path, $params = array())
1188
  {
1189
  $params += array(
1190
+ '_nosid' => true,
1191
+ '_secure' => !Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http'),
1192
  );
1193
 
1194
  return Mage::getUrl($path, $params);
1195
  }
1196
 
1197
+ /**
1198
+ * Get redirect URL
1199
+ *
1200
+ * @param int $xpcSlot Slot index of the XPC payment method
1201
+ * @param bool $dropToken Drop current token or not
1202
+ * @param string $checkoutMethod Checkout method (guest, register, etc)
1203
+ * @param array $params URL parameters
1204
+ *
1205
+ * @return string
1206
+ */
1207
+ protected function getRedirectUrl($xpcSlot, $dropToken = false, $checkoutMethod = '', $params = array())
1208
+ {
1209
+ $params['xpc_slot'] = $xpcSlot;
1210
+
1211
+ if ($dropToken) {
1212
+ $params['drop_token'] = '1';
1213
+ }
1214
+
1215
+ if ($checkoutMethod) {
1216
+ $params['checkout_method'] = $checkoutMethod;
1217
+ }
1218
+
1219
+ return $this->getXpcCheckoutUrl('xpaymentsconnector/processing/redirect', $params);
1220
+ }
1221
+
1222
  /**
1223
  * Get some JSON data for javascript at checkout
1224
  *
1226
  */
1227
  public function getXpcJsonData()
1228
  {
1229
+ $settings = Mage::helper('settings_xpc');
 
1230
 
1231
+ // Display iframe on the review step (after payment step) or not
1232
+ $isDisplayOnReviewStep = 'review' == $settings->getIframePlace();
1233
 
1234
  $data = array(
1235
+ 'origins' => $settings->getAllowedOrigins(),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1236
  'displayOnReviewStep' => $isDisplayOnReviewStep,
1237
+ 'useIframe' => $settings->isUseIframe(),
1238
+ 'isOneStepCheckout' => $settings->checkOscModuleEnabled(),
1239
+ 'isFirecheckout' => $settings->checkFirecheckoutModuleEnabled(),
1240
  'height' => 0,
1241
  );
1242
 
1243
+ for ($xpcSlot = 1; $xpcSlot <= Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS; $xpcSlot++) {
1244
+ $data['url']['xpayments' . $xpcSlot] = array(
1245
+ 'redirect' => $this->getRedirectUrl($xpcSlot),
1246
+ 'dropTokenAndRedirect' => $this->getRedirectUrl($xpcSlot, true),
1247
+ 'setMethodRegister' => $this->getRedirectUrl($xpcSlot, true, 'register'),
1248
+ 'setMethodGuest' => $this->getRedirectUrl($xpcSlot, true, 'guest'),
1249
+ 'saveCheckoutData' => $this->getXpcCheckoutUrl('xpaymentsconnector/processing/save_checkout_data', array('xpc_slot' => $xpcSlot)),
1250
+ 'changeMethod' => $this->getXpcCheckoutUrl('checkout/cart/'),
1251
+ 'checkAgreements' => $this->getXpcCheckoutUrl('xpaymentsconnector/processing/check_agreements'),
1252
+ );
1253
+ }
1254
+
1255
  return json_encode($data, JSON_FORCE_OBJECT);
1256
  }
1257
 
1258
  /**
1259
  * Clear init data and something about "unset prepared order"
1260
  *
1261
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
1262
+ *
1263
  * @return void
1264
  */
1265
+ public function resetInitData(Cdev_XPaymentsConnector_Model_Quote $quote)
1266
  {
1267
+ $quote->getXpcData()->clear();
 
 
 
 
 
 
 
 
1268
  }
1269
 
1270
  /**
1271
  * Find last order by X-Payments transaction ID
1272
  *
1273
  * @param string $txnId
1274
+ * @param string $parentTxnId
1275
  *
1276
  * @return Mage_Sales_Model_Order
1277
  */
1278
+ public function getOrderByTxnId($txnId, $parentTxnId = '')
1279
  {
1280
+ $order = Mage::getModel('sales/order')->getCollection()
1281
  ->addAttributeToSelect('*')
1282
  ->addFieldToFilter('xpc_txnid', $txnId)
1283
  ->getLastItem();
1284
+
1285
+ if (
1286
+ !$order->getId()
1287
+ && $parentTxnId
1288
+ ) {
1289
+
1290
+ $order = Mage::getModel('sales/order')->getCollection()
1291
+ ->addAttributeToSelect('*')
1292
+ ->addFieldToFilter('xpc_txnid', $parentTxnId)
1293
+ ->getLastItem();
1294
+
1295
+ // We've found the child order, so now update its transaction reference with the actual value
1296
+ $order->setData('xpc_txnid', $txnId)->save();
1297
+ }
1298
+
1299
+ return $order;
1300
  }
1301
 
1302
  /**
1303
+ * Get order's Fraud check data colection
1304
  *
1305
+ * @param string $orderId
 
 
1306
  *
1307
+ * @return Cdev_XPaymentsConnector_Model_Mysql4_FraudCheckData_Collection
1308
  */
1309
+ public function getOrderFraudCheckData($orderId)
1310
  {
1311
+ return Mage::getModel('xpaymentsconnector/fraudcheckdata')->getCollection()
1312
+ ->addAttributeToSelect('*')
1313
+ ->addFieldToFilter('order_id', $orderId);
 
 
 
 
 
 
 
 
 
 
 
 
 
1314
  }
1315
  }
app/code/community/Cdev/XPaymentsConnector/Helper/Settings/Data.php ADDED
@@ -0,0 +1,891 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Helper for settings
25
+ */
26
+
27
+ class Cdev_XPaymentsConnector_Helper_Settings_Data extends Cdev_XPaymentsConnector_Helper_Abstract
28
+ {
29
+ /**
30
+ * Maximum quantity of the payment methods that can be enabled
31
+ */
32
+ const MAX_SLOTS = 3;
33
+
34
+ /**
35
+ * List of tabs
36
+ */
37
+ const TAB_WELCOME = 'welcome';
38
+ const TAB_CONNECTION = 'connection';
39
+ const TAB_PAYMENT_METHODS = 'payment_methods';
40
+ const TAB_ZERO_AUTH = 'zero_auth';
41
+
42
+ // Configuration settings path
43
+ const XPATH_XPC = 'xpaymentsconnector/settings/';
44
+ const XPATH_PAYMENT = 'payment/xpayments';
45
+ const XPATH_SAVED_CARDS = 'payment/savedcards/';
46
+
47
+ // Validation regexp for serialized bundle
48
+ const BUNDLE_REGEXP = '/a:[56]:{s:8:"store_id";s:\d+:"[0-9a-z]+";s:3:"url";s:\d+:"[^"]+";s:10:"public_key";s:\d+:"-----BEGIN CERTIFICATE-----[^"]+-----END CERTIFICATE-----";s:11:"private_key";s:\d+:"-----BEGIN [A-Z ]*PRIVATE KEY-----[^"]+-----END [A-Z ]*PRIVATE KEY-----";s:20:"private_key_password";s:32:".{32}";(s:9:"server_ip";s:\d+:"[0-9a-fA-F\.:]*";)?}/s';
49
+
50
+ // Requirements errors
51
+ const REQ_CURL = 'PHP extension cURL is not installed on your server';
52
+ const REQ_OPENSSL = 'PHP extension OpenSSL is not installed on your server';
53
+ const REQ_DOM = 'PHP extension DOM is not installed on your server';
54
+
55
+ // Configuration errors
56
+ const CONF_CART_ID = 'Store ID is empty or has an incorrect value';
57
+ const CONF_URL = 'X-Payments URL is empty or has an incorrect value';
58
+ const CONF_PUBLIC_KEY = 'Public key is empty';
59
+ const CONF_PRIVATE_KEY = 'Private key is empty';
60
+ const CONF_PRIVATE_KEY_PASS = 'Private key password is empty';
61
+ const CONF_API_VERSION = 'API version is empty';
62
+
63
+ /**
64
+ * Disabled zero auth method index
65
+ */
66
+ const ZERO_AUTH_DISABLED = -1;
67
+
68
+ /**
69
+ * List of supported API versions
70
+ */
71
+ private $apiVersions = array(
72
+ '1.7',
73
+ '1.6',
74
+ );
75
+
76
+ /**
77
+ * Api Version. Check connection result.
78
+ */
79
+ private $apiVersion = null;
80
+
81
+ /**
82
+ * Tab names
83
+ */
84
+ private $tabs = array(
85
+ self::TAB_WELCOME => 'Welcome',
86
+ self::TAB_CONNECTION => 'Connection settings',
87
+ self::TAB_PAYMENT_METHODS => 'Payment methods',
88
+ self::TAB_ZERO_AUTH => 'Save credit card setup',
89
+ );
90
+
91
+ /**
92
+ * List of configuration errors
93
+ */
94
+ private static $configurationErrors = null;
95
+
96
+ /**
97
+ * List of server requirements errors
98
+ */
99
+ private static $requirementsErrors = null;
100
+
101
+ /**
102
+ * Flag indicating if at least one of the payment configurations allows to save cards
103
+ */
104
+ private static $canSaveCardsFlag = null;
105
+
106
+ /**
107
+ * Zero auth mehod model
108
+ */
109
+ private static $zeroAuthMethod = null;
110
+
111
+ /**
112
+ * Is it necessary to re-check connection
113
+ */
114
+ private static $recheckFlag = false;
115
+
116
+ /**
117
+ * Flag indicating configuration is in progress
118
+ * To prevent concurent requests to X-Payments
119
+ */
120
+ private static $configurationInProgressFlag = false;
121
+
122
+ /**
123
+ * Map of fields stored in the bundle
124
+ */
125
+ private $bundleMap = array(
126
+ 'xpay_cart_id' => 'store_id',
127
+ 'xpay_url' => 'url',
128
+ 'xpay_public_key' => 'public_key',
129
+ 'xpay_private_key' => 'private_key',
130
+ 'xpay_private_key_pass' => 'private_key_password',
131
+ );
132
+
133
+ /**
134
+ * Constructor
135
+ *
136
+ * @return void
137
+ */
138
+ public function _construct()
139
+ {
140
+ parent::_construct();
141
+
142
+ // Translate tabs
143
+ foreach ($this->tabs as $tab => $tabName) {
144
+ $this->tabs[$tab] = Mage::helper('adminhtml')->__($tabName);
145
+ }
146
+ }
147
+
148
+ /**
149
+ * Get tabs
150
+ *
151
+ * @return array
152
+ */
153
+ public function getTabs()
154
+ {
155
+ return $this->tabs;
156
+ }
157
+
158
+ /**
159
+ * Set flag to force the connection check.
160
+ * And null other flags/cache just in case.
161
+ *
162
+ * Flag is reverted after the connection check is done.
163
+ *
164
+ * @return void
165
+ */
166
+ public function setRecheckFlag()
167
+ {
168
+ static::$configurationErrors = null;
169
+ static::$requirementsErrors = null;
170
+ static::$canSaveCardsFlag = null;
171
+ static::$zeroAuthMethod = null;
172
+
173
+ static::$recheckFlag = true;
174
+ }
175
+
176
+ /**
177
+ * Check if X-Payments Connector module is configured
178
+ *
179
+ * @return bool
180
+ */
181
+ public function isConfigured()
182
+ {
183
+ // If configuration is in progress return true to avoid the concurent checking
184
+ if (static::$configurationInProgressFlag) {
185
+ return true;
186
+ }
187
+
188
+ if (static::$recheckFlag) {
189
+
190
+ // Prevent concurent requests when configuration is in progress
191
+ // E.g. do not obtain API version during payment confs import
192
+ static::$configurationInProgressFlag = true;
193
+
194
+ try {
195
+
196
+ $result = false;
197
+
198
+ $configuration = $this->getXpcConfig('xpay_conf_bundle');
199
+
200
+ if (!empty($configuration)) {
201
+
202
+ $errors = $this->getConfigurationErrors();
203
+
204
+ if (empty($errors)) {
205
+ $result = true;
206
+ }
207
+ }
208
+
209
+ $this->setXpcConfig('xpay_is_configured', $result, true);
210
+
211
+ } catch (Exception $exception) {
212
+
213
+ // Switch off configuration in progress flag for any exception
214
+ static::$configurationInProgressFlag = false;
215
+
216
+ // And throw exception further
217
+ throw $exception;
218
+ }
219
+
220
+ // Switch off configuration checking flags
221
+ static::$recheckFlag = false;
222
+ static::$configurationInProgressFlag = false;
223
+ }
224
+
225
+ return $this->getXpcConfig('xpay_is_configured');
226
+ }
227
+
228
+ /**
229
+ * Check connection with X-Payments via test request. Set the API version
230
+ *
231
+ * @return string Error message during communication with X-Payments (if any)
232
+ */
233
+ private function obtainApiVersion()
234
+ {
235
+ $isUpgradeNeeded = false;
236
+
237
+ $errors = array();
238
+
239
+ try {
240
+
241
+ $this->setXpcConfig('xpay_api_version', '', true);
242
+
243
+ foreach ($this->apiVersions as $version) {
244
+
245
+ $response = Mage::helper('api_xpc')->testConnection($version);
246
+
247
+ if ($response->getStatus()) {
248
+
249
+ $this->setXpcConfig('xpay_api_version', $version, true);
250
+ break;
251
+
252
+ } elseif (!empty($response->getErrorCode())) {
253
+
254
+ if ('506' == $response->getErrorCode()) {
255
+ $isUpgradeNeeded = true;
256
+ }
257
+
258
+ $errors[] = $response->getErrorMessage();
259
+ }
260
+ }
261
+
262
+ if (!$this->getXpcConfig('xpay_api_version')) {
263
+
264
+ if ($isUpgradeNeeded) {
265
+ $error = 'Unable to detect supported API version for your X-Payments installation. You should upgrade X-Payments or X-Payments connector extension';
266
+ } else {
267
+ $error = implode(PHP_EOL, $errors);
268
+ }
269
+
270
+ } else {
271
+
272
+ $error = false;
273
+ }
274
+
275
+ } catch (Exception $e) {
276
+
277
+ $error = $e->getMessage();
278
+ }
279
+
280
+ return $error;
281
+ }
282
+
283
+ /**
284
+ * Check if some external checkout module is enablled and activated
285
+ *
286
+ * @param string $name Module name
287
+ * @param string $configPath Configuration path to activate the module
288
+ *
289
+ * @return bool
290
+ */
291
+ private function checkExternalCheckoutModuleEnabled($name, $configPath)
292
+ {
293
+ $modules = Mage::getConfig()->getNode('modules')->children();
294
+ $modules = (array)$modules;
295
+
296
+ $result = false;
297
+
298
+ if (isset($modules[$name])) {
299
+
300
+ $module = $modules[$name];
301
+
302
+ if ($module->active) {
303
+ $result = (bool)Mage::getStoreConfig($configPath, Mage::app()->getStore());
304
+ }
305
+ }
306
+
307
+ return $result;
308
+ }
309
+
310
+ /**
311
+ * Check if Idev OneStepCheckout module is enablled and activated
312
+ *
313
+ * @return bool
314
+ */
315
+ public function checkOscModuleEnabled()
316
+ {
317
+ return $this->checkExternalCheckoutModuleEnabled(
318
+ 'Idev_OneStepCheckout',
319
+ 'onestepcheckout/general/rewrite_checkout_links'
320
+ );
321
+ }
322
+
323
+ /**
324
+ * Check if Firecheckout module is enablled and activated
325
+ *
326
+ * @return bool
327
+ */
328
+ public function checkFirecheckoutModuleEnabled()
329
+ {
330
+ return $this->checkExternalCheckoutModuleEnabled(
331
+ 'TM_FireCheckout',
332
+ 'firecheckout/general/enabled'
333
+ );
334
+ }
335
+
336
+ /**
337
+ * Check if iframe should be used or not
338
+ *
339
+ * @return bool
340
+ */
341
+ public function isUseIframe()
342
+ {
343
+ return $this->checkOscModuleEnabled()
344
+ || $this->checkFirecheckoutModuleEnabled()
345
+ || $this->getXpcConfig('xpay_use_iframe');
346
+ }
347
+
348
+ /**
349
+ * Get place to display iframe. Review or payment step of checkout
350
+ *
351
+ * @return string "payment" or "review"
352
+ */
353
+ public function getIframePlace()
354
+ {
355
+ $place = $this->getXpcConfig('xpay_iframe_place');
356
+
357
+ if (
358
+ $this->checkOscModuleEnabled()
359
+ || $this->checkFirecheckoutModuleEnabled()
360
+ ) {
361
+ $place = 'payment';
362
+ } elseif (
363
+ $place != 'payment'
364
+ && $place != 'review'
365
+ ) {
366
+ $place = 'payment';
367
+ }
368
+
369
+ return $place;
370
+ }
371
+
372
+ /**
373
+ * Get configuration errors list
374
+ *
375
+ * @return array
376
+ */
377
+ public function getConfigurationErrors()
378
+ {
379
+ if (is_array(static::$configurationErrors)) {
380
+ return static::$configurationErrors;
381
+ }
382
+
383
+ static::$configurationErrors = array();
384
+
385
+ // Check shopping cart id
386
+ if (
387
+ !$this->getXpcConfig('xpay_cart_id')
388
+ || !preg_match('/^[\da-f]{32}$/Ss', $this->getXpcConfig('xpay_cart_id'))
389
+ ) {
390
+ static::$configurationErrors[] = self::CONF_CART_ID;
391
+ }
392
+
393
+ // Check URL
394
+ if (!$this->getXpcConfig('xpay_url')) {
395
+ static::$configurationErrors[] = self::CONF_URL;
396
+ }
397
+
398
+ $parsed_url = @parse_url($this->getXpcConfig('xpay_url'));
399
+
400
+ if (!$parsed_url || !isset($parsed_url['scheme']) || $parsed_url['scheme'] != 'https') {
401
+ static::$configurationErrors[] = self::CONF_URL;
402
+ }
403
+
404
+ // Check public key
405
+ if (!$this->getXpcConfig('xpay_public_key')) {
406
+ static::$configurationErrors[] = self::CONF_PUBLIC_KEY;
407
+ }
408
+
409
+ // Check private key
410
+ if (!$this->getXpcConfig('xpay_private_key')) {
411
+ static::$configurationErrors[] = self::CONF_PRIVATE_KEY;
412
+ }
413
+
414
+ // Check private key password
415
+ if (!$this->getXpcConfig('xpay_private_key_pass')) {
416
+ static::$configurationErrors[] = self::CONF_PRIVATE_KEY_PASS;
417
+ }
418
+
419
+ // Obtain API version from X-Payments if necessary
420
+ if (static::$recheckFlag) {
421
+ $error = $this->obtainApiVersion();
422
+ }
423
+
424
+ // Check API version
425
+ if (!$this->getXpcConfig('xpay_api_version')) {
426
+ static::$configurationErrors[] = !empty($error) ? $error : self::CONF_API_VERSION;
427
+ }
428
+
429
+ return static::$configurationErrors;
430
+ }
431
+
432
+ /**
433
+ * Get list of the server requirements errors
434
+ *
435
+ * @return array
436
+ */
437
+ public function getRequirementsErrors()
438
+ {
439
+ if (is_array(static::$requirementsErrors)) {
440
+ return static::$requirementsErrors;
441
+ }
442
+
443
+ static::$requirementsErrors = array();
444
+
445
+ if (!function_exists('curl_init')) {
446
+ static::$requirementsErrors[] = self::REQ_CURL;
447
+ }
448
+
449
+ if (
450
+ !function_exists('openssl_pkey_get_public') || !function_exists('openssl_public_encrypt')
451
+ || !function_exists('openssl_get_privatekey') || !function_exists('openssl_private_decrypt')
452
+ || !function_exists('openssl_free_key')
453
+ ) {
454
+ static::$requirementsErrors[] = self::REQ_OPENSSL;
455
+ }
456
+
457
+ if (!class_exists('DOMDocument')) {
458
+ static::$requirementsErrors[] = self::REQ_DOM;
459
+ }
460
+
461
+ return static::$requirementsErrors;
462
+ }
463
+
464
+ /**
465
+ * Check - module requirements is passed or not
466
+ *
467
+ * @return bool
468
+ */
469
+ public function checkRequirements()
470
+ {
471
+ $errors = $this->getRequirementsErrors();
472
+
473
+ return empty($errors);
474
+ }
475
+
476
+ /**
477
+ * Check if at least one of the payment configurations can be used for saving cards
478
+ *
479
+ * @return bool
480
+ */
481
+ public function isCanSaveCards()
482
+ {
483
+ if (!is_null(static::$canSaveCardsFlag)) {
484
+ return static::$canSaveCardsFlag;
485
+ }
486
+
487
+ static::$canSaveCardsFlag = false;
488
+
489
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
490
+
491
+ if (!empty($list)) {
492
+
493
+ foreach ($list as $paymentConf) {
494
+ if ('Y' == $paymentConf->getData('can_save_cards')) {
495
+ static::$canSaveCardsFlag = true;
496
+ break;
497
+ }
498
+ }
499
+ }
500
+
501
+ return static::$canSaveCardsFlag;
502
+ }
503
+
504
+ /**
505
+ * Get payment configuration ID by slot index of the XPC payment method
506
+ *
507
+ * @param int $xpcSlot Slot index of the XPC payment method
508
+ *
509
+ * @return int
510
+ */
511
+ public function getConfidByXpcSlot($xpcSlot)
512
+ {
513
+ $xpcSlot = $this->checkXpcSlot($xpcSlot);
514
+
515
+ return Mage::helper('settings_xpc')->getPaymentConfig('confid', $xpcSlot);
516
+ }
517
+
518
+ /**
519
+ * Get slot index of the XPC payment method by payment configuration ID
520
+ *
521
+ * @param int $confid Payment configuration ID
522
+ *
523
+ * @return int
524
+ */
525
+ public function getXpcSlotByConfid($confid)
526
+ {
527
+ $found = false;
528
+
529
+ for ($xpcSlot = 1; $xpcSlot <= self::MAX_SLOTS; $xpcSlot++) {
530
+ if (Mage::helper('settings_xpc')->getPaymentConfig('confid', $xpcSlot) == $confid) {
531
+ $found = true;
532
+ break;
533
+ }
534
+ }
535
+
536
+ if (!$found) {
537
+ throw new Exception('Payment configuration is not configured. ID: ' . $confid);
538
+ }
539
+
540
+ return $xpcSlot;
541
+ }
542
+
543
+ /**
544
+ * Get redirect form URL
545
+ *
546
+ * @return string
547
+ */
548
+ public function getPaymentUrl()
549
+ {
550
+ $url = $this->getXpcConfig('xpay_url');
551
+ $url = rtrim($url, '/') . '/payment.php';
552
+
553
+ return $url;
554
+ }
555
+
556
+ /**
557
+ * Get admin URL
558
+ *
559
+ * @return string
560
+ */
561
+ public function getAdminUrl()
562
+ {
563
+ $url = $this->getXpcConfig('xpay_url');
564
+ $url = rtrim($url, '/') . '/admin.php';
565
+
566
+ return $url;
567
+ }
568
+
569
+ /**
570
+ * Get admin URL
571
+ *
572
+ * @return string
573
+ */
574
+ public function getApiUrl()
575
+ {
576
+ $url = $this->getXpcConfig('xpay_url');
577
+ $url = rtrim($url, '/') . '/api.php';
578
+
579
+ return $url;
580
+ }
581
+
582
+ /**
583
+ * List of the allowed JS events' origins
584
+ *
585
+ * @return array
586
+ */
587
+ public function getAllowedOrigins()
588
+ {
589
+ $xpHost = parse_url($this->getXpcConfig('xpay_url'), PHP_URL_HOST);
590
+
591
+ // Use both HTTP and HTTPS protocols
592
+ $result = array(
593
+ 'https://' . $xpHost,
594
+ 'https://' . parse_url(Mage::getStoreConfig('web/secure/base_url'), PHP_URL_HOST),
595
+ 'http://' . $xpHost,
596
+ 'http://' . parse_url(Mage::getStoreConfig('web/unsecure/base_url'), PHP_URL_HOST),
597
+ );
598
+
599
+ return array_unique($result);
600
+ }
601
+
602
+ /**
603
+ * Validate slot index of the XPC payment method
604
+ *
605
+ * @param int $xpcSlot Slot index of the XPC payment method
606
+ * @param bool $throwException Throw exception or not
607
+ *
608
+ * @throws Exception
609
+ *
610
+ * @return int
611
+ */
612
+ public function checkXpcSlot($xpcSlot, $throwException = true)
613
+ {
614
+ if (
615
+ !is_numeric($xpcSlot)
616
+ || $xpcSlot < 1
617
+ || $xpcSlot > self::MAX_SLOTS
618
+ ) {
619
+
620
+ $xpcSlot = var_export($xpcSlot, true);
621
+
622
+ $this->writeLog('Access to the invalid X-Payments method. Slot: ' . $xpcSlot, '', true);
623
+
624
+ if ($throwException) {
625
+ throw new Exception('Access to the invalid X-Payments method. Slot: ' . $xpcSlot);
626
+ } else {
627
+ $xpcSlot = 0;
628
+ }
629
+ }
630
+
631
+ return $xpcSlot;
632
+ }
633
+
634
+ /**
635
+ * Check if zero auth method is configured
636
+ *
637
+ * @return bool
638
+ */
639
+ public function isZeroAuthMethodConfigured()
640
+ {
641
+ $result = false;
642
+
643
+ if ($this->getXpcConfig('xpay_zero_auth_confid')) {
644
+
645
+ try {
646
+
647
+ $result = (bool)$this->getZeroAuthMethod();
648
+
649
+ } catch (Exception $e) {
650
+
651
+ // Do nothing
652
+ }
653
+ }
654
+
655
+ return $result;
656
+ }
657
+
658
+ /**
659
+ * Check if zero auth method is disaled
660
+ *
661
+ * @return bool
662
+ */
663
+ public function isZeroAuthMethodDisabled()
664
+ {
665
+ return self::ZERO_AUTH_DISABLED == $this->getXpcConfig('xpay_zero_auth_confid');
666
+ }
667
+
668
+ /**
669
+ * Get payment method model for zero auth
670
+ *
671
+ * @return Cdev_XPaymentsConnector_Model_Payment_Cc
672
+ */
673
+ public function getZeroAuthMethod()
674
+ {
675
+ if (is_null(static::$zeroAuthMethod)) {
676
+
677
+ $confid = $this->getXpcConfig('xpay_zero_auth_confid');
678
+
679
+ $found = false;
680
+
681
+ for ($xpcSlot = 1; $xpcSlot <= self::MAX_SLOTS; $xpcSlot++) {
682
+ if (Mage::helper('settings_xpc')->getPaymentConfig('confid', $xpcSlot) == $confid) {
683
+ $found = true;
684
+ break;
685
+ }
686
+ }
687
+
688
+ if (!$found) {
689
+ throw new Exception('Card setup payment method is not configured');
690
+ }
691
+
692
+ static::$zeroAuthMethod = Mage::getModel('xpaymentsconnector/payment_cc' . $xpcSlot);
693
+ }
694
+
695
+ return static::$zeroAuthMethod;
696
+ }
697
+
698
+ /**
699
+ * Check if the payment method code is X-Payments' one
700
+ *
701
+ * @param $code Payment method code to check
702
+ * @param $includeSavedCards Include seved cards method or not
703
+ *
704
+ * @return bool
705
+ */
706
+ public function isXpcMethod($code, $includeSavedCards = true)
707
+ {
708
+ return 0 === strpos($code, 'xpayments')
709
+ || (
710
+ $includeSavedCards
711
+ && 'savedcards' == $code
712
+ );
713
+ }
714
+
715
+ /**
716
+ * Check if the payment method code is X-Payments' saved cards one
717
+ *
718
+ * @param $code Payment method code to check
719
+ *
720
+ * @return bool
721
+ */
722
+ public function isSavedCardsMethod($code)
723
+ {
724
+ return 'savedcards' == $code;
725
+ }
726
+
727
+ /**
728
+ * Get config option value for specific payment method
729
+ *
730
+ * @param string $name Option name
731
+ * @param int $xpcSlot Slot index of the XPC payment method
732
+ *
733
+ * @return string (or whatever is there)
734
+ */
735
+ public function getPaymentConfig($name, $xpcSlot)
736
+ {
737
+ $xpcSlot = $this->checkXpcSlot($xpcSlot);
738
+
739
+ $path = self::XPATH_PAYMENT . $xpcSlot . '/' . $name;
740
+
741
+ return Mage::getStoreConfig($path);
742
+ }
743
+
744
+ /**
745
+ * Set config option value for specific payment method
746
+ *
747
+ * @param string $name Option name
748
+ * @param string $value Option value
749
+ * @param int $xpcSlot Slot index of the XPC payment method
750
+ *
751
+ * @return void
752
+ */
753
+ public function setPaymentConfig($name, $value, $xpcSlot)
754
+ {
755
+ $id = $this->checkXpcSlot($xpcSlot);
756
+
757
+ $path = self::XPATH_PAYMENT . $xpcSlot . '/' . $name;
758
+
759
+ $config = new Mage_Core_Model_Config();
760
+ $config->saveConfig($path, $value);
761
+ }
762
+
763
+ /**
764
+ * Get config option value for saved cards payment method
765
+ *
766
+ * @param string $name Option name
767
+ *
768
+ * @return string (or whatever is there)
769
+ */
770
+ public function getSavedCardsConfig($name)
771
+ {
772
+ $path = self::XPATH_SAVED_CARDS . $name;
773
+
774
+ return Mage::getStoreConfig($path);
775
+ }
776
+
777
+ /**
778
+ * Set config option value for saved cards payment method
779
+ *
780
+ * @param string $name Option name
781
+ * @param string $value Option value
782
+ *
783
+ * @return void
784
+ */
785
+ public function setSavedCardsConfig($name, $value)
786
+ {
787
+ $path = self::XPATH_SAVED_CARDS . $name;
788
+
789
+ $config = new Mage_Core_Model_Config();
790
+ $config->saveConfig($path, $value);
791
+ }
792
+
793
+ /**
794
+ * Decode bundle. It's base64 encoded
795
+ * serialized or JSON-encoded array
796
+ *
797
+ * @param string $bundle If not passed use value from the config
798
+ *
799
+ * @return array
800
+ */
801
+ public function decodeBundle($bundle = null)
802
+ {
803
+ if (is_null($bundle)) {
804
+ $bundle = $this->getXpcConfig('xpay_conf_bundle');
805
+ }
806
+
807
+ $decoded = base64_decode($bundle, true);
808
+
809
+ if (false !== $decoded) {
810
+
811
+ if (preg_match(self::BUNDLE_REGEXP, $decoded)) {
812
+ // Try old-fashioned serialized bundle
813
+ $result = @unserialize($decoded);
814
+ } else {
815
+ // Try modern JSON bundle
816
+ $result = json_decode($decoded, true);
817
+ }
818
+ }
819
+
820
+ if (empty($result) || !is_array($result)) {
821
+ $result = array();
822
+ }
823
+
824
+ return $result;
825
+ }
826
+
827
+ /**
828
+ * Get config option value common for all payment methods
829
+ *
830
+ * @param string $name Option name
831
+ *
832
+ * @return string (or whatever is there)
833
+ */
834
+ public function getXpcConfig($name)
835
+ {
836
+ $path = self::XPATH_XPC . $name;
837
+
838
+ if (array_key_exists($name, $this->bundleMap)) {
839
+ $bundle = $this->decodeBundle();
840
+ $value = $bundle[$this->bundleMap[$name]];
841
+ } else {
842
+ $value = Mage::getStoreConfig($path);
843
+ }
844
+
845
+ return $value;
846
+ }
847
+
848
+ /**
849
+ * Set config option value common for all payment methods
850
+ *
851
+ * @param string $name Option name
852
+ * @param string $value Option value
853
+ * @param bool $reinit Is it necessary to reload config
854
+ *
855
+ * @return void
856
+ */
857
+ public function setXpcConfig($name, $value, $reinit = false)
858
+ {
859
+ $path = self::XPATH_XPC . $name;
860
+
861
+ $config = new Mage_Core_Model_Config();
862
+ $config->saveConfig($path, $value);
863
+
864
+ if ($reinit) {
865
+
866
+ // This cleans up config cache. But looks like not realy necessary now.
867
+ // Mage::app()->getCacheInstance()->cleanType('config');
868
+
869
+ // This reloads config. This is realy necessary.
870
+ Mage::app()->getConfig()->reinit();
871
+ }
872
+ }
873
+
874
+ /**
875
+ * Process and save bundle in the config
876
+ *
877
+ * @param $bundle Base64 encoded, serialized bundle
878
+ *
879
+ * @return void
880
+ */
881
+ public function setXpcBundle($bundle)
882
+ {
883
+ $decoded = $this->decodeBundle($bundle);
884
+
885
+ if (!empty($decoded['server_ip'])) {
886
+ $this->setXpcConfig('xpay_allowed_ip_addresses', $decoded['server_ip']);
887
+ }
888
+
889
+ $this->setXpcConfig('xpay_conf_bundle', $bundle, true);
890
+ }
891
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Adminhtml/System/Config/Source/Placedisplay.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
@@ -39,4 +39,4 @@ class Cdev_XPaymentsConnector_Model_Adminhtml_System_Config_Source_Placedisplay
39
 
40
  return $themes;
41
  }
42
- }
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
39
 
40
  return $themes;
41
  }
42
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Fraudcheckdata.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Coupon/Usage.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ class Cdev_XPaymentsConnector_Model_Mysql4_Coupon_Usage extends Mage_SalesRule_Model_Resource_Coupon_Usage
24
+ {
25
+ /**
26
+ * Decrement times_used counter
27
+ *
28
+ * @param int $customerId
29
+ * @param int $couponId
30
+ *
31
+ * @return void
32
+ */
33
+ public function decreaseCustomerCouponTimesUsed($customerId, $couponId)
34
+ {
35
+ $read = $this->_getReadAdapter();
36
+ $select = $read->select();
37
+ $select->from($this->getMainTable(), array('times_used'))
38
+ ->where('coupon_id = :coupon_id')
39
+ ->where('customer_id = :customer_id');
40
+
41
+ $timesUsed = $read->fetchOne($select, array(':coupon_id' => $couponId, ':customer_id' => $customerId));
42
+
43
+ if ($timesUsed > 0) {
44
+ $this->_getWriteAdapter()->update(
45
+ $this->getMainTable(),
46
+ array(
47
+ 'times_used' => $timesUsed - 1
48
+ ),
49
+ array(
50
+ 'coupon_id = ?' => $couponId,
51
+ 'customer_id = ?' => $customerId,
52
+ )
53
+ );
54
+ }
55
+ }
56
+
57
+ /**
58
+ * This is the WA fix for default Magento code
59
+ * Correctly updates zero coupon usage
60
+ *
61
+ * @param mixed $customerId
62
+ * @param mixed $couponId
63
+ *
64
+ * @return void
65
+ */
66
+ public function updateCustomerCouponTimesUsed($customerId, $couponId)
67
+ {
68
+ $read = $this->_getReadAdapter();
69
+ $select = $read->select();
70
+ $select->from($this->getMainTable(), array('times_used'))
71
+ ->where('coupon_id = :coupon_id')
72
+ ->where('customer_id = :customer_id');
73
+
74
+ $timesUsed = $read->fetchOne($select, array(':coupon_id' => $couponId, ':customer_id' => $customerId));
75
+
76
+ if (is_numeric($timesUsed)) { // Fix is here
77
+ $this->_getWriteAdapter()->update(
78
+ $this->getMainTable(),
79
+ array(
80
+ 'times_used' => $timesUsed + 1
81
+ ),
82
+ array(
83
+ 'coupon_id = ?' => $couponId,
84
+ 'customer_id = ?' => $customerId,
85
+ )
86
+ );
87
+ } else {
88
+ $this->_getWriteAdapter()->insert(
89
+ $this->getMainTable(),
90
+ array(
91
+ 'coupon_id' => $couponId,
92
+ 'customer_id' => $customerId,
93
+ 'times_used' => 1
94
+ )
95
+ );
96
+ }
97
+ }
98
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Fraudcheckdata.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Fraudcheckdata/Collection.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration/Collection.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Quote/Xpcdata.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Quote/Xpcdata/Collection.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards/Collection.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Observer.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,312 +13,115 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
  * Class Cdev_XPaymentsConnector_Model_Observer
24
  */
25
-
26
  class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model_Observer
27
  {
28
  protected $_current_customer_id = null;
29
 
30
- public function preDispatchCheckout($observer)
31
- {
32
-
33
- Mage::getSingleton('checkout/session')->unsetData('user_card_save');
34
-
35
- //unset x-payment form place settings
36
- $unsetParams = array('place_display');
37
- $xpHelper = Mage::helper('xpaymentsconnector');
38
- $xpHelper->unsetXpaymentPrepareOrder($unsetParams);
39
-
40
- }
41
-
42
- public function paymentMethodIsActive($observer)
43
- {
44
- $event = $observer->getEvent();
45
- $method = $event->getMethodInstance();
46
- $result = $event->getResult();
47
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
48
- $prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
49
-
50
- if (($method->getCode() == $saveCardsPaymentCode) || ($method->getCode() == $prepaidpayments)) {
51
- $quote = $event->getQuote();
52
- if ($quote) {
53
- $customerId = $quote->getData('customer_id');
54
- $isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD;
55
- if ($method->getCode() == $prepaidpayments) {
56
- $isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
57
- }
58
- if ($customerId) {
59
- $cardsCount = Mage::getModel('xpaymentsconnector/usercards')
60
- ->getCollection()
61
- ->addFieldToFilter('user_id', $customerId)
62
- ->addFieldToFilter('usage_type', $isBalanceCard)
63
- ->count();
64
- if ($cardsCount == 0) {
65
- $result->isAvailable = false;
66
- }
67
- } else {
68
- $result->isAvailable = false;
69
- }
70
- }
71
- }
72
- }
73
-
74
-
75
- /**
76
- * Dispatch: checkout_type_onepage_save_order_after
77
- * @param $observer
78
  */
79
-
80
- public function updateOrder($observer)
81
  {
82
- $xpHelper = Mage::helper('xpaymentsconnector');
83
- $event = $observer->getEvent();
84
- $order = $event->getOrder();
85
-
86
- $checkoutSession = Mage::getSingleton('checkout/session');
87
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
88
- $paymentCcModel = Mage::getModel('xpaymentsconnector/payment_cc');
89
- $xpaymentPaymentCode = $paymentCcModel->getCode();
90
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
91
- $useIframe = Mage::helper('xpaymentsconnector')->isUseIframe();
92
- $quote = $observer->getQuote();
93
-
94
- $noticeHelper = $xpHelper->getFailureCheckoutNoticeHelper();
95
-
96
- if ($paymentMethod == $saveCardsPaymentCode) {
97
-
98
- $order->setCanSendNewEmailFlag(false);
99
- $paymentCardNumber = NULL;
100
- $grandTotal = NULL;
101
- $cardData = NULL;
102
- $paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
103
- $cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
104
-
105
- $response = $paymentCcModel->sendAgainTransactionRequest($order->getId(),$paymentCardNumber,$grandTotal,$cardData);
106
-
107
- if ($response['success']) {
108
- $result = $paymentCcModel->updateOrderByXpaymentResponse($order->getId(), $response['response']['transaction_id']);
109
 
110
- // Reload order data, since it has been changed
111
- $order = Mage::getModel('sales/order')->load($order->getId());
112
-
113
- if (!$result['success']) {
114
- $checkoutSession->addError($result['error_message']);
115
- $checkoutSession->addNotice($noticeHelper);
116
- } else {
117
- // Auto create invoice if necessary
118
- Mage::helper('xpaymentsconnector')->processCreateInvoice($order);
119
- }
120
- } else {
121
- $checkoutSession->addError($response['error_message']);
122
- $checkoutSession->addNotice($noticeHelper);
123
- }
124
 
 
 
 
125
  }
126
-
127
-
128
  }
129
 
130
-
131
  /**
 
 
132
  * @param Varien_Event_Observer $observer
 
 
133
  */
134
- public function orderSuccessAction($observer)
135
  {
136
- Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder();
137
- }
138
 
 
 
 
139
 
140
- /**
141
- * @param Varien_Event_Observer $observer
142
- */
143
- public function postdispatchAdminhtmlSalesOrderCreateSave($observer)
144
- {
145
- $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
146
- $incrementId = $quote->getData('reserved_order_id');
147
- $order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
148
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
149
- $admSession = Mage::getSingleton('adminhtml/session');
150
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
151
- $prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
152
-
153
- if ($paymentMethod == $saveCardsPaymentCode) {
154
- $orderId = $order->getId();
155
- $grandTotal = $quote->getData('grand_total');
156
- $this->adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal);
157
- } elseif ($paymentMethod == $prepaidpayments) {
158
- $xpPrepaidPaymentsCard = $admSession->getData('xp_prepaid_payments');
159
- $currentUserCard = Mage::getModel('xpaymentsconnector/usercards')->load($xpPrepaidPaymentsCard);
160
- $txnid = $currentUserCard->getData('txnId');
161
- $lastTransId = $txnid;
162
-
163
- $order->setData('xpc_txnid',$txnid);
164
- $order->getPayment()->setTransactionId($txnid);
165
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
166
- list($status, $response) = $api->requestPaymentInfo($txnid,false,true);
167
-
168
- if($status){
169
- $currentTransaction = end($response['transactions']);
170
- $lastTransId = $currentTransaction['txnid'];
171
- }
172
 
173
- $order->getPayment()->setLastTransId($lastTransId);
174
- $order->setData('xp_card_data',serialize($currentUserCard->getData()));
175
- $order->setState(
176
- Mage_Sales_Model_Order::STATE_PROCESSING,
177
- (bool)Mage_Sales_Model_Order::STATE_PROCESSING,
178
- Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
179
  );
180
- $order->save();
181
  }
182
- $admSession->unsetData('xp_payment_card');
183
- $admSession->unsetData('xp_prepaid_payments');
184
-
185
  }
186
 
187
-
188
  /**
189
- * Send transaction to X-Payment for 'order edit' event
 
190
  * @param Varien_Event_Observer $observer
 
 
191
  */
192
- public function postdispatchAdminhtmlSalesOrderEditSave($observer)
193
  {
194
- $adminhtmlSessionQuote = Mage::getSingleton('adminhtml/session_quote');
195
- $parentOrder = $adminhtmlSessionQuote->getOrder();
196
- $incrementId = $parentOrder->getRelationChildRealId();
197
-
198
- if($incrementId){
199
- $order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
200
- $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
201
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
202
-
203
- if ($paymentMethod == $saveCardsPaymentCode && $order) {
204
- $orderId = $order->getId();
205
- $grandTotal = $order->getGrandTotal();
206
- $parentOrderGrandTotal = $parentOrder->getGrandTotal();
207
-
208
- if($grandTotal > $parentOrderGrandTotal){
209
- $checkOrderAmount = false;
210
- $recalculcateGrandTotal = $grandTotal-$parentOrderGrandTotal;
211
- $this->adminhtmlSendSaveCardsPaymentTransaction($orderId,$recalculcateGrandTotal,$checkOrderAmount);
212
- }
213
- }
214
- }
215
- }
216
 
217
- /**
218
- * Send transaction from the admin panel
219
- * @param int $orderId
220
- * @param float $grandTotal
221
- * @param bool $checkOrderAmount
222
- */
223
- protected function adminhtmlSendSaveCardsPaymentTransaction($orderId,$grandTotal,$checkOrderAmount = true)
224
- {
225
- $admSession = Mage::getSingleton('adminhtml/session');
226
- $xpCreditCards = $admSession->getData('xp_payment_card');
227
-
228
- $response = Mage::getModel('xpaymentsconnector/payment_cc')->sendAgainTransactionRequest($orderId, $xpCreditCards, $grandTotal);
229
- if ($response['success']) {
230
- Mage::getModel('xpaymentsconnector/payment_cc')->updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id'],$checkOrderAmount);
231
- } else {
232
- Mage::getSingleton('adminhtml/session')->addError($response['error_message']);
233
  }
234
 
235
- }
236
-
237
- public function predispatchAdminhtmlSalesOrderCreateSave($observer)
238
- {
239
- $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
240
- $paymentMethod = $quote->getPayment()->getMethodInstance()->getCode();
241
- $prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
242
- if ($paymentMethod == $prepaidpayments) {
243
- $admSession = Mage::getSingleton('adminhtml/session');
244
- $xpPrepaidPaymentsCard = $admSession->getData('xp_prepaid_payments');
245
- $currentUserCard = Mage::getModel('xpaymentsconnector/usercards')->load($xpPrepaidPaymentsCard);
246
- $grandTotal = $quote->getData('grand_total');
247
- $cardAmount = $currentUserCard->getAmount();
248
- if ($cardAmount < $grandTotal) {
249
- $errorMessage = Mage::helper('xpaymentsconnector')
250
- ->__("You can't make an order using card (**%s) worth over %s",
251
- $currentUserCard->getData('last_4_cc_num'),
252
- Mage::helper('core')->currency($cardAmount));
253
- $admSession->addError($errorMessage);
254
- /*redirect to last page*/
255
- Mage::app()->getResponse()->setRedirect($_SERVER['HTTP_REFERER']);
256
- Mage::app()->getResponse()->sendResponse();
257
- exit;
258
- } else {
259
- $cardBalance = $cardAmount - $grandTotal;
260
- if ($cardBalance == 0) {
261
- $currentUserCard->delete();
262
- } else {
263
- $currentUserCard->setAmount($cardBalance)->save();
264
- }
265
 
266
- }
267
- }
268
  }
269
 
270
- public function adminhtmlSavePaymentCard()
271
- {
272
- $payment = Mage::app()->getRequest()->getPost('payment');
273
- $saveCardsPaymentCode = Mage::getModel('xpaymentsconnector/payment_savedcards')->getCode();
274
- $prepaidpayments = Mage::getModel('xpaymentsconnector/payment_prepaidpayments')->getCode();
275
-
276
- if ($payment) {
277
- if ($payment['method'] == $saveCardsPaymentCode) {
278
- if ($payment['xp_payment_card']) {
279
- $admSession = Mage::getSingleton('adminhtml/session');
280
- $admSession->setData('xp_payment_card', $payment['xp_payment_card']);
281
- }
282
- } elseif ($payment['method'] == $prepaidpayments) {
283
- if ($payment['xp_prepaid_payments']) {
284
- $admSession = Mage::getSingleton('adminhtml/session');
285
- $admSession->setData('xp_prepaid_payments', $payment['xp_prepaid_payments']);
286
- }
287
- }
288
- }
289
- }
290
-
291
- public function unsetXpaymentSelectedCard()
292
  {
293
- $admSession = Mage::getSingleton('adminhtml/session');
294
- $admSession->unsetData('xp_payment_card');
295
- $admSession->unsetData('xp_prepaid_payments');
296
- }
297
 
298
- public function orderInvoiceSaveBefore($observer)
299
- {
300
- $invoice = $observer->getEvent()->getInvoice();
301
- $order = $invoice->getOrder();
302
- $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
303
- if (Mage::helper('xpaymentsconnector')->isXpaymentsMethod($paymentCode)) {
304
- $txnid = $order->getData('xpc_txnid');
305
- $invoice->setTransactionId($txnid);
306
  }
307
- }
308
 
309
- public function invoiceVoid($observer)
310
- {
311
- $invoice = $observer->getInvoice();
312
- $order = $invoice->getOrder();
313
- $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
314
- if (Mage::helper('xpaymentsconnector')->isXpaymentsMethod($paymentCode)) {
315
- $data = array(
316
- 'txnId' => $order->getData('xpc_txnid'),
317
- 'amount' => number_format($invoice->getGrandTotal(), 2, '.', ''),
318
- );
319
- Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('void', $data);
320
- }
321
  }
322
 
323
  public function createOrdersByCustomerSubscriptions($observer)
@@ -385,7 +189,7 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
385
  $orderItemInfo = unserialize($orderItemInfo);
386
  }
387
 
388
- $initialFeeAmount = $orderItemInfo['recurring_initial_fee'];
389
 
390
  $isFirstRecurringOrder = false;
391
 
@@ -433,27 +237,6 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
433
 
434
  }
435
 
436
- /**
437
- * Add redirect for buying recurring product by xpayments method(without iframe)
438
- * @param $observer
439
- */
440
- public function addRedirectForXpaymentMethod($observer)
441
- {
442
- $profiles = $observer->getData('recurring_profiles');
443
- if (!empty($profiles)) {
444
- $profile = current($profiles);
445
- $currentPaymentMethodCode = $profile->getData('method_code');
446
- $xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
447
- $useIframe = Mage::helper('xpaymentsconnector')->isUseIframe();
448
- if (($currentPaymentMethodCode == $xpaymentPaymentCode) && !$useIframe) {
449
- $redirectUrl = Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
450
- Mage::getSingleton('checkout/session')->setRedirectUrl($redirectUrl);
451
- }
452
-
453
- }
454
-
455
- }
456
-
457
  /**
458
  * Set discount for recurring product(for ajax cart item quantity update)
459
  * Remove X-Payments token
@@ -462,9 +245,7 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
462
  */
463
  public function updateCartItem($observer)
464
  {
465
- $unsetParams = array('token');
466
  $xpHelper = Mage::helper('xpaymentsconnector');
467
- $xpHelper->unsetXpaymentPrepareOrder($unsetParams);
468
 
469
  // update InitAmount for recurring products
470
  $cart = $observer->getCart('quote');
@@ -506,128 +287,4 @@ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model
506
  //
507
 
508
  }
509
-
510
- /**
511
- * Remove X-Payments token;
512
- * Update initial Fee for recurring product;
513
- * @param $observer
514
- */
515
- public function checkoutCartAdd($observer)
516
- {
517
- $xpHelper = Mage::helper('xpaymentsconnector');
518
- $unsetParams = array('token');
519
- $xpHelper->unsetXpaymentPrepareOrder($unsetParams);
520
- }
521
-
522
- /**
523
- * Remove X-Payments token and prepare order number.
524
- * @param $observer
525
- */
526
- public function postdispatchCartDelete($observer)
527
- {
528
- $unsetParams = array('token', 'prepare_order_id');
529
- Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder($unsetParams);
530
- }
531
-
532
-
533
- /**
534
- * Set 'place_display' flag for feature x-payment form.
535
- * @param $observer
536
- */
537
- public function predispatchSaveShippingMethod()
538
- {
539
- Mage::helper('xpaymentsconnector')->setIframePlaceDisplaySettings();
540
- }
541
-
542
- /**
543
- * Remove X-Payments token after update shipping method
544
- * @param $observer
545
- */
546
- public function postdispatchSaveShippingMethod($observer)
547
- {
548
- $xpHelper = Mage::helper('xpaymentsconnector');
549
- $isPaymentPlaceDisplayFlag = $xpHelper->isIframePaymentPlaceDisplay();
550
- if (!$isPaymentPlaceDisplayFlag) {
551
- $unsetParams = array('token');
552
- $xpHelper->unsetXpaymentPrepareOrder($unsetParams);
553
- }
554
- }
555
-
556
- public function postDispatchSavePayment($observer)
557
- {
558
- $quote = Mage::getSingleton('checkout/session')->getQuote();
559
- $paymentMethodCode = $quote->getPayment()->getMethodInstance()->getCode();
560
- $xpaymentPaymentCode = Mage::getModel('xpaymentsconnector/payment_cc')->getCode();
561
- $xpHelper = Mage::helper('xpaymentsconnector');
562
-
563
- if ($paymentMethodCode == $xpaymentPaymentCode) {
564
- $saveCard = Mage::app()->getRequest()->getPost('savecard');
565
- if ($saveCard) {
566
- Mage::getSingleton('checkout/session')->setData('user_card_save', $saveCard);
567
- }
568
- } else {
569
- Mage::getSingleton('checkout/session')->unsetData('user_card_save');
570
- }
571
- }
572
-
573
- /**
574
- * Set discount for recurring product
575
- * @param $observer
576
- */
577
- public function preDispatchCartIndex($observer)
578
- {
579
- $unsetXpPrepareOrder = Mage::app()->getRequest()->getParam('unset_xp_prepare_order');
580
- $xpHelper = Mage::helper('xpaymentsconnector');
581
- if (isset($unsetXpPrepareOrder)) {
582
- $unsetParams = array('token');
583
- $xpHelper->unsetXpaymentPrepareOrder($unsetParams);
584
- }
585
- }
586
-
587
-
588
- /**
589
- * Send xp transaction from 'XP Order State tab'
590
- * @param $observer
591
- */
592
- public function adminhtmlSalesOrderView($observer){
593
- $xpTransactionData = Mage::app()->getRequest()->getPost();
594
- if(!empty($xpTransactionData)){
595
-
596
- if(!empty($xpTransactionData)
597
- && isset($xpTransactionData['xpaction'])
598
- && isset($xpTransactionData['xpc_txnid'])
599
- && isset($xpTransactionData['transaction_amount'])
600
- ){
601
-
602
- $xpaymentModel = Mage::getModel('xpaymentsconnector/payment_cc');
603
- $data = array(
604
- 'txnId' => $xpTransactionData['xpc_txnid'],
605
- 'amount' => number_format($xpTransactionData['transaction_amount'], 2, '.', ''),
606
- );
607
- $result = array();
608
- switch ($xpTransactionData['xpaction']) {
609
- case 'refund':
610
- $result = $xpaymentModel->authorizedTransactionRequest('refund', $data);
611
- break;
612
- case 'capture':
613
- $result = $xpaymentModel->authorizedTransactionRequest('capture', $data);
614
- break;
615
- case 'void':
616
- $result = $xpaymentModel->authorizedTransactionRequest('void', $data);
617
- break;
618
- }
619
-
620
- if(empty($result['error_message'])){
621
- $message = Mage::helper('xpaymentsconnector')->__("Transaction '%s' to order (%s) was successful!",
622
- $xpTransactionData['xpaction'],
623
- $xpTransactionData['orderid']);
624
- Mage::getSingleton('adminhtml/session')->addSuccess($message);
625
- } else{
626
- Mage::getSingleton('adminhtml/session')->addError($result['error_message']);
627
- }
628
-
629
- }
630
- }
631
- }
632
-
633
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Class Cdev_XPaymentsConnector_Model_Observer
25
  */
 
26
  class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model_Observer
27
  {
28
  protected $_current_customer_id = null;
29
 
30
+ /**
31
+ * Process event before invoice is saved
32
+ *
33
+ * @param Varien_Event_Observer $observer
34
+ *
35
+ * @return void
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  */
37
+ public function orderInvoiceSaveBefore($observer)
 
38
  {
39
+ $invoice = $observer->getEvent()->getInvoice();
40
+ $order = $invoice->getOrder();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
41
 
42
+ $isXpc = Mage::helper('settings_xpc')->isXpcMethod(
43
+ $order->getPayment()->getMethodInstance()->getCode()
44
+ );
 
 
 
 
 
 
 
 
 
 
 
45
 
46
+ if ($isXpc) {
47
+ $txnid = $order->getData('xpc_txnid');
48
+ $invoice->setTransactionId($txnid);
49
  }
 
 
50
  }
51
 
 
52
  /**
53
+ * Process event when invoice is canceled
54
+ *
55
  * @param Varien_Event_Observer $observer
56
+ *
57
+ * @return void
58
  */
59
+ public function invoiceVoid($observer)
60
  {
61
+ $invoice = $observer->getInvoice();
62
+ $order = $invoice->getOrder();
63
 
64
+ $isXpc = Mage::helper('settings_xpc')->isXpcMethod(
65
+ $order->getPayment()->getMethodInstance()->getCode()
66
+ );
67
 
68
+ if ($isXpc) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
69
 
70
+ // Cancel payment in X-Payments
71
+ Mage::helper('api_xpc')->requestPaymentVoid(
72
+ $order->getData('xpc_txnid'),
73
+ $invoice->getGrandTotal()
 
 
74
  );
 
75
  }
 
 
 
76
  }
77
 
 
78
  /**
79
+ * Process event when order is deleted
80
+ *
81
  * @param Varien_Event_Observer $observer
82
+ *
83
+ * @return void
84
  */
85
+ public function orderDeleteBefore($observer)
86
  {
87
+ $order = $observer->getOrder();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
88
 
89
+ if (
90
+ !$order
91
+ || empty($order->getData('xpc_txnid'))
92
+ ) {
93
+ return;
 
 
 
 
 
 
 
 
 
 
 
94
  }
95
 
96
+ // Get associated quote ID
97
+ $quoteId = Mage::getModel('xpaymentsconnector/quote_xpcdata')
98
+ ->load($order->getData('xpc_txnid'), 'txn_id')
99
+ ->getData('quote_id');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
100
 
101
+ // Delete all XPC data records for quote
102
+ Mage::getModel('xpaymentsconnector/quote_xpcdata')->deleteByQuoteId($quoteId);
103
  }
104
 
105
+ /**
106
+ * Process event when quote is deleted
107
+ *
108
+ * @param Varien_Event_Observer $observer
109
+ *
110
+ * @return void
111
+ */
112
+ public function quoteDeleteBefore($observer)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  {
114
+ $quote = $observer->getQuote();
 
 
 
115
 
116
+ if (
117
+ !$quote
118
+ || empty($quote->getId())
119
+ ) {
120
+ return;
 
 
 
121
  }
 
122
 
123
+ // Delete all XPC data records for quote
124
+ Mage::getModel('xpaymentsconnector/quote_xpcdata')->deleteByQuoteId($quote->getId());
 
 
 
 
 
 
 
 
 
 
125
  }
126
 
127
  public function createOrdersByCustomerSubscriptions($observer)
189
  $orderItemInfo = unserialize($orderItemInfo);
190
  }
191
 
192
+ $initialFeeAmount = isset($orderItemInfo['recurring_initial_fee']) ? $orderItemInfo['recurring_initial_fee'] : 0;
193
 
194
  $isFirstRecurringOrder = false;
195
 
237
 
238
  }
239
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  /**
241
  * Set discount for recurring product(for ajax cart item quantity update)
242
  * Remove X-Payments token
245
  */
246
  public function updateCartItem($observer)
247
  {
 
248
  $xpHelper = Mage::helper('xpaymentsconnector');
 
249
 
250
  // update InitAmount for recurring products
251
  $cart = $observer->getCart('quote');
287
  //
288
 
289
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
290
  }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Abstract.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ /**
23
+ * Abstract class for X-Payments CC and saved CC payment methods
24
+ */
25
+ abstract class Cdev_XPaymentsConnector_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
26
+ implements Mage_Payment_Model_Recurring_Profile_MethodInterface
27
+ {
28
+ /**
29
+ * Order (cache)
30
+ */
31
+ private $order = null;
32
+
33
+ /**
34
+ * Get payment configuration model
35
+ *
36
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
37
+ */
38
+ abstract public function getPaymentConfiguration();
39
+
40
+ /**
41
+ * Get internal XPC method code
42
+ * (number from xpayments1, xpayments1, etc)
43
+ *
44
+ * @return int
45
+ */
46
+ abstract public function getXpcSlot();
47
+
48
+ /**
49
+ * Get order
50
+ *
51
+ * @return Mage_Sales_Model_Order
52
+ */
53
+ public function getOrder()
54
+ {
55
+ if (!$this->order) {
56
+ $this->order = $this->getInfoInstance()->getOrder();
57
+ }
58
+
59
+ return $this->order;
60
+ }
61
+
62
+ /**
63
+ * Check method availability
64
+ *
65
+ * @param Mage_Sales_Model_Quote $quote Quote
66
+ *
67
+ * @return boolean
68
+ */
69
+ public function isAvailable($quote = null)
70
+ {
71
+ return parent::isAvailable($quote)
72
+ && Mage::helper('settings_xpc')->isConfigured()
73
+ && Mage::helper('settings_xpc')->checkRequirements()
74
+ && '1' != Mage::getStoreConfig('advanced/modules_disable_output/Cdev_XPaymentsConnector');
75
+ }
76
+
77
+ /**
78
+ * Check - can method Authorize transaction or not
79
+ *
80
+ * @return boolean
81
+ */
82
+ public function canAuthorize()
83
+ {
84
+ return (bool)$this->getPaymentConfiguration()->getData('is_auth');
85
+ }
86
+
87
+ /**
88
+ * Check - can method Capture transaction or not
89
+ *
90
+ * @return boolean
91
+ */
92
+ public function canCapture()
93
+ {
94
+ $result = false;
95
+
96
+ $order = $this->getOrder();
97
+
98
+ if ($order->getData('xpc_txnid')) {
99
+
100
+ $response = Mage::helper('api_xpc')->requestPaymentInfo($order->getData('xpc_txnid'));
101
+
102
+ if (
103
+ $response->getStatus()
104
+ && $response->getField('status') == Cdev_XPaymentsConnector_Helper_Api_Data::AUTH_ACTION
105
+ ) {
106
+ $result = true;
107
+ }
108
+ }
109
+
110
+ return $result;
111
+ }
112
+
113
+ /**
114
+ * Check - can method Refund transaction or not
115
+ *
116
+ * @return boolean
117
+ */
118
+ public function canRefund()
119
+ {
120
+ return (bool)$this->getPaymentConfiguration()->getData('is_refund');
121
+ }
122
+
123
+ /**
124
+ * Check - can method Partial refund transaction or not
125
+ *
126
+ * @return boolean
127
+ */
128
+ public function canRefundPartialPerInvoice()
129
+ {
130
+ return (bool)$this->getPaymentConfiguration()->getData('is_part_refund');
131
+ }
132
+
133
+ /**
134
+ * Check - can method Void transaction or not
135
+ *
136
+ * @param Varien_Object $payment Payment
137
+ *
138
+ * @return boolean
139
+ */
140
+ public function canVoid(Varien_Object $payment)
141
+ {
142
+ return (bool)$this->getPaymentConfiguration()->getData('is_void');
143
+ }
144
+
145
+ /**
146
+ * Capture specified amount for payment
147
+ *
148
+ * @param Varien_Object $payment
149
+ * @param float $amount
150
+ *
151
+ * @return Mage_Payment_Model_Abstract
152
+ */
153
+ public function capture(Varien_Object $payment, $amount)
154
+ {
155
+ if (!$this->canCapture()) {
156
+
157
+ Mage::throwException(
158
+ Mage::helper('xpaymentsconnector')->__('Capture action is not available.')
159
+ );
160
+ }
161
+
162
+ $response = Mage::helper('api_xpc')->requestPaymentCapture($this->getOrder()->getData('xpc_txnid'), $amount);
163
+
164
+ if (!$response->getStatus()) {
165
+
166
+ $message = $response->getErrorMessage('Capture operation failed');
167
+
168
+ Mage::throwException(
169
+ Mage::helper('xpaymentsconnector')->__($message)
170
+ );
171
+ }
172
+
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Refund specified amount for payment
178
+ *
179
+ * @param Varien_Object $payment
180
+ * @param float $amount
181
+ *
182
+ * @return Mage_Payment_Model_Abstract
183
+ */
184
+ public function refund(Varien_Object $payment, $amount)
185
+ {
186
+ if (!$this->canRefund()) {
187
+ Mage::throwException(
188
+ Mage::helper('xpaymentsconnector')->__('Refund action is not available.')
189
+ );
190
+ }
191
+
192
+ $response = Mage::helper('api_xpc')->requestPaymentRefund($this->getOrder()->getData('xpc_txnid'), $amount);
193
+
194
+ if (!$response->getStatus()) {
195
+
196
+ $message = $response->getErrorMessage('Refund operation failed');
197
+
198
+ Mage::throwException(
199
+ Mage::helper('xpaymentsconnector')->__($message)
200
+ );
201
+ }
202
+
203
+ return $this;
204
+ }
205
+
206
+ /**
207
+ * Validate data
208
+ *
209
+ * @param Mage_Payment_Model_Recurring_Profile $profile
210
+ *
211
+ * @throws Mage_Core_Exception
212
+ */
213
+ public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
214
+ {
215
+ // To be implemented.
216
+ }
217
+
218
+ /**
219
+ * Process recurring profile when quote is converted to order
220
+ *
221
+ * @param Mage_Payment_Model_Recurring_Profile $profile
222
+ * @param Mage_Payment_Model_Info $paymentInfo
223
+ *
224
+ * @return void
225
+ */
226
+ public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
227
+ {
228
+ // To be implemented.
229
+ }
230
+
231
+ /**
232
+ * Fetch details
233
+ *
234
+ * @param string $referenceId
235
+ *
236
+ * @param Varien_Object $result
237
+ */
238
+ public function getRecurringProfileDetails($referenceId, Varien_Object $result)
239
+ {
240
+ // To be implemented.
241
+ }
242
+
243
+ /**
244
+ * Check whether can get recurring profile details
245
+ *
246
+ * @return bool
247
+ */
248
+ public function canGetRecurringProfileDetails()
249
+ {
250
+ return true;
251
+ }
252
+
253
+ /**
254
+ * Update data
255
+ *
256
+ * @param Mage_Payment_Model_Recurring_Profile $profile
257
+ */
258
+ public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile)
259
+ {
260
+ // To be implemented.
261
+ }
262
+
263
+ /**
264
+ * Manage status
265
+ *
266
+ * @param Mage_Payment_Model_Recurring_Profile $profile
267
+ */
268
+ public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile)
269
+ {
270
+ // To be implemented.
271
+ }
272
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php CHANGED
@@ -13,117 +13,17 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
-
23
-
24
  /**
25
- * Processor
26
- *
27
- * @package Cdev_XPaymentsConnector
28
- * @see ____class_see____
29
- * @since 1.0.0
30
  */
31
-
32
- function xpc_curl_headers_collector()
33
- {
34
- static $headers = '';
35
- $args = func_get_args();
36
- if (count($args) == 1) {
37
- $return = '';
38
- if ($args[0] == true) {
39
- $return = $headers;
40
- }
41
- $headers = '';
42
- return $return;
43
- }
44
-
45
- if (trim($args[1]) != '') {
46
- $headers .= $args[1];
47
- }
48
-
49
- return strlen($args[1]);
50
-
51
- }
52
-
53
-
54
- class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method_Abstract
55
- implements Mage_Payment_Model_Recurring_Profile_MethodInterface
56
  {
57
- // Configuration settings
58
- const XPATH_CART_ID = 'xpaymentsconnector/settings/xpay_cart_id';
59
- const XPATH_URL = 'xpaymentsconnector/settings/xpay_url';
60
- const XPATH_PUBLIC_KEY = 'xpaymentsconnector/settings/xpay_public_key';
61
- const XPATH_PRIVATE_KEY = 'xpaymentsconnector/settings/xpay_private_key';
62
- const XPATH_PRIVATE_KEY_PASS = 'xpaymentsconnector/settings/xpay_private_key_pass';
63
- const XPATH_IP_ADDRESSES = 'xpaymentsconnector/settings/xpay_allowed_ip_addresses';
64
- const XPATH_CURRENCY = 'xpaymentsconnector/settings/xpay_currency';
65
- const XPATH_CONF_BUNDLE = 'xpaymentsconnector/settings/xpay_conf_bundle';
66
- const XPATH_API_VERSION = 'xpaymentsconnector/settings/xpay_api_version';
67
-
68
- // Error codes
69
- const REQ_CURL = 1;
70
- const REQ_OPENSSL = 2;
71
- const REQ_DOM = 4;
72
-
73
- // COnfiguration errors codes
74
- const CONF_CART_ID = 1;
75
- const CONF_URL = 2;
76
- const CONF_PUBLIC_KEY = 4;
77
- const CONF_PRIVATE_KEY = 8;
78
- const CONF_PRIVATE_KEY_PASS = 16;
79
-
80
- // Salt block length
81
- const SALT_LENGTH = 32;
82
-
83
- // Salt generator start character code
84
- const SALT_BEGIN = 33;
85
-
86
- // Salt generator end character code
87
- const SALT_END = 255;
88
-
89
- // Encryption check length
90
- const CHUNK_LENGTH = 128;
91
-
92
- // Root-level tag for all XML messages
93
- const TAG_ROOT = 'data';
94
-
95
- // Value of the 'type' attribute for list items in XML
96
- const TYPE_CELL = 'cell';
97
-
98
- // Payment statuses
99
- const NEW_STATUS = 1;
100
- const AUTH_STATUS = 2;
101
- const DECLINED_STATUS = 3;
102
- const CHARGED_STATUS = 4;
103
-
104
- // Payment actions
105
- const NEW_ACTION = 1;
106
- const AUTH_ACTION = 2;
107
- const CHARGED_ACTION = 3;
108
- const DECLINED_ACTION = 4;
109
- const REFUND_ACTION = 5;
110
- const PART_REFUND_ACTION = 6;
111
-
112
- // Transaction types
113
- const TRAN_TYPE_AUTH = 'auth';
114
- const TRAN_TYPE_CAPTURE = 'capture';
115
- const TRAN_TYPE_CAPTURE_PART = 'capturePart';
116
- const TRAN_TYPE_CAPTURE_MULTI = 'captureMulti';
117
- const TRAN_TYPE_VOID = 'void';
118
- const TRAN_TYPE_VOID_PART = 'voidPart';
119
- const TRAN_TYPE_VOID_MULTI = 'voidMulti';
120
- const TRAN_TYPE_REFUND = 'refund';
121
- const TRAN_TYPE_PART_REFUND = 'refundPart';
122
- const TRAN_TYPE_REFUND_MULTI = 'refundMulti';
123
- const TRAN_TYPE_GET_INFO = 'getInfo';
124
- const TRAN_TYPE_ACCEPT = 'accept';
125
- const TRAN_TYPE_DECLINE = 'decline';
126
-
127
  /**
128
  * Show or not save card checkbox statuses
129
  */
@@ -131,1158 +31,52 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
131
  const SAVE_CARD_REQUIRED = 'Y';
132
  const SAVE_CARD_OPTIONAL = 'O';
133
 
134
- /**
135
- * List of supported API versions
136
- */
137
- private $apiVersions = array(
138
- 1.7,
139
- 1.6,
140
- );
141
-
142
- /**
143
- * unique internal payment method identifier
144
- *
145
- * @var string [a-z0-9_]
146
- **/
147
- protected $_code = 'xpayments';
148
-
149
-
150
  protected $_isGateway = false;
151
- protected $_canUseForMultishipping = false;
152
- protected $_canUseInternal = false;
153
 
154
- protected $_paymentMethod = 'cc';
155
  protected $_defaultLocale = 'en';
156
 
157
  protected $_canUseCheckout = true;
 
 
158
 
159
- protected $_canRefund = true;
160
- protected $_canRefundInvoicePartial = true;
161
-
162
- protected $_canCapturePartial = true;
163
- protected $_canCapture = true;
164
-
165
- /**
166
- * Payment method info block
167
- *
168
- * @var string
169
- * @access protected
170
- * @see ____var_see____
171
- * @since 1.0.0
172
- */
173
- protected $_infoBlockType = 'xpaymentsconnector/info_cc';
174
-
175
- /**
176
- * Payment method form block
177
- *
178
- * @var string
179
- * @access protected
180
- * @see ____var_see____
181
- * @since 1.0.1
182
- */
183
- protected $_formBlockType = 'xpaymentsconnector/form_cc';
184
-
185
- /**
186
- * Order (cache)
187
- *
188
- * @var Mage_Sales_Model_Order
189
- * @access protected
190
- * @see ____var_see____
191
- * @since 1.0.0
192
- */
193
- protected $_order = null;
194
-
195
- public $_currentProfileId = null;
196
- public $firstTransactionSuccess = true;
197
-
198
-
199
- /**
200
- * Get order
201
- *
202
- * @return Mage_Sales_Model_Order
203
- * @access public
204
- * @see ____func_see____
205
- * @since 1.0.0
206
- */
207
- public function getOrder()
208
- {
209
- if (!$this->_order) {
210
- $this->_order = $this->getInfoInstance()->getOrder();
211
- }
212
-
213
- return $this->_order;
214
- }
215
-
216
- /**
217
- * Get redirect URL for order placing procedure
218
- *
219
- * @return string
220
- */
221
- public function getOrderPlaceRedirectUrl()
222
- {
223
- $result = false;
224
-
225
- if (!Mage::helper('xpaymentsconnector')->isUseIframe()) {
226
- $result = Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
227
- }
228
-
229
- return $result;
230
- }
231
-
232
-
233
- /**
234
- * Get payment method type
235
- *
236
- * @return string
237
- * @access public
238
- * @see ____func_see____
239
- * @since 1.0.0
240
- */
241
- public function getPaymentMethodType()
242
- {
243
- return $this->_paymentMethod;
244
- }
245
-
246
- /**
247
- * Check - can method Authorize transaction or not
248
- *
249
- * @return boolean
250
- * @access public
251
- * @see ____func_see____
252
- * @since 1.0.0
253
- */
254
- public function canAuthorize()
255
- {
256
- return (bool)$this->getPaymentConfiguration()->getData('is_auth');
257
- }
258
-
259
- /**
260
- * Check - can method Capture transaction or not
261
- *
262
- * @return boolean
263
- * @access public
264
- * @see ____func_see____
265
- * @since 1.0.0
266
- */
267
- public function canCapture()
268
- {
269
- $order = $this->getOrder();
270
- list($status, $response) = $this->requestPaymentInfo($order->getData('xpc_txnid'));
271
- if($status){
272
- if($response['status'] == self::CHARGED_STATUS){
273
- return false;
274
- }
275
- elseif($response['status'] == self::AUTH_ACTION){
276
- return true;
277
- }
278
- }else{
279
- return false;
280
- }
281
- }
282
-
283
- /**
284
- * Check - can method Refund transaction or not
285
- *
286
- * @return boolean
287
- * @access public
288
- * @see ____func_see____
289
- * @since 1.0.0
290
- */
291
- public function canRefund()
292
- {
293
- return (bool)$this->getPaymentConfiguration()->getData('is_refund');
294
- }
295
-
296
- /**
297
- * Check - can method Partial refund transaction or not
298
- *
299
- * @return boolean
300
- * @access public
301
- * @see ____func_see____
302
- * @since 1.0.0
303
- */
304
- public function canRefundPartialPerInvoice()
305
- {
306
- return (bool)$this->getPaymentConfiguration()->getData('is_part_refund');
307
- }
308
-
309
- /**
310
- * Check - can method Void transaction or not
311
- *
312
- * @param Varien_Object $payment Payment
313
- *
314
- * @return boolean
315
- * @access public
316
- * @see ____func_see____
317
- * @since 1.0.0
318
- */
319
- public function canVoid(Varien_Object $payment)
320
- {
321
- return (bool)$this->getPaymentConfiguration()->getData('is_void');
322
- }
323
-
324
- /**
325
- * Get redirect form URL
326
- *
327
- * @return string
328
- * @access public
329
- * @see ____func_see____
330
- * @since 1.0.0
331
- */
332
- public function getUrl()
333
- {
334
- return preg_replace('/\/+$/Ss', '', $this->getConfig('xpay_url'))
335
- . '/payment.php';
336
- }
337
-
338
- /**
339
- * Get module configuration setting value
340
- *
341
- * @param string $name Configuration setting name
342
- *
343
- * @return mixed
344
- * @access public
345
- * @see ____func_see____
346
- * @since 1.0.0
347
- */
348
- public function getConfig($name)
349
- {
350
- static $required1 = array(
351
- 'store_id',
352
- 'url',
353
- 'public_key',
354
- 'private_key',
355
- 'private_key_password',
356
- );
357
- $required1 = unserialize(base64_decode(Mage::getStoreConfig(self::XPATH_CONF_BUNDLE)));
358
- //print_r($required1);
359
-
360
- static $keys = array(
361
- // 'xpay_cart_id' => $required1['store_id'],
362
- // 'xpay_url' => $required1['url'],
363
- // 'xpay_public_key' => $required1['public_key'],
364
- // 'xpay_private_key' => $required1['private_key'],
365
- // 'xpay_private_key_pass' => $required1['private_key_password'],
366
- 'xpay_allowed_ip_addresses' => self::XPATH_IP_ADDRESSES,
367
- 'xpay_currency' => self::XPATH_CURRENCY,
368
- 'xpay_conf_bundle' => self::XPATH_CONF_BUNDLE,
369
-
370
- );
371
- switch ($name) {
372
- case 'xpay_cart_id' :
373
- return $required1['store_id'];
374
- case 'xpay_url' :
375
- return $required1['url'];
376
- case 'xpay_public_key' :
377
- return $required1['public_key'];
378
- case 'xpay_private_key' :
379
- return $required1['private_key'];
380
- case 'xpay_private_key_pass' :
381
- return $required1['private_key_password'];
382
- }
383
- return isset($keys[$name]) ? Mage::getStoreConfig($keys[$name]) : null;
384
-
385
-
386
- }
387
-
388
- /**
389
- * Get API version setting
390
- *
391
- * @return string
392
- */
393
- public function getApiVersion()
394
- {
395
- return Mage::getStoreConfig(self::XPATH_API_VERSION);
396
- }
397
-
398
- /**
399
- * Check - module is configured
400
- *
401
- * @return boolean
402
- * @access public
403
- * @see ____func_see____
404
- * @since 1.0.0
405
- */
406
- public function isConfigured()
407
- {
408
- return 0 === $this->getConfigurationErrors();
409
- }
410
-
411
- /**
412
- * Get configuration errors code
413
- *
414
- * @return integer
415
- * @access public
416
- * @see ____func_see____
417
- * @since 1.0.0
418
- */
419
- public function getConfigurationErrors()
420
- {
421
- $result = 0;
422
-
423
- // Check shopping cart id
424
- if (
425
- !$this->getConfig('xpay_cart_id')
426
- || !preg_match('/^[\da-f]{32}$/Ss', $this->getConfig('xpay_cart_id'))
427
- ) {
428
- $result = $result | self::CONF_CART_ID;
429
- }
430
-
431
- // Check URL
432
- if (!$this->getConfig('xpay_url')) {
433
- $result = $result | self::CONF_URL;
434
- }
435
-
436
- $parsed_url = @parse_url($this->getConfig('xpay_url'));
437
-
438
- if (!$parsed_url || !isset($parsed_url['scheme']) || $parsed_url['scheme'] != 'https') {
439
- $result = $result | self::CONF_URL;
440
- }
441
-
442
- // Check public key
443
- if (!$this->getConfig('xpay_public_key')) {
444
- $result = $result | self::CONF_PUBLIC_KEY;
445
- }
446
-
447
- // Check private key
448
- if (!$this->getConfig('xpay_private_key')) {
449
- $result = $result | self::CONF_PRIVATE_KEY;
450
- }
451
-
452
- // Check private key password
453
- if (!$this->getConfig('xpay_private_key_pass')) {
454
- $result = $result | self::CONF_PRIVATE_KEY_PASS;
455
- }
456
-
457
- return $result;
458
- }
459
-
460
- /**
461
- * Check - module requirements is passed or not
462
- *
463
- * @return boolean
464
- * @access public
465
- * @see ____func_see____
466
- * @since 1.0.0
467
- */
468
- public function checkRequirements()
469
- {
470
- $code = 0;
471
-
472
- if (!function_exists('curl_init')) {
473
- $code = $code | self::REQ_CURL;
474
- }
475
-
476
- if (
477
- !function_exists('openssl_pkey_get_public') || !function_exists('openssl_public_encrypt')
478
- || !function_exists('openssl_get_privatekey') || !function_exists('openssl_private_decrypt')
479
- || !function_exists('openssl_free_key')
480
- ) {
481
- $code = $code | self::REQ_OPENSSL;
482
- }
483
-
484
- if (!class_exists('DOMDocument')) {
485
- $code = $code | self::REQ_DOM;
486
- }
487
-
488
- return $code;
489
- }
490
-
491
- /**
492
- * Send Handshake request
493
- *
494
- * @param Mage_Sales_Model_Order $order Order
495
- *
496
- * @return string Payment token
497
- * @access public
498
- * @see ____func_see____
499
- * @since 1.0.0
500
- */
501
- public function sendHandshakeRequest(Mage_Sales_Model_Order $order)
502
- {
503
- $refId = $order->getIncrementId();
504
-
505
- $quoteId = $order->getQuoteId();
506
- $cartModel = Mage::getModel('sales/quote')->load($quoteId);
507
-
508
- $xpHelper = Mage::helper('xpaymentsconnector');
509
-
510
- // Prepare cart
511
- $cart = $xpHelper->prepareCart($cartModel);
512
-
513
- // Data to send to X-Payments
514
- $data = array(
515
- 'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
516
- 'refId' => $refId,
517
- 'cart' => $cart,
518
- 'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/return',
519
- array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
520
- 'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback',
521
- array('order_refid' => $refId,'quote_id' => $quoteId,'_secure' => true)),
522
- 'saveCard' => 'Y',
523
- 'api_version' => $this->getApiVersion(),
524
- );
525
-
526
- list($status, $response) = $this->request('payment', 'init', $data);
527
-
528
- if ($status && (!isset($response['token']) || !is_string($response['token']))) {
529
-
530
- $errorMessage = $xpHelper->__('Transaction token can not be found or has wrong type. ');
531
- if (isset($response['error_message']) && !empty($response['error_message'])) {
532
- $errorMessage .= $xpHelper->__('X-Payments response was - %s. ', $response['error_message']);
533
- }
534
-
535
- if (isset($response['error']) && !empty($response['error'])) {
536
- $errorMessage .= $xpHelper->__('(error: %s)', $response['error']);
537
- }
538
-
539
- $this->getAPIError($errorMessage);
540
- $status = false;
541
- }
542
-
543
- if ($status) {
544
- Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
545
- }
546
-
547
- $xPaymentDataResponse = array();
548
- $xPaymentDataResponse['status'] = $status;
549
- $xPaymentDataResponse['response'] = $response;
550
-
551
- return $xPaymentDataResponse;
552
- }
553
-
554
- /**
555
- * Send Payment info request
556
- *
557
- * @param string $txn_id X-Payments transaction id
558
- * @param boolean $refresh Refresh data flag
559
- * @param boolean $withAdditionalInf info class
560
- *
561
- * @return array (Operation status & response array)
562
- * @access public
563
- * @see ____func_see____
564
- * @since 1.0.0
565
- */
566
- public function requestPaymentInfo($txn_id, $refresh = false,$withAdditionalInfo = false)
567
- {
568
-
569
- Mage::helper('xpaymentsconnector')->writeLog('INFO', array($txn_id, $refresh, $withAdditionalInfo));
570
-
571
- if($withAdditionalInfo){
572
- $data = array(
573
- 'txnId' => $txn_id,
574
- );
575
- $infoClass = 'get_additional_info';
576
- }else{
577
- $data = array(
578
- 'txnId' => $txn_id,
579
- 'refresh' => $refresh ? 1 : 0
580
- );
581
- $infoClass = 'get_info';
582
- }
583
-
584
- list($status, $response) = $this->request('payment', $infoClass, $data);
585
-
586
- if (!$withAdditionalInfo) {
587
-
588
- $checkResponse = $response;
589
-
590
- } elseif (!empty($response['payment'])) {
591
-
592
- $checkResponse = $response['payment'];
593
-
594
- } else {
595
-
596
- $checkResponse = array();
597
- }
598
-
599
- if ($status) {
600
- if (!is_array($response) || !isset($checkResponse['status'])) {
601
- $this->getAPIError('GetInfo request. Server response has not status');
602
- $status = false;
603
-
604
- } elseif (!isset($checkResponse['message'])) {
605
- $this->getAPIError('GetInfo request. Server response has not message');
606
- $status = false;
607
-
608
- } elseif (!isset($checkResponse['transactionInProgress'])) {
609
- $this->getAPIError('GetInfo request. Server response has not transaction progress status');
610
- $status = false;
611
-
612
- } elseif (!isset($checkResponse['isFraudStatus'])) {
613
- $this->getAPIError('GetInfo request. Server response has not fraud filter status');
614
- $status = false;
615
-
616
- } elseif (!isset($checkResponse['currency']) || strlen($checkResponse['currency']) != 3) {
617
- $this->getAPIError('GetInfo request. Server response has not currency code or currency code has wrong format');
618
- $status = false;
619
-
620
- } elseif (!isset($checkResponse['amount'])) {
621
- $this->getAPIError('GetInfo request. Server response has not payment amount');
622
- $status = false;
623
-
624
- } elseif (!isset($checkResponse['capturedAmount'])) {
625
- $this->getAPIError('GetInfo request. Server response has not captured amount');
626
- $status = false;
627
-
628
- } elseif (!isset($checkResponse['capturedAmountAvail'])) {
629
- $this->getAPIError('GetInfo request. Server response has not available for capturing amount');
630
- $status = false;
631
-
632
- } elseif (!isset($checkResponse['refundedAmount'])) {
633
- $this->getAPIError('GetInfo request. Server response has not refunded amount');
634
- $status = false;
635
-
636
- } elseif (!isset($checkResponse['refundedAmountAvail'])) {
637
- $this->getAPIError('GetInfo request. Server response has not available for refunding amount');
638
- $status = false;
639
-
640
- } elseif (!isset($checkResponse['voidedAmount'])) {
641
- $this->getAPIError('GetInfo request. Server response has not voided amount');
642
- $status = false;
643
-
644
- } elseif (!isset($checkResponse['voidedAmountAvail'])) {
645
- $this->getAPIError('GetInfo request. Server response has not available for cancelling amount');
646
- $status = false;
647
-
648
- }
649
- }
650
-
651
- return array($status, $response);
652
- }
653
-
654
- /**
655
- * Send test request
656
- *
657
- * @return boolean
658
- * @access public
659
- * @see ____func_see____
660
- * @since 1.0.0
661
- */
662
- public function sendTestRequest()
663
- {
664
- srand();
665
-
666
- $hashCode = strval(rand(0, 1000000));
667
-
668
- $params = array(
669
- 'testCode' => $hashCode,
670
- );
671
-
672
- foreach ($this->apiVersions as $version) {
673
-
674
- $params['api_version'] = $version;
675
-
676
- // Make test request
677
- list($status, $response) = $this->request(
678
- 'connect',
679
- 'test',
680
- $params
681
- );
682
-
683
- if (
684
- $status
685
- && isset($response['hashCode'])
686
- && md5($hashCode) == $response['hashCode']
687
- ) {
688
-
689
- // Save working API version
690
- Mage::getConfig()->saveConfig(self::XPATH_API_VERSION, $version);
691
- Mage::getConfig()->reinit();
692
- break;
693
-
694
- } else {
695
-
696
- $status = false;
697
- }
698
- }
699
-
700
- return $status;
701
- }
702
-
703
- /**
704
- * Send Get payment configurations request
705
- *
706
- * @return array Payment configurations list
707
- * @access public
708
- * @see ____func_see____
709
- * @since 1.0.0
710
- */
711
- public function requestPaymentMethods()
712
- {
713
- $result = array();
714
-
715
- // Call the "api.php?target=payment_confs&action=get" URL
716
- list($status, $response) = $this->request(
717
- 'payment_confs',
718
- 'get',
719
- array()
720
- );
721
-
722
- // Check status
723
- if ($status && (!isset($response['payment_module']) || !is_array($response['payment_module']))) {
724
- $status = false;
725
- }
726
-
727
- return $status ? $response['payment_module'] : false;
728
- }
729
-
730
- /**
731
- * Request
732
- *
733
- * @param string $target Request target
734
- * @param string $action Request action
735
- * @param array $data Data
736
- *
737
- * @return array (Operation status & response array)
738
- * @access protected
739
- * @see ____func_see____
740
- * @since 1.0.0
741
- */
742
- protected function request($target, $action, array $data = array())
743
- {
744
-
745
- // Check requirements
746
- if (!$this->isConfigured()) {
747
- return $this->getAPIError('Module is not configured');
748
- }
749
-
750
- if ($this->checkRequirements() != 0) {
751
- return $this->getAPIError('Check module requirements is failed');
752
- }
753
-
754
- $data['target'] = $target;
755
- $data['action'] = $action;
756
- if(!isset($data['api_version'])){
757
- $data['api_version'] = $this->getApiVersion();
758
- }
759
-
760
-
761
- // Convert array to XML
762
- $xml = $this->convertHash2XML($data);
763
-
764
- if (!$xml) {
765
- return $this->getAPIError('Data is not valid');
766
- }
767
-
768
- // Encrypt
769
- $xml = $this->encrypt($xml);
770
- if (!$xml) {
771
- return $this->getAPIError('Data is not encrypted');
772
- }
773
-
774
- // HTTPS request
775
- $post = array(
776
- 'cart_id' => $this->getConfig('xpay_cart_id'),
777
- 'request' => $xml
778
- );
779
-
780
- $https = new Varien_Http_Client(
781
- $this->getConfig('xpay_url') . '/api.php',
782
- array(
783
- 'timeout' => 15,
784
- )
785
- );
786
-
787
-
788
- /*update*/
789
- $ch = curl_init();
790
-
791
- curl_setopt($ch, CURLOPT_URL, $this->getConfig('xpay_url') . '/api.php');
792
- curl_setopt($ch, CURLOPT_HEADER, false);
793
- curl_setopt($ch, CURLOPT_TIMEOUT, 15000);
794
- curl_setopt($ch, CURLOPT_POST, true);
795
- curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
796
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
797
- curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
798
- curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'xpc_curl_headers_collector');
799
-
800
- $body = curl_exec($ch);
801
- $errno = curl_errno($ch);
802
- $error = curl_error($ch);
803
- // Check raw data
804
- if (substr($body, 0, 3) !== 'API') {
805
-
806
- if (substr(strstr($body, 'API'), 0, 3) !== 'API') {
807
-
808
- return $this->getAPIError(
809
- 'Response is not valid.' . "\n"
810
- //. 'Response headers: ' . var_export($headers, true) . "\n"
811
- . 'Response: ' . $body . $error . "\n"
812
- );
813
-
814
- } else {
815
-
816
- $body = strstr($body, 'API');
817
-
818
- }
819
-
820
- }
821
-
822
- // Decrypt
823
- list($responseStatus, $response) = $this->decrypt($body);
824
-
825
- if (!$responseStatus) {
826
- return $this->getAPIError('Response is not decrypted (Error: ' . $response . ')');
827
- }
828
-
829
- // Convert XML to array
830
- $response = $this->convertXML2Hash($response);
831
-
832
- if (!is_array($response)) {
833
- return $this->getAPIError('Unable to convert response into XML');
834
- }
835
-
836
- // The 'Data' tag must be set in response
837
- if (!isset($response[self::TAG_ROOT])) {
838
- return $this->getAPIError('Response does not contain any data');
839
- }
840
-
841
- // Process errors
842
- if ($this->processAPIError($response)) {
843
- return array(false, 'X-Payments internal error');
844
- }
845
-
846
- return array(true, $response[self::TAG_ROOT]);
847
- }
848
-
849
- /**
850
- * Decrypt separate XML block
851
- *
852
- * @param string $body Encrypted XML data
853
- *
854
- * @return array
855
- * @access public
856
- * @see ____func_see____
857
- * @since 1.0.0
858
- */
859
- public function decryptXML($body)
860
- {
861
- // Check raw data
862
- if (substr($body, 0, 3) !== 'API') {
863
- return $this->getAPIError(
864
- 'Encrypted XML data is not valid.' . "\n"
865
- );
866
- }
867
-
868
- // Decrypt
869
- list($responseStatus, $response) = $this->decrypt($body);
870
-
871
- if (!$responseStatus) {
872
- return $this->getAPIError('Encrypted XML data is not decrypted (Error: ' . $response . ')');
873
- }
874
-
875
- // Convert XML to array
876
- $response = $this->convertXML2Hash($response);
877
-
878
- if (!is_array($response)) {
879
- return $this->getAPIError('Unable to convert encrypted data into XML');
880
- }
881
-
882
- // The 'Data' tag must be set in response
883
- if (!isset($response[self::TAG_ROOT])) {
884
- return $this->getAPIError('Encrypted XML data does not contain any data');
885
- }
886
-
887
- return $response[self::TAG_ROOT];
888
- }
889
-
890
- /**
891
- * Get API error response and save error message into log
892
- *
893
- * @param string $msg Error message
894
- *
895
- * @return array
896
- * @access protected
897
- * @see ____func_see____
898
- * @since 1.0.0
899
- */
900
- protected function getAPIError($msg)
901
- {
902
- $xpHelper = Mage::helper('xpaymentsconnector');
903
- Mage::log(
904
- sprintf('XPayments connector error: %s', $msg),
905
- null,
906
- $xpHelper::XPAYMENTS_LOG_FILE,
907
- true
908
- );
909
-
910
- return array(false, $msg);
911
- }
912
-
913
- /**
914
- * Process API error
915
- *
916
- * @param array $response Prepared response
917
- *
918
- * @return boolean Has reponse any error(s) or not
919
- * @access protected
920
- * @see ____func_see____
921
- * @since 1.0.0
922
- */
923
- protected function processAPIError(array $response)
924
- {
925
- $error = false;
926
-
927
- if (isset($response['error']) && $response['error']) {
928
- $this->getAPIError(
929
- 'X-Payments error (code: ' . $response['error'] . '): '
930
- . (isset($response['error_message']) ? $response['error_message'] : 'Unknown')
931
- );
932
- $error = true;
933
- }
934
-
935
- return $error;
936
- }
937
-
938
- /**
939
- * Check - force use authorization request or not
940
- *
941
- * @return boolean
942
- */
943
- protected function isForceAuth()
944
- {
945
- if ('cardadd' == Mage::app()->getRequest()->getActionName()) {
946
-
947
- // Force auth only for zero-auth/card setup
948
- $result = true;
949
-
950
- } else {
951
-
952
- // Use option for regular products
953
- $result = (bool)Mage::getStoreConfig('payment/xpayments/use_authorize');
954
-
955
- $helper = Mage::helper('xpaymentsconnector');
956
-
957
- $item = $helper->getRecurringQuoteItem();
958
-
959
- if ($item) {
960
-
961
- $product = $item->getProduct();
962
-
963
- $checkQuoteItemResult = $helper->checkStartDateDataByProduct($product, $item);
964
-
965
- if (
966
- $checkQuoteItemResult[$product->getId()]['success']
967
- && !$item->getXpRecurringInitialFee()
968
- ) {
969
-
970
- // Force auth because... It was forced.
971
- $result = true;
972
-
973
- } else {
974
-
975
- // Use option for recurring products
976
- $result = (bool)Mage::getStoreConfig('payment/xpayments/use_initialfee_authorize');
977
- }
978
- }
979
- }
980
-
981
- return $result;
982
- }
983
-
984
- /**
985
- * Get currency code
986
- *
987
- * @return string
988
- */
989
- public function getCurrency()
990
- {
991
- return strtoupper($this->getConfig('xpay_currency'));
992
- }
993
-
994
- /**
995
- * Convert hash to XML
996
- *
997
- * @param array $data Hash
998
- * @param integer $level Parentness level
999
- *
1000
- * @return string
1001
- * @access protected
1002
- * @see ____func_see____
1003
- * @since 1.0.0
1004
- */
1005
- public function convertHash2XML(array $data, $level = 0)
1006
- {
1007
- $xml = '';
1008
-
1009
- foreach ($data as $name => $value) {
1010
-
1011
- if ($this->isAnonymousArray($value)) {
1012
- foreach ($value as $item) {
1013
- $xml .= $this->writeXMLTag($item, $name, $level, self::TYPE_CELL);
1014
- }
1015
- } else {
1016
- $xml .= $this->writeXMLTag($value, $name, $level);
1017
- }
1018
-
1019
- }
1020
-
1021
- return $xml;
1022
- }
1023
-
1024
- /**
1025
- * Check - argument is plain array or not
1026
- *
1027
- * @param array $data Array
1028
- *
1029
- * @return boolean
1030
- * @access protected
1031
- * @see ____func_see____
1032
- * @since 1.0.0
1033
- */
1034
- protected function isAnonymousArray($data)
1035
- {
1036
- return is_array($data)
1037
- && 1 > count(preg_grep('/^\d+$/', array_keys($data), PREG_GREP_INVERT));
1038
- }
1039
-
1040
- /**
1041
- * Write XML tag
1042
- *
1043
- * @param mixed $data Data
1044
- * @param string $name Tag name
1045
- * @param integer $level Parentness level
1046
- * @param string $type Tag type
1047
- *
1048
- * @return string
1049
- * @access protected
1050
- * @see ____func_see____
1051
- * @since 1.0.0
1052
- */
1053
- protected function writeXMLTag($data, $name, $level = 0, $type = '')
1054
- {
1055
- $xml = '';
1056
- $indent = str_repeat(' ', $level);
1057
-
1058
- // Open tag
1059
- $xml .= $indent . '<' . $name . (empty($type) ? '' : ' type="' . $type . '"') . '>';
1060
-
1061
- // Sublevel tags or tag value
1062
- if (is_array($data)) {
1063
- $xml .= "\n" . $this->convertHash2XML($data, $level + 1) . $indent;
1064
-
1065
- } elseif (function_exists('iconv')) {
1066
- $trn = iconv('UTF-8', 'UTF-8//IGNORE', $data);
1067
- $data = false === $trn ? $data : $trn;
1068
- $data = str_replace(
1069
- array("\n", "\t", "\r", "\f",),
1070
- array(' ', ' ', '', '',),
1071
- $data
1072
- );
1073
- $xml .= $data;
1074
-
1075
- } else {
1076
- $data = str_replace(
1077
- array("\n", "\t", "\r", "\f",),
1078
- array(' ', ' ', '', '',),
1079
- $data
1080
- );
1081
- $xml .= $data;
1082
- }
1083
-
1084
- // Close tag
1085
- $xml .= '</' . $name . '>' . "\n";
1086
-
1087
- return $xml;
1088
- }
1089
-
1090
- /**
1091
- * Convert XML-to-hash
1092
- *
1093
- * @param string $xml XML string
1094
- *
1095
- * @return array or string
1096
- * @access protected
1097
- * @see ____func_see____
1098
- * @since 1.0.0
1099
- */
1100
- protected function convertXML2Hash($xml)
1101
- {
1102
- $data = array();
1103
-
1104
- while (
1105
- !empty($xml)
1106
- && preg_match('/<([\w\d]+)(?:\s*type=["\'](\w+)["\']\s*)?' . '>(.*)<\/\1>/Us', $xml, $matches)
1107
- ) {
1108
-
1109
- // Sublevel tags or tag value
1110
- if (self::TYPE_CELL === $matches[2]) {
1111
- $data[$matches[1]][] = $this->convertXML2Hash($matches[3]);
1112
-
1113
- } else {
1114
- $data[$matches[1]] = $this->convertXML2Hash($matches[3]);
1115
- }
1116
-
1117
- // Exclude parsed part from XML
1118
- $xml = str_replace($matches[0], '', $xml);
1119
-
1120
- }
1121
-
1122
- return empty($data) ? $xml : $data;
1123
- }
1124
-
1125
- /**
1126
- * Encrypt data
1127
- *
1128
- * @param string $data Data
1129
- *
1130
- * @return string
1131
- * @access protected
1132
- * @see ____func_see____
1133
- * @since 1.0.0
1134
- */
1135
- public function encrypt($data)
1136
- {
1137
- // Preprocess
1138
- srand(time());
1139
- $salt = '';
1140
- for ($i = 0; $i < self::SALT_LENGTH; $i++) {
1141
- $salt .= chr(rand(self::SALT_BEGIN, self::SALT_END));
1142
- }
1143
-
1144
- $lenSalt = strlen($salt);
1145
-
1146
- $crcType = 'MD5';
1147
- $crc = md5($data, true);
1148
-
1149
- $crc = str_repeat(' ', 8 - strlen($crcType)) . $crcType . $crc;
1150
- $lenCRC = strlen($crc);
1151
-
1152
- $lenData = strlen($data);
1153
-
1154
- $data = str_repeat('0', 12 - strlen((string)$lenSalt)) . $lenSalt . $salt
1155
- . str_repeat('0', 12 - strlen((string)$lenCRC)) . $lenCRC . $crc
1156
- . str_repeat('0', 12 - strlen((string)$lenData)) . $lenData . $data;
1157
-
1158
- // Encrypt
1159
- $key = openssl_pkey_get_public($this->getConfig('xpay_public_key'));
1160
- if (!$key) {
1161
- return false;
1162
- }
1163
-
1164
- $data = str_split($data, self::CHUNK_LENGTH);
1165
- $crypttext = null;
1166
- foreach ($data as $k => $chunk) {
1167
- if (!openssl_public_encrypt($chunk, $crypttext, $key)) {
1168
- return false;
1169
- }
1170
-
1171
- $data[$k] = $crypttext;
1172
- }
1173
-
1174
- // Postprocess
1175
- $data = array_map('base64_encode', $data);
1176
-
1177
- return 'API' . implode("\n", $data);
1178
- }
1179
-
1180
- /**
1181
- * Decrypt
1182
- *
1183
- * @param string $data Encrypted data
1184
- *
1185
- * @return string
1186
- * @access protected
1187
- * @see ____func_see____
1188
- * @since 1.0.0
1189
- */
1190
- protected function decrypt($data)
1191
- {
1192
-
1193
- // Decrypt
1194
- $res = openssl_get_privatekey(
1195
- $this->getConfig('xpay_private_key'),
1196
- $this->getConfig('xpay_private_key_pass')
1197
- );
1198
- if (!$res) {
1199
- return array(false, 'Private key is not initialized');
1200
- }
1201
-
1202
- $data = substr($data, 3);
1203
-
1204
- $data = explode("\n", $data);
1205
- $data = array_map('base64_decode', $data);
1206
- foreach ($data as $k => $s) {
1207
- if (!openssl_private_decrypt($s, $newsource, $res)) {
1208
- return array(false, 'Can not decrypt chunk');
1209
- }
1210
-
1211
- $data[$k] = $newsource;
1212
- }
1213
-
1214
- openssl_free_key($res);
1215
-
1216
- $data = implode('', $data);
1217
-
1218
- // Postprocess
1219
- $lenSalt = substr($data, 0, 12);
1220
- if (!preg_match('/^\d+$/Ss', $lenSalt)) {
1221
- return array(false, 'Salt length prefix has wrong format');
1222
- }
1223
-
1224
- $lenSalt = intval($lenSalt);
1225
- $data = substr($data, 12 + intval($lenSalt));
1226
-
1227
- $lenCRC = substr($data, 0, 12);
1228
- if (!preg_match('/^\d+$/Ss', $lenCRC) || $lenCRC < 9) {
1229
- return array(false, 'CRC length prefix has wrong format');
1230
- }
1231
-
1232
- $lenCRC = intval($lenCRC);
1233
- $crcType = trim(substr($data, 12, 8));
1234
- if ($crcType !== 'MD5') {
1235
- return array(false, 'CRC hash is not MD5');
1236
- }
1237
- $crc = substr($data, 20, $lenCRC - 8);
1238
-
1239
- $data = substr($data, 12 + $lenCRC);
1240
 
1241
- $lenData = substr($data, 0, 12);
1242
- if (!preg_match('/^\d+$/Ss', $lenData)) {
1243
- return array(false, 'Data block length prefix has wrong format');
1244
- }
1245
 
1246
- $data = substr($data, 12, intval($lenData));
 
 
 
1247
 
1248
- $currentCRC = md5($data, true);
1249
- if ($currentCRC !== $crc) {
1250
- return array(false, 'Original CRC and calculated CRC is not equal');
1251
- }
1252
 
1253
- return array(true, $data);
1254
- }
1255
 
1256
  /**
1257
- * Get payment configuration model
 
1258
  *
1259
- * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
1260
- * @access protected
1261
- * @see ____func_see____
1262
- * @since 1.0.0
1263
  */
1264
- protected function getPaymentConfiguration()
1265
  {
1266
- return Mage::getModel('xpaymentsconnector/paymentconfiguration')
1267
- ->load($this->getConfigData('confid'));
1268
  }
1269
 
1270
  /**
1271
- * Check method availability
1272
- *
1273
- * @param Mage_Sales_Model_Quote $quote Quote
1274
  *
1275
- * @return boolean
1276
- * @access public
1277
- * @see ____func_see____
1278
- * @since 1.0.0
1279
  */
1280
- public function isAvailable($quote = null)
1281
  {
1282
- return $this->isConfigured()
1283
- && 0 === $this->checkRequirements()
1284
- && '1' != Mage::getStoreConfig('advanced/modules_disable_output/Cdev_XPaymentsConnector')
1285
- && parent::isAvailable($quote);
1286
  }
1287
 
1288
  /**
@@ -1302,43 +96,47 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1302
  }
1303
 
1304
  /**
1305
- * Send Handshake request
1306
- *
1307
- * @param bool $useDefaultTemplate
1308
- * @param bool $isCardAuthorizePayment
1309
- * @param array $updateSendData
1310
  *
1311
- * @param Mage_Sales_Model_Order $order Order
 
1312
  *
1313
- * @return string Payment token
1314
- * @access public
1315
- * @see ____func_see____
1316
- * @since 1.0.0
1317
- *
1318
- * @return array
1319
  */
1320
- public function sendIframeHandshakeRequest($zeroAuth = false)
1321
  {
1322
  $helper = Mage::helper('xpaymentsconnector');
1323
 
1324
- if ($zeroAuth) {
 
 
 
 
 
 
 
 
1325
 
1326
  $refId = 'authorization';
1327
-
1328
- $customer = Mage::getSingleton('customer/session')->getCustomer();
1329
  $entityId = $customer->getId();
1330
 
1331
- $preparedCart = $helper->prepareFakeCart($customer);
 
 
1332
 
1333
  } else {
1334
 
1335
- $checkoutSession = Mage::getSingleton('checkout/session');
1336
- $quote = $checkoutSession->getQuote();
1337
  $entityId = $quote->getEntityId();
1338
 
1339
- $preparedCart = $helper->prepareCart($quote);
 
 
 
 
 
 
1340
 
1341
- $refId = $this->getTmpRefId($quote);
1342
  }
1343
 
1344
  // Data to send to X-Payments
@@ -1346,81 +144,53 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1346
  'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
1347
  'refId' => $refId,
1348
  'cart' => $preparedCart,
1349
- 'returnUrl' => $helper->getReturnUrl($refId, $entityId, $zeroAuth),
1350
- 'callbackUrl' => $helper->getCallbackUrl($refId, $entityId, $zeroAuth),
1351
  );
1352
 
1353
- list($status, $response) = $this->request('payment', 'init', $data);
1354
-
1355
- $helper->writeLog('Payment initialization request', $data);
1356
- $helper->writeLog('Payment initialization response', $response);
1357
 
1358
- // Result transport array
1359
- $result = array(
1360
- 'order_refid' => $refId,
1361
- 'status' => $status,
1362
- 'response' => $response,
1363
- );
1364
 
1365
  if (
1366
- !$status
1367
- || empty($response['token'])
1368
- || !is_string($response['token'])
1369
  ) {
 
 
 
 
1370
 
1371
- $result['success'] = false;
1372
-
1373
- $error = array(
1374
- $helper->__('Transaction token can not be found or has wrong type.')
1375
- );
1376
-
1377
- if (!empty($response['error_message'])) {
1378
- $error[] = $helper->__('X-Payments response was - %s.', $response['error_message']);
1379
- }
1380
-
1381
- if (!empty($response['error'])) {
1382
- $error[] = $helper->__('(error: %s)', $response['error']);
1383
- }
1384
-
1385
- $errorMessage = implode(' ', $error);
1386
-
1387
- $this->getAPIError($errorMessage);
1388
-
1389
- $result['error_message'] = $errorMessage;
1390
-
1391
- } else {
1392
-
1393
- $result['success'] = true;
1394
-
1395
- if (!$zeroAuth) {
1396
-
1397
- $helper->getQuoteXpcData($quote)
1398
- ->setData('token', $response['token'])
1399
- ->setData('txn_id', $response['txnId'])
1400
- ->save();
1401
  }
1402
  }
1403
 
1404
- return $result;
1405
  }
1406
 
1407
  /**
1408
  * Checks if Save Card checkbox must be forced to be Required
1409
  *
 
 
1410
  * @return string
1411
  */
1412
- protected function getAllowSaveCard()
1413
  {
1414
  $helper = Mage::helper('xpaymentsconnector');
1415
 
1416
  // Check if save card feature is available for customer
1417
- $showToUser = $helper->isRegisteredUser()
1418
- && Mage::getStoreConfig('payment/savedcards/active');
 
 
 
1419
 
1420
- if ($showToUser) {
1421
 
1422
  // Check if recurring product is purchased
1423
- $allowSaveCard = $helper->getRecurringQuoteItem()
1424
  ? static::SAVE_CARD_REQUIRED
1425
  : static::SAVE_CARD_OPTIONAL;
1426
 
@@ -1432,385 +202,40 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1432
  return $allowSaveCard;
1433
  }
1434
 
1435
- /**
1436
- * Prepare payment initialization token. From session, or from X-Payments
1437
- *
1438
- * @return void
1439
- */
1440
- protected function prepareToken($zeroAuth = false)
1441
- {
1442
- $helper = Mage::helper('xpaymentsconnector');
1443
-
1444
- $quote = Mage::getSingleton('checkout/session')->getQuote();
1445
-
1446
- if (!$helper->getQuoteXpcData($quote)->getData('token')) {
1447
- // This saves token in the quote model
1448
- $data = $this->sendIframeHandshakeRequest();
1449
- }
1450
- }
1451
-
1452
  /**
1453
  * Check if payment initialization token is valid.
1454
  *
 
 
1455
  * @return bool
1456
  */
1457
- public function checkToken()
1458
  {
1459
- $this->prepareToken();
1460
-
1461
- $helper = Mage::helper('xpaymentsconnector');
1462
-
1463
- $quote = Mage::getSingleton('checkout/session')->getQuote();
1464
 
1465
- return (bool)$helper->getQuoteXpcData($quote)->getData('token');
1466
  }
1467
 
1468
  /**
1469
  * Fields for form redirecting to the payment page
1470
  *
 
 
1471
  * @return array
1472
  */
1473
- public function getFormFields()
1474
  {
1475
- $helper = Mage::helper('xpaymentsconnector');
1476
-
1477
- $quote = Mage::getSingleton('checkout/session')->getQuote();
1478
-
1479
- $token = $helper->getQuoteXpcData($quote)->getData('token');
1480
 
1481
  return array(
1482
  'target' => 'main',
1483
  'action' => 'start',
1484
  'token' => $token,
1485
- 'allow_save_card' => $this->getAllowSaveCard(),
1486
- );
1487
- }
1488
-
1489
- public function sendAgainTransactionRequest($order_id = NULL,$paymentCardNumber = NULL,$grandTotal = NULL, $cardData = NULL){
1490
-
1491
-
1492
- $quote = Mage::getSingleton('checkout/session')->getQuote();
1493
- $xpHelper = Mage::helper('xpaymentsconnector');
1494
- if(is_null($paymentCardNumber)){
1495
- $paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
1496
- }
1497
- if(is_null($grandTotal)){
1498
- $grandTotal = $quote->getGrandTotal();
1499
- }
1500
-
1501
- if(is_null($cardData)){
1502
- $cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
1503
- if($cardData){
1504
- $cardData = $cardData->getData();
1505
- }
1506
- }
1507
-
1508
- $data = array(
1509
- 'txnId' => $cardData['txnId'],
1510
- 'amount' => number_format($grandTotal, 2, '.',''),
1511
- 'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback', array('_secure' => true))
1512
- );
1513
- $order = NULL;
1514
-
1515
- if(!is_null($order_id)){
1516
- $order = Mage::getModel('sales/order')->load($order_id);
1517
- $orderIcrementId = $order->getIncrementId();
1518
- $data['description'] = 'Order #' . $orderIcrementId;
1519
- }else{
1520
- $xpOrderKey = $xpHelper->getOrderKey();
1521
- if(!$xpOrderKey){
1522
- $xpOrderKey = $xpHelper->prepareSimpleOrderKey();
1523
- }
1524
- $data['description'] = 'Order(i-frame) #' . $xpOrderKey;
1525
- }
1526
-
1527
-
1528
- list($status, $response) = $this->request('payment', 'recharge', $data);
1529
-
1530
- $xPaymentDataResponse['status'] = $status;
1531
- $xPaymentDataResponse['response'] = $response;
1532
-
1533
- if($order){
1534
- $order->setData('xp_card_data',serialize($cardData));
1535
- $order->save();
1536
-
1537
- if ($status && (!isset($response['transaction_id']) || !is_string($response['transaction_id']))) {
1538
- $xpHelper->unsetXpaymentPrepareOrder();
1539
- $order->cancel();
1540
-
1541
- $errorMessage = $xpHelper->__('Failed to place a transaction using token %s. ', $cardData['txnId']);
1542
- if (isset($response['error_message']) && !empty($response['error_message'])) {
1543
- $errorMessage .= $xpHelper->__('X-Payments response was - %s. ', $response['error_message']);
1544
- }
1545
-
1546
- if (isset($response['error']) && !empty($response['error'])) {
1547
- $errorMessage .= $xpHelper->__('(error: %s)', $response['error']);
1548
- }
1549
-
1550
- $this->getAPIError($errorMessage);
1551
- $order->addStatusToHistory(
1552
- $order::STATE_CANCELED,
1553
- $errorMessage
1554
- );
1555
-
1556
- $order->save();
1557
- $result['success'] = false;
1558
- $result['error_message'] = $errorMessage;
1559
-
1560
- return $result;
1561
- }
1562
-
1563
- }
1564
-
1565
-
1566
- $xPaymentDataResponse['success'] = true;
1567
-
1568
- return $xPaymentDataResponse;
1569
-
1570
- }
1571
-
1572
- /**
1573
- * Update order data by xpayment response data
1574
- * @param int $orderId
1575
- * @param string $txnid
1576
- * @param bool $checkOrderAmount
1577
- * @return array
1578
- */
1579
- public function updateOrderByXpaymentResponse($orderId,$txnid,$checkOrderAmount = true){
1580
-
1581
- $result = array();
1582
- $order = Mage::getModel('sales/order')->load($orderId);
1583
- $order->setData('xpc_txnid', $txnid);
1584
- $xpaymentsHelper = Mage::helper('xpaymentsconnector');
1585
-
1586
- /* update order by xpyament response state */
1587
- list($status, $response) = $this->requestPaymentInfo($txnid,false,true);
1588
-
1589
- if (
1590
- $status
1591
- && in_array($response['payment']['status'], array(self::AUTH_STATUS, self::CHARGED_STATUS))
1592
- ) {
1593
-
1594
- if ($response['payment']['amount'] != number_format($order->getGrandTotal(), 2, '.','') && $checkOrderAmount) {
1595
- $order->cancel();
1596
- $order->save();
1597
-
1598
- // Total wrong
1599
- $errorMessage = 'Order total amount doesn\'t match: Order total = ' . number_format($order->getGrandTotal(), 2, '.','').
1600
- ', X-Payments amount = ' . $response['payment']['amount'];
1601
- $this->getAPIError($errorMessage);
1602
-
1603
- $result['success'] = false;
1604
- return $result;
1605
-
1606
- } elseif ($response['payment']['currency'] != $this->getCurrency()) {
1607
- $order->cancel();
1608
- $order->save();
1609
-
1610
- // Currency wrong
1611
- $errorMessage = 'Order currency doesn\'t match: Order currency = ' . $this->getCurrency()
1612
- . ', X-Payments currency = ' . $response['payment']['currency'];
1613
- $this->getAPIError($errorMessage);
1614
-
1615
- $result['success'] = false;
1616
- return $result;
1617
-
1618
- } else {
1619
-
1620
- $order->getPayment()->setTransactionId($txnid);
1621
-
1622
- $currentTransaction = end($response['transactions']);
1623
- $order->getPayment()->setLastTransId($currentTransaction['txnid']);
1624
-
1625
- if (isset($response['payment']['advinfo']) && isset($response['payment']['advinfo']['AVS'])) {
1626
- $order->getPayment()->setCcAvsStatus($response['payment']['advinfo']['AVS']);
1627
- }
1628
-
1629
- $state = Mage_Sales_Model_Order::STATE_PROCESSING;
1630
-
1631
- $statusMessage = $xpaymentsHelper->getResultMessage($response);
1632
-
1633
- if (
1634
- isset($response['payment']['isFraudStatus'])
1635
- && $response['payment']['isFraudStatus']
1636
- ) {
1637
-
1638
- $status = Cdev_XPaymentsConnector_Helper_Data::STATUS_FRAUD;
1639
-
1640
- } elseif (self::AUTH_ACTION == $response['payment']['status']) {
1641
-
1642
- $status = Cdev_XPaymentsConnector_Helper_Data::STATUS_AUTHORIZED;
1643
-
1644
- } else {
1645
-
1646
- $status = Cdev_XPaymentsConnector_Helper_Data::STATUS_CHARGED;
1647
- }
1648
-
1649
- $order->setState($state, $status, $statusMessage, false);
1650
-
1651
- $order->save();
1652
-
1653
- if(method_exists($order,'sendNewOrderEmail')){
1654
- $order->sendNewOrderEmail();
1655
- }elseif(method_exists($order,'queueNewOrderEmail')){
1656
- $order->queueNewOrderEmail();
1657
- }
1658
-
1659
- }
1660
- $result['success'] = true;
1661
- return $result;
1662
- }else{
1663
- $xpaymentsHelper->unsetXpaymentPrepareOrder();
1664
- $order->cancel();
1665
- $order->addStatusToHistory(
1666
- $order::STATE_CANCELED,
1667
- $xpaymentsHelper->__('charge: Callback request')
1668
- );
1669
- $order->save();
1670
-
1671
- $result['success'] = false;
1672
-
1673
- if (!empty($response['error_message'])) {
1674
- $result['error_message'] = $xpaymentsHelper->__('%s. The order has been canceled.', $response['error_message']);
1675
- } elseif (!empty($response['payment']['advinfo']['Message'])) {
1676
- $result['error_message'] = $xpaymentsHelper->__('%s. The order has been canceled.', $response['payment']['advinfo']['Message']);
1677
- } else {
1678
- $transactionStatusLabel = $this->getTransactionStatusLabels();
1679
- if (
1680
- isset($response['payment'])
1681
- && is_array($response['payment'])
1682
- && isset($response['payment']['status'])
1683
- && isset($transactionStatusLabel[$response['payment']['status']])
1684
- ) {
1685
- $status = $transactionStatusLabel[$response['payment']['status']];
1686
- } else {
1687
- $status = 'unknown';
1688
- }
1689
-
1690
- $result['error_message'] = $xpaymentsHelper->__('Transaction status is "%s". The order has been canceled.', $status);
1691
- }
1692
-
1693
- return $result;
1694
- }
1695
- /*end ( update order) */
1696
-
1697
- }
1698
-
1699
- /**
1700
- * @param array $cardData
1701
- * @param int $usageType
1702
- * @return Mage_Core_Model_Abstract
1703
- */
1704
- public function saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD){
1705
-
1706
- $customerSession = Mage::getSingleton('customer/session');
1707
- $xpHelper = Mage::helper('xpaymentsconnector');
1708
- if($customerSession->isLoggedIn()){
1709
- $customer = $customerSession->getCustomer();
1710
- try
1711
- {
1712
- if ($xpHelper->isNeedToSaveUserCard()) {
1713
- $usercards = Mage::getModel('xpaymentsconnector/usercards');
1714
-
1715
- $usercards->setData(array(
1716
- 'user_id' => $customer->getId(),
1717
- 'txnId' => $cardData['txnId'],
1718
- 'last_4_cc_num' => $cardData['last4'],
1719
- 'first6' => $cardData['first6'],
1720
- 'card_type' => $cardData['type'],
1721
- 'expire_month' => $cardData['expire_month'],
1722
- 'expire_year' => $cardData['expire_year'],
1723
- 'usage_type' => $usageType,)
1724
-
1725
- );
1726
-
1727
- $xpHelper->userCardSaved();
1728
-
1729
- return $usercards->save();
1730
- }
1731
- }
1732
- catch(Exception $e)
1733
- {
1734
- echo $e->getMessage;exit;
1735
- }
1736
- }
1737
-
1738
- }
1739
-
1740
- public function authorizedTransactionRequest($action,$data){
1741
- $data['target'] = 'payment';
1742
- list($status, $response) = $this->request('payment', $action, $data);
1743
-
1744
- return $response;
1745
-
1746
- }
1747
-
1748
-
1749
- /**
1750
- * Capture payment abstract method
1751
- *
1752
- * @param Varien_Object $payment
1753
- * @param float $amount
1754
- *
1755
- * @return Mage_Payment_Model_Abstract
1756
- */
1757
- public function capture(Varien_Object $payment, $amount)
1758
- {
1759
- if (!$this->canCapture()) {
1760
- $xpaymentsHelper = Mage::helper('xpaymentsconnector');
1761
- Mage::throwException($xpaymentsHelper->__('Capture action is not available.'));
1762
- }
1763
-
1764
- $order = $this->getOrder();
1765
- $data = array(
1766
- 'txnId' => $order->getData('xpc_txnid'),
1767
- 'amount' => number_format($amount, 2, '.', ''),
1768
- );
1769
-
1770
- $this->authorizedTransactionRequest('capture', $data);
1771
-
1772
-
1773
- return $this;
1774
- }
1775
-
1776
- /**
1777
- * Refund specified amount for payment
1778
- *
1779
- * @param Varien_Object $payment
1780
- * @param float $amount
1781
- *
1782
- * @return Mage_Payment_Model_Abstract
1783
- */
1784
- public function refund(Varien_Object $payment, $amount)
1785
- {
1786
-
1787
- if (!$this->canRefund()) {
1788
- $xpaymentsHelper = Mage::helper('xpaymentsconnector');
1789
- Mage::throwException($xpaymentsHelper->__('Refund action is not available.'));
1790
- }
1791
-
1792
- /*processing during create invoice*/
1793
- $order = $this->getOrder();
1794
- /*processing during capture invoice*/
1795
- $data = array(
1796
- 'txnId' => $order->getData('xpc_txnid'),
1797
- 'amount' => number_format($amount, 2, '.', ''),
1798
  );
1799
-
1800
- $this->authorizedTransactionRequest('refund', $data);
1801
-
1802
-
1803
- return $this;
1804
- }
1805
-
1806
- /**
1807
- * Validate data
1808
- *
1809
- * @param Mage_Payment_Model_Recurring_Profile $profile
1810
- * @throws Mage_Core_Exception
1811
- */
1812
- public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
1813
-
1814
  }
1815
 
1816
  /**
@@ -1829,7 +254,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1829
  $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN);
1830
 
1831
  $quote = $profile->getQuote();
1832
- $txnId = $helper->getQuoteXpcData($quote)->getData('txn_id');
1833
 
1834
  if (empty($txnId)) {
1835
 
@@ -1847,7 +272,7 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1847
 
1848
  $orderId = $helper->createOrder($profile, true);
1849
 
1850
- $helper->getQuoteXpcData($quote)
1851
  ->setData('recurring_order_id', $orderId)
1852
  ->setData('recurring_profile_id', $profile->getInternalReferenceId())
1853
  ->save();
@@ -1855,57 +280,6 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1855
  $helper->writeLog('Submit recurring profile #' . $profile->getInternalReferenceId() . ' TxnId: ' . $txnId);
1856
  }
1857
 
1858
- /**
1859
- * Fetch details
1860
- *
1861
- * @param string $referenceId
1862
- * @param Varien_Object $result
1863
- */
1864
- public function getRecurringProfileDetails($referenceId, Varien_Object $result){
1865
- // TODO
1866
- }
1867
-
1868
- /**
1869
- * Check whether can get recurring profile details
1870
- *
1871
- * @return bool
1872
- */
1873
- public function canGetRecurringProfileDetails(){
1874
- return false;
1875
- }
1876
-
1877
- /**
1878
- * Update data
1879
- *
1880
- * @param Mage_Payment_Model_Recurring_Profile $profile
1881
- */
1882
- public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
1883
- // TODO
1884
- }
1885
-
1886
- /**
1887
- * Manage status
1888
- *
1889
- * @param Mage_Payment_Model_Recurring_Profile $profile
1890
- */
1891
- public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile){
1892
- return false;
1893
-
1894
- }
1895
-
1896
- /**
1897
- * @return array
1898
- */
1899
- public function getTransactionStatusLabels(){
1900
- $statuses = array(
1901
- self::NEW_STATUS => 'New',
1902
- self::AUTH_STATUS => 'Authorized',
1903
- self::DECLINED_STATUS => 'Declined',
1904
- self::CHARGED_STATUS => 'Charged',
1905
- );
1906
- return $statuses;
1907
- }
1908
-
1909
  /**
1910
  *
1911
  * @param Mage_Payment_Model_Recurring_Profile $profile
@@ -1949,12 +323,6 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1949
  $newTransactionDate = new Zend_Date(time());
1950
  $profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
1951
  $profile->setXpCountSuccessTransaction(1);
1952
- if (is_null($this->_currentProfileId)) {
1953
- //save user card
1954
- Mage::getSingleton('checkout/session')->setData('user_card_save', true);
1955
- $this->saveUserCard($cardData, $usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
1956
- }
1957
-
1958
  }
1959
 
1960
  $this->_currentProfileId = $profile->getProfileId();
@@ -1962,49 +330,4 @@ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method
1962
  return $profile;
1963
 
1964
  }
1965
-
1966
- /**
1967
- * Processing for fraud transaction
1968
- * @param $action (decline,accept)
1969
- */
1970
- public function sendFraudRequest($xpcTxnid,$action)
1971
- {
1972
- $status = false;
1973
- try {
1974
- $admSession = Mage::getSingleton('adminhtml/session');
1975
- $xpaymentsHelper = Mage::helper('xpaymentsconnector');
1976
-
1977
- $data = array(
1978
- 'txnId' => $xpcTxnid
1979
- );
1980
-
1981
- list($status, $response) = $this->request('payment', $action, $data);
1982
-
1983
- if ($status) {
1984
- $message = $xpaymentsHelper->__('\'%s fraud transaction\' was successful!',ucfirst($action));
1985
- if (isset($response['message']) && !empty($response['message'])) {
1986
- $message .= $xpaymentsHelper->__(' ( X-Payment server response: %s )',$response['message']);
1987
- }
1988
- $admSession->addNotice($message);
1989
-
1990
- } else {
1991
- $message = $xpaymentsHelper->__('\'%s fraud transaction\' was failed!',ucfirst($action));
1992
- if (isset($response['message']) && !empty($response['message'])) {
1993
- $message .= $xpaymentsHelper->__(' ( X-Payment server response: %s )',$response['message']);
1994
- }
1995
- $admSession->addError($message);
1996
- }
1997
-
1998
- }
1999
- catch (Mage_Core_Exception $e) {
2000
- $admSession->addError($e->getMessage());
2001
- }
2002
- catch (Exception $e) {
2003
- $admSession->addError($xpaymentsHelper->__('Transaction to the X-Payment server was broken!'));
2004
- }
2005
-
2006
- return $status;
2007
-
2008
- }
2009
  }
2010
-
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
 
 
22
  /**
23
+ * Abstract class for X-Payments payment methods (3 slots)
 
 
 
 
24
  */
25
+ abstract class Cdev_XPaymentsConnector_Model_Payment_Cc extends Cdev_XPaymentsConnector_Model_Payment_Abstract
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
  /**
28
  * Show or not save card checkbox statuses
29
  */
31
  const SAVE_CARD_REQUIRED = 'Y';
32
  const SAVE_CARD_OPTIONAL = 'O';
33
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
  protected $_isGateway = false;
 
 
35
 
 
36
  protected $_defaultLocale = 'en';
37
 
38
  protected $_canUseCheckout = true;
39
+ protected $_canUseInternal = true;
40
+ protected $_canUseForMultishipping = false;
41
 
42
+ protected $_canCapture = true;
43
+ protected $_canCapturePartial = true;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ protected $_canRefund = true;
46
+ protected $_canRefundInvoicePartial = true;
 
 
47
 
48
+ /**
49
+ * Payment method info block
50
+ */
51
+ protected $_infoBlockType = 'xpaymentsconnector/info_cc';
52
 
53
+ /**
54
+ * Payment method form block
55
+ */
56
+ protected $_formBlockType = 'xpaymentsconnector/form_cc';
57
 
58
+ public $_currentProfileId = null;
 
59
 
60
  /**
61
+ * Get slot index of the XPC payment method
62
+ * (number from xpayments1, xpayments2, etc)
63
  *
64
+ * @return int
 
 
 
65
  */
66
+ public function getXpcSlot()
67
  {
68
+ return substr($this->getCode(), -1);
 
69
  }
70
 
71
  /**
72
+ * Get payment configuration model
 
 
73
  *
74
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
 
 
 
75
  */
76
+ public function getPaymentConfiguration()
77
  {
78
+ return Mage::getModel('xpaymentsconnector/paymentconfiguration')
79
+ ->load($this->getConfigData('confid'));
 
 
80
  }
81
 
82
  /**
96
  }
97
 
98
  /**
99
+ * Obtain token from X-Payments via initial payment request
 
 
 
 
100
  *
101
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote Quote (for checkout or backend order)
102
+ * @param Mage_Customer_Model_Customer $customer (for zero auth)
103
  *
104
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
 
 
 
 
 
105
  */
106
+ public function obtainToken(Cdev_XPaymentsConnector_Model_Quote $quote = null, Mage_Customer_Model_Customer $customer = null)
107
  {
108
  $helper = Mage::helper('xpaymentsconnector');
109
 
110
+ if (!is_null($customer)) {
111
+ $isZeroAuth = true;
112
+ } elseif (!is_null($quote)) {
113
+ $isZeroAuth = false;
114
+ } else {
115
+ throw new Exception('Incorrect data for initial payment request');
116
+ }
117
+
118
+ if ($isZeroAuth) {
119
 
120
  $refId = 'authorization';
 
 
121
  $entityId = $customer->getId();
122
 
123
+ $preparedCart = Mage::helper('cart_xpc')->prepareFakeCart($customer, $this->getXpcSlot());
124
+
125
+ $isBackend = (bool)$customer->getXpBufer();
126
 
127
  } else {
128
 
 
 
129
  $entityId = $quote->getEntityId();
130
 
131
+ if ($quote->isBackendOrderQuote()) {
132
+ $refId = $quote->getXpcData()->getData('backend_orderid');
133
+ $isBackend = true;
134
+ } else {
135
+ $refId = $this->getTmpRefId($quote);
136
+ $isBackend = false;
137
+ }
138
 
139
+ $preparedCart = Mage::helper('cart_xpc')->prepareCart($quote, $refId);
140
  }
141
 
142
  // Data to send to X-Payments
144
  'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
145
  'refId' => $refId,
146
  'cart' => $preparedCart,
147
+ 'returnUrl' => $helper->getReturnUrl($entityId, $this->getXpcSlot(), $isZeroAuth, $isBackend),
148
+ 'callbackUrl' => $helper->getCallbackUrl($entityId, $this->getXpcSlot(), $isZeroAuth),
149
  );
150
 
151
+ $response = Mage::helper('api_xpc')->initPayment($data);
 
 
 
152
 
153
+ $response->setData('order_refid', $refId);
 
 
 
 
 
154
 
155
  if (
156
+ $response->getStatus()
157
+ && !$isZeroAuth
 
158
  ) {
159
+ $quote->getXpcData()
160
+ ->setData('token', $response->getField('token'))
161
+ ->setData('txn_id', $response->getField('txnId'))
162
+ ->save();
163
 
164
+ if ($quote->isBackendOrderQuote()) {
165
+ $quote->getBackendOrder()->setData('xpc_txnid', $response->getField('txnId'))->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  }
167
  }
168
 
169
+ return $response;
170
  }
171
 
172
  /**
173
  * Checks if Save Card checkbox must be forced to be Required
174
  *
175
+ * @param Mage_Sales_Model_Quote $quote Quote
176
+ *
177
  * @return string
178
  */
179
+ protected function getAllowSaveCard(Mage_Sales_Model_Quote $quote)
180
  {
181
  $helper = Mage::helper('xpaymentsconnector');
182
 
183
  // Check if save card feature is available for customer
184
+ $checkCustomer = $quote->isBackendOrderQuote()
185
+ || Mage::helper('xpaymentsconnector')->isRegisteredUser();
186
+
187
+ // Check if feature is available
188
+ $checkSettings = Mage::helper('settings_xpc')->isCanSaveCards();
189
 
190
+ if ($checkCustomer && $checkSettings) {
191
 
192
  // Check if recurring product is purchased
193
+ $allowSaveCard = $quote->getRecurringItem()
194
  ? static::SAVE_CARD_REQUIRED
195
  : static::SAVE_CARD_OPTIONAL;
196
 
202
  return $allowSaveCard;
203
  }
204
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
205
  /**
206
  * Check if payment initialization token is valid.
207
  *
208
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote Quote
209
+ *
210
  * @return bool
211
  */
212
+ public function prepareToken(Cdev_XPaymentsConnector_Model_Quote $quote)
213
  {
214
+ if (!$quote->getXpcData()->getData('token')) {
215
+ // This saves token in the quote XPC data model
216
+ $this->obtainToken($quote);
217
+ }
 
218
 
219
+ return (bool)$quote->getXpcData()->getData('token');
220
  }
221
 
222
  /**
223
  * Fields for form redirecting to the payment page
224
  *
225
+ * @param Mage_Sales_Model_Quote $quote Quote
226
+ *
227
  * @return array
228
  */
229
+ public function getFormFields(Mage_Sales_Model_Quote $quote)
230
  {
231
+ $token = $quote->getXpcData()->getData('token');
 
 
 
 
232
 
233
  return array(
234
  'target' => 'main',
235
  'action' => 'start',
236
  'token' => $token,
237
+ 'allow_save_card' => $this->getAllowSaveCard($quote),
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
238
  );
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
239
  }
240
 
241
  /**
254
  $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_UNKNOWN);
255
 
256
  $quote = $profile->getQuote();
257
+ $txnId = $quote->getXpcData()->getData('txn_id');
258
 
259
  if (empty($txnId)) {
260
 
272
 
273
  $orderId = $helper->createOrder($profile, true);
274
 
275
+ $quote->getXpcData()
276
  ->setData('recurring_order_id', $orderId)
277
  ->setData('recurring_profile_id', $profile->getInternalReferenceId())
278
  ->save();
280
  $helper->writeLog('Submit recurring profile #' . $profile->getInternalReferenceId() . ' TxnId: ' . $txnId);
281
  }
282
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
283
  /**
284
  *
285
  * @param Mage_Payment_Model_Recurring_Profile $profile
323
  $newTransactionDate = new Zend_Date(time());
324
  $profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
325
  $profile->setXpCountSuccessTransaction(1);
 
 
 
 
 
 
326
  }
327
 
328
  $this->_currentProfileId = $profile->getProfileId();
330
  return $profile;
331
 
332
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
333
  }
 
app/code/community/Cdev/XPaymentsConnector/{Block/Form/Container.php → Model/Payment/Cc1.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,21 +13,20 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
-
23
- class Cdev_XPaymentsConnector_Block_Form_Container extends Mage_Checkout_Block_Onepage_Payment_Methods
 
 
24
  {
25
- public function getMethods()
26
- {
27
- $methods = parent::getMethods();
28
- Mage::helper('xpaymentsconnector')->setAllowedPaymentsMethods($methods);
29
- return $methods;
30
-
31
- }
32
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
+ /**
24
+ * X-Payments Payment Method (1st slot)
25
+ */
26
+ class Cdev_XPaymentsConnector_Model_Payment_Cc1 extends Cdev_XPaymentsConnector_Model_Payment_Cc
27
  {
28
+ /**
29
+ * Unique internal payment method identifier
30
+ **/
31
+ protected $_code = 'xpayments1';
 
 
 
32
  }
app/code/community/Cdev/XPaymentsConnector/{Block/Customer/Success.php → Model/Payment/Cc2.php} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,26 +13,20 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
- * This is success block for add payment card action.
24
- *
25
- * @package Cdev_XPaymentsConnector
26
- * @see ____class_see____
27
- * @since 1.0.0
28
  */
29
- class Cdev_XPaymentsConnector_Block_Customer_Success extends Mage_Core_Block_Template
30
  {
31
-
32
- protected function _construct()
33
- {
34
- parent::_construct();
35
- $this->setTemplate('xpaymentsconnector/customer/cardaddsuccess.phtml');
36
- }
37
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * X-Payments Payment Method (2nd slot)
 
 
 
 
25
  */
26
+ class Cdev_XPaymentsConnector_Model_Payment_Cc2 extends Cdev_XPaymentsConnector_Model_Payment_Cc
27
  {
28
+ /**
29
+ * Unique internal payment method identifier
30
+ **/
31
+ protected $_code = 'xpayments2';
 
 
32
  }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc3.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * X-Payments Payment Method (3rd slot)
25
+ */
26
+ class Cdev_XPaymentsConnector_Model_Payment_Cc3 extends Cdev_XPaymentsConnector_Model_Payment_Cc
27
+ {
28
+ /**
29
+ * Unique internal payment method identifier
30
+ **/
31
+ protected $_code = 'xpayments3';
32
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Prepaidpayments.php DELETED
@@ -1,89 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- * "Prepaid Payments (X-Payments)" method (only for admin)
24
- * Class Cdev_XPaymentsConnector_Model_Payment_Prepaidpayments
25
- */
26
-
27
- class Cdev_XPaymentsConnector_Model_Payment_Prepaidpayments extends Mage_Payment_Model_Method_Abstract
28
- {
29
- protected $_code = "prepaidpayments";
30
- protected $_formBlockType = 'xpaymentsconnector/form_prepaidpayments';
31
- protected $_infoBlockType = 'xpaymentsconnector/info_prepaidpayments';
32
-
33
-
34
- protected $_isGateway = false;
35
- protected $_paymentMethod = 'cc';
36
- protected $_defaultLocale = 'en';
37
- protected $_canCapturePartial = true;
38
- protected $_canCapture = false;
39
- protected $_canUseInternal = true;
40
- protected $_canUseCheckout = false;
41
- protected $_canUseForMultishipping = false;
42
-
43
- protected $_canRefund = true;
44
- protected $_canRefundInvoicePartial = true;
45
-
46
- protected $_order = null;
47
-
48
-
49
- /**
50
- * Get order
51
- *
52
- * @return Mage_Sales_Model_Order
53
- * @access public
54
- * @see ____func_see____
55
- * @since 1.0.0
56
- */
57
- public function getOrder()
58
- {
59
- if (!$this->_order) {
60
- $this->_order = $this->getInfoInstance()->getOrder();
61
- }
62
-
63
- return $this->_order;
64
- }
65
-
66
-
67
- public function refund(Varien_Object $payment, $amount)
68
- {
69
-
70
- if (!$this->canRefund()) {
71
- Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
72
- }
73
-
74
- /*processing during create invoice*/
75
- $order = $this->getOrder();
76
- /*processing during capture invoice*/
77
- $data = array(
78
- 'txnId' => $order->getData("xpc_txnid"),
79
- 'amount' => number_format($amount, 2, '.', ''),
80
- );
81
-
82
- Mage::getModel("xpaymentsconnector/payment_cc")->authorizedTransactionRequest('refund', $data);
83
-
84
- return $this;
85
- }
86
-
87
-
88
- }
89
-
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Recurring/Profile.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -18,10 +19,11 @@
18
  * versions in the future. If you wish to customize Magento for your
19
  * needs please refer to http://www.magentocommerce.com for more information.
20
  *
21
- * @category Mage
22
- * @package Mage_Payment
23
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
24
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 
25
  */
26
 
27
  /**
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
19
  * versions in the future. If you wish to customize Magento for your
20
  * needs please refer to http://www.magentocommerce.com for more information.
21
  *
22
+ * @author Qualiteam Software <info@x-cart.com>
23
+ * @category Cdev
24
+ * @package Cdev_XPaymentsConnector
25
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
26
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
27
  */
28
 
29
  /**
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,226 +13,204 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
  * 'Use saved credit cards (X-Payments)'
24
- * Class Cdev_XPaymentsConnector_Model_Payment_Savedcards
25
  */
26
-
27
- class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Mage_Payment_Model_Method_Abstract
28
  implements Mage_Payment_Model_Recurring_Profile_MethodInterface
29
  {
 
 
 
30
  protected $_code = 'savedcards';
31
- protected $_formBlockType = 'xpaymentsconnector/form_savedcards';
32
- protected $_infoBlockType = 'xpaymentsconnector/info_savedcards';
33
-
34
 
35
  protected $_isGateway = false;
36
- protected $_paymentMethod = 'cc';
37
  protected $_defaultLocale = 'en';
38
- protected $_canCapturePartial = true;
39
- protected $_canCapture = true;
40
- protected $_canUseInternal = true;
41
  protected $_canUseCheckout = true;
 
42
  protected $_canUseForMultishipping = false;
43
 
 
 
44
  protected $_canRefund = true;
45
  protected $_canRefundInvoicePartial = true;
46
 
47
- protected $_order = null;
48
- public $firstTransactionSuccess = true;
49
 
 
 
 
 
 
 
 
 
 
 
 
50
 
 
 
 
 
 
 
 
 
 
 
 
51
 
52
  /**
53
- * Get order
54
  *
55
- * @return Mage_Sales_Model_Order
56
- * @access public
57
- * @see ____func_see____
58
- * @since 1.0.0
59
  */
60
- public function getOrder()
61
  {
62
- if (!$this->_order) {
63
- $this->_order = $this->getInfoInstance()->getOrder();
64
- }
65
 
66
- return $this->_order;
 
67
  }
68
 
69
  /**
70
- * Capture payment abstract method
71
- *
72
- * @param Varien_Object $payment
73
- * @param float $amount
74
  *
75
- * @return Mage_Payment_Model_Abstract
76
  */
77
- public function capture(Varien_Object $payment, $amount)
78
  {
79
-
80
- if (!$this->canCapture()) {
81
- Mage::throwException(Mage::helper('payment')->__('Capture action is not available.'));
82
- }
83
-
84
- $order = $this->getOrder();
85
- $data = array(
86
- 'txnId' => $order->getData('xpc_txnid'),
87
- 'amount' => number_format($amount, 2, '.', ''),
88
  );
89
-
90
- Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('capture', $data);
91
-
92
-
93
- return $this;
94
  }
95
 
96
-
97
- public function refund(Varien_Object $payment, $amount)
 
 
 
 
 
 
98
  {
99
-
100
- if (!$this->canRefund()) {
101
- Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
 
 
 
 
 
 
 
102
  }
103
 
104
- /*processing during create invoice*/
105
- $order = $this->getOrder();
106
- /*processing during capture invoice*/
 
 
 
 
107
  $data = array(
108
- 'txnId' => $order->getData('xpc_txnid'),
109
- 'amount' => number_format($amount, 2, '.', ''),
 
 
 
 
110
  );
111
 
112
- Mage::getModel('xpaymentsconnector/payment_cc')->authorizedTransactionRequest('refund', $data);
113
 
114
- return $this;
115
  }
116
 
117
-
118
  /**
119
- * Validate data
 
 
120
  *
121
- * @param Mage_Payment_Model_Recurring_Profile $profile
122
- * @throws Mage_Core_Exception
123
  */
124
- public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
 
 
 
 
 
 
 
 
 
 
 
 
125
 
 
 
 
 
 
 
 
 
126
  }
127
 
128
  /**
129
- * Submit to the gateway
130
  *
131
- * @param Mage_Payment_Model_Recurring_Profile $profile
132
- * @param Mage_Payment_Model_Info $paymentInfo
133
  */
134
- public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo){
135
-
136
- $xpHelper = Mage::helper('xpaymentsconnector');
137
- $xpHelper->setPrepareOrderType();
138
- $quote = $profile->getQuote();
139
- $orderItemInfo = $profile->getData('order_item_info');
140
- // registered new user and update profile
141
- $xpHelper->addXpDefaultRecurringSettings($profile);
142
- // end registered user
143
- $paymentCardNumber = $quote->getPayment()->getData('xp_payment_card');
144
- $cardData = Mage::getModel('xpaymentsconnector/usercards')->load($paymentCardNumber);
145
- $txnid = $cardData->getData('txnId');
146
-
147
- if ($xpHelper->getRecurringQuoteItem()) {
148
- if(is_null($xpHelper->payDeferredProfileId)){
149
- $payDeferredSubscription = $xpHelper->payDeferredSubscription($profile);
150
- if(!$payDeferredSubscription){
151
- $grandTotal = $orderItemInfo['nominal_row_total'];
152
- if($txnid){
153
- $orderId = $xpHelper->createOrder($profile,$isFirstRecurringOrder = true);
154
- $response = Mage::getModel('xpaymentsconnector/payment_cc')->
155
- sendAgainTransactionRequest($orderId, NULL, $grandTotal);
156
-
157
- if ($response['success']) {
158
- $result = Mage::getModel('xpaymentsconnector/payment_cc')->
159
- updateOrderByXpaymentResponse($orderId, $response['response']['transaction_id']);
160
- if (!$result['success']) {
161
- Mage::getSingleton('checkout/session')->addError($result['error_message']);
162
- Mage::getSingleton('checkout/session')
163
- ->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
164
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
165
- } else {
166
- // additional subscription profile setting for success transaction
167
- $newTransactionDate = new Zend_Date(time());
168
- $profile->setXpSuccessTransactionDate($newTransactionDate
169
- ->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
170
- $profile->setXpCountSuccessTransaction(1);
171
-
172
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
173
- }
174
-
175
- } else {
176
- Mage::getSingleton('checkout/session')->addError($response['error_message']);
177
- Mage::getSingleton('checkout/session')->addNotice($xpHelper->getFailureCheckoutNoticeHelper());
178
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
179
- }
180
- }
181
- }
182
-
183
- $xpHelper->prepareOrderKeyByRecurringProfile($profile);
184
  }
185
 
186
- if($profile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_CANCELED){
187
- $this->firstTransactionSuccess = false;
188
- }else{
189
- if (!$this->firstTransactionSuccess) {
190
- $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
191
- }
192
- };
193
- }
194
 
195
- $profile->setReferenceId($txnid);
196
 
197
- }
 
 
 
198
 
199
- /**
200
- * Fetch details
201
- *
202
- * @param string $referenceId
203
- * @param Varien_Object $result
204
- */
205
- public function getRecurringProfileDetails($referenceId, Varien_Object $result){
206
- // TODO
207
- }
208
 
209
- /**
210
- * Check whether can get recurring profile details
211
- *
212
- * @return bool
213
- */
214
- public function canGetRecurringProfileDetails(){
215
- return true;
216
- }
217
 
218
- /**
219
- * Update data
220
- *
221
- * @param Mage_Payment_Model_Recurring_Profile $profile
222
- */
223
- public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
224
- // TODO
225
- }
226
 
227
- /**
228
- * Manage status
229
- *
230
- * @param Mage_Payment_Model_Recurring_Profile $profile
231
- */
232
- public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile){
233
- // TODO
234
- }
235
 
 
 
236
  }
237
-
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * 'Use saved credit cards (X-Payments)'
 
25
  */
26
+ class Cdev_XPaymentsConnector_Model_Payment_Savedcards extends Cdev_XPaymentsConnector_Model_Payment_Abstract
 
27
  implements Mage_Payment_Model_Recurring_Profile_MethodInterface
28
  {
29
+ /**
30
+ * Unique internal payment method identifier
31
+ **/
32
  protected $_code = 'savedcards';
 
 
 
33
 
34
  protected $_isGateway = false;
35
+
36
  protected $_defaultLocale = 'en';
37
+
38
+ protected $_paymentMethod = 'cc';
39
+
40
  protected $_canUseCheckout = true;
41
+ protected $_canUseInternal = true;
42
  protected $_canUseForMultishipping = false;
43
 
44
+ protected $_canCapture = true;
45
+ protected $_canCapturePartial = true;
46
  protected $_canRefund = true;
47
  protected $_canRefundInvoicePartial = true;
48
 
 
 
49
 
50
+ /**
51
+ * Payment method info block
52
+ */
53
+ protected $_infoBlockType = 'xpaymentsconnector/info_savedcards';
54
+
55
+ /**
56
+ * Payment method form block
57
+ */
58
+ protected $_formBlockType = 'xpaymentsconnector/form_savedcards';
59
+
60
+ public $firstTransactionSuccess = true;
61
 
62
+ /**
63
+ * Get saved card data from order
64
+ *
65
+ * @return array
66
+ */
67
+ private function getOrderCardData()
68
+ {
69
+ return Mage::helper('xpaymentsconnector')->getOrderXpcCardData(
70
+ $this->getOrder()
71
+ );
72
+ }
73
 
74
  /**
75
+ * Get payment configuration model
76
  *
77
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
 
 
 
78
  */
79
+ public function getPaymentConfiguration()
80
  {
81
+ $data = $this->getOrderCardData();
 
 
82
 
83
+ return Mage::getModel('xpaymentsconnector/paymentconfiguration')
84
+ ->load($data['confid']);
85
  }
86
 
87
  /**
88
+ * Get internal XPC method code
89
+ * (number from xpayments1, xpayments1, etc)
 
 
90
  *
91
+ * @return int
92
  */
93
+ public function getXpcSlot()
94
  {
95
+ return Mage::helper('settings_xpc')->getXpcSlotByConfid(
96
+ $this->getPaymentConfiguration()->getData('confid')
 
 
 
 
 
 
 
97
  );
 
 
 
 
 
98
  }
99
 
100
+ /**
101
+ * Process payment by saved card
102
+ *
103
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote Quote (for checkout or backend order)
104
+ *
105
+ * @return Cdev_XPaymentsConnector_Transport_ApiResponse
106
+ */
107
+ public function processPayment(Cdev_XPaymentsConnector_Model_Quote $quote)
108
  {
109
+ $entityId = $quote->getEntityId();
110
+
111
+ if ($quote->isBackendOrderQuote()) {
112
+ $isBackend = true;
113
+ $refId = $quote->getXpcData()->getData('backend_orderid');
114
+ $amount = $quote->getBackendOrder()->getGrandTotal();
115
+ } else {
116
+ $isBackend = false;
117
+ $refId = $quote->getData('reserved_order_id');
118
+ $amount = $quote->getGrandTotal();
119
  }
120
 
121
+ $description = 'Order #' . $refId;
122
+
123
+ $preparedCart = Mage::helper('cart_xpc')->prepareCart($quote, $refId);
124
+
125
+ $cardData = $this->getOrderCardData();
126
+
127
+ // Data to send to X-Payments
128
  $data = array(
129
+ 'txnId' => $cardData['txnId'],
130
+ 'refId' => $refId,
131
+ 'amount' => $amount,
132
+ 'description' => $description,
133
+ 'cart' => $preparedCart,
134
+ 'callbackUrl' => Mage::helper('xpaymentsconnector')->getCallbackUrl($entityId, $this->getXpcSlot(), false),
135
  );
136
 
137
+ $response = Mage::helper('api_xpc')->requestPaymentRecharge($data);
138
 
139
+ return $response;
140
  }
141
 
 
142
  /**
143
+ * Check method availability
144
+ *
145
+ * @param Mage_Sales_Model_Quote $quote Quote
146
  *
147
+ * @return boolean
 
148
  */
149
+ public function isAvailable($quote = null)
150
+ {
151
+ if (
152
+ parent::isAvailable($quote)
153
+ && $quote
154
+ && $quote->getData('customer_id')
155
+ ) {
156
+
157
+ $cardsCount = Mage::getModel('xpaymentsconnector/usercards')
158
+ ->getCollection()
159
+ ->addFieldToFilter('user_id', $quote->getData('customer_id'))
160
+ ->addFieldToFilter('usage_type', Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD)
161
+ ->count();
162
 
163
+ $result = (bool)$cardsCount;
164
+
165
+ } else {
166
+
167
+ $result = false;
168
+ }
169
+
170
+ return $result;
171
  }
172
 
173
  /**
174
+ * Get redirect URL to process recharge
175
  *
176
+ * @return string
 
177
  */
178
+ public function getOrderPlaceRedirectUrl()
179
+ {
180
+ $request = Mage::app()->getRequest()->getParam('payment');
181
+
182
+ $session = Mage::getSingleton('checkout/session');
183
+
184
+ try {
185
+
186
+ // Check card from checkout
187
+ if (empty($request['xp_payment_card'])) {
188
+ throw new Exception('Wrong card id');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  }
190
 
191
+ $cardId = $request['xp_payment_card'];
192
+ $customerId = $session->getQuote()->getCustomerId();
 
 
 
 
 
 
193
 
194
+ $card = Mage::getModel('xpaymentsconnector/usercards')->load($cardId);
195
 
196
+ // Make sure this card belongs to the current customer
197
+ if ($card->getUserId() != $customerId) {
198
+ throw new Exception('Wrong card id');
199
+ }
200
 
201
+ $session->setXpcSaveCardId($cardId);
 
 
 
 
 
 
 
 
202
 
203
+ } catch (Exception $exception) {
 
 
 
 
 
 
 
204
 
205
+ // Save error to display
206
+ $session->addError($e->getMessage());
 
 
 
 
 
 
207
 
208
+ // And throw it further
209
+ throw $exception;
210
+ }
211
+
212
+ $url = Mage::getUrl('xpaymentsconnector/processing/recharge');
 
 
 
213
 
214
+ return $url;
215
+ }
216
  }
 
app/code/community/Cdev/XPaymentsConnector/Model/Paymentconfiguration.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Quote.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,50 +13,286 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  class Cdev_XPaymentsConnector_Model_Quote extends Mage_Sales_Model_Quote
23
  {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
24
 
25
- public function getReservedOrderId()
 
 
 
 
 
26
  {
27
- $reservedOrderId = Mage::helper("xpaymentsconnector")->getOrderKey();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
28
 
29
- if ($reservedOrderId) {
30
- return $reservedOrderId;
31
  } else {
32
- return parent::getReservedOrderId();
 
33
  }
 
 
34
  }
35
 
36
  /**
37
- * Adding new item to quote
38
  *
39
- * @param Mage_Sales_Model_Quote_Item $item
40
- * @return Mage_Sales_Model_Quote
41
  */
42
- public function addItem(Mage_Sales_Model_Quote_Item $item)
43
  {
44
- /**
45
- * Temporary workaround for purchase process: it is too dangerous to purchase more than one nominal item
46
- * or a mixture of nominal and non-nominal items, although technically possible.
47
- *
48
- * The problem is that currently it is implemented as sequential submission of nominal items and order, by one click.
49
- * It makes logically impossible to make the process of the purchase failsafe.
50
- * Proper solution is to submit items one by one with customer confirmation each time.
51
- */
52
 
53
- $item->setQuote($this);
54
- if (!$item->getId()) {
55
- $this->getItemsCollection()->addItem($item);
56
- Mage::dispatchEvent('sales_quote_add_item', array('quote_item' => $item));
 
57
  }
58
- return $this;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
59
  }
60
- }
61
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  class Cdev_XPaymentsConnector_Model_Quote extends Mage_Sales_Model_Quote
24
  {
25
+ /**
26
+ * Slot index of the XPC payment method
27
+ */
28
+ private $xpcSlot = null;
29
+
30
+ /**
31
+ * Set slot index of the XPC payment method
32
+ *
33
+ * @param int $xpcSlot Slot index of the XPC payment method
34
+ *
35
+ * @return Cdev_XPaymentsConnector_Model_Quote
36
+ */
37
+ public function setXpcSlot($xpcSlot)
38
+ {
39
+ $xpcSlot = Mage::helper('settings_xpc')->checkXpcSlot($xpcSlot);
40
+
41
+ $this->xpcSlot = $xpcSlot;
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Get slot index of the XPC payment method
48
+ *
49
+ * @return int
50
+ */
51
+ public function getXpcSlot()
52
+ {
53
+ return Mage::helper('settings_xpc')->checkXpcSlot($this->xpcSlot);
54
+ }
55
+
56
+ /**
57
+ * Get Quote xpc data
58
+ *
59
+ * @return Cdev_XPaymentsConnector_Model_Quote_XpcData
60
+ */
61
+ public function getXpcData()
62
+ {
63
+ $model = Mage::getModel('xpaymentsconnector/quote_xpcdata')
64
+ ->getCollection()
65
+ ->addFieldToFilter('quote_id', $this->getEntityId())
66
+ ->addFieldToFilter('xpc_slot', $this->getXpcSlot())
67
+ ->getFirstItem();
68
+
69
+ if (!$model->getQuoteId()) {
70
+ // Fill "primary key" for the new entity
71
+ $model->setQuoteId($this->getEntityId())
72
+ ->setXpcSlot($this->getXpcSlot())
73
+ ->save();
74
+ }
75
+
76
+ return $model;
77
+ }
78
 
79
+ /**
80
+ * Check if this quote is for backend order or not
81
+ *
82
+ * @return bool
83
+ */
84
+ public function isBackendOrderQuote()
85
  {
86
+ return (bool)$this->getXpcData()->getData('backend_orderid');
87
+ }
88
+
89
+ /**
90
+ * Get backend order from Quote (if any)
91
+ *
92
+ * @return Mage_Sales_Model_Order
93
+ */
94
+ public function getBackendOrder()
95
+ {
96
+ $orderId = $this->getXpcData()->getData('backend_orderid');
97
+
98
+ return Mage::getModel('sales/order')->load($orderId, 'increment_id');
99
+ }
100
+
101
+ /**
102
+ * Get quote or its backend order customer
103
+ *
104
+ * @return Mage_Customer_Model_Customer
105
+ */
106
+ public function getCustomer()
107
+ {
108
+ if ($this->isBackendOrderQuote()) {
109
+
110
+ $customer = Mage::getModel('customer/customer')->load(
111
+ $this->getBackendOrder()->getCustomerId()
112
+ );
113
 
 
 
114
  } else {
115
+
116
+ $customer = parent::getCustomer();
117
  }
118
+
119
+ return $customer;
120
  }
121
 
122
  /**
123
+ * Get all visible items for quote or its backend order
124
  *
125
+ * @return array
 
126
  */
127
+ public function getAllVisibleItems()
128
  {
129
+ if ($this->isBackendOrderQuote()) {
 
 
 
 
 
 
 
130
 
131
+ $items = $this->getBackendOrder()->getAllVisibleItems();
132
+
133
+ } else {
134
+
135
+ $items = parent::getAllVisibleItems();
136
  }
137
+
138
+ return $items;
139
+ }
140
+
141
+ /**
142
+ * Get all items for quote or its backend order
143
+ *
144
+ * @return array
145
+ */
146
+ public function getAllItems()
147
+ {
148
+ if ($this->isBackendOrderQuote()) {
149
+
150
+ $items = $this->getBackendOrder()->getAllItems();
151
+
152
+ } else {
153
+
154
+ $items = parent::getAllItems();
155
+ }
156
+
157
+ return $items;
158
+ }
159
+
160
+ /**
161
+ * Get quote or its backend order item for the recurring product. If any.
162
+ *
163
+ * @return Mage_Sales_Model_Quote_Item or false
164
+ */
165
+ public function getRecurringItem()
166
+ {
167
+ $result = false;
168
+
169
+ foreach ($this->getAllItems() as $item) {
170
+
171
+ if (
172
+ $item
173
+ && $item->getProduct()
174
+ && $item->getProduct()->getIsRecurring()
175
+ ) {
176
+
177
+ $result = $item;
178
+ break;
179
+ }
180
+ }
181
+
182
+ return $result;
183
+ }
184
+
185
+ /**
186
+ * Get quote or its backend order currency
187
+ *
188
+ * @return array
189
+ */
190
+ public function getCurrency()
191
+ {
192
+ if ($this->isBackendOrderQuote()) {
193
+
194
+ $currency = $this->getBackendOrder()->getData('order_currency_code');
195
+
196
+ } else {
197
+
198
+ $currency = $this->getData('quote_currency_code');
199
+ }
200
+
201
+ return $currency;
202
  }
 
203
 
204
+ /**
205
+ * Check if billing address should be saved in address book
206
+ *
207
+ * @return bool
208
+ */
209
+ public function isSaveBillingAddressInAddressBook()
210
+ {
211
+ // Grab data saved at checkout
212
+ $data = @unserialize($this->getXpcData()->getData('checkout_data'));
213
+
214
+ return $this->getBillingAddress()->getData('save_in_address_book')
215
+ || !empty($data['billing']['save_in_address_book']);
216
+ }
217
+
218
+ /**
219
+ * Check if shipping address should be saved in address book
220
+ *
221
+ * @return bool
222
+ */
223
+ public function isSaveShippingAddressInAddressBook()
224
+ {
225
+ // Grab data saved at checkout
226
+ $data = @unserialize($this->getXpcData()->getData('checkout_data'));
227
+
228
+ return (
229
+ $this->getShippingAddress()->getData('save_in_address_book')
230
+ && !$this->getShippingAddress()->getData('same_as_billing')
231
+ ) || (
232
+ !empty($data['shipping']['save_in_address_book'])
233
+ && empty($data['shipping']['same_as_billing'])
234
+ );
235
+ }
236
+
237
+ /**
238
+ * Get all addresses
239
+ *
240
+ * @return array
241
+ */
242
+ public function getAllAddresses()
243
+ {
244
+ $addresses = parent::getAllAddresses();
245
+
246
+ if (
247
+ count($addresses) > 2
248
+ && Mage::helper('settings_xpc')->checkFirecheckoutModuleEnabled()
249
+ ) {
250
+
251
+ // Remove "extra" addresses for the Firecheckout module
252
+ // See XP-659
253
+
254
+ $shippingFound = $billingFound = false;
255
+
256
+ foreach ($addresses as $key => $address) {
257
+
258
+ if ($address::TYPE_BILLING == $address->getAddressType()) {
259
+
260
+ if (!$billingFound) {
261
+ $billingFound = true;
262
+ } else {
263
+ unset($addresses[$key]);
264
+ }
265
+
266
+ } elseif ($address::TYPE_SHIPPING == $address->getAddressType()) {
267
+
268
+ if (!$shippingFound) {
269
+ $shippingFound = true;
270
+ } else {
271
+ unset($addresses[$key]);
272
+ }
273
+
274
+ } else {
275
+
276
+ unset($addresses[$key]);
277
+ }
278
+ }
279
+ }
280
+
281
+ return $addresses;
282
+ }
283
+
284
+ /**
285
+ * Save exception message to the log and throw it
286
+ *
287
+ * @param string $message Message
288
+ * @param string $paramm Some parameter
289
+ *
290
+ * @return void
291
+ */
292
+ private function throwException($message, $param = null)
293
+ {
294
+ Mage::helper('xpaymentsconnector')->writeLog($message, $param);
295
+
296
+ throw new Exception($message);
297
+ }
298
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,10 +13,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
@@ -30,12 +31,11 @@ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal extends Mage_Sal
30
  * Invoke collector for nominal items
31
  *
32
  * @param Mage_Sales_Model_Quote_Address $address
33
- * @param Mage_Sales_Model_Quote_Address_Total_Nominal
 
34
  */
35
  public function collect(Mage_Sales_Model_Quote_Address $address)
36
  {
37
- Mage::helper('xpaymentsconnector')->updateAllRecurringQuoteItem();
38
-
39
  $collector = Mage::getSingleton('sales/quote_address_total_nominal_collector',
40
  array('store' => $address->getQuote()->getStore())
41
  );
@@ -94,5 +94,4 @@ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal extends Mage_Sal
94
 
95
  return $this;
96
  }
97
-
98
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
31
  * Invoke collector for nominal items
32
  *
33
  * @param Mage_Sales_Model_Quote_Address $address
34
+ *
35
+ * @return Mage_Sales_Model_Quote_Address_Total_Nominal
36
  */
37
  public function collect(Mage_Sales_Model_Quote_Address $address)
38
  {
 
 
39
  $collector = Mage::getSingleton('sales/quote_address_total_nominal_collector',
40
  array('store' => $address->getQuote()->getStore())
41
  );
94
 
95
  return $this;
96
  }
 
97
  }
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Discount.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Initialfee/Tax.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Xpcdata.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -53,4 +53,20 @@ class Cdev_XPaymentsConnector_Model_Quote_Xpcdata extends Mage_Core_Model_Abstra
53
  ->setData('checkout_data', '')
54
  ->save();
55
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
53
  ->setData('checkout_data', '')
54
  ->save();
55
  }
56
+
57
+ /**
58
+ * Delete records for quote
59
+ *
60
+ * @param int $quoteId Quote ID
61
+ *
62
+ * @return void
63
+ */
64
+ public function deleteByQuoteId($quoteId)
65
+ {
66
+ $collection = $this->getCollection()->addFieldToFilter('quote_id', $quoteId);
67
+
68
+ foreach ($collection as $model) {
69
+ $model->delete();
70
+ }
71
+ }
72
  }
app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,41 +13,142 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
- class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile {
23
-
 
 
 
24
  const STATE_FINISHED = 'finished';
25
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
26
  /**
27
  * Determine nearest possible profile start date
28
  *
29
  * @param Zend_Date $minAllowed
 
30
  * @return Mage_Payment_Model_Recurring_Profile
31
  */
32
  public function setNearestStartDatetime(Zend_Date $minAllowed = null)
33
  {
34
- $paymentMethodCode = $this->getMethodCode();
35
 
36
- $isXpaymentMethod = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentMethodCode);
37
- if($isXpaymentMethod){
38
- $date = $minAllowed;
39
- if (!$date) {
40
- $date = new Zend_Date(time());
41
- }
42
  $this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
43
- return $this;
44
 
 
 
 
45
  }
46
- return parent::setNearestStartDatetime($minAllowed);
47
- }
48
 
 
 
49
 
 
 
 
 
 
50
  public function createOrder()
51
  {
52
  $items = array();
@@ -61,24 +163,30 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
61
  $qty = 0;
62
 
63
  foreach ($itemInfoObjects as $itemInfo) {
 
64
  $item = $this->_getItem($itemInfo);
 
65
  $price = $item->getPrice();
66
  if(!is_null($itemInfo->getRowTotal())){
67
  $price = $itemInfo->getRowTotal();
68
  }
 
69
  $billingAmount += $price;
70
  $shippingAmount += $itemInfo->getShippingAmount();
 
71
  $taxAmount += $item->getTaxAmount();
72
 
73
- if($itemInfo->getQty()){
74
  $qty = $itemInfo->getQty();
75
  }
 
76
  $weight += $item->getWeight();
 
77
  if (!$item->getIsVirtual()) {
78
  $isVirtual = 0;
79
  }
80
 
81
- if(!is_null($itemInfo->getDiscountAmount())){
82
  $discountAmount -= $itemInfo->getDiscountAmount();
83
  $item->setOriginalDiscountAmount($itemInfo->getDiscountAmount());
84
  $item->setBaseOriginalDiscountAmount($itemInfo->getDiscountAmount());
@@ -95,8 +203,7 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
95
  $order = Mage::getModel('sales/order');
96
 
97
  $billingAddressInfo = $this->getBillingAddressInfo();
98
- // add check for recurring profile order
99
- if(!is_array($billingAddressInfo)){
100
  $billingAddressInfo = unserialize($billingAddressInfo);
101
  }
102
  $billingAddress = Mage::getModel('sales/order_address')
@@ -104,11 +211,9 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
104
  ->setId(null);
105
 
106
  $shippingInfo = $this->getShippingAddressInfo();
107
- // add check for recurring profile order
108
- if(!is_array($shippingInfo)){
109
  $shippingInfo = unserialize($shippingInfo);
110
  }
111
-
112
  $shippingAddress = Mage::getModel('sales/order_address')
113
  ->setData($shippingInfo)
114
  ->setId(null);
@@ -127,20 +232,24 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
127
  );
128
 
129
  $orderInfo = $this->getOrderInfo();
130
-
131
- // add check for recurring profile order
132
- if(!is_array($orderInfo)){
133
  $orderInfo = unserialize($orderInfo);
134
  }
135
 
136
  foreach ($transferDataKays as $key) {
 
137
  if (isset($orderInfo[$key])) {
 
138
  $order->setData($key, $orderInfo[$key]);
 
139
  } elseif (isset($shippingInfo[$key])) {
 
140
  $order->setData($key, $shippingInfo[$key]);
141
  }
142
  }
 
143
  $qty = ($qty)?$qty:$orderInfo['items_qty'];
 
144
  $order->setStoreId($this->getStoreId())
145
  ->setState(Mage_Sales_Model_Order::STATE_NEW)
146
  ->setBaseToOrderRate($orderInfo['base_to_quote_rate'])
@@ -170,161 +279,85 @@ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_M
170
  return $order;
171
  }
172
 
173
-
174
  /**
175
- * Check whether the workflow allows to suspend the profile
176
  *
177
  * @return bool
178
  */
179
- public function canSuspend()
180
  {
181
- $paymentMethodCode = $this->getMethodCode();
182
- $isXpaymentMethod = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentMethodCode);
183
- if($isXpaymentMethod){
184
- return false;
185
- }else{
186
- return parent::canSuspend();
187
- }
188
-
189
  }
190
 
191
  /**
192
- * Create and return new order item based on profile item data and $itemInfo
193
- * for regular payment
194
  *
195
- * @param Varien_Object $itemInfo
196
- * @return Mage_Sales_Model_Order_Item
197
  */
198
- protected function _getRegularItem($itemInfo)
199
  {
200
- $price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
201
- $rowTotal = $price;
202
- $baseRowTotal = $price;
203
- $rowTotalInclTax = $price;
204
- $baseRowTotalInclTax = $price;
205
- $originalPrice = $price;
206
-
207
- if(!is_null($itemInfo->getRowTotal())){
208
- $rowTotal = $itemInfo->getRowTotal();
209
- }
210
- if(!is_null($itemInfo->getBaseRowTotal())){
211
- $baseRowTotal = $itemInfo->getBaseRowTotal();
212
- }
213
- if(!is_null($itemInfo->getRowTotalInclTax())){
214
- $rowTotalInclTax = $itemInfo->getRowTotalInclTax();
215
- }
216
- if(!is_null($itemInfo->getBaseRowTotalInclTax())){
217
- $baseRowTotalInclTax = $itemInfo->getBaseRowTotalInclTax();
218
- }
219
- if(!is_null($itemInfo->getOriginalPrice())){
220
- $originalPrice = $itemInfo->getOriginalPrice();
221
  }
222
 
223
- $shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : $this->getShippingAmount();
224
- $taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
225
- $orderItemInfo = $this->getOrderItemInfo();
226
- if(!is_array($orderItemInfo)){
227
- $orderItemInfo = unserialize($orderItemInfo);
228
- }
229
-
230
- $item = Mage::getModel('sales/order_item')
231
- ->setData($orderItemInfo)
232
- ->setQtyOrdered($orderItemInfo['qty'])
233
- ->setBaseOriginalPrice($orderItemInfo['price'])
234
- ->setPrice($price)
235
- ->setBasePrice($price)
236
- ->setRowTotal($rowTotal)
237
- ->setBaseRowTotal($baseRowTotal)
238
- ->setRowTotalInclTax($rowTotalInclTax)
239
- ->setBaseRowTotalInclTax($baseRowTotalInclTax)
240
- ->setOriginalPrice($originalPrice)
241
- ->setTaxAmount($taxAmount)
242
- ->setShippingAmount($shippingAmount)
243
- ->setId(null);
244
-
245
- return $item;
246
- }
247
-
248
- /**
249
- * Check whether the workflow allows to activate the profile
250
- *
251
- * @return bool
252
- */
253
- public function canActivate()
254
- {
255
- return false;
256
  }
257
 
258
  /**
259
  * Set state finished for current profile
 
 
260
  */
261
  public function finished()
262
  {
263
  $this->_checkWorkflow(self::STATE_FINISHED, false);
 
264
  $this->setNewState(self::STATE_FINISHED);
 
265
  $this->getMethodInstance()->updateRecurringProfileStatus($this);
266
- $this->setState(self::STATE_FINISHED)
267
- ->save();
268
- }
269
 
270
- /**
271
- * Initialize the workflow reference
272
- */
273
- protected function _initWorkflow()
274
- {
275
- if (null === $this->_workflow) {
276
- $this->_workflow = array(
277
- 'unknown' => array('pending', 'active', 'suspended', 'canceled'),
278
- 'pending' => array('active', 'canceled'),
279
- 'active' => array('suspended', 'canceled', 'finished'),
280
- 'suspended' => array('active', 'canceled'),
281
- 'canceled' => array(),
282
- 'expired' => array(),
283
- 'finished' => array()
284
- );
285
- }
286
  }
287
 
288
  /**
289
  * Get state label based on the code
290
  *
291
  * @param string $state
 
292
  * @return string
293
  */
294
  public function getStateLabel($state)
295
  {
296
- switch ($state) {
297
- case self::STATE_UNKNOWN: return Mage::helper('sales')->__('Not Initialized');
298
- case self::STATE_PENDING: return Mage::helper('sales')->__('Pending');
299
- case self::STATE_ACTIVE: return Mage::helper('sales')->__('Active');
300
- case self::STATE_SUSPENDED: return Mage::helper('sales')->__('Suspended');
301
- case self::STATE_FINISHED: return Mage::helper('xpaymentsconnector')->__('Finished');
302
- case self::STATE_CANCELED: return Mage::helper('sales')->__('Canceled');
303
- case self::STATE_EXPIRED: return Mage::helper('sales')->__('Expired');
304
- default: return $state;
305
- }
306
  }
307
 
308
  /**
309
- * Getter for all available states
310
  *
311
  * @param bool $withLabels
 
312
  * @return array
313
  */
314
  public function getAllStates($withLabels = true)
315
  {
316
- $states = array(self::STATE_UNKNOWN, self::STATE_PENDING, self::STATE_ACTIVE,
317
- self::STATE_SUSPENDED, self::STATE_CANCELED, self::STATE_EXPIRED, self::STATE_FINISHED
 
 
 
 
 
 
318
  );
319
- if ($withLabels) {
320
- $result = array();
321
- foreach ($states as $state) {
322
- $result[$state] = $this->getStateLabel($state);
323
- }
324
- return $result;
325
- }
326
- return $states;
327
- }
328
-
329
 
 
 
 
 
330
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
+ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile
24
+ {
25
+ /**
26
+ * Finished state
27
+ */
28
  const STATE_FINISHED = 'finished';
29
 
30
+ /**
31
+ * Initialize the workflow reference
32
+ *
33
+ * @return void
34
+ */
35
+ protected function _initWorkflow()
36
+ {
37
+ if (is_null($this->_workflow)) {
38
+
39
+ $this->_workflow = array(
40
+ 'unknown' => array('pending', 'active', 'suspended', 'canceled'),
41
+ 'pending' => array('active', 'canceled'),
42
+ 'active' => array('suspended', 'canceled', 'finished'),
43
+ 'suspended' => array('active', 'canceled'),
44
+ 'canceled' => array(),
45
+ 'expired' => array(),
46
+ 'finished' => array()
47
+ );
48
+ }
49
+ }
50
+
51
+ /**
52
+ * Create and return new order item based on profile item data and $itemInfo
53
+ * for regular payment
54
+ *
55
+ * @param Varien_Object $itemInfo
56
+ *
57
+ * @return Mage_Sales_Model_Order_Item
58
+ */
59
+ protected function _getRegularItem($itemInfo)
60
+ {
61
+ $price = $itemInfo->getPrice()
62
+ ? $itemInfo->getPrice()
63
+ : $this->getBillingAmount();
64
+
65
+ $rowTotal = $price;
66
+ $baseRowTotal = $price;
67
+ $rowTotalInclTax = $price;
68
+ $baseRowTotalInclTax = $price;
69
+ $originalPrice = $price;
70
+
71
+ if (!is_null($itemInfo->getRowTotal())) {
72
+ $rowTotal = $itemInfo->getRowTotal();
73
+ }
74
+
75
+ if (!is_null($itemInfo->getBaseRowTotal())) {
76
+ $baseRowTotal = $itemInfo->getBaseRowTotal();
77
+ }
78
+
79
+ if (!is_null($itemInfo->getRowTotalInclTax())) {
80
+ $rowTotalInclTax = $itemInfo->getRowTotalInclTax();
81
+ }
82
+
83
+ if (!is_null($itemInfo->getBaseRowTotalInclTax())) {
84
+ $baseRowTotalInclTax = $itemInfo->getBaseRowTotalInclTax();
85
+ }
86
+
87
+ if (!is_null($itemInfo->getOriginalPrice())) {
88
+ $originalPrice = $itemInfo->getOriginalPrice();
89
+ }
90
+
91
+ $shippingAmount = $itemInfo->getShippingAmount()
92
+ ? $itemInfo->getShippingAmount()
93
+ : $this->getShippingAmount();
94
+
95
+ $taxAmount = $itemInfo->getTaxAmount()
96
+ ? $itemInfo->getTaxAmount()
97
+ : $this->getTaxAmount();
98
+
99
+ $orderItemInfo = $this->getOrderItemInfo();
100
+ if (!is_array($orderItemInfo)) {
101
+ $orderItemInfo = unserialize($orderItemInfo);
102
+ }
103
+
104
+ $item = Mage::getModel('sales/order_item')
105
+ ->setData($orderItemInfo)
106
+ ->setQtyOrdered($orderItemInfo['qty'])
107
+ ->setBaseOriginalPrice($orderItemInfo['price'])
108
+ ->setPrice($price)
109
+ ->setBasePrice($price)
110
+ ->setRowTotal($rowTotal)
111
+ ->setBaseRowTotal($baseRowTotal)
112
+ ->setRowTotalInclTax($rowTotalInclTax)
113
+ ->setBaseRowTotalInclTax($baseRowTotalInclTax)
114
+ ->setOriginalPrice($originalPrice)
115
+ ->setTaxAmount($taxAmount)
116
+ ->setShippingAmount($shippingAmount)
117
+ ->setId(null);
118
+
119
+ return $item;
120
+ }
121
+
122
  /**
123
  * Determine nearest possible profile start date
124
  *
125
  * @param Zend_Date $minAllowed
126
+ *
127
  * @return Mage_Payment_Model_Recurring_Profile
128
  */
129
  public function setNearestStartDatetime(Zend_Date $minAllowed = null)
130
  {
131
+ if (Mage::helper('settings_xpc')->isXpcMethod($this->getMethodCode())) {
132
 
133
+ $date = is_null($minAllowed)
134
+ ? new Zend_Date(time())
135
+ : $minAllowed;
136
+
 
 
137
  $this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
 
138
 
139
+ } else {
140
+
141
+ parent::setNearestStartDatetime($minAllowed);
142
  }
 
 
143
 
144
+ return $this;
145
+ }
146
 
147
+ /**
148
+ * Create order
149
+ *
150
+ * @return Mage_Sales_Model_Order
151
+ */
152
  public function createOrder()
153
  {
154
  $items = array();
163
  $qty = 0;
164
 
165
  foreach ($itemInfoObjects as $itemInfo) {
166
+
167
  $item = $this->_getItem($itemInfo);
168
+
169
  $price = $item->getPrice();
170
  if(!is_null($itemInfo->getRowTotal())){
171
  $price = $itemInfo->getRowTotal();
172
  }
173
+
174
  $billingAmount += $price;
175
  $shippingAmount += $itemInfo->getShippingAmount();
176
+
177
  $taxAmount += $item->getTaxAmount();
178
 
179
+ if ($itemInfo->getQty()) {
180
  $qty = $itemInfo->getQty();
181
  }
182
+
183
  $weight += $item->getWeight();
184
+
185
  if (!$item->getIsVirtual()) {
186
  $isVirtual = 0;
187
  }
188
 
189
+ if (!is_null($itemInfo->getDiscountAmount())) {
190
  $discountAmount -= $itemInfo->getDiscountAmount();
191
  $item->setOriginalDiscountAmount($itemInfo->getDiscountAmount());
192
  $item->setBaseOriginalDiscountAmount($itemInfo->getDiscountAmount());
203
  $order = Mage::getModel('sales/order');
204
 
205
  $billingAddressInfo = $this->getBillingAddressInfo();
206
+ if (!is_array($billingAddressInfo)) {
 
207
  $billingAddressInfo = unserialize($billingAddressInfo);
208
  }
209
  $billingAddress = Mage::getModel('sales/order_address')
211
  ->setId(null);
212
 
213
  $shippingInfo = $this->getShippingAddressInfo();
214
+ if (!is_array($shippingInfo)) {
 
215
  $shippingInfo = unserialize($shippingInfo);
216
  }
 
217
  $shippingAddress = Mage::getModel('sales/order_address')
218
  ->setData($shippingInfo)
219
  ->setId(null);
232
  );
233
 
234
  $orderInfo = $this->getOrderInfo();
235
+ if (!is_array($orderInfo)) {
 
 
236
  $orderInfo = unserialize($orderInfo);
237
  }
238
 
239
  foreach ($transferDataKays as $key) {
240
+
241
  if (isset($orderInfo[$key])) {
242
+
243
  $order->setData($key, $orderInfo[$key]);
244
+
245
  } elseif (isset($shippingInfo[$key])) {
246
+
247
  $order->setData($key, $shippingInfo[$key]);
248
  }
249
  }
250
+
251
  $qty = ($qty)?$qty:$orderInfo['items_qty'];
252
+
253
  $order->setStoreId($this->getStoreId())
254
  ->setState(Mage_Sales_Model_Order::STATE_NEW)
255
  ->setBaseToOrderRate($orderInfo['base_to_quote_rate'])
279
  return $order;
280
  }
281
 
 
282
  /**
283
+ * Check whether the workflow allows to activate the profile
284
  *
285
  * @return bool
286
  */
287
+ public function canActivate()
288
  {
289
+ return false;
 
 
 
 
 
 
 
290
  }
291
 
292
  /**
293
+ * Check whether the workflow allows to suspend the profile
 
294
  *
295
+ * @return bool
 
296
  */
297
+ public function canSuspend()
298
  {
299
+ if (Mage::helper('settings_xpc')->isXpcMethod($this->getMethodCode())) {
300
+ $result = false;
301
+ } else {
302
+ $result = parent::canSuspend();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
303
  }
304
 
305
+ return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  }
307
 
308
  /**
309
  * Set state finished for current profile
310
+ *
311
+ * @return void
312
  */
313
  public function finished()
314
  {
315
  $this->_checkWorkflow(self::STATE_FINISHED, false);
316
+
317
  $this->setNewState(self::STATE_FINISHED);
318
+
319
  $this->getMethodInstance()->updateRecurringProfileStatus($this);
 
 
 
320
 
321
+ $this->setState(self::STATE_FINISHED)->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
322
  }
323
 
324
  /**
325
  * Get state label based on the code
326
  *
327
  * @param string $state
328
+ *
329
  * @return string
330
  */
331
  public function getStateLabel($state)
332
  {
333
+ $states = $this->getAllStates();
334
+
335
+ return !empty($states[$state])
336
+ ? $states[$state]
337
+ : $state;
 
 
 
 
 
338
  }
339
 
340
  /**
341
+ * Get all available states
342
  *
343
  * @param bool $withLabels
344
+ *
345
  * @return array
346
  */
347
  public function getAllStates($withLabels = true)
348
  {
349
+ $states = array(
350
+ self::STATE_UNKNOWN => Mage::helper('sales')->__('Not Initialized'),
351
+ self::STATE_PENDING => Mage::helper('sales')->__('Pending'),
352
+ self::STATE_ACTIVE => Mage::helper('sales')->__('Active'),
353
+ self::STATE_SUSPENDED => Mage::helper('sales')->__('Suspended'),
354
+ self::STATE_CANCELED => Mage::helper('xpaymentsconnector')->__('Finished'),
355
+ self::STATE_EXPIRED => Mage::helper('sales')->__('Canceled'),
356
+ self::STATE_FINISHED => Mage::helper('sales')->__('Expired'),
357
  );
 
 
 
 
 
 
 
 
 
 
358
 
359
+ return $withLabels
360
+ ? $states
361
+ : array_keys($states);
362
+ }
363
  }
app/code/community/Cdev/XPaymentsConnector/Model/Source/Paymentconfiguration.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/Model/Usercards.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,10 +13,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
@@ -23,12 +24,15 @@
23
  * Used for management of customer cards
24
  * Class Cdev_XPaymentsConnector_Model_Usercards
25
  */
26
-
27
  class Cdev_XPaymentsConnector_Model_Usercards extends Mage_Core_Model_Abstract
28
  {
29
- const SIMPLE_CARD = 0;
30
- const BALANCE_CARD = 1;
 
 
 
31
  const RECURRING_CARD = 2;
 
32
  /**
33
  * Internal constructor
34
  *
@@ -43,14 +47,95 @@ class Cdev_XPaymentsConnector_Model_Usercards extends Mage_Core_Model_Abstract
43
  }
44
 
45
  /**
 
 
46
  * @return array
47
  */
48
- public function getCardsUsageOptions(){
49
- $options = array();
50
- $options[self::SIMPLE_CARD] = "Simple";
51
- $options[self::BALANCE_CARD] = "Balance";
52
- $options[self::RECURRING_CARD] = "Recurring";
53
- return $options;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
54
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
  }
56
 
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
24
  * Used for management of customer cards
25
  * Class Cdev_XPaymentsConnector_Model_Usercards
26
  */
 
27
  class Cdev_XPaymentsConnector_Model_Usercards extends Mage_Core_Model_Abstract
28
  {
29
+ /**
30
+ * Card usage types
31
+ */
32
+ const SIMPLE_CARD = 0;
33
+ const BALANCE_CARD = 1;
34
  const RECURRING_CARD = 2;
35
+
36
  /**
37
  * Internal constructor
38
  *
47
  }
48
 
49
  /**
50
+ * Get card usage types
51
+ *
52
  * @return array
53
  */
54
+ public function getCardsUsageOptions()
55
+ {
56
+ return array(
57
+ self::SIMPLE_CARD => 'Simple',
58
+ self::BALANCE_CARD => 'Balance',
59
+ self::RECURRING_CARD => 'Recurring',
60
+ );
61
+ }
62
+
63
+ /**
64
+ * Check usage type
65
+ *
66
+ * @param string $usageType Usage type
67
+ *
68
+ * @return string
69
+ */
70
+ private function checkUsageType($usageType)
71
+ {
72
+ $types = array_keys($this->getCardsUsageOptions());
73
+
74
+ if (!in_array($usageType, $types)) {
75
+ $usageType = self::SIMPLE_CARD;
76
+ }
77
+
78
+ return $usageType;
79
+ }
80
+
81
+ /**
82
+ * Process masked card data from the callback request
83
+ *
84
+ * @param array $cardData Card data
85
+ * @param int $customerId Customer ID
86
+ *
87
+ * @return Cdev_XPaymentsConnector_Model_Usercards
88
+ */
89
+ public function saveUserCard($cardData, $customerId, $usageType = self::SIMPLE_CARD)
90
+ {
91
+ $txnId = $cardData['txnId'];
92
+
93
+ $usageType = $this->checkUsageType($usageType);
94
+
95
+ // Try to find card with already existing txnId.
96
+ // Then update it or fill the empty found entity.
97
+ $usercards = Mage::getModel('xpaymentsconnector/usercards')
98
+ ->getCollection()
99
+ ->addFieldToFilter('txnId', $txnId)
100
+ ->getFirstItem();
101
+
102
+ $data = array(
103
+ 'user_id' => $customerId,
104
+ 'txnId' => $txnId,
105
+ 'last_4_cc_num' => !empty($cardData['last4']) ? $cardData['last4'] : '',
106
+ 'first6' => !empty($cardData['first6']) ? $cardData['first6'] : '',
107
+ 'card_type' => !empty($cardData['type']) ? $cardData['type'] : '',
108
+ 'expire_month' => !empty($cardData['expire_month']) ? $cardData['expire_month'] : '',
109
+ 'expire_year' => !empty($cardData['expire_year']) ? $cardData['expire_year'] : '',
110
+ 'confid' => $cardData['confid'],
111
+ 'usage_type' => $usageType,
112
+ );
113
+
114
+ if ($usercards->getData('xp_card_id')) {
115
+ $data['xp_card_id'] = $usercards->getData('xp_card_id');
116
+ }
117
+
118
+ $usercards->setData($data)->save();
119
+
120
+ return $usercards;
121
  }
122
+
123
+ /**
124
+ * Check that card with certain txnId is saved in customer's profile
125
+ *
126
+ * @param int $customerId Customer ID
127
+ * @param string $txnId X-Payments txnId
128
+ *
129
+ * @return bool
130
+ */
131
+ public function checkSavedCard($customerId, $txnId)
132
+ {
133
+ $count = $this->getCollection()
134
+ ->addFieldToFilter('user_id', $customerId)
135
+ ->addFieldToFilter('txnId', $txnId)
136
+ ->count();
137
+
138
+ return 0 < $count;
139
+ }
140
  }
141
 
app/code/community/Cdev/XPaymentsConnector/Transport/ApiResponse.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * API response transport
25
+ */
26
+
27
+ class Cdev_XPaymentsConnector_Transport_ApiResponse extends Varien_Object
28
+ {
29
+ /**
30
+ * Get status
31
+ *
32
+ * @return bool
33
+ */
34
+ public function getStatus()
35
+ {
36
+ return (bool)parent::getStatus()
37
+ && empty($this->getErrorCode())
38
+ && empty($this->getErrorMessage());
39
+ }
40
+
41
+ /**
42
+ * Get field value from the response array
43
+ *
44
+ * @return string
45
+ */
46
+ public function getField($name)
47
+ {
48
+ return !empty($this->getResponse()[$name])
49
+ ? $this->getResponse()[$name]
50
+ : '';
51
+ }
52
+
53
+ /**
54
+ * Get error message
55
+ *
56
+ * @param string $defaultMessage Default message
57
+ *
58
+ * @return string
59
+ */
60
+ public function getErrorMessage($defaultMessage = '')
61
+ {
62
+ $message = parent::getErrorMessage();
63
+
64
+ if (empty($message)) {
65
+ $message = parent::getMessage();
66
+ }
67
+
68
+ if (empty($message)) {
69
+ $message = $defaultMessage;
70
+ }
71
+
72
+ return $message;
73
+ }
74
+
75
+ /**
76
+ * Get message
77
+ *
78
+ * @param string $defaultMessage Default message
79
+ *
80
+ * @return string
81
+ */
82
+ public function getMessage($defaultMessage = '')
83
+ {
84
+ $message = parent::getMessage();
85
+
86
+ if (empty($message)) {
87
+ $message = $defaultMessage;
88
+ }
89
+
90
+ return $message;
91
+ }
92
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/AddnewcardController.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ *
25
+ * Class Cdev_XPaymentsConnector_Adminhtml_AddnewcardController
26
+ */
27
+ class Cdev_XPaymentsConnector_Adminhtml_AddnewcardController extends Mage_Adminhtml_Controller_Action
28
+ {
29
+ /**
30
+ * Check if pay for order is allowed for user
31
+ *
32
+ * @return bool
33
+ */
34
+ protected function _isAllowed()
35
+ {
36
+ return Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/payment_cards');
37
+ }
38
+
39
+ /**
40
+ * Default action
41
+ *
42
+ * @return void
43
+ */
44
+ public function indexAction()
45
+ {
46
+ try {
47
+
48
+ $customer = $this->getCustomer();
49
+
50
+ $customer->setXpBufer(true);
51
+
52
+ $this->loadLayout();
53
+
54
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_usercards_add');
55
+
56
+ $block->setCustomer($customer);
57
+ $block->setAddressId($this->getRequest()->getParam('address_id'));
58
+
59
+ $response = Mage::helper('settings_xpc')->getZeroAuthMethod()
60
+ ->obtainToken(null, $customer);
61
+
62
+ $customer->setXpBufer(false);
63
+
64
+ if (!$response->getStatus()) {
65
+
66
+ $error = !empty($response->getErrorMessage())
67
+ ? $response->getErrorMessage()
68
+ : 'Unable to obtain token from X-Payments';
69
+
70
+ $block->setError($error);
71
+
72
+ } else {
73
+
74
+ $fields = Mage::getSingleton('admin/session')->getData('xpc_fields');
75
+
76
+ if (!is_array($fields)) {
77
+ $fields = array();
78
+ }
79
+
80
+ $fields[$this->getCustomer()->getId()] = array(
81
+ 'target' => 'main',
82
+ 'action' => 'start',
83
+ 'token' => $response->getField('token'),
84
+ 'allow_save_card' => 'Y',
85
+ );
86
+
87
+ Mage::getSingleton('admin/session')->setData('xpc_fields', $fields);
88
+ }
89
+
90
+ $this->_addContent($block);
91
+
92
+ $this->renderLayout();
93
+
94
+ } catch (Exception $e) {
95
+
96
+ $this->_getSession()->addError($this->__($e->getMessage()));
97
+
98
+ $this->_redirect(
99
+ '*/customer/edit',
100
+ array(
101
+ 'id' => $this->getRequest()->getParam('customer_id'),
102
+ 'tab' => 'customer_edit_tab_usercards',
103
+ )
104
+ );
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Iframe action
110
+ *
111
+ * @return void
112
+ */
113
+ public function iframeAction()
114
+ {
115
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_usercards_iframe');
116
+
117
+ try {
118
+
119
+ $fields = Mage::getSingleton('admin/session')->getData('xpc_fields');
120
+ $fields = $fields[$this->getCustomer()->getId()];
121
+
122
+ $block->setFields($fields);
123
+
124
+ } catch (Exception $e) {
125
+
126
+ $block->setError($e->getMessage());
127
+ }
128
+
129
+ echo $block->toHtml();
130
+ exit;
131
+ }
132
+
133
+ /**
134
+ * Validate Form Key
135
+ *
136
+ * @return bool
137
+ */
138
+ protected function _validateFormKey()
139
+ {
140
+ $result = parent::_validateFormKey();
141
+
142
+ if ($this->getRequest()->getParam('action') == 'return') {
143
+
144
+ // This is necessary to allow POST request on return, which doesn't contain form key
145
+ $result = true;
146
+ }
147
+
148
+ return $result;
149
+ }
150
+
151
+ /**
152
+ * Return action
153
+ *
154
+ * @return void
155
+ */
156
+ public function returnAction()
157
+ {
158
+ // If were here, then everything is OK, the transaction was authorized by the gateway.
159
+ // But we need to make sure that the card was saved by the store successfully.
160
+
161
+ $isCardSaved = Mage::getModel('xpaymentsconnector/usercards')
162
+ ->checkSavedCard(
163
+ $this->getRequest()->getParam('customer_id'),
164
+ $this->getRequest()->getParam('txnId')
165
+ );
166
+
167
+ if ($isCardSaved) {
168
+
169
+ $this->_getSession()->addSuccess($this->__('Payment card saved'));
170
+
171
+ } else {
172
+
173
+ $this->_getSession()->addError($this->__(
174
+ 'Payment gateway reported about successful authorization, but the store is unable to receive the payment token. '
175
+ . 'Please check the settings in X-Payments and in the payment gateway backend.'
176
+ ));
177
+ }
178
+
179
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_usercards_iframe');
180
+ $block->setReturnFlag(true);
181
+
182
+ echo $block->toHtml();
183
+ exit;
184
+ }
185
+
186
+ /**
187
+ * Get current customer profile
188
+ *
189
+ * @return Mage_Customer_Model_Customer
190
+ */
191
+ private function getCustomer()
192
+ {
193
+ $customer = Mage::getModel('customer/customer')->load(
194
+ $this->getRequest()->getParam('customer_id')
195
+ );
196
+
197
+ if (!$customer->getId()) {
198
+ throw new Exception('Wrong customer reference.');
199
+ }
200
+
201
+ return $customer;
202
+ }
203
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/CustomerController.php CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,33 +13,67 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  /**
23
  * Customer admin controller
24
  */
25
-
26
  require_once 'Mage/Adminhtml/controllers/CustomerController.php';
27
 
28
  class Cdev_XPaymentsConnector_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
29
  {
30
- public function usercardsAction(){
31
- echo $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_customer_edit_tab_usercards')->toHtml();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
32
  }
33
 
34
- public function cardsMassDeleteAction(){
35
- $xpCardIds = $this->getRequest()->getPost('ids');
36
- $itemCollection = Mage::getModel("xpaymentsconnector/usercards")
37
- ->getCollection()
38
- ->addFieldToFilter('xp_card_id', array('in' => $xpCardIds));
39
- foreach($itemCollection as $item) {
40
- $item->delete();
41
- }
 
 
 
 
42
 
43
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  }
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
  * Customer admin controller
25
  */
 
26
  require_once 'Mage/Adminhtml/controllers/CustomerController.php';
27
 
28
  class Cdev_XPaymentsConnector_Adminhtml_CustomerController extends Mage_Adminhtml_CustomerController
29
  {
30
+ /**
31
+ * Check if X-Payments Connector configuration is allowed for user
32
+ *
33
+ * @return bool
34
+ */
35
+ protected function _isAllowed()
36
+ {
37
+ $result = parent::_isAllowed();
38
+
39
+ $action = $this->getRequest()->getParam('action');
40
+
41
+ if (
42
+ $result
43
+ && ('usercards' == $action || 'cardsMassDelete' == $action)
44
+ ) {
45
+ // Check role permissions for the XPC actions
46
+ $result = Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/payment_cards');
47
  }
48
 
49
+ return $result;
50
+ }
51
+
52
+ /**
53
+ * Display cards list
54
+ *
55
+ * @return void
56
+ */
57
+ public function usercardsAction()
58
+ {
59
+ echo $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_customer_edit_tab_usercards')->toHtml();
60
+ }
61
 
62
+ /**
63
+ * Delete cards
64
+ *
65
+ * @return void
66
+ */
67
+ public function cardsMassDeleteAction()
68
+ {
69
+ $ids = $this->getRequest()->getPost('ids');
70
+
71
+ $items = Mage::getModel('xpaymentsconnector/usercards')
72
+ ->getCollection()
73
+ ->addFieldToFilter('xp_card_id', array('in' => $ids));
74
+
75
+ foreach($items as $item) {
76
+ $item->delete();
77
+ }
78
+ }
79
  }
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/CreateController.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Create order controller
25
+ */
26
+ require_once 'Mage/Adminhtml/controllers/Sales/Order/CreateController.php';
27
+
28
+ class Cdev_XPaymentsConnector_Adminhtml_Sales_Order_CreateController extends Mage_Adminhtml_Sales_Order_CreateController
29
+ {
30
+ /**
31
+ * Check if pay for order is allowed for user
32
+ *
33
+ * @return bool
34
+ */
35
+ protected function _isAllowed()
36
+ {
37
+ return Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/pay_orders');
38
+ }
39
+
40
+ /**
41
+ * Saving quote and create order
42
+ *
43
+ * @return void
44
+ */
45
+ public function saveAction()
46
+ {
47
+ parent::saveAction();
48
+
49
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
50
+ $incrementId = $quote->getData('reserved_order_id');
51
+ $order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
52
+
53
+ $payment = $this->getRequest()->getPost('payment');
54
+
55
+ if (
56
+ isset($payment['method'])
57
+ && $order->getId()
58
+ ) {
59
+ if (Mage::helper('settings_xpc')->isXpcMethod($payment['method'], false)) {
60
+
61
+ // Redirect user to the payment page
62
+ $this->_redirect('adminhtml/sales_order_payment/pay', array('order_id' => $order->getId()));
63
+
64
+ } elseif (Mage::helper('settings_xpc')->isSavedCardsMethod($payment['method'])) {
65
+
66
+ // Process payment by saved card
67
+ // Redirect to the different controller to process the recharge action
68
+
69
+ $params = array(
70
+ 'order_id' => $order->getId(),
71
+ 'card_id' => $payment['xp_payment_card'],
72
+ );
73
+
74
+ $this->_redirect('adminhtml/sales_order_payment/recharge', $params);
75
+ }
76
+ }
77
+ }
78
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/FraudController.php DELETED
@@ -1,92 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
-
22
- /**
23
- *
24
- * Class Mage_Adminhtml_Sales_OrderController
25
- */
26
- class Cdev_XPaymentsConnector_Adminhtml_Sales_Order_FraudController extends Mage_Adminhtml_Controller_Action
27
- {
28
-
29
- public function acceptAction()
30
- {
31
-
32
- if ($order = $this->_initOrder()) {
33
-
34
- $xpcTxnid = $order->getXpcTxnid();
35
- if(!empty($xpcTxnid)){
36
- $xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
37
- $result = $xpaymentCCModel->sendFraudRequest($xpcTxnid,'accept');
38
-
39
- if ($result) {
40
- // TODO: Make sure for authorized payments the correct status is set
41
- $order->setStatus(Cdev_XPaymentsConnector_Helper_Data::STATUS_CHARGED);
42
- $order->save();
43
- }
44
- }
45
-
46
-
47
- $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
48
- }
49
- }
50
-
51
- public function declineAction()
52
- {
53
-
54
- if ($order = $this->_initOrder()) {
55
- $xpcTxnid = $order->getXpcTxnid();
56
- if(!empty($xpcTxnid)){
57
- $xpaymentCCModel = Mage::getModel('xpaymentsconnector/payment_cc');
58
- $result = $xpaymentCCModel->sendFraudRequest($xpcTxnid,'decline');
59
-
60
- if ($result) {
61
- $order->cancel();
62
- $order->save();
63
- }
64
- }
65
-
66
- $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
67
- }
68
- }
69
-
70
-
71
- /**
72
- * Initialize order model instance
73
- *
74
- * @return Mage_Sales_Model_Order || false
75
- */
76
- protected function _initOrder()
77
- {
78
- $id = $this->getRequest()->getParam('order_id');
79
- $order = Mage::getModel('sales/order')->load($id);
80
-
81
- if (!$order->getId()) {
82
- $this->_getSession()->addError($this->__('This order no longer exists.'));
83
- $this->_redirect('*/*/');
84
- $this->setFlag('', self::FLAG_NO_DISPATCH, true);
85
- return false;
86
- }
87
- Mage::register('sales_order', $order);
88
- Mage::register('current_order', $order);
89
- return $order;
90
- }
91
-
92
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Sales/Order/PaymentController.php ADDED
@@ -0,0 +1,370 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ *
25
+ * Class Mage_Adminhtml_Sales_OrderController
26
+ */
27
+ class Cdev_XPaymentsConnector_Adminhtml_Sales_Order_PaymentController extends Mage_Adminhtml_Controller_Action
28
+ {
29
+ /**
30
+ * Check if pay for order is allowed for user
31
+ *
32
+ * @return bool
33
+ */
34
+ protected function _isAllowed()
35
+ {
36
+ return Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/pay_orders');
37
+ }
38
+
39
+ /**
40
+ * Validate Form Key
41
+ *
42
+ * @return bool
43
+ */
44
+ protected function _validateFormKey()
45
+ {
46
+ $result = parent::_validateFormKey();
47
+
48
+ if ($this->getRequest()->getParam('action') == 'return') {
49
+
50
+ // This is necessary to allow POST request on return, which doesn't contain form key
51
+ $result = true;
52
+ }
53
+
54
+ return $result;
55
+ }
56
+
57
+ /**
58
+ * Pay action
59
+ *
60
+ * @return void
61
+ */
62
+ public function payAction()
63
+ {
64
+ try {
65
+
66
+ $order = $this->getOrder();
67
+
68
+ if (!$order) {
69
+ throw new Exception('Invalid order');
70
+ }
71
+
72
+ $paymentMethod = $order->getPayment()->getMethodInstance();
73
+
74
+ $helper = Mage::helper('xpaymentsconnector');
75
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
76
+ ->setXpcSlot($paymentMethod->getXpcSlot());
77
+
78
+ // For some reason quote is empty here. But we actually need only its ID.
79
+ // All the necessary data is taken from the quote XPC data
80
+ $quote->setEntityId($order->getQuoteId());
81
+
82
+ $quote->getXpcData()->setData('backend_orderid', $order->getIncrementId())->save();
83
+
84
+ if (!$paymentMethod->prepareToken($quote)) {
85
+ throw new Exception('Unable to obtain payment token');
86
+ }
87
+
88
+ $fields = $paymentMethod->getFormFields($quote);
89
+
90
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_sales_order_pay');
91
+
92
+ $block->setFields($fields);
93
+
94
+ echo $block->toHtml();
95
+ exit;
96
+
97
+ } catch (Exception $e) {
98
+
99
+ $this->_getSession()->addError($this->__($e->getMessage()));
100
+
101
+ $this->_redirect('*/sales_order/view', array('order_id' => $this->getRequest()->getParam('order_id')));
102
+ }
103
+ }
104
+
105
+ /**
106
+ * Return action
107
+ *
108
+ * @return void
109
+ */
110
+ public function returnAction()
111
+ {
112
+ try {
113
+
114
+ $order = $this->getOrder();
115
+
116
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING) {
117
+
118
+ $this->_getSession()->addSuccess('Order was paid');
119
+
120
+ } else {
121
+
122
+ $this->_getSession()->addError('Order was not paid');
123
+ }
124
+
125
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
126
+
127
+ } catch (Exception $e) {
128
+
129
+ $this->_getSession()->addError($this->__($e->getMessage()));
130
+ $this->_redirect('*/*/');
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Process X-Payments response and redirect
136
+ *
137
+ * @param Cdev_XPaymentsConnector_Transport_ApiResponse $response X-Payments response
138
+ * @param string $successMessage Default success message
139
+ * @param string $errorMessage Default error message
140
+ *
141
+ * @return void
142
+ */
143
+ private function processResponseAndRedirect(Cdev_XPaymentsConnector_Transport_ApiResponse $response, $successMessage, $errorMessage)
144
+ {
145
+ if ($response->getStatus()) {
146
+
147
+ $message = $response->getMessage($successMessage);
148
+
149
+ $this->_getSession()->addSuccess($this->__($message));
150
+
151
+ } else {
152
+
153
+ $message = $response->getErrorMessage($errorMessage);
154
+
155
+ throw new Exception($message);
156
+ }
157
+
158
+ $this->_redirect('*/sales_order/view', array('order_id' => $this->getOrder()->getId()));
159
+ }
160
+
161
+ /**
162
+ * Secondary action (capture, void, refund)
163
+ *
164
+ * @return void
165
+ */
166
+ public function secondaryAction()
167
+ {
168
+ try {
169
+
170
+ // Model is not necessary to perform the action
171
+ // But we need to validate it
172
+ $order = $this->getOrder();
173
+
174
+ $api = Mage::helper('api_xpc');
175
+
176
+ $txnId = $this->getRequest()->getParam('xpc_txnid');
177
+ $action = $this->getRequest()->getParam('xpc_action');
178
+ $amount = $this->getRequest()->getParam('transaction_amount');
179
+
180
+ switch ($action) {
181
+
182
+ case 'refund':
183
+ $response = $api->requestPaymentRefund($txnId, $amount);
184
+ break;
185
+
186
+ case 'capture':
187
+ $response = $api->requestPaymentCapture($txnId, $amount);
188
+ break;
189
+
190
+ case 'void':
191
+ $response = $api->requestPaymentVoid($txnId, $amount);
192
+ break;
193
+
194
+ default:
195
+ throw new Exception('Incorrect action');
196
+ break;
197
+ }
198
+
199
+ $this->processResponseAndRedirect(
200
+ $response,
201
+ 'Operation successful',
202
+ 'Operation failed'
203
+ );
204
+
205
+ } catch (Exception $e) {
206
+
207
+ $this->_getSession()->addError($this->__($e->getMessage()));
208
+
209
+ if ($order) {
210
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
211
+ } else {
212
+ $this->_redirect('*/*/');
213
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
214
+ }
215
+ }
216
+ }
217
+
218
+ /**
219
+ * Accept action
220
+ *
221
+ * @return void
222
+ */
223
+ public function acceptAction()
224
+ {
225
+ try {
226
+
227
+ $order = $this->getOrder();
228
+
229
+ $response = Mage::helper('api_xpc')->requestPaymentAccept($order->getData('xpc_txnid'));
230
+
231
+ $this->processResponseAndRedirect(
232
+ $response,
233
+ 'Transaction accepted',
234
+ 'Transaction was not accepted'
235
+ );
236
+
237
+ } catch (Exception $e) {
238
+
239
+ $this->_getSession()->addError($this->__($e->getMessage()));
240
+
241
+ if ($order) {
242
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
243
+ } else {
244
+ $this->_redirect('*/*/');
245
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
246
+ }
247
+ }
248
+ }
249
+
250
+ /**
251
+ * Decline action
252
+ *
253
+ * @return void
254
+ */
255
+ public function declineAction()
256
+ {
257
+ try {
258
+
259
+ $order = $this->getOrder();
260
+
261
+ $response = Mage::helper('api_xpc')->requestPaymentDecline($order->getData('xpc_txnid'));
262
+
263
+ $this->processResponseAndRedirect(
264
+ $response,
265
+ 'Transaction declined',
266
+ 'Transaction was not declined'
267
+ );
268
+
269
+ } catch (Exception $e) {
270
+
271
+ $this->_getSession()->addError($this->__($e->getMessage()));
272
+
273
+ if ($order) {
274
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
275
+ } else {
276
+ $this->_redirect('*/*/');
277
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
278
+ }
279
+ }
280
+ }
281
+
282
+ /**
283
+ * Recharge action (for saved card payment)
284
+ *
285
+ * @return void
286
+ */
287
+ public function rechargeAction()
288
+ {
289
+ try {
290
+
291
+ $helper = Mage::helper('xpaymentsconnector');
292
+
293
+ $order = $this->getOrder();
294
+
295
+ $cardData = Mage::getModel('xpaymentsconnector/usercards')->load(
296
+ $this->getRequest()->getParam('card_id')
297
+ )->getData();
298
+
299
+ $helper->saveMaskedCardToOrder($order, $cardData);
300
+ $order->setData('xpc_txnid', $cardData['txnId'])->save();
301
+
302
+ $paymentMethod = $order->getPayment()->getMethodInstance();
303
+
304
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
305
+ ->setXpcSlot($paymentMethod->getXpcSlot());
306
+
307
+ // For some reason quote is empty here. But we actually need only its ID.
308
+ // All the necessary data is taken from the quote XPC data
309
+ $quote->setEntityId($order->getQuoteId());
310
+
311
+ $quote->getXpcData()->setData('backend_orderid', $order->getIncrementId())->save();
312
+
313
+ $response = $paymentMethod->processPayment($quote);
314
+
315
+ $this->processResponseAndRedirect(
316
+ $response,
317
+ 'Order was paid',
318
+ 'Order was not paid'
319
+ );
320
+
321
+ } catch (Exception $e) {
322
+
323
+ $this->_getSession()->addError($this->__($e->getMessage()));
324
+
325
+ if ($order) {
326
+ $this->_redirect('*/sales_order/view', array('order_id' => $order->getId()));
327
+ } else {
328
+ $this->_redirect('*/*/');
329
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
330
+ }
331
+ }
332
+ }
333
+
334
+ /**
335
+ * Initialize order model instance
336
+ *
337
+ * @return Mage_Sales_Model_Order
338
+ */
339
+ private function getOrder()
340
+ {
341
+ $order = Mage::getModel('sales/order')->load(
342
+ $this->getRequest()->getParam('order_id')
343
+ );
344
+
345
+ if (!$order->getEntityId()) {
346
+
347
+ if ($this->getRequest()->getParam('refId')) {
348
+
349
+ $order = Mage::getModel('sales/order')->loadByIncrementId(
350
+ $this->getRequest()->getParam('refId')
351
+ );
352
+
353
+ } elseif ($this->getRequest()->getParam('txnId')) {
354
+
355
+ $order = Mage::helper('xpaymentsconnector')
356
+ ->getOrderByTxnId($this->getRequest()->getParam('txnId'));
357
+ }
358
+ }
359
+
360
+ if (!$order->getEntityId()) {
361
+ throw new Exception('This order no longer exists.'); // This ugly message exists in Magento core
362
+ }
363
+
364
+ if (!Mage::helper('settings_xpc')->isXpcMethod($order->getPayment()->getMethod())) {
365
+ throw new Exception('Payment method for this order is not X-Payments');
366
+ }
367
+
368
+ return $order;
369
+ }
370
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/Settings/XpcController.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -29,182 +29,650 @@
29
  */
30
  class Cdev_XPaymentsConnector_Adminhtml_Settings_XpcController extends Mage_Adminhtml_Controller_Action
31
  {
32
- const ERROR_TEXT = 'Conection failed. Please check the X-Payment Connector settings and try again. If all options is ok review your X-Payments settings and make sure you have properly defined shopping cart properties.';
 
 
 
 
 
 
 
 
 
33
 
34
  /**
35
- * Check connection with X-Payments via test request. Set the API version
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
36
  *
 
 
 
 
 
 
 
 
 
 
37
  * @return void
38
  */
39
- public function checkConnection()
40
  {
41
- $session = Mage::getSingleton('adminhtml/session');
42
 
43
- $model = Mage::getModel('xpaymentsconnector/payment_cc');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
  try {
46
 
47
- $result = $model->sendTestRequest();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
  } catch (Exception $e) {
50
 
51
- $result = false;
 
52
  }
53
 
54
- if ($result) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
55
 
56
- $text = Mage::helper('adminhtml')->__('Connection with X-Payments is OK. API version: ')
57
- . $model->getApiVersion();
 
58
 
59
- $session->addSuccess($text);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
60
 
61
  } else {
62
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
63
 
64
- $session->addError(
65
- Mage::helper('adminhtml')->__(self::ERROR_TEXT)
 
66
  );
 
 
 
 
67
  }
68
  }
69
 
70
  /**
71
- * General action
72
- *
 
 
73
  * @return void
74
  */
75
- public function indexAction()
76
  {
77
- $this->_title($this->__('System'))->_title($this->__('X-Payments Connector settings'));
78
 
79
- $this->loadLayout();
 
 
 
80
 
81
- $this->_setActiveMenu('system');
82
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'));
83
- $this->_addBreadcrumb(Mage::helper('adminhtml')->__('X-Payments connector control'), Mage::helper('adminhtml')->__('X-Payments Connector settings'));
84
 
85
- $this->checkConnection();
 
 
 
 
 
 
 
86
 
87
- $this->_initLayoutMessages('adminhtml/session');
 
 
 
88
 
89
- $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_settings_xpc');
90
- $this->_addContent($block);
 
 
91
 
92
- $this->renderLayout();
93
  }
94
 
95
  /**
96
- * Request and import payment configurations from X-Payments
97
- *
98
  * @return void
99
- * @access public
100
- * @see ____func_see____
101
- * @since 1.0.0
102
  */
103
- public function requestAction()
104
  {
105
- $session = Mage::getSingleton('adminhtml/session');
 
 
 
 
 
 
106
 
107
- $model = Mage::getModel('xpaymentsconnector/payment_cc');
108
 
109
- $this->deleteAllPaymentConfigurations();
110
- $store = Mage::app()->getStore(null)->getCode();
111
- Mage::getConfig()->saveConfig('stores/' . $store . '/payment/xpayments/active', 0);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
112
 
113
  try {
114
- $list = $model->requestPaymentMethods();
115
- if ($list) {
116
- foreach ($list as $data) {
117
- $pc = Mage::getModel('xpaymentsconnector/paymentconfiguration')->setData(
118
- array(
119
- 'confid' => $data['id'],
120
- 'name' => $data['name'],
121
- 'module' => $data['moduleName'],
122
- 'auth_exp' => $data['authCaptureInfo']['authExp'],
123
- 'capture_min' => $data['authCaptureInfo']['captMinLimit'],
124
- 'capture_max' => $data['authCaptureInfo']['captMaxLimit'],
125
- 'hash' => $data['settingsHash'],
126
- 'is_auth' => $data['transactionTypes']['auth'],
127
- 'is_capture' => $data['transactionTypes']['capture'],
128
- 'is_void' => $data['transactionTypes']['void'],
129
- 'is_refund' => $data['transactionTypes']['refund'],
130
- 'is_part_refund' => $data['transactionTypes']['refundPart'],
131
- 'is_accept' => $data['transactionTypes']['accept'],
132
- 'is_decline' => $data['transactionTypes']['decline'],
133
- 'is_get_info' => $data['transactionTypes']['getInfo'],
134
-
135
- )
136
- );
137
-
138
- $pc->save();
139
-
140
- }
141
-
142
- $session->addSuccess(Mage::helper('adminhtml')->__('Payment methods have been successfully imported.'));
143
-
144
- } elseif (is_array($list)) {
145
- $session->addError(Mage::helper('adminhtml')->__('There are no payment configurations for this store.'));
146
- } else {
147
- $session->addError(Mage::helper('adminhtml')->__('An error has occured during requesting payment methods from X-Payments. See log files for details.'));
148
  }
149
 
 
 
150
  } catch (Exception $e) {
151
- $session->addException($e, 'An error has occured during requesting payment methods from X-Payments. See log files for details.');
 
152
  }
153
 
154
  $this->_redirect('*/*/index');
155
  }
156
 
157
  /**
158
- * Clear imported payment configurations
159
- *
160
  * @return void
161
- * @access public
162
- * @see ____func_see____
163
- * @since 1.0.0
164
  */
165
- public function clearAction()
166
  {
167
- $this->deleteAllPaymentConfigurations();
168
- $store = Mage::app()->getStore(null)->getCode();
169
- Mage::getConfig()->saveConfig('stores/' . $store . '/payment/xpayments/active', 0);
170
 
171
- Mage::getSingleton('adminhtml/session')->addSuccess(
172
- Mage::helper('adminhtml')->__('The list of imported payment configurations has been cleared. X-Payments connector payment method has been disabled.')
173
- );
174
 
175
- $this->_redirect('*/*/index');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
176
  }
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
 
179
  /**
180
- * Delete all payment configurations
181
- *
182
  * @return void
183
- * @access protected
184
- * @see ____func_see____
185
- * @since 1.0.0
186
  */
 
 
 
 
 
 
 
 
 
 
187
 
188
- protected function deleteAllPaymentConfigurations()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
189
  {
190
- try {
191
- $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
192
- if ($list) {
193
- foreach ($list as $item) {
194
- $item->delete();
195
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196
  }
197
 
198
- } catch (Exception $e) {
199
- Mage::log(
200
- sprintf('Couldn\'t delete payment configuration. [%s]', var_export($item, true)),
201
- Zend_Log::ERR
 
202
  );
203
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
204
  }
205
 
206
- protected function _isAllowed()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  {
208
- return Mage::getSingleton('admin/session')->isAllowed('system/control');
 
 
209
  }
210
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
29
  */
30
  class Cdev_XPaymentsConnector_Adminhtml_Settings_XpcController extends Mage_Adminhtml_Controller_Action
31
  {
32
+ /**
33
+ * Some error messages
34
+ */
35
+ const ERROR_EMPTY_IMPORTED_METHODS = 'Payment methods import failed. Make sure you’ve activated your payment configurations and assigned them to this store in X-Payments dashboard.';
36
+ const ERROR_INVALID_BUNDLE = 'Invalid configuration bundle';
37
+
38
+ /**
39
+ * This is the remembered data about payment configurations during re-import
40
+ */
41
+ private $remember = array();
42
 
43
  /**
44
+ * Data POST-ed to the controller for update payment metods action
45
+ */
46
+ private $updateData = array();
47
+
48
+ /**
49
+ * Payment method data POST-ed to the controller for update payment metods action
50
+ */
51
+ private $methodData = array();
52
+
53
+ /**
54
+ * Here we count the active payment configurations during the update payment metods action.
55
+ * Value should not exceed Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS
56
+ */
57
+ private $activeCount = 0;
58
+
59
+ /**
60
+ * If at least one active payment configurations is configured to save cards
61
+ */
62
+ private $saveCardsActive = false;
63
+
64
+ /**
65
+ * Default data for payment configuration (e.g. just imported)
66
+ */
67
+ private $defaultPaymentData = array(
68
+ 'title' => 'Credit card (X-Payments)',
69
+ 'sort_order' => '0',
70
+ 'allowspecific' => '0',
71
+ 'specificcountry' => '',
72
+ 'use_authorize' => '0',
73
+ 'use_initialfee_authorize' => '0',
74
+ );
75
+
76
+ /**
77
+ * Check if X-Payments Connector configuration is allowed for user
78
  *
79
+ * @return bool
80
+ */
81
+ protected function _isAllowed()
82
+ {
83
+ return Mage::getSingleton('admin/session')->isAllowed('system/xpaymentsconnector/configuration');
84
+ }
85
+
86
+ /**
87
+ * General action
88
+ *
89
  * @return void
90
  */
91
+ public function indexAction()
92
  {
93
+ $this->_title($this->__('System'))->_title($this->__('X-Payments Connector settings'));
94
 
95
+ Mage::helper('settings_xpc')->setRecheckFlag();
96
+
97
+ $this->loadLayout();
98
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/adminhtml_settings_xpc');
99
+ $this->_addContent($block);
100
+
101
+ $this->renderLayout();
102
+ }
103
+
104
+ /**
105
+ * Deploy configuration bundle action
106
+ * Auto (re)import payment methods
107
+ *
108
+ * @return void
109
+ */
110
+ public function deployAction()
111
+ {
112
+ $redirect = '*/*/index';
113
 
114
  try {
115
 
116
+ $settings = Mage::helper('settings_xpc');
117
+
118
+ $settings->setXpcConfig('xpay_conf_bundle', '');
119
+ $settings->setXpcConfig('xpay_api_version', '');
120
+
121
+ $bundle = Mage::app()->getRequest()->getParam('bundle');
122
+ $bundle = strval($bundle);
123
+
124
+ // Check submitted bundle
125
+ if (empty($settings->decodeBundle($bundle))) {
126
+ $settings->setXpcConfig('xpay_is_configured', false, true);
127
+ throw new Exception(self::ERROR_INVALID_BUNDLE);
128
+ }
129
+
130
+ // Save bundle and reload config
131
+ $settings->setXpcBundle($bundle);
132
+
133
+ // Force recheck configuration
134
+ $settings->setRecheckFlag();
135
+
136
+ if ($settings->isConfigured()) {
137
+ $this->importPaymentMethods();
138
+ $this->autoActivateZeroAuth();
139
+ $this->addSuccessTopMessage('Configuration bundle has been deployed successfully');
140
+ } else {
141
+ $redirect = '*/*/index/tab/connection';
142
+ }
143
+
144
 
145
  } catch (Exception $e) {
146
 
147
+ $this->addErrorTopMessage($e->getMessage());
148
+ $redirect = '*/*/index/tab/connection';
149
  }
150
 
151
+ $this->_redirect($redirect);
152
+ }
153
+
154
+ /**
155
+ * Update settings action
156
+ *
157
+ * @return void
158
+ */
159
+ public function updateAction()
160
+ {
161
+ $helper = Mage::helper('settings_xpc');
162
+
163
+ // Save IP address
164
+ $ip = strval(Mage::app()->getRequest()->getParam('ip_address'));
165
+ $helper->setXpcConfig('xpay_allowed_ip_addresses', $ip);
166
 
167
+ // Save use iframe
168
+ $useIframe = (bool)Mage::app()->getRequest()->getParam('use_iframe');
169
+ $helper->setXpcConfig('xpay_use_iframe', $useIframe);
170
 
171
+ // Save iframe place
172
+ $iframePlace = Mage::app()->getRequest()->getParam('iframe_place');
173
+ if (in_array($iframePlace, array('payment', 'review'))) {
174
+ $helper->setXpcConfig('xpay_iframe_place', $iframePlace);
175
+ }
176
+
177
+ // Save force HTTP option
178
+ $forceHttp = (bool)Mage::app()->getRequest()->getParam('force_http');
179
+ $helper->setXpcConfig('xpay_force_http', $forceHttp);
180
+
181
+ $this->_redirect('*/*/index/tab/connection');
182
+ }
183
+
184
+ /**
185
+ * Set value for the Active param
186
+ *
187
+ * @param Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf Payment configuration
188
+ *
189
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
190
+ */
191
+ private function setActiveParamValue(Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf)
192
+ {
193
+ $confId = $paymentConf->getConfid();
194
+
195
+ if (
196
+ !isset($this->updateData['active'][$confId])
197
+ || 'Y' != $this->updateData['active'][$confId]
198
+ || $this->activeCount > Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS
199
+ ) {
200
+ $active = 'N';
201
+ } else {
202
+ $active = 'Y';
203
+ $this->activeCount++;
204
+ }
205
+
206
+ return $paymentConf->setActive($active);
207
+ }
208
+
209
+ /**
210
+ * Set value for the Save cards param
211
+ *
212
+ * @param Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf Payment configuration
213
+ *
214
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
215
+ */
216
+ private function setSaveCardsParamValue(Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf)
217
+ {
218
+ $confId = $paymentConf->getConfid();
219
+
220
+ if (
221
+ !isset($this->updateData['savecard'][$confId])
222
+ || 'Y' != $this->updateData['savecard'][$confId]
223
+ || 'Y' != $paymentConf->getCanSaveCards()
224
+ ) {
225
+ $saveCards = 'N';
226
+ } else {
227
+ $saveCards = 'Y';
228
+ if ($paymentConf->getActive() == 'Y') {
229
+ $this->saveCardsActive = true;
230
+ }
231
+ }
232
+
233
+ return $paymentConf->setSaveCards($saveCards);
234
+ }
235
+
236
+ /**
237
+ * Get default payment method data
238
+ *
239
+ * @param mixed $paymentConf Payment configuration
240
+ *
241
+ * @return array
242
+ */
243
+ private function getDefaultPaymentData($paymentConf = null)
244
+ {
245
+ $result = $this->defaultPaymentData;
246
+
247
+ if ($paymentConf instanceof Cdev_XPaymentsConnector_Model_Paymentconfiguration) {
248
+
249
+ $result['title'] = 'Credit card (' . $paymentConf->getData('name') . ')';
250
+
251
+ } elseif (
252
+ is_array($paymentConf)
253
+ && !empty($paymentConf['name'])
254
+ ) {
255
+
256
+ $result['title'] = 'Credit card (' . $paymentConf['name'] . ')';
257
+ }
258
+
259
+ return $result;
260
+ }
261
+
262
+ /**
263
+ * Set value for the payment method data param
264
+ *
265
+ * @param Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf Payment configuration
266
+ *
267
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
268
+ */
269
+ private function setPaymentMethodDataParamValue(Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf)
270
+ {
271
+ $confId = $paymentConf->getConfid();
272
+
273
+ if (isset($this->methodData[$confId])) {
274
+
275
+ $pmd = $this->methodData[$confId];
276
+
277
+ if (
278
+ isset($pmd['specificcountry'])
279
+ && is_array($pmd['specificcountry'])
280
+ && $pmd['allowspecific']
281
+ ) {
282
+ $pmd['specificcountry'] = implode(',', $pmd['specificcountry']);
283
+ } else {
284
+ $pmd['specificcountry'] = '';
285
+ }
286
 
287
  } else {
288
 
289
+ $pmd = $this->getDefaultPaymentData($paymentConf);
290
+ }
291
+
292
+ return $paymentConf->setPaymentMethodData(serialize($pmd));
293
+ }
294
+
295
+ /**
296
+ * Process data for payment method associated with the payment configuration
297
+ *
298
+ * @param Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf Payment configuration
299
+ *
300
+ * @return void
301
+ */
302
+ private function processPaymentConfMethod(Cdev_XPaymentsConnector_Model_Paymentconfiguration $paymentConf)
303
+ {
304
+ if ('Y' == $paymentConf->getActive()) {
305
+
306
+ $confId = $paymentConf->getConfid();
307
+ $data = unserialize($paymentConf->getPaymentMethodData());
308
 
309
+ $data += array(
310
+ 'confid' => $confId,
311
+ 'active' => 1,
312
  );
313
+
314
+ foreach ($data as $name => $value) {
315
+ Mage::helper('settings_xpc')->setPaymentConfig($name, $value, $this->activeCount);
316
+ }
317
  }
318
  }
319
 
320
  /**
321
+ * Deactivate unused or "extra" payment methods, including the "Saved cards" one
322
+ *
323
+ * @param int $startId Slot index of the XPC payment method to start with
324
+ *
325
  * @return void
326
  */
327
+ private function deactivatePaymentMethods($startSlot = 1)
328
  {
329
+ $settings = Mage::helper('settings_xpc');
330
 
331
+ // Deactivate
332
+ for ($xpcSlot = $startSlot; $xpcSlot <= Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS; $xpcSlot++) {
333
+ $settings->setPaymentConfig('active', 0, $xpcSlot);
334
+ }
335
 
336
+ // Deactivate "Saved cards" payment method
337
+ $settings->setSavedCardsConfig('active', false);
338
+ }
339
 
340
+ /**
341
+ * Process data for "Saved cards" payment method
342
+ *
343
+ * @return void
344
+ */
345
+ private function processSavedCardsMethod()
346
+ {
347
+ $settings = Mage::helper('settings_xpc');
348
 
349
+ $settings->setSavedCardsConfig(
350
+ 'title',
351
+ Mage::app()->getRequest()->getParam('savedcards_title')
352
+ );
353
 
354
+ $settings->setSavedCardsConfig(
355
+ 'sort_order',
356
+ Mage::app()->getRequest()->getParam('savedcards_sort_order')
357
+ );
358
 
359
+ $settings->setSavedCardsConfig('active', $this->saveCardsActive);
360
  }
361
 
362
  /**
363
+ * Subaction (mode) to update the payment methods
364
+ *
365
  * @return void
 
 
 
366
  */
367
+ private function updatePaymentMethods()
368
  {
369
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
370
+
371
+ $this->saveCardsActive = false;
372
+ $this->activeCount = 0;
373
+
374
+ $this->updateData = Mage::app()->getRequest()->getParam('payment_methods');
375
+ $this->methodData = Mage::app()->getRequest()->getParam('payment_method_data');
376
 
377
+ foreach ($list as $paymentConf) {
378
 
379
+ // Save data for payment configuration
380
+ $this->setActiveParamValue($paymentConf);
381
+ $this->setSaveCardsParamValue($paymentConf);
382
+ $this->setPaymentMethodDataParamValue($paymentConf);
383
+ $paymentConf->save();
384
+
385
+ // Update payment method
386
+ $this->processPaymentConfMethod($paymentConf);
387
+ }
388
+
389
+ // Deactivate "extra" payment methods
390
+ $this->deactivatePaymentMethods($this->activeCount + 1);
391
+
392
+ // Update saved cards payment method
393
+ $this->processSavedCardsMethod();
394
+ }
395
+
396
+ /**
397
+ * Update payment methods action
398
+ *
399
+ * @return void
400
+ */
401
+ public function paymentmethodsAction()
402
+ {
403
+ $mode = Mage::app()->getRequest()->getParam('mode');
404
 
405
  try {
406
+
407
+ if ('update' == $mode) {
408
+
409
+ $this->updatePaymentMethods();
410
+ $this->addSuccessTopMessage('Payment methods updated successfully');
411
+
412
+ } elseif ('import' == $mode) {
413
+
414
+ $this->importPaymentMethods();
415
+ $this->addSuccessTopMessage('Payment methods import successful');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
416
  }
417
 
418
+ $this->autoActivateZeroAuth();
419
+
420
  } catch (Exception $e) {
421
+
422
+ $this->addSuccessTopMessage($e->getMessage());
423
  }
424
 
425
  $this->_redirect('*/*/index');
426
  }
427
 
428
  /**
429
+ * Update zero auth action
430
+ *
431
  * @return void
 
 
 
432
  */
433
+ public function zeroauthAction()
434
  {
435
+ $settings = Mage::helper('settings_xpc');
 
 
436
 
437
+ $result = false;
 
 
438
 
439
+ // Save configuration ID
440
+ $confid = Mage::app()->getRequest()->getParam('zero_auth_confid');
441
+ $settings->setXpcConfig('xpay_zero_auth_confid', $confid);
442
+
443
+ // Save description
444
+ $description = strval(Mage::app()->getRequest()->getParam('zero_auth_description'));
445
+ if ($description) {
446
+ $settings->setXpcConfig('xpay_zero_auth_description', $description);
447
+ $result = true;
448
+ }
449
+
450
+ // Save amount
451
+ $amount = Mage::app()->getRequest()->getParam('zero_auth_amount');
452
+ if (is_numeric($amount)) {
453
+ $amount = round($amount, 2);
454
+ $settings->setXpcConfig('xpay_zero_auth_amount', $amount);
455
+ $result = true;
456
+ }
457
+
458
+ if ($result) {
459
+ $this->addSuccessTopMessage('Settings updated');
460
+ } else {
461
+ $this->addErrorTopMessage('Settings not updated');
462
+ }
463
+
464
+ $this->_redirect('*/*/index/tab/zero_auth');
465
  }
466
 
467
+ /**
468
+ * Clear ipmorted payment methods
469
+ *
470
+ * @return void
471
+ */
472
+ private function clearPaymentMethods()
473
+ {
474
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
475
+
476
+ if ($list) {
477
+ foreach ($list as $pc) {
478
+
479
+ $this->remember[$pc->getConfid()] = array(
480
+ 'name' => $pc->getName(),
481
+ 'module' => $pc->getModule(),
482
+ 'hash' => $pc->getHash(),
483
+ 'save_cards' => $pc->getSaveCards(),
484
+ 'active' => $pc->getActive(),
485
+ 'data' => $pc->getPaymentMethodData(),
486
+ );
487
+
488
+ $pc->delete();
489
+ }
490
+ }
491
+
492
+ // Deactivate all payment methods
493
+ $this->deactivatePaymentMethods();
494
+ }
495
 
496
  /**
497
+ * Import payment methods
498
+ *
499
  * @return void
 
 
 
500
  */
501
+ private function importPaymentMethods()
502
+ {
503
+ $settings = Mage::helper('settings_xpc');
504
+
505
+ // Clear existing payment configurations, but save their data.
506
+ // Disable all X-Payments payment methods including the "Saved cards" one.
507
+ $this->clearPaymentMethods();
508
+
509
+ // Obtain payment methods from X-Payments
510
+ $list = Mage::helper('api_xpc')->requestPaymentMethods();
511
 
512
+ if (empty($list)) {
513
+ throw new Exception(self::ERROR_EMPTY_IMPORTED_METHODS);
514
+ }
515
+
516
+ foreach ($list as $data) {
517
+
518
+ $paymentConfigurationData = $this->fillPaymentConfigurationData($data);
519
+
520
+ // Save payment configuration data
521
+ Mage::getModel('xpaymentsconnector/paymentconfiguration')
522
+ ->setData($paymentConfigurationData)
523
+ ->save();
524
+
525
+ // Re-active payment method if it was active before re-import
526
+ if ('Y' == $paymentConfigurationData['active']) {
527
+
528
+ try {
529
+
530
+ $xpcSlot = $settings->getXpcSlotByConfid($data['id']);
531
+ $settings->setPaymentConfig('active', true, $xpcSlot);
532
+
533
+ } catch (Exception $e) {
534
+
535
+ // Just in case.
536
+ // This payment configuration is not associated with payment method.
537
+ }
538
+ }
539
+ }
540
+ }
541
+
542
+ /**
543
+ * Fill payment configuration data
544
+ *
545
+ * @param array $data Payment configuration data passed from X-Payments
546
+ *
547
+ * @return array
548
+ */
549
+ private function fillPaymentConfigurationData($data)
550
  {
551
+ $confId = $data['id'];
552
+
553
+ $pcData = array(
554
+ 'confid' => $confId,
555
+ 'name' => $data['name'],
556
+ 'module' => $data['moduleName'],
557
+ 'auth_exp' => $data['authCaptureInfo']['authExp'],
558
+ 'capture_min' => $data['authCaptureInfo']['captMinLimit'],
559
+ 'capture_max' => $data['authCaptureInfo']['captMaxLimit'],
560
+ 'hash' => $data['settingsHash'],
561
+ 'is_auth' => $data['transactionTypes']['auth'],
562
+ 'is_capture' => $data['transactionTypes']['capture'],
563
+ 'is_void' => $data['transactionTypes']['void'],
564
+ 'is_refund' => $data['transactionTypes']['refund'],
565
+ 'is_part_refund' => $data['transactionTypes']['refundPart'],
566
+ 'is_accept' => $data['transactionTypes']['accept'],
567
+ 'is_decline' => $data['transactionTypes']['decline'],
568
+ 'is_get_info' => $data['transactionTypes']['getInfo'],
569
+ 'can_save_cards' => $data['canSaveCards'],
570
+ 'save_cards' => $data['canSaveCards'], // Auto-enable recharges if possible
571
+ 'currency' => $data['currency'],
572
+ 'active' => 0,
573
+ 'payment_method_data' => serialize($this->getDefaultPaymentData($data)),
574
+ );
575
+
576
+ if (isset($this->remember[$confId])) {
577
+
578
+ $remember = $this->remember[$confId];
579
+
580
+ if (
581
+ $remember['name'] == $pcData['name']
582
+ || $remember['module'] == $pcData['module']
583
+ || $remember['hash'] == $pcData['hash']
584
+ ) {
585
+
586
+ // Restore save cards flag
587
+ $pcData['save_cards'] = $remember['save_cards'];
588
+
589
+ // Resore active flag
590
+ $pcData['active'] = $remember['active'];
591
+
592
+ // Resore payment method data
593
+ $pcData['payment_method_data'] = $remember['data'];
594
+
595
+ // Remembered data matches the imported one
596
+ $this->remember[$confId]['match'] = true;
597
+
598
+ } else {
599
+
600
+ // Remembered data doesn't match the imported one
601
+ $this->remember[$confId]['match'] = false;
602
  }
603
 
604
+ } else {
605
+
606
+ // This is a new/unknown payment configuration
607
+ $this->remember[$confId] = array(
608
+ 'match' => false,
609
  );
610
  }
611
+
612
+ return $pcData;
613
+ }
614
+
615
+ /**
616
+ * Automaticaly activate zero-auth if necessary
617
+ *
618
+ * @return void
619
+ */
620
+ private function autoActivateZeroAuth()
621
+ {
622
+ $settings = Mage::helper('settings_xpc');
623
+
624
+ if ($settings->isZeroAuthMethodDisabled()) {
625
+ return;
626
+ }
627
+
628
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
629
+
630
+ $zeroAuthConfId = false;
631
+
632
+ // Search for payment configuration suitable for zero auth
633
+ foreach ($list as $paymentConf) {
634
+
635
+ if (
636
+ 'Y' == $paymentConf->getData('active')
637
+ && 'Y' == $paymentConf->getData('save_cards')
638
+ ) {
639
+ $zeroAuthConfId = $paymentConf->getData('confid');
640
+ break;
641
+ }
642
+ }
643
+
644
+ // Auto enable zero auth
645
+ if ($zeroAuthConfId) {
646
+ $settings->setXpcConfig('xpay_zero_auth_confid', $zeroAuthConfId);
647
+ }
648
+
649
  }
650
 
651
+ /**
652
+ * Add success message to session
653
+ *
654
+ * @param string $message Message
655
+ *
656
+ * @return void
657
+ */
658
+ private function addSuccessTopMessage($message)
659
+ {
660
+ Mage::getSingleton('adminhtml/session')->addSuccess(
661
+ $this->__($message)
662
+ );
663
+ }
664
+
665
+ /**
666
+ * Add success message to session
667
+ *
668
+ * @param string $message Message
669
+ *
670
+ * @return void
671
+ */
672
+ private function addErrorTopMessage($message)
673
  {
674
+ Mage::getSingleton('adminhtml/session')->addError(
675
+ $this->__($message)
676
+ );
677
  }
678
  }
app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php CHANGED
@@ -13,169 +13,223 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
- * Customer account controller
25
  */
26
 
27
  class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Front_Action
28
  {
29
-
30
  /**
31
  * Check customer authentication
 
 
32
  */
33
  public function preDispatch()
34
  {
35
  parent::preDispatch();
36
- $action = $this->getRequest()->getActionName();
37
  $loginUrl = Mage::helper('customer')->getLoginUrl();
38
 
39
  if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
40
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
41
  }
 
 
42
  }
43
 
44
  /**
45
- * Display downloadable links bought by customer
46
  *
 
47
  */
48
  public function usercardsAction()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
49
  {
50
  $request = $this->getRequest()->getPost();
51
 
52
- if (
53
- !empty($request)
54
- && !empty($request['action'])
55
- && 'remove' == $request['action']
56
- ) {
57
- if (
58
- isset($request['card'])
59
- && count($request['card']) > 0
60
- ) {
61
 
62
- $itemCollection = Mage::getModel('xpaymentsconnector/usercards')
63
- ->getCollection()
64
- ->addFieldToFilter('xp_card_id', array('in' => $request['card']));
65
 
66
- foreach ($itemCollection as $item) {
 
 
67
 
68
- if ($item->getUsageType() == Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD) {
69
 
70
- $recurringProfile = Mage::getModel('sales/recurring_profile')->load($item->getData('txnId'), 'reference_id');
71
 
72
- if ($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE) {
73
 
74
- $errorMessage = Mage::helper('xpaymentsconnector')->__(
75
- 'You can\'t delete %s card. Because this is recurring card and this recurring(s) is still active.',
76
- $item->getXpCardId()
77
- );
78
 
79
- Mage::getSingleton('customer/session')->addError($errorMessage);
 
 
 
 
 
80
 
81
- continue;
82
- }
83
- }
84
 
85
- $item->delete();
86
- }
 
87
 
88
- $message = $this->__('Credit cards have been removed successfully.');
89
- Mage::getSingleton('customer/session')->addSuccess($message);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
90
 
91
  } else {
92
 
93
- $message = $this->__('You have not selected any credit card.');
94
- Mage::getSingleton('customer/session')->addError($message);
 
 
 
 
 
 
95
  }
96
- }
97
 
 
98
 
99
- $this->loadLayout();
100
- $this->_initLayoutMessages('customer/session');
101
- if ($block = $this->getLayout()->getBlock('xpaymentsconnector_customer_usercards')) {
102
- $block->setRefererUrl($this->_getRefererUrl());
103
- }
104
- $headBlock = $this->getLayout()->getBlock('head');
105
- if ($headBlock) {
106
- $headBlock->setTitle(Mage::helper('xpaymentsconnector')->__('My Payment Cards'));
107
  }
108
- $this->renderLayout();
109
  }
110
 
 
 
 
 
 
 
 
 
 
 
111
 
112
- public function cardaddAction(){
 
113
 
114
- $customer = Mage::getSingleton('customer/session')->getCustomer();
115
- if ($customer) {
116
- if (empty($customer->getDefaultBillingAddress()))
117
- Mage::getSingleton("core/session")->addError("Please specify billing address for this credit card.");
118
  }
119
 
120
- $isPostResponse = $this->getRequest()->isPost();
121
- if($isPostResponse){
122
- // Check request data
123
- $request = $this->getRequest()->getPost();
124
 
125
- if (empty($request)) {
126
- Mage::throwException('Request doesn\'t contain POST elements.');
127
- }
 
 
 
 
 
 
128
 
129
- // check txn id
130
- if (empty($request['txnId'])) {
131
- Mage::throwException('Missing or invalid transaction ID');
132
- }
 
133
 
 
134
 
135
- $CCPaymentModel = Mage::getModel('xpaymentsconnector/payment_cc');
136
- $transactionStatusLabel = $CCPaymentModel->getTransactionStatusLabels();
137
- $resultMessage = '';
138
 
139
- list($status, $response) = $CCPaymentModel->requestPaymentInfo($request['txnId']);
140
 
141
- if (
142
- !$status
143
- || !in_array($response['status'], array($CCPaymentModel::AUTH_STATUS, $CCPaymentModel::CHARGED_STATUS))
144
- ) {
145
- if (!empty($response['advinfo']['Message'])) {
146
- $errorMessage = $this->__('%s New card has not been saved.', $response['advinfo']['Message']);
147
- } elseif (isset($transactionStatusLabel[$response['status']])) {
148
- $errorMessage = $this->__("Transaction status is '%s'. New card has not been saved.", $transactionStatusLabel[$response['status']]);
149
- } else {
150
- $errorMessage = $this->__('%s New card has not been saved.', $response['error_message']);
151
- }
152
 
153
- Mage::getSingleton('customer/session')->addError($errorMessage);
154
- $resultMessage = 'Card authorization has been cancelled.';
155
- }else{
156
- $resultMessage = $this->__('Payment card has been added successfully!');
157
 
158
- Mage::getSingleton('customer/session')->addSuccess( $this->__("You created new card. Transaction status is '%s'.", $transactionStatusLabel[$response['status']]));
159
- }
 
160
 
161
- $this->getResponse()->setBody(
162
- $this->getLayout()
163
- ->createBlock('xpaymentsconnector/customer_success')->setData('result_message',$resultMessage)
164
- ->toHtml()
165
- );
166
- return;
167
- }
 
168
 
169
- $this->loadLayout();
170
- $this->_initLayoutMessages('customer/session');
171
- if ($block = $this->getLayout()->getBlock('xpaymentsconnector_customer_cardadd')) {
172
- $block->setRefererUrl($this->_getRefererUrl());
173
- }
174
- $headBlock = $this->getLayout()->getBlock('head');
175
- if ($headBlock) {
176
- $headBlock->setTitle(Mage::helper('xpaymentsconnector')->__('Add new credit card to list (X-Payments)'));
177
  }
178
- $this->renderLayout();
179
- }
180
 
 
 
181
  }
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
23
  /**
24
+ * Customer account controller for user cards
25
  */
26
 
27
  class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Front_Action
28
  {
 
29
  /**
30
  * Check customer authentication
31
+ *
32
+ * @return Mage_Core_Controller_Front_Action
33
  */
34
  public function preDispatch()
35
  {
36
  parent::preDispatch();
37
+
38
  $loginUrl = Mage::helper('customer')->getLoginUrl();
39
 
40
  if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
41
  $this->setFlag('', self::FLAG_NO_DISPATCH, true);
42
  }
43
+
44
+ return $this;
45
  }
46
 
47
  /**
48
+ * Display list of customer's cards
49
  *
50
+ * @return void
51
  */
52
  public function usercardsAction()
53
+ {
54
+ $this->loadLayout();
55
+ $this->_initLayoutMessages('customer/session');
56
+
57
+ $block = $this->getLayout()->getBlock('xpaymentsconnector_customer_usercards_list');
58
+ $block->setRefererUrl($this->_getRefererUrl());
59
+
60
+ $headBlock = $this->getLayout()->getBlock('head');
61
+ $headBlock->setTitle(Mage::helper('xpaymentsconnector')->__('My Payment Cards'));
62
+
63
+ $this->renderLayout();
64
+ }
65
+
66
+ /**
67
+ * Remove card action
68
+ *
69
+ * @return void
70
+ */
71
+ public function removecardAction()
72
  {
73
  $request = $this->getRequest()->getPost();
74
 
75
+ $result = false;
 
 
 
 
 
 
 
 
76
 
77
+ if (!empty($request['card'])) {
 
 
78
 
79
+ $items = Mage::getModel('xpaymentsconnector/usercards')
80
+ ->getCollection()
81
+ ->addFieldToFilter('xp_card_id', array('in' => $request['card']));
82
 
83
+ foreach ($items as $item) {
84
 
85
+ if (Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD == $item->getUsageType()) {
86
 
87
+ $recurringProfile = Mage::getModel('sales/recurring_profile')->load($item->getData('txnId'), 'reference_id');
88
 
89
+ if (Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE == $recurringProfile->getState()) {
 
 
 
90
 
91
+ $message = Mage::helper('xpaymentsconnector')->__(
92
+ 'You can\'t delete %s card. Because this is recurring card and this recurring(s) is still active.',
93
+ $item->getXpCardId()
94
+ );
95
+
96
+ Mage::getSingleton('customer/session')->addError($errorMessage);
97
 
98
+ continue;
99
+ }
100
+ }
101
 
102
+ $item->delete();
103
+ $result = true;
104
+ }
105
 
106
+ if ($result) {
107
+ Mage::getSingleton('customer/session')->addSuccess('Credit cards have been removed successfully.');
108
+ }
109
+ }
110
+
111
+ $this->_redirect('xpaymentsconnector/customer/usercards');
112
+ }
113
+
114
+ /**
115
+ * Add new card action
116
+ *
117
+ * @return void
118
+ */
119
+ public function cardaddAction()
120
+ {
121
+ try {
122
+
123
+ $customer = $this->getCustomer();
124
+
125
+ $this->loadLayout();
126
+
127
+ $block = $this->getLayout()->getBlock('xpaymentsconnector_customer_usercards_add');
128
+
129
+ $response = Mage::helper('settings_xpc')->getZeroAuthMethod()
130
+ ->obtainToken(null, $customer);
131
+
132
+ if (!$response->getStatus()) {
133
+
134
+ $error = !empty($response->getErrorMessage())
135
+ ? $response->getErrorMessage()
136
+ : 'Unable to obtain token from X-Payments';
137
+
138
+ $block->setError($error);
139
 
140
  } else {
141
 
142
+ $fields = array(
143
+ 'target' => 'main',
144
+ 'action' => 'start',
145
+ 'token' => $response->getField('token'),
146
+ 'allow_save_card' => 'Y',
147
+ );
148
+
149
+ Mage::getSingleton('customer/session')->setData('xpc_fields', $fields);
150
  }
 
151
 
152
+ $this->renderLayout();
153
 
154
+ } catch (Exception $e) {
155
+
156
+ Mage::getSingleton('customer/session')->addError($this->__($e->getMessage()));
157
+
158
+ $this->_redirect('xpaymentsconnector/customer/usercards');
 
 
 
159
  }
 
160
  }
161
 
162
+ /**
163
+ * Iframe action
164
+ *
165
+ * @return void
166
+ */
167
+ public function iframeAction()
168
+ {
169
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/customer_usercards_iframe');
170
+
171
+ try {
172
 
173
+ $fields = Mage::getSingleton('customer/session')->getData('xpc_fields');
174
+ $block->setFields($fields);
175
 
176
+ } catch (Exception $e) {
177
+
178
+ $block->setError($e->getMessage());
 
179
  }
180
 
181
+ echo $block->toHtml();
182
+ exit;
183
+ }
 
184
 
185
+ /**
186
+ * Return action
187
+ *
188
+ * @return void
189
+ */
190
+ public function returnAction()
191
+ {
192
+ // If were here, then everything is OK, the transaction was authorized by the gateway.
193
+ // But we need to make sure that the card was saved by the store successfully.
194
 
195
+ $isCardSaved = Mage::getModel('xpaymentsconnector/usercards')
196
+ ->checkSavedCard(
197
+ $this->getRequest()->getParam('customer_id'),
198
+ $this->getRequest()->getParam('txnId')
199
+ );
200
 
201
+ if ($isCardSaved) {
202
 
203
+ Mage::getSingleton('customer/session')->addSuccess($this->__('Payment card saved'));
 
 
204
 
205
+ } else {
206
 
207
+ Mage::getSingleton('customer/session')->addError($this->__(
208
+ 'Payment gateway reported about successful authorization, but the store is unable to receive the payment token. '
209
+ . 'Please contact the store admnistrator.'
210
+ ));
211
+ }
 
 
 
 
 
 
212
 
213
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/customer_usercards_iframe');
214
+ $block->setReturnFlag(true);
 
 
215
 
216
+ echo $block->toHtml();
217
+ exit;
218
+ }
219
 
220
+ /**
221
+ * Get current customer profile
222
+ *
223
+ * @return Mage_Customer_Model_Customer
224
+ */
225
+ private function getCustomer()
226
+ {
227
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
228
 
229
+ if (!$customer->getId()) {
230
+ throw new Exception('Wrong customer reference.');
 
 
 
 
 
 
231
  }
 
 
232
 
233
+ return $customer;
234
+ }
235
  }
app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php CHANGED
@@ -14,10 +14,10 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
 
@@ -89,62 +89,29 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
89
  return $result;
90
  }
91
 
92
- /**
93
- * Process masked card data from the callback request
94
- *
95
- * @param array $cardData Card data
96
- * @param int $customerId Customer ID
97
- *
98
- * @return void
99
- */
100
- protected function saveUserCard($cardData, $customerId)
101
- {
102
- $txnId = $cardData['txnId'];
103
-
104
- // Try to find card with already existing txnId.
105
- // Then update it or fill the empty found entity.
106
- $usercards = Mage::getModel('xpaymentsconnector/usercards')
107
- ->getCollection()
108
- ->addFieldToFilter('txnId', $txnId)
109
- ->getFirstItem();
110
-
111
- $data = array(
112
- 'user_id' => $customerId,
113
- 'txnId' => $txnId,
114
- 'last_4_cc_num' => $cardData['last4'],
115
- 'first6' => $cardData['first6'],
116
- 'card_type' => $cardData['type'],
117
- 'expire_month' => $cardData['expire_month'],
118
- 'expire_year' => $cardData['expire_year'],
119
- 'usage_type' => Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD,
120
- );
121
-
122
- if ($usercards->getData('xp_card_id')) {
123
- $data['xp_card_id'] = $usercards->getData('xp_card_id');
124
- }
125
-
126
- $usercards->setData($data)->save();
127
- }
128
-
129
  /**
130
  * Process masked card data from the callback request
131
  *
132
  * @param array $data Update data
 
 
133
  * @param string $txnId Payment reference
 
134
  *
135
  * @return void
136
  */
137
- protected function processMaskedCardData($data, $txnId)
138
  {
139
  if (!empty($data['maskedCardData'])) {
140
 
141
  $helper = Mage::helper('xpaymentsconnector');
142
 
143
- $order = $helper->getOrderByTxnId($txnId);
144
  $customerId = Mage::app()->getRequest()->getParam('customer_id');
145
 
146
  $cardData = $data['maskedCardData'];
147
  $cardData['txnId'] = $txnId;
 
148
 
149
  if (!empty($data['advinfo'])) {
150
  $cardData['advinfo'] = $data['advinfo'];
@@ -155,17 +122,28 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
155
  $helper->saveMaskedCardToOrder($order, $cardData);
156
 
157
  $customerId = $order->getData('customer_id');
158
- }
159
 
160
- $successStatus = Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS == $data['status']
161
- || Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS == $data['status'];
 
 
 
 
 
 
 
162
 
163
  if (
164
- $successStatus
165
  && isset($data['saveCard'])
166
  && 'Y' == $data['saveCard']
167
  ) {
168
- $this->saveUserCard($cardData, $customerId);
 
 
 
 
 
169
  }
170
  }
171
  }
@@ -201,10 +179,10 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
201
 
202
  $modelData = array(
203
  'order_id' => $order->getId(),
204
- 'code' => $fraudCheckData['code'],
205
- 'service' => $fraudCheckData['service'],
206
- 'result' => $fraudCheckData['result'],
207
- 'status' => $fraudCheckData['status'],
208
  'score' => isset($fraudCheckData['score']) ? $fraudCheckData['score'] : 0,
209
  'message' => isset($fraudCheckData['message']) ? $fraudCheckData['message'] : '',
210
  'transaction_id' => isset($fraudCheckData['transactionId']) ? $fraudCheckData['transactionId'] : '',
@@ -229,18 +207,200 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
229
  }
230
 
231
  /**
232
- * Process payment status from the callback request. Chhange order status.
233
  *
234
  * @param array $data Update data
235
  * @param string $txnId Payment reference
 
236
  *
237
  * @return void
238
  */
239
- protected function processPaymentStatus($data, $txnId)
240
  {
241
  $helper = Mage::helper('xpaymentsconnector');
 
242
 
243
- $order = $helper->getOrderByTxnId($txnId);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
244
 
245
  if (
246
  !$order->getId()
@@ -249,21 +409,35 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
249
 
250
  $helper->writeLog('Order not found for ' . $txnId);
251
 
252
- return;
253
  }
254
 
255
  $status = $state = false;
256
 
257
- $quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
258
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
 
 
259
 
260
  $message = $helper->getResultMessage($data);
261
 
262
  if (
263
- $api::AUTH_STATUS == $data['status']
264
- || $api::CHARGED_STATUS == $data['status']
265
  ) {
266
 
 
 
 
 
 
 
 
 
 
 
 
 
267
  // Success
268
 
269
  try {
@@ -271,14 +445,6 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
271
  // Set X-Payments payment reference
272
  $order->getPayment()->setTransactionId($txnId);
273
 
274
- // Set AVS. Something wrong actually. Need to add cardValidation
275
- if (
276
- isset($data['advinfo'])
277
- && isset($data['advinfo']['AVS'])
278
- ) {
279
- $order->getPayment()->setCcAvsStatus($data['advinfo']['AVS']);
280
- }
281
-
282
  // Set status
283
  $status = $api::AUTH_STATUS == $data['status']
284
  ? Cdev_XPaymentsConnector_Helper_Data::STATUS_AUTHORIZED
@@ -316,11 +482,37 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
316
  $state = $status = $order::STATE_CANCELED;
317
 
318
  // Save error message for quote
319
- $helper->getQuoteXpcData($quote)
320
  ->setData('xpc_message', $message)
321
  ->save();
322
 
 
 
 
323
  $quote->setIsActive(true)->save();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
324
  }
325
 
326
  if ($status) {
@@ -335,32 +527,61 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
335
  // Message for status change
336
  $statusMessage = 'Callback request. ' . $message;
337
 
338
- $order->setState($state, $status, $statusMessage, false);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
339
 
340
  $order->save();
341
 
342
  $helper->writeLog('Order status changed by callback request.', $logMessage);
343
  }
 
 
344
  }
345
 
346
  /**
347
  * Get check cart response for checkout
348
  *
349
  * @param string $quoteId
 
350
  *
351
  * @return array
352
  */
353
- protected function getQuoteCheckCartResponse($quoteId)
354
  {
355
  $helper = Mage::helper('xpaymentsconnector');
356
 
357
- $quote = Mage::getModel('sales/quote')->load($quoteId);
 
358
 
359
- if ($helper->getRecurringQuoteItem($quote)) {
 
 
 
 
 
 
 
 
 
 
360
 
361
  // Place order with recurring profile.
362
  // After that checking for nominal item is not possible.
363
- $refId = $helper->funcPlaceOrder($quote);
364
 
365
  // Send nominal items "as is"
366
  $response = array(
@@ -370,12 +591,12 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
370
  } else {
371
 
372
  // Place regular order.
373
- $refId = $helper->funcPlaceOrder($quote);
374
 
375
  if ($refId) {
376
 
377
  // Cart data to update payment
378
- $preparedCart = $helper->prepareCart($quote, $refId);
379
 
380
  $response = array(
381
  'status' => 'cart-changed',
@@ -404,20 +625,43 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
404
  */
405
  protected function getCustomerCheckCartResponse($customerId)
406
  {
407
- $helper = Mage::helper('xpaymentsconnector');
408
-
409
- $customer = Mage::getModel('customer/customer')->load($customerId);
410
- $preparedCart = $helper->prepareFakeCart($customer);
411
-
412
  $data = array(
413
- 'status' => 'cart-changed',
414
  'ref_id' => 'Authorization',
415
- 'cart' => $preparedCart,
416
  );
417
 
418
  return $data;
419
  }
420
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
421
  /**
422
  * Process callback request
423
  *
@@ -439,7 +683,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
439
  Mage::throwException('Invalid request');
440
  }
441
 
442
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
443
 
444
  // Check IP addresses
445
  if (!$this->checkIpAdress()) {
@@ -450,9 +694,12 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
450
 
451
  $quoteId = Mage::app()->getRequest()->getParam('quote_id');
452
  $customerId = Mage::app()->getRequest()->getParam('customer_id');
 
 
453
 
454
  if (
455
  'check_cart' == $request['action']
 
456
  && (
457
  !empty($quoteId)
458
  || !empty($customerId)
@@ -462,7 +709,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
462
  // Process check-cart callback request
463
 
464
  $data = $quoteId
465
- ? $this->getQuoteCheckCartResponse($quoteId)
466
  : $this->getCustomerCheckCartResponse($customerId, $request['txnId']);
467
 
468
  $helper->writeLog('Response for check-cart request', $data);
@@ -471,9 +718,8 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
471
  $xml = $api->convertHash2XML($data);
472
  $xml = $api->encrypt($xml);
473
 
474
- echo $xml;
475
-
476
- exit;
477
 
478
  } elseif (
479
  'callback' == $request['action']
@@ -487,14 +733,23 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
487
 
488
  $helper->writeLog('Callback request received', $data);
489
 
 
 
 
 
 
 
490
  // Save used credit card
491
- $this->processMaskedCardData($data, $request['txnId']);
492
 
493
  // Process fraud check data
494
- $this->processFraudCheckData($data, $request['txnId']);
495
 
496
- // Change order status according to the X-Payments payment status
497
- $this->processPaymentStatus($data, $request['txnId']);
 
 
 
498
 
499
  } else {
500
 
@@ -503,38 +758,6 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
503
 
504
  }
505
 
506
- /**
507
- * Payment is success
508
- *
509
- * @return void
510
- * @access public
511
- * @see ____func_see____
512
- * @since 1.0.0
513
- */
514
- public function successAction()
515
- {
516
- Mage::getSingleton('checkout/session')->setData('xpayments_token', null);
517
- $this->_redirect('checkout/onepage/success');
518
- }
519
-
520
- /**
521
- * Payment is cancelled
522
- *
523
- * @return void
524
- * @access public
525
- * @see ____func_see____
526
- * @since 1.0.0
527
- */
528
- public function cancelAction()
529
- {
530
- Mage::helper('xpaymentsconnector')->unsetXpaymentPrepareOrder();
531
- $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
532
- if(empty($profileIds)){
533
- $this->_getCheckout()->addError(Mage::helper('xpaymentsconnector')->__('The order has been canceled.'));
534
- }
535
- $this->_redirect('checkout/cart');
536
- }
537
-
538
  /**
539
  * Process cancel by customer (from X-Payments interface)
540
  *
@@ -587,95 +810,21 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
587
 
588
  }
589
 
590
- /**
591
- * Start payment (handshake + redirect to X-Payments)
592
- *
593
- * @return void
594
- * @access public
595
- * @see ____func_see____
596
- * @since 1.0.0
597
- */
598
- public function redirectAction()
599
- {
600
- try {
601
- $session = $this->_getCheckout();
602
-
603
- // Get order id
604
- $order = Mage::getModel('sales/order');
605
- $orderId = $session->getLastRealOrderId();
606
- $api = Mage::getModel('xpaymentsconnector/payment_cc');
607
-
608
- if($orderId){
609
-
610
- $order->loadByIncrementId($orderId);
611
-
612
- $result = $api->sendHandshakeRequest($order);
613
-
614
- if (!$result) {
615
- $failedCompleteMessage = 'Failed to complete the payment transaction.'
616
- .' Please use another payment method or contact the store administrator.';
617
- $this->_getCheckout()->addError($failedCompleteMessage);
618
-
619
- } else {
620
-
621
- // Update order
622
- if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
623
- $order->setState(
624
- Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
625
- (bool)Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
626
- Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
627
- )->save();
628
- }
629
-
630
- $this->loadLayout();
631
-
632
- $this->renderLayout();
633
-
634
- return;
635
- }
636
- }
637
-
638
- $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
639
- if(!empty($profileIds)){
640
- $this->loadLayout();
641
- $this->renderLayout();
642
- return;
643
- }
644
-
645
- if (!$orderId || $profileIds) {
646
- Mage::throwException('No order or profile for processing found');
647
- }
648
-
649
-
650
-
651
- } catch (Mage_Core_Exception $e) {
652
- $this->_getCheckout()->addError($e->getMessage());
653
-
654
- } catch(Exception $e) {
655
- Mage::logException($e);
656
- }
657
-
658
- $this->_redirect('checkout/cart');
659
- }
660
-
661
  /**
662
  * Save address in the address book
663
  *
664
  * @param array $data Address data to save
 
665
  *
666
  * @return void
667
  */
668
- private function saveAddress($data)
669
  {
670
- if (empty($data['customer_id'])) {
671
- return;
672
- }
673
-
674
  $newAddress = Mage::getModel('customer/address');
675
 
676
  $newAddress->setData($data)
677
- ->setCustomerId($data['customer_id'])
678
- ->setSaveInAddressBook('1');
679
 
680
  $newAddress->save();
681
  }
@@ -683,38 +832,40 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
683
  /**
684
  * Save addresses in address book (if necessary)
685
  *
686
- * @param Mage_Sales_Model_Quote $quote
 
687
  *
688
  * @return void
689
  */
690
- private function processSaveAddresses(Mage_Sales_Model_Quote $quote)
691
  {
692
- if (Mage::helper('xpaymentsconnector')->getQuoteXpcData($quote)->getData('address_saved')) {
 
 
693
  // Address already saved during customer registration
694
  return;
695
  }
696
 
697
- if ($quote->getBillingAddress()->getData('save_in_address_book')) {
698
- $this->saveAddress($quote->getBillingAddress()->getData());
 
 
699
  }
700
 
701
- if (
702
- $quote->getShippingAddress()->getData('save_in_address_book')
703
- && !$quote->getShippingAddress()->getData('same_as_billing')
704
- ) {
705
- $this->saveAddress($quote->getShippingAddress()->getData());
706
  }
707
  }
708
 
709
  /**
710
  * Process return after successful payment
711
  *
712
- * @param Mage_Sales_Model_Quote $quote
713
  * @param Mage_Sales_Model_Order $order
714
  *
715
  * @return void
716
  */
717
- private function processReturnSuccess(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order)
718
  {
719
  $quoteId = $quote->getId();
720
 
@@ -733,7 +884,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
733
  Mage::helper('xpaymentsconnector')->processCreateInvoice($order);
734
 
735
  // Save addresses in the adress book if necessary
736
- $this->processSaveAddresses($quote);
737
 
738
  $session->setXpcRedirectUrl(Mage::getUrl('checkout/onepage/success'));
739
  }
@@ -741,17 +892,17 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
741
  /**
742
  * Process return after declined payment
743
  *
744
- * @param Mage_Sales_Model_Quote $quote
745
  * @param Mage_Sales_Model_Order $order
746
  *
747
  * @return void
748
  */
749
- private function processReturnDecline(Mage_Sales_Model_Quote $quote, Mage_Sales_Model_Order $order)
750
  {
751
  $session = $this->getOnePage()->getCheckout();
752
  $helper = Mage::helper('xpaymentsconnector');
753
 
754
- $message = $helper->getQuoteXpcData($quote)->getData('xpc_message');
755
 
756
  if (!$message) {
757
  $message = 'Order declined. Try again';
@@ -761,7 +912,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
761
 
762
  $quote->setAsActive(true);
763
 
764
- $helper->resetInitData();
765
 
766
  Mage::getSingleton('core/session')->addError($message);
767
  $this->_getCheckout()->addError($message);
@@ -770,21 +921,21 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
770
  /**
771
  * Process return when order is lost
772
  *
773
- * @param Mage_Sales_Model_Quote $quote
774
  *
775
  * @return void
776
  */
777
- private function processReturnLostOrder(Mage_Sales_Model_Quote $quote)
778
  {
779
  $helper = Mage::helper('xpaymentsconnector');
780
 
781
- $message = $helper->getQuoteXpcData($quote)->getData('xpc_message');
782
 
783
  if (!$message) {
784
  $message = 'Order was lost';
785
  }
786
 
787
- $helper->resetInitData();
788
 
789
  Mage::throwException($message);
790
  }
@@ -792,7 +943,7 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
792
  /**
793
  * Send confirmation email
794
  *
795
- * @param Mage_Sales_Model_Quote $quote
796
  *
797
  * @return void
798
  */
@@ -846,7 +997,10 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
846
  $helper->writeLog('Customer returned from X-Payments', $request);
847
 
848
  $quoteId = Mage::app()->getRequest()->getParam('quote_id');
849
- $quote = Mage::getModel('sales/quote')->load($quoteId);
 
 
 
850
 
851
  try {
852
 
@@ -903,32 +1057,47 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
903
  $this->renderLayout();
904
  }
905
 
 
 
 
 
 
 
 
 
 
 
906
 
907
- public function saveusercardAction(){
908
- $request = $this->getRequest()->getPost();
909
- if(!empty($request)){
910
- if($request['user_card_save']){
911
- Mage::getSingleton('checkout/session')->setData('user_card_save',$request['user_card_save']);
912
- }
913
- }
914
  }
915
 
916
  /**
917
- * Redirect iframe to the X-Payments URL
 
918
  *
919
  * @return void
920
  */
921
- public function redirectiframeAction()
922
  {
 
 
 
 
 
 
923
  if (Mage::app()->getRequest()->getParam('checkout_method')) {
924
 
925
  Mage::getSingleton('checkout/session')->setData('xpc_checkout_method', Mage::app()->getRequest()->getParam('checkout_method'));
926
  }
927
 
928
- if (Mage::app()->getRequest()->getParam('unset_xp_prepare_order')) {
929
 
930
- $helper = Mage::helper('xpaymentsconnector');
931
- $helper->resetInitData();
 
932
  }
933
 
934
  if (!Mage::app()->getRequest()->isXmlHttpRequest()) {
@@ -939,6 +1108,77 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
939
  }
940
  }
941
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
942
  /**
943
  * Save checkout data before submitting the order
944
  *
@@ -948,22 +1188,23 @@ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_
948
  {
949
  $request = $this->getRequest();
950
 
 
 
951
  if (
952
  !$request->isPost()
953
  || !$request->isXmlHttpRequest()
 
954
  ) {
955
  Mage::throwException('Invalid request');
956
  }
957
 
958
- $helper = Mage::helper('xpaymentsconnector');
959
-
960
- $quote = Mage::getSingleton('checkout/session')->getQuote();
961
-
962
- $helper->getQuoteXpcData($quote)
963
  ->setData('checkout_data', serialize($request->getPost()))
964
  ->save();
965
 
966
- if ($helper->checkFirecheckoutModuleEnabled()) {
967
  // return properly formatted {} for Firecheckout
968
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array()));
969
  }
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
 
89
  return $result;
90
  }
91
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
92
  /**
93
  * Process masked card data from the callback request
94
  *
95
  * @param array $data Update data
96
+ * @param int $xpcSlot Slot index of the XPC payment method
97
+ * @param int $confId Payment configuration ID
98
  * @param string $txnId Payment reference
99
+ * @param string $parentTxnId Parent payment reference
100
  *
101
  * @return void
102
  */
103
+ protected function processMaskedCardData($data, $xpcSlot, $confId, $txnId, $parentTxnId = '')
104
  {
105
  if (!empty($data['maskedCardData'])) {
106
 
107
  $helper = Mage::helper('xpaymentsconnector');
108
 
109
+ $order = $helper->getOrderByTxnId($txnId, $parentTxnId);
110
  $customerId = Mage::app()->getRequest()->getParam('customer_id');
111
 
112
  $cardData = $data['maskedCardData'];
113
  $cardData['txnId'] = $txnId;
114
+ $cardData['confid'] = $confId;
115
 
116
  if (!empty($data['advinfo'])) {
117
  $cardData['advinfo'] = $data['advinfo'];
122
  $helper->saveMaskedCardToOrder($order, $cardData);
123
 
124
  $customerId = $order->getData('customer_id');
 
125
 
126
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
127
+ ->setXpcSlot($xpcSlot);
128
+
129
+ $isRecurring = (bool)$quote->getRecurringItem();
130
+
131
+ } else {
132
+
133
+ $isRecurring = false;
134
+ }
135
 
136
  if (
137
+ Mage::helper('api_xpc')->isSuccessStatus($data['status'])
138
  && isset($data['saveCard'])
139
  && 'Y' == $data['saveCard']
140
  ) {
141
+
142
+ $usageType = $isRecurring
143
+ ? Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD
144
+ : Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD;
145
+
146
+ Mage::getModel('xpaymentsconnector/usercards')->saveUserCard($cardData, $customerId, $usageType);
147
  }
148
  }
149
  }
179
 
180
  $modelData = array(
181
  'order_id' => $order->getId(),
182
+ 'code' => $fraudCheckData['code'], // All these fields are considered as mandatory.
183
+ 'service' => $fraudCheckData['service'], // So it's normal to cause a notice or an exception
184
+ 'result' => $fraudCheckData['result'], // in case one of them is missing.
185
+ 'status' => isset($fraudCheckData['status']) ? $fraudCheckData['status'] : '',
186
  'score' => isset($fraudCheckData['score']) ? $fraudCheckData['score'] : 0,
187
  'message' => isset($fraudCheckData['message']) ? $fraudCheckData['message'] : '',
188
  'transaction_id' => isset($fraudCheckData['transactionId']) ? $fraudCheckData['transactionId'] : '',
207
  }
208
 
209
  /**
210
+ * Process flat order payment data from the callback request
211
  *
212
  * @param array $data Update data
213
  * @param string $txnId Payment reference
214
+ * @param string $parentTxnId Parent payment reference
215
  *
216
  * @return void
217
  */
218
+ protected function processFlatOrderPaymentData($data, $txnId, $parentTxnId = '')
219
  {
220
  $helper = Mage::helper('xpaymentsconnector');
221
+ $order = $helper->getOrderByTxnId($txnId, $parentTxnId);
222
 
223
+ try {
224
+
225
+ // Process AVS
226
+ if (!empty($data['advinfo']['AVS'])) {
227
+
228
+ $avs = $data['advinfo']['AVS'];
229
+
230
+ } elseif (!empty($data['cardValidation'])) {
231
+
232
+ $cardValidation = array(
233
+ 'avs_z' => 'AVS ZIP/Postal code',
234
+ 'avs_a' => 'AVS Address (street)',
235
+ 'avs_c' => 'AVS Cardholder name',
236
+ );
237
+
238
+ $avs = array();
239
+
240
+ foreach ($cardValidation as $key => $title) {
241
+ if ($data['cardValidation'][$key]) {
242
+ $avs[] = $title . ': ' . ('1' == $data['cardValidation'][$key] ? 'Match' : 'Not match');
243
+ }
244
+ }
245
+
246
+ $avs = implode(PHP_EOL, $avs);
247
+
248
+ } else {
249
+
250
+ $avs = '';
251
+ }
252
+
253
+ // Process CVV
254
+ if (!empty($data['advinfo']['CVV'])) {
255
+
256
+ $cvv = $data['advinfo']['CVV'];
257
+
258
+ } elseif (
259
+ !empty($data['cardValidation'])
260
+ && $data['cardValidation']['cvv']
261
+ ) {
262
+
263
+ $cvv = 'CVV2/CVD/Card secure code: ' . ('1' == $data['cardValidation']['cvv'] ? 'Match' : 'Not match');
264
+
265
+ } else {
266
+
267
+ $cvv = '';
268
+ }
269
+
270
+ $ccOwner = isset($data['maskedCardData']['cardholder_name'])
271
+ ? $data['maskedCardData']['cardholder_name']
272
+ : '';
273
+
274
+ // This is for the USAePay module
275
+ if (!empty($data['advinfo']['UMcardRef'])) {
276
+
277
+ $encCardNumber = $data['advinfo']['UMcardRef'];
278
+
279
+ } else {
280
+
281
+ $parentOrder = $helper->getOrderByTxnId($parentTxnId);
282
+
283
+ if (
284
+ $parentOrder->getEntityId()
285
+ && $parentOrder->getPayment()->getData('cc_number_enc')
286
+ ) {
287
+
288
+ $encCardNumber = $parentOrder->getPayment()->getData('cc_number_enc');
289
+
290
+ } else {
291
+
292
+ $encCardNumber = '';
293
+ }
294
+ }
295
+
296
+ // This is for Payflow Pro module
297
+ if (!empty($data['advinfo']['PNREF'])) {
298
+ $lastTransId = $data['advinfo']['PNREF'];
299
+ } else {
300
+ $lastTransId = '';
301
+ }
302
+
303
+ $order->getPayment()
304
+ ->setData('cc_avs_status', $avs)
305
+ ->setData('cc_cid_status', $cvv)
306
+ ->setData('cc_owner', $ccOwner)
307
+ ->setData('cc_last4', $data['maskedCardData']['last4'])
308
+ ->setData('cc_type', $data['maskedCardData']['type'])
309
+ ->setData('cc_number_enc', $encCardNumber)
310
+ ->setData('cc_exp_month', $data['maskedCardData']['expire_month'])
311
+ ->setData('cc_exp_year', $data['maskedCardData']['expire_year'])
312
+ ->setData('cc_trans_id', $data['advinfo']['txn_id'])
313
+ ->setData('cc_status', $data['advinfo']['Message'])
314
+ ->setData('last_trans_id', $lastTransId)
315
+ ->save();
316
+
317
+ } catch (Exception $e) {
318
+ $helper->writeLog('Error while saving flat order payment data data: ' . $e->getMessage(), $e->getTraceAsString());
319
+ }
320
+ }
321
+
322
+ /**
323
+ * Check returned transaction total and currency
324
+ *
325
+ * @param Mage_Sales_Model_Order $order
326
+ * @param array $data Update data
327
+ *
328
+ * @return bool
329
+ */
330
+ private function checkTotalAndCurrency(Mage_Sales_Model_Order $order, $data)
331
+ {
332
+ $total = $order->getGrandTotal();
333
+
334
+ $currency = $order->getData('order_currency_code');
335
+
336
+ return $currency == $data['currency']
337
+ && 0.001 > abs($total - $data['amount']);
338
+ }
339
+
340
+ /**
341
+ * Clear usage information of the coupon for the declined/canceled order
342
+ *
343
+ * @param Mage_Sales_Model_Order $order
344
+ *
345
+ * @return void
346
+ */
347
+ private function clearCouponUsage(Mage_Sales_Model_Order $order)
348
+ {
349
+ $couponCode = $order->getCouponCode();
350
+
351
+ if (!empty($couponCode)) {
352
+
353
+ try {
354
+
355
+ $coupon = Mage::getModel('salesrule/coupon');
356
+ $coupon->load($couponCode, 'code');
357
+
358
+ if ($coupon->getRuleId()) {
359
+
360
+ $coupon->setTimesUsed($coupon->getTimesUsed() - 1)->save();
361
+
362
+ $customerId = $order->getCustomerId();
363
+
364
+ if ($customerId) {
365
+
366
+ $customerCoupon = Mage::getModel('salesrule/rule_customer')->loadByCustomerRule($customerId, $coupon->getRuleId());
367
+
368
+ if ($customerCoupon) {
369
+ $customerCoupon->setTimesUsed($customerCoupon->getTimesUsed() - 1)->save();
370
+ }
371
+
372
+ $couponUsage = Mage::getResourceModel('salesrule/coupon_usage');
373
+ $couponUsage->decreaseCustomerCouponTimesUsed($customerId, $coupon->getId());
374
+ }
375
+ }
376
+
377
+ Mage::helper('xpaymentsconnector')->writeLog('Clear coupon usage. Code: ' . $couponCode);
378
+
379
+ } catch (Exception $e) {
380
+
381
+ Mage::helper('xpaymentsconnector')->writeLog(
382
+ 'Error in clear coupon usage. Code: : ' . $couponCode . PHP_EOL . $e->getMessage(),
383
+ $e->getTraceAsString()
384
+ );
385
+ }
386
+ }
387
+ }
388
+
389
+ /**
390
+ * Process payment status from the callback request. Chhange order status.
391
+ *
392
+ * @param array $data Update data
393
+ * @param int $xpcSlot Slot index of the XPC payment method
394
+ * @param string $txnId Payment reference
395
+ * @param string $parentTxnId Parent payment reference
396
+ *
397
+ * @return array
398
+ */
399
+ protected function processPaymentStatus($data, $xpcSlot, $txnId, $parentTxnId = '')
400
+ {
401
+ $helper = Mage::helper('xpaymentsconnector');
402
+
403
+ $order = $helper->getOrderByTxnId($txnId, $parentTxnId);
404
 
405
  if (
406
  !$order->getId()
409
 
410
  $helper->writeLog('Order not found for ' . $txnId);
411
 
412
+ return $data;
413
  }
414
 
415
  $status = $state = false;
416
 
417
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
418
+ ->setXpcSlot($xpcSlot);
419
+
420
+ $api = Mage::helper('api_xpc');
421
 
422
  $message = $helper->getResultMessage($data);
423
 
424
  if (
425
+ $api->isSuccessStatus($data['status'])
426
+ && !$this->checkTotalAndCurrency($order, $data)
427
  ) {
428
 
429
+ $data['status'] = $api::DECLINED_STATUS;
430
+
431
+ $message = $this->__(
432
+ 'Gateway reported about the successfull transaction, but the transaction amount %s, or currency %s do not match the order. Original response was: %s',
433
+ $data['amount'],
434
+ $data['currency'],
435
+ $message
436
+ );
437
+ }
438
+
439
+ if ($api->isSuccessStatus($data['status'])) {
440
+
441
  // Success
442
 
443
  try {
445
  // Set X-Payments payment reference
446
  $order->getPayment()->setTransactionId($txnId);
447
 
 
 
 
 
 
 
 
 
448
  // Set status
449
  $status = $api::AUTH_STATUS == $data['status']
450
  ? Cdev_XPaymentsConnector_Helper_Data::STATUS_AUTHORIZED
482
  $state = $status = $order::STATE_CANCELED;
483
 
484
  // Save error message for quote
485
+ $quote->getXpcData()
486
  ->setData('xpc_message', $message)
487
  ->save();
488
 
489
+ // Clear coupon usage information
490
+ $this->clearCouponUsage($order);
491
+
492
  $quote->setIsActive(true)->save();
493
+
494
+ } elseif ($api::REFUNDED_STATUS == $data['status']) {
495
+
496
+ // Order is refunded
497
+
498
+ $state = $status = $order::STATE_CLOSED;
499
+
500
+ // Save error message for quote (if any)
501
+ $quote->getXpcData()
502
+ ->setData('xpc_message', $message)
503
+ ->save();
504
+
505
+ } elseif ($api::PART_REFUNDED_STATUS == $data['status']) {
506
+
507
+ // Order is partially refunded
508
+ // Curently processing is the most suitable state
509
+
510
+ $state = $status = $order::STATE_PROCESSING;
511
+
512
+ // Save error message for quote (if any)
513
+ $quote->getXpcData()
514
+ ->setData('xpc_message', $message)
515
+ ->save();
516
  }
517
 
518
  if ($status) {
527
  // Message for status change
528
  $statusMessage = 'Callback request. ' . $message;
529
 
530
+ if (
531
+ $order::STATE_CLOSED == $state
532
+ || $order::STATE_COMPLETE == $state
533
+ ) {
534
+
535
+ // These states cannot be set manually.
536
+ // So use this way to avoid error.
537
+
538
+ $order->setData('state', $state);
539
+ $order->setData('status', $status);
540
+
541
+ } else {
542
+
543
+ $order->setState($state, $status, $statusMessage, false);
544
+
545
+ }
546
 
547
  $order->save();
548
 
549
  $helper->writeLog('Order status changed by callback request.', $logMessage);
550
  }
551
+
552
+ return $data;
553
  }
554
 
555
  /**
556
  * Get check cart response for checkout
557
  *
558
  * @param string $quoteId
559
+ * @param int $xpcSlot Slot index of the XPC payment method
560
  *
561
  * @return array
562
  */
563
+ protected function getQuoteCheckCartResponse($quoteId, $xpcSlot)
564
  {
565
  $helper = Mage::helper('xpaymentsconnector');
566
 
567
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($quoteId)
568
+ ->setXpcSlot($xpcSlot);
569
 
570
+ if ($quote->isBackendOrderQuote()) {
571
+
572
+ // This order has been created in the backend. We'll not place it again
573
+ $refId = $quote->getXpcData()->getData('backend_orderid');
574
+
575
+ // Send items "as is"
576
+ $response = array(
577
+ 'status' => 'cart-not-changed',
578
+ );
579
+
580
+ } elseif ($quote->getRecurringItem($quote)) {
581
 
582
  // Place order with recurring profile.
583
  // After that checking for nominal item is not possible.
584
+ $refId = $helper->funcPlaceOrder($quote, $xpcSlot);
585
 
586
  // Send nominal items "as is"
587
  $response = array(
591
  } else {
592
 
593
  // Place regular order.
594
+ $refId = $helper->funcPlaceOrder($quote, $xpcSlot);
595
 
596
  if ($refId) {
597
 
598
  // Cart data to update payment
599
+ $preparedCart = Mage::helper('cart_xpc')->prepareCart($quote, $refId);
600
 
601
  $response = array(
602
  'status' => 'cart-changed',
625
  */
626
  protected function getCustomerCheckCartResponse($customerId)
627
  {
 
 
 
 
 
628
  $data = array(
629
+ 'status' => 'cart-not-changed',
630
  'ref_id' => 'Authorization',
 
631
  );
632
 
633
  return $data;
634
  }
635
 
636
+ /**
637
+ * Flush response
638
+ *
639
+ * @param string $response Response
640
+ *
641
+ * @return void
642
+ */
643
+ protected function flushResponse($response = '')
644
+ {
645
+ ob_end_clean();
646
+
647
+ header('Connection: close');
648
+
649
+ ignore_user_abort(true);
650
+
651
+ ob_start();
652
+
653
+ echo $response;
654
+
655
+ $size = ob_get_length();
656
+
657
+ header('Content-Length: ' . $size);
658
+
659
+ ob_end_flush();
660
+ flush();
661
+
662
+ exit;
663
+ }
664
+
665
  /**
666
  * Process callback request
667
  *
683
  Mage::throwException('Invalid request');
684
  }
685
 
686
+ $api = Mage::helper('api_xpc');
687
 
688
  // Check IP addresses
689
  if (!$this->checkIpAdress()) {
694
 
695
  $quoteId = Mage::app()->getRequest()->getParam('quote_id');
696
  $customerId = Mage::app()->getRequest()->getParam('customer_id');
697
+ $xpcSlot = Mage::app()->getRequest()->getParam('xpc_slot');
698
+ $confId = Mage::helper('settings_xpc')->getConfidByXpcSlot($xpcSlot);
699
 
700
  if (
701
  'check_cart' == $request['action']
702
+ && !empty($xpcSlot)
703
  && (
704
  !empty($quoteId)
705
  || !empty($customerId)
709
  // Process check-cart callback request
710
 
711
  $data = $quoteId
712
+ ? $this->getQuoteCheckCartResponse($quoteId, $xpcSlot)
713
  : $this->getCustomerCheckCartResponse($customerId, $request['txnId']);
714
 
715
  $helper->writeLog('Response for check-cart request', $data);
718
  $xml = $api->convertHash2XML($data);
719
  $xml = $api->encrypt($xml);
720
 
721
+ // Flush response, close connection and exit
722
+ $this->flushResponse($xml);
 
723
 
724
  } elseif (
725
  'callback' == $request['action']
733
 
734
  $helper->writeLog('Callback request received', $data);
735
 
736
+ $txnId = $request['txnId'];
737
+ $parentTxnId = !empty($data['parentId']) ? $data['parentId'] : '';
738
+
739
+ // Change order status according to the X-Payments payment status
740
+ $data = $this->processPaymentStatus($data, $xpcSlot, $txnId, $parentTxnId);
741
+
742
  // Save used credit card
743
+ $this->processMaskedCardData($data, $xpcSlot, $confId, $txnId, $parentTxnId);
744
 
745
  // Process fraud check data
746
+ $this->processFraudCheckData($data, $txnId);
747
 
748
+ // Process flat order payment data
749
+ $this->processFlatOrderPaymentData($data, $txnId, $parentTxnId);
750
+
751
+ // Close connection and exit
752
+ $this->flushResponse();
753
 
754
  } else {
755
 
758
 
759
  }
760
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
761
  /**
762
  * Process cancel by customer (from X-Payments interface)
763
  *
810
 
811
  }
812
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
813
  /**
814
  * Save address in the address book
815
  *
816
  * @param array $data Address data to save
817
+ * @param int $customerId Customer Id
818
  *
819
  * @return void
820
  */
821
+ private function saveAddress($data, $customerId)
822
  {
 
 
 
 
823
  $newAddress = Mage::getModel('customer/address');
824
 
825
  $newAddress->setData($data)
826
+ ->setCustomerId($customerId)
827
+ ->setSaveInAddressBook(true);
828
 
829
  $newAddress->save();
830
  }
832
  /**
833
  * Save addresses in address book (if necessary)
834
  *
835
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
836
+ * @param Mage_Sales_Model_Order $order
837
  *
838
  * @return void
839
  */
840
+ private function processSaveAddresses(Cdev_XPaymentsConnector_Model_Quote $quote, Mage_Sales_Model_Order $order)
841
  {
842
+ $customerId = $quote->getCustomer()->getId();
843
+
844
+ if ($quote->getXpcData()->getData('address_saved')) {
845
  // Address already saved during customer registration
846
  return;
847
  }
848
 
849
+ $customerId = $quote->getCustomer()->getId();
850
+
851
+ if ($quote->isSaveBillingAddressInAddressBook()) {
852
+ $this->saveAddress($order->getBillingAddress()->getData(), $customerId);
853
  }
854
 
855
+ if ($quote->isSaveShippingAddressInAddressBook()) {
856
+ $this->saveAddress($order->getShippingAddress()->getData(), $customerId);
 
 
 
857
  }
858
  }
859
 
860
  /**
861
  * Process return after successful payment
862
  *
863
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
864
  * @param Mage_Sales_Model_Order $order
865
  *
866
  * @return void
867
  */
868
+ private function processReturnSuccess(Cdev_XPaymentsConnector_Model_Quote $quote, Mage_Sales_Model_Order $order)
869
  {
870
  $quoteId = $quote->getId();
871
 
884
  Mage::helper('xpaymentsconnector')->processCreateInvoice($order);
885
 
886
  // Save addresses in the adress book if necessary
887
+ $this->processSaveAddresses($quote, $order);
888
 
889
  $session->setXpcRedirectUrl(Mage::getUrl('checkout/onepage/success'));
890
  }
892
  /**
893
  * Process return after declined payment
894
  *
895
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
896
  * @param Mage_Sales_Model_Order $order
897
  *
898
  * @return void
899
  */
900
+ private function processReturnDecline(Cdev_XPaymentsConnector_Model_Quote $quote, Mage_Sales_Model_Order $order)
901
  {
902
  $session = $this->getOnePage()->getCheckout();
903
  $helper = Mage::helper('xpaymentsconnector');
904
 
905
+ $message = $quote->getXpcData()->getData('xpc_message');
906
 
907
  if (!$message) {
908
  $message = 'Order declined. Try again';
912
 
913
  $quote->setAsActive(true);
914
 
915
+ $helper->resetInitData($quote);
916
 
917
  Mage::getSingleton('core/session')->addError($message);
918
  $this->_getCheckout()->addError($message);
921
  /**
922
  * Process return when order is lost
923
  *
924
+ * @param Cdev_XPaymentsConnector_Model_Quote $quote
925
  *
926
  * @return void
927
  */
928
+ private function processReturnLostOrder(Cdev_XPaymentsConnector_Model_Quote $quote)
929
  {
930
  $helper = Mage::helper('xpaymentsconnector');
931
 
932
+ $message = $quote->getXpcData()->getData('xpc_message');
933
 
934
  if (!$message) {
935
  $message = 'Order was lost';
936
  }
937
 
938
+ $helper->resetInitData($quote);
939
 
940
  Mage::throwException($message);
941
  }
943
  /**
944
  * Send confirmation email
945
  *
946
+ * @param Mage_Sales_Model_Order $order
947
  *
948
  * @return void
949
  */
997
  $helper->writeLog('Customer returned from X-Payments', $request);
998
 
999
  $quoteId = Mage::app()->getRequest()->getParam('quote_id');
1000
+ $xpcSlot = Mage::app()->getRequest()->getParam('xpc_slot');
1001
+
1002
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($quoteId)
1003
+ ->setXpcSlot($xpcSlot);
1004
 
1005
  try {
1006
 
1057
  $this->renderLayout();
1058
  }
1059
 
1060
+ /**
1061
+ * Get quote model
1062
+ *
1063
+ * @param int $xpcSlot Slot index of the XPC payment method
1064
+ *
1065
+ * @return Cdev_XPaymentsConnector_Model_Quote
1066
+ */
1067
+ private function getCheckoutSessionQuote($xpcSlot)
1068
+ {
1069
+ $quoteId = Mage::getSingleton('checkout/session')->getQuoteId();
1070
 
1071
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($quoteId)
1072
+ ->setXpcSlot($xpcSlot);
1073
+
1074
+ return $quote;
 
 
 
1075
  }
1076
 
1077
  /**
1078
+ * Redirect action
1079
+ * Submit form to X-Payments payment start action
1080
  *
1081
  * @return void
1082
  */
1083
+ public function redirectAction()
1084
  {
1085
+ $xpcSlot = Mage::app()->getRequest()->getParam('xpc_slot');
1086
+
1087
+ if (!Mage::helper('settings_xpc')->checkXpcSlot($xpcSlot, false)) {
1088
+ Mage::throwException('Invalid request');
1089
+ }
1090
+
1091
  if (Mage::app()->getRequest()->getParam('checkout_method')) {
1092
 
1093
  Mage::getSingleton('checkout/session')->setData('xpc_checkout_method', Mage::app()->getRequest()->getParam('checkout_method'));
1094
  }
1095
 
1096
+ if (Mage::app()->getRequest()->getParam('drop_token')) {
1097
 
1098
+ $quote = $this->getCheckoutSessionQuote($xpcSlot);
1099
+
1100
+ Mage::helper('xpaymentsconnector')->resetInitData($quote);
1101
  }
1102
 
1103
  if (!Mage::app()->getRequest()->isXmlHttpRequest()) {
1108
  }
1109
  }
1110
 
1111
+ /**
1112
+ * Recharge action
1113
+ * Pay by saved card at checkout
1114
+ *
1115
+ * @return void
1116
+ */
1117
+ public function rechargeAction()
1118
+ {
1119
+ $session = Mage::getSingleton('checkout/session');
1120
+
1121
+ $cardId = $session->getXpcSaveCardId();
1122
+ $order = Mage::getModel('sales/order')->load(
1123
+ $session->getLastOrderId()
1124
+ );
1125
+
1126
+ $card = Mage::getModel('xpaymentsconnector/usercards')->load($cardId);
1127
+
1128
+ $helper = Mage::helper('xpaymentsconnector');
1129
+
1130
+ $helper->saveMaskedCardToOrder($order, $card->getData());
1131
+ $order->setData('xpc_txnid', $card->getData('txnId'))->save();
1132
+
1133
+ $paymentMethod = $order->getPayment()->getMethodInstance();
1134
+
1135
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
1136
+ ->setXpcSlot($paymentMethod->getXpcSlot());
1137
+
1138
+ $response = $paymentMethod->processPayment($quote);
1139
+
1140
+ // Reload order and quote data, since it has been changed
1141
+ $order = Mage::getModel('sales/order')->load($order->getId());
1142
+ $quote = Mage::getModel('xpaymentsconnector/quote')->load($order->getQuoteId())
1143
+ ->setXpcSlot($paymentMethod->getXpcSlot());
1144
+
1145
+ if (
1146
+ !$response->getStatus()
1147
+ || !Mage::helper('api_xpc')->isSuccessStatus($response->getField('status'))
1148
+ ) {
1149
+
1150
+ // Payment is declined (or something went wrong)
1151
+
1152
+ if ($quote->getXpcData()->getData('xpc_message')) {
1153
+ $message = $quote->getXpcData()->getData('xpc_message');
1154
+ } else {
1155
+ $message = $response->getErrorMessage('Transaction failed');
1156
+ }
1157
+
1158
+ // Cancel order if it's not canceled yet
1159
+ if ($order::STATE_CANCELED != $order->getState()) {
1160
+
1161
+ $order->cancel();
1162
+ $order->setState($order::STATE_CANCELED, false, $message, false)->save();
1163
+
1164
+ $quote->setIsActive(true)->save();
1165
+ }
1166
+
1167
+ Mage::getSingleton('core/session')->addError($message);
1168
+
1169
+ $this->_redirect('checkout/cart');
1170
+
1171
+ } else {
1172
+
1173
+ // Payment is processed
1174
+
1175
+ // Auto create invoice if necessary
1176
+ Mage::helper('xpaymentsconnector')->processCreateInvoice($order);
1177
+
1178
+ $this->_redirect('checkout/onepage/success');
1179
+ }
1180
+ }
1181
+
1182
  /**
1183
  * Save checkout data before submitting the order
1184
  *
1188
  {
1189
  $request = $this->getRequest();
1190
 
1191
+ $xpcSlot = Mage::app()->getRequest()->getParam('xpc_slot');
1192
+
1193
  if (
1194
  !$request->isPost()
1195
  || !$request->isXmlHttpRequest()
1196
+ || !Mage::helper('settings_xpc')->checkXpcSlot($xpcSlot, false)
1197
  ) {
1198
  Mage::throwException('Invalid request');
1199
  }
1200
 
1201
+ $quote = $this->getCheckoutSessionQuote($xpcSlot);
1202
+
1203
+ $quote->getXpcData()
 
 
1204
  ->setData('checkout_data', serialize($request->getPost()))
1205
  ->save();
1206
 
1207
+ if (Mage::helper('settings_xpc')->checkFirecheckoutModuleEnabled()) {
1208
  // return properly formatted {} for Firecheckout
1209
  $this->getResponse()->setBody(Mage::helper('core')->jsonEncode(array()));
1210
  }
app/code/community/Cdev/XPaymentsConnector/etc/adminhtml.xml CHANGED
@@ -1,4 +1,5 @@
1
  <?xml version="1.0"?>
 
2
  <!--
3
  /**
4
  * Magento
@@ -13,10 +14,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  -->
@@ -24,11 +25,11 @@
24
  <menu>
25
  <system>
26
  <children>
27
- <control translate="title" module="xpaymentsconnector">
28
  <title>X-Payments Connector</title>
29
  <sort_order>300</sort_order>
30
- <action>adminhtml/settings_xpc/index</action>
31
- </control>
32
  </children>
33
  </system>
34
  </menu>
@@ -36,18 +37,23 @@
36
  <resources>
37
  <admin>
38
  <children>
39
- <system>
40
  <children>
41
- <control>
42
  <title>X-Payments Connector</title>
43
- </control>
44
- <config>
45
  <children>
46
- <xpaymentsconnector translate="title" module="xpaymentsconnector">
47
- <title>X-Payments Connector Settings</title>
48
- </xpaymentsconnector>
 
 
 
 
 
 
49
  </children>
50
- </config>
51
  </children>
52
  </system>
53
  </children>
1
  <?xml version="1.0"?>
2
+ <!-- vim: set ts=4 sw=4 sts=4 et: -->
3
  <!--
4
  /**
5
  * Magento
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
25
  <menu>
26
  <system>
27
  <children>
28
+ <xpaymentsconnector translate="title" module="xpaymentsconnector">
29
  <title>X-Payments Connector</title>
30
  <sort_order>300</sort_order>
31
+ <action>adminhtml/settings_xpc/</action>
32
+ </xpaymentsconnector>
33
  </children>
34
  </system>
35
  </menu>
37
  <resources>
38
  <admin>
39
  <children>
40
+ <system translate="title" module="xpaymentsconnector">
41
  <children>
42
+ <xpaymentsconnector translate="title" module="xpaymentsconnector">
43
  <title>X-Payments Connector</title>
44
+ <sort_order>300</sort_order>
 
45
  <children>
46
+ <configuration>
47
+ <title>X-Payments Connector configuration</title>
48
+ </configuration>
49
+ <payment_cards>
50
+ <title>Manage customer's payment cards</title>
51
+ </payment_cards>
52
+ <pay_orders>
53
+ <title>Pay for orders and secondary actions</title>
54
+ </pay_orders>
55
  </children>
56
+ </xpaymentsconnector>
57
  </children>
58
  </system>
59
  </children>
app/code/community/Cdev/XPaymentsConnector/etc/config.xml CHANGED
@@ -14,26 +14,30 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
24
  <config>
25
  <modules>
26
  <Cdev_XPaymentsConnector>
27
- <version>1.1.3</version>
28
  </Cdev_XPaymentsConnector>
29
  </modules>
30
  <global>
31
  <models>
 
 
 
 
 
32
  <sales>
33
  <rewrite>
34
  <recurring_profile>Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile</recurring_profile>
35
  <quote_address_total_nominal>Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal</quote_address_total_nominal>
36
- <quote>Cdev_XPaymentsConnector_Model_Quote</quote>
37
  </rewrite>
38
  </sales>
39
  <payment>
@@ -67,6 +71,18 @@
67
  <xpaymentsconnector>
68
  <class>Cdev_XPaymentsConnector_Helper</class>
69
  </xpaymentsconnector>
 
 
 
 
 
 
 
 
 
 
 
 
70
  </helpers>
71
  <resources>
72
  <xpaymentsconnector_setup>
@@ -101,7 +117,6 @@
101
  </xpaymentsconnector>
102
  <checkout>
103
  <rewrite>
104
- <onepage_payment_methods>Cdev_XPaymentsConnector_Block_Form_Container</onepage_payment_methods>
105
  <onepage_success>Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success</onepage_success>
106
  </rewrite>
107
  </checkout>
@@ -112,207 +127,62 @@
112
  </adminhtml>
113
  </blocks>
114
  <events>
 
 
115
  <sales_order_payment_cancel_invoice>
116
  <observers>
117
- <xpaymentsconnector>
118
  <type>singleton</type>
119
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
120
  <method>invoiceVoid</method>
121
  </xpaymentsconnector>
122
  </observers>
123
  </sales_order_payment_cancel_invoice>
 
 
124
  <sales_order_invoice_save_before>
125
  <observers>
126
- <xpaymentsconnector>
127
  <type>singleton</type>
128
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
129
  <method>orderInvoiceSaveBefore</method>
130
  </xpaymentsconnector>
131
  </observers>
132
  </sales_order_invoice_save_before>
133
- <controller_action_predispatch_checkout_onepage_index>
134
- <observers>
135
- <xpaymentsconnector>
136
- <type>singleton</type>
137
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
138
- <method>preDispatchCheckout</method>
139
- </xpaymentsconnector>
140
- </observers>
141
- </controller_action_predispatch_checkout_onepage_index>
142
- <controller_action_postdispatch_checkout_onepage_savePayment>
143
- <observers>
144
- <xpaymentsconnector>
145
- <type>singleton</type>
146
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
147
- <method>postDispatchSavePayment</method>
148
- </xpaymentsconnector>
149
- </observers>
150
- </controller_action_postdispatch_checkout_onepage_savePayment>
151
- <!--<checkout_type_onepage_save_order_after>-->
152
- <checkout_type_onepage_save_order_after>
153
- <observers>
154
- <xpaymentsconnector>
155
- <type>singleton</type>
156
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
157
- <method>updateOrder</method>
158
- </xpaymentsconnector>
159
- </observers>
160
- </checkout_type_onepage_save_order_after>
161
- <checkout_onepage_controller_success_action>
162
- <observers>
163
- <xpaymentsconnector>
164
- <type>singleton</type>
165
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
166
- <method>orderSuccessAction</method>
167
- </xpaymentsconnector>
168
- </observers>
169
- </checkout_onepage_controller_success_action>
170
- <payment_method_is_active>
171
- <observers>
172
- <paymentfilter_payment_method_is_active>
173
- <type>singleton</type>
174
- <class>xpaymentsconnector/observer</class>
175
- <method>paymentMethodIsActive</method>
176
- </paymentfilter_payment_method_is_active>
177
- </observers>
178
- </payment_method_is_active>
179
- <!--send xp transaction from 'XP Order State tab'-->
180
- <controller_action_predispatch_adminhtml_sales_order_view>
181
- <observers>
182
- <xpaymentsconnector>
183
- <type>singleton</type>
184
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
185
- <method>adminhtmlSalesOrderView</method>
186
- </xpaymentsconnector>
187
- </observers>
188
- </controller_action_predispatch_adminhtml_sales_order_view>
189
 
190
- <controller_action_postdispatch_adminhtml_sales_order_create_save>
191
- <observers>
192
- <xpaymentsconnector>
193
- <type>singleton</type>
194
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
195
- <method>postdispatchAdminhtmlSalesOrderCreateSave</method>
196
- </xpaymentsconnector>
197
- </observers>
198
- </controller_action_postdispatch_adminhtml_sales_order_create_save>
199
- <controller_action_predispatch_adminhtml_sales_order_create_save>
200
- <observers>
201
- <xpaymentsconnector>
202
- <type>singleton</type>
203
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
204
- <method>predispatchAdminhtmlSalesOrderCreateSave</method>
205
- </xpaymentsconnector>
206
- </observers>
207
- </controller_action_predispatch_adminhtml_sales_order_create_save>
208
- <!--add x-payments transaction for 'admin order edit' event -->
209
- <controller_action_postdispatch_adminhtml_sales_order_edit_save>
210
- <observers>
211
- <xpaymentsconnector>
212
- <type>singleton</type>
213
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
214
- <method>postdispatchAdminhtmlSalesOrderEditSave</method>
215
- </xpaymentsconnector>
216
- </observers>
217
- </controller_action_postdispatch_adminhtml_sales_order_edit_save>
218
- <controller_action_predispatch_adminhtml_sales_order_create_index>
219
- <observers>
220
- <xpaymentsconnector>
221
- <type>singleton</type>
222
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
223
- <method>unsetXpaymentSelectedCard</method>
224
- </xpaymentsconnector>
225
- </observers>
226
- </controller_action_predispatch_adminhtml_sales_order_create_index>
227
- <!--save selected x-payment card on admin side -->
228
- <controller_action_postdispatch_adminhtml_sales_order_edit_loadBlock>
229
- <observers>
230
- <xpaymentsconnector>
231
- <type>singleton</type>
232
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
233
- <method>adminhtmlSavePaymentCard</method>
234
- </xpaymentsconnector>
235
- </observers>
236
- </controller_action_postdispatch_adminhtml_sales_order_edit_loadBlock>
237
- <controller_action_postdispatch_adminhtml_sales_order_create_loadBlock>
238
- <observers>
239
- <xpaymentsconnector>
240
- <type>singleton</type>
241
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
242
- <method>adminhtmlSavePaymentCard</method>
243
- </xpaymentsconnector>
244
- </observers>
245
- </controller_action_postdispatch_adminhtml_sales_order_create_loadBlock>
246
- <!--add redirect for buying recurring product by xpayments method(without iframe) -->
247
- <checkout_submit_all_after>
248
- <observers>
249
- <xpaymentsconnector>
250
- <type>singleton</type>
251
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
252
- <method>addRedirectForXpaymentMethod</method>
253
- </xpaymentsconnector>
254
- </observers>
255
- </checkout_submit_all_after>
256
  <!--set discount for recurring product(for ajax cart item quantity update). Remove X-Payments token -->
257
  <checkout_cart_update_items_after>
258
  <observers>
259
- <web4proall_upd>
260
  <type>singleton</type>
261
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
262
  <method>updateCartItem</method>
263
- </web4proall_upd>
264
  </observers>
265
  </checkout_cart_update_items_after>
266
- <!--Remove X-Payments token -->
267
- <checkout_cart_add_product_complete>
268
- <observers>
269
- <web4proall_upd>
270
- <type>singleton</type>
271
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
272
- <method>checkoutCartAdd</method>
273
- </web4proall_upd>
274
- </observers>
275
- </checkout_cart_add_product_complete>
276
- <!--set discount for recurring product-->
277
- <controller_action_predispatch_checkout_cart_index>
278
- <observers>
279
- <web4procheckout>
280
- <type>singleton</type>
281
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
282
- <method>preDispatchCartIndex</method>
283
- </web4procheckout>
284
- </observers>
285
- </controller_action_predispatch_checkout_cart_index>
286
- <!--Remove X-Payments token and prepare order number -->
287
- <controller_action_postdispatch_checkout_cart_delete>
288
- <observers>
289
- <web4procheckout>
290
- <type>singleton</type>
291
- <class>Cdev_XPaymentsConnector_Model_Observer</class>
292
- <method>postdispatchCartDelete</method>
293
- </web4procheckout>
294
- </observers>
295
- </controller_action_postdispatch_checkout_cart_delete>
296
- <!--Remove X-Payments token after update shipping method -->
297
- <controller_action_postdispatch_checkout_onepage_saveShippingMethod>
298
  <observers>
299
- <web4procheckout>
300
  <type>singleton</type>
301
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
302
- <method>postdispatchSaveShippingMethod</method>
303
- </web4procheckout>
304
  </observers>
305
- </controller_action_postdispatch_checkout_onepage_saveShippingMethod>
306
- <!--Remove X-Payments token after update shipping method -->
307
- <controller_action_predispatch_checkout_onepage_saveShippingMethod>
 
308
  <observers>
309
- <web4procheckout>
310
  <type>singleton</type>
311
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
312
- <method>predispatchSaveShippingMethod</method>
313
- </web4procheckout>
314
  </observers>
315
- </controller_action_predispatch_checkout_onepage_saveShippingMethod>
 
316
  </events>
317
  <sales>
318
  <quote>
@@ -389,14 +259,27 @@
389
  </adminhtml>
390
  <default>
391
  <payment>
392
- <xpayments>
393
  <active>0</active>
394
- <model>xpaymentsconnector/payment_cc</model>
395
  <order_status>1</order_status>
396
  <allowspecific>0</allowspecific>
397
  <title>Credit Card (X-Payments)</title>
398
- <use_iframe>1</use_iframe>
399
- </xpayments>
 
 
 
 
 
 
 
 
 
 
 
 
 
400
  <savedcards>
401
  <active>0</active>
402
  <model>xpaymentsconnector/payment_savedcards</model>
@@ -404,20 +287,15 @@
404
  <allowspecific>0</allowspecific>
405
  <title>Use saved payment cards (X-Payments)</title>
406
  </savedcards>
407
- <!-- @TODO: need process 'charge response' from 'x-payment server' -->
408
- <!--<prepaidpayments>
409
- <active>0</active>
410
- <model>xpaymentsconnector/payment_prepaidpayments</model>
411
- <order_status>1</order_status>
412
- <allowspecific>0</allowspecific>
413
- <title>Prepaid Payments (X-Payments)</title>
414
- </prepaidpayments>-->
415
  </payment>
416
  <xpaymentsconnector>
417
  <settings>
418
  <activationstatus>0</activationstatus>
419
- <xpay_minimum_payment_recurring_amount>0.5</xpay_minimum_payment_recurring_amount>
420
- <xpay_currency>USD</xpay_currency>
 
 
 
421
  </settings>
422
  </xpaymentsconnector>
423
  </default>
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
24
  <config>
25
  <modules>
26
  <Cdev_XPaymentsConnector>
27
+ <version>1.8.0</version>
28
  </Cdev_XPaymentsConnector>
29
  </modules>
30
  <global>
31
  <models>
32
+ <salesrule_resource>
33
+ <rewrite>
34
+ <coupon_usage>Cdev_XPaymentsConnector_Model_Mysql4_Coupon_Usage</coupon_usage>
35
+ </rewrite>
36
+ </salesrule_resource>
37
  <sales>
38
  <rewrite>
39
  <recurring_profile>Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile</recurring_profile>
40
  <quote_address_total_nominal>Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal</quote_address_total_nominal>
 
41
  </rewrite>
42
  </sales>
43
  <payment>
71
  <xpaymentsconnector>
72
  <class>Cdev_XPaymentsConnector_Helper</class>
73
  </xpaymentsconnector>
74
+ <settings_xpc>
75
+ <class>Cdev_XPaymentsConnector_Helper_Settings</class>
76
+ </settings_xpc>
77
+ <api_xpc>
78
+ <class>Cdev_XPaymentsConnector_Helper_Api</class>
79
+ </api_xpc>
80
+ <address_xpc>
81
+ <class>Cdev_XPaymentsConnector_Helper_Address</class>
82
+ </address_xpc>
83
+ <cart_xpc>
84
+ <class>Cdev_XPaymentsConnector_Helper_Cart</class>
85
+ </cart_xpc>
86
  </helpers>
87
  <resources>
88
  <xpaymentsconnector_setup>
117
  </xpaymentsconnector>
118
  <checkout>
119
  <rewrite>
 
120
  <onepage_success>Cdev_XPaymentsConnector_Block_Checkout_Onepage_Success</onepage_success>
121
  </rewrite>
122
  </checkout>
127
  </adminhtml>
128
  </blocks>
129
  <events>
130
+
131
+ <!-- Cancel payment in X-Payments -->
132
  <sales_order_payment_cancel_invoice>
133
  <observers>
134
+ <xpaymentsconnector ifconfig="xpaymentsconnector/settings/xpay_is_configured">
135
  <type>singleton</type>
136
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
137
  <method>invoiceVoid</method>
138
  </xpaymentsconnector>
139
  </observers>
140
  </sales_order_payment_cancel_invoice>
141
+
142
+ <!-- Capture payment in X-Payments -->
143
  <sales_order_invoice_save_before>
144
  <observers>
145
+ <xpaymentsconnector ifconfig="xpaymentsconnector/settings/xpay_is_configured">
146
  <type>singleton</type>
147
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
148
  <method>orderInvoiceSaveBefore</method>
149
  </xpaymentsconnector>
150
  </observers>
151
  </sales_order_invoice_save_before>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
152
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
153
  <!--set discount for recurring product(for ajax cart item quantity update). Remove X-Payments token -->
154
  <checkout_cart_update_items_after>
155
  <observers>
156
+ <xpaymentsconnector ifconfig="xpaymentsconnector/settings/xpay_is_configured">
157
  <type>singleton</type>
158
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
159
  <method>updateCartItem</method>
160
+ </xpaymentsconnector>
161
  </observers>
162
  </checkout_cart_update_items_after>
163
+
164
+ <!-- Delete associated quote XPC data -->
165
+ <sales_order_delete_before>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
166
  <observers>
167
+ <xpaymentsconnector ifconfig="xpaymentsconnector/settings/active">
168
  <type>singleton</type>
169
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
170
+ <method>orderDeleteBefore</method>
171
+ </xpaymentsconnector>
172
  </observers>
173
+ </sales_order_delete_before>
174
+
175
+ <!-- Delete associated quote XPC data -->
176
+ <sales_quote_delete_before>
177
  <observers>
178
+ <xpaymentsconnector ifconfig="xpaymentsconnector/settings/active">
179
  <type>singleton</type>
180
  <class>Cdev_XPaymentsConnector_Model_Observer</class>
181
+ <method>quoteDeleteBefore</method>
182
+ </xpaymentsconnector>
183
  </observers>
184
+ </sales_quote_delete_before>
185
+
186
  </events>
187
  <sales>
188
  <quote>
259
  </adminhtml>
260
  <default>
261
  <payment>
262
+ <xpayments1>
263
  <active>0</active>
264
+ <model>xpaymentsconnector/payment_cc1</model>
265
  <order_status>1</order_status>
266
  <allowspecific>0</allowspecific>
267
  <title>Credit Card (X-Payments)</title>
268
+ </xpayments1>
269
+ <xpayments2>
270
+ <active>0</active>
271
+ <model>xpaymentsconnector/payment_cc2</model>
272
+ <order_status>1</order_status>
273
+ <allowspecific>0</allowspecific>
274
+ <title>Credit Card (X-Payments)</title>
275
+ </xpayments2>
276
+ <xpayments3>
277
+ <active>0</active>
278
+ <model>xpaymentsconnector/payment_cc3</model>
279
+ <order_status>1</order_status>
280
+ <allowspecific>0</allowspecific>
281
+ <title>Credit Card (X-Payments)</title>
282
+ </xpayments3>
283
  <savedcards>
284
  <active>0</active>
285
  <model>xpaymentsconnector/payment_savedcards</model>
287
  <allowspecific>0</allowspecific>
288
  <title>Use saved payment cards (X-Payments)</title>
289
  </savedcards>
 
 
 
 
 
 
 
 
290
  </payment>
291
  <xpaymentsconnector>
292
  <settings>
293
  <activationstatus>0</activationstatus>
294
+ <xpay_api_version>1.7</xpay_api_version>
295
+ <xpay_use_iframe>1</xpay_use_iframe>
296
+ <xpay_iframe_place>payment</xpay_iframe_place>
297
+ <xpay_zero_auth_amount>0.5</xpay_zero_auth_amount>
298
+ <xpay_zero_auth_description>Card setup</xpay_zero_auth_description>
299
  </settings>
300
  </xpaymentsconnector>
301
  </default>
app/code/community/Cdev/XPaymentsConnector/etc/system.xml CHANGED
@@ -1,4 +1,5 @@
1
  <?xml version="1.0"?>
 
2
  <!--
3
  /**
4
  * Magento
@@ -13,120 +14,19 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  -->
23
  <config>
24
- <sections>
25
- <payment>
26
- <groups>
27
- <xpayments translate="label" module="xpaymentsconnector">
28
- <label>X-Payments connector</label>
29
- <frontend_type>text</frontend_type>
30
- <sort_order>201</sort_order>
31
- <show_in_default>1</show_in_default>
32
- <show_in_website>1</show_in_website>
33
- <show_in_store>0</show_in_store>
34
- <fields>
35
- <active translate="label">
36
- <label>Enabled</label>
37
- <frontend_type>select</frontend_type>
38
- <source_model>adminhtml/system_config_source_yesno</source_model>
39
- <sort_order>1</sort_order>
40
- <show_in_default>1</show_in_default>
41
- <show_in_website>1</show_in_website>
42
- <show_in_store>0</show_in_store>
43
- </active>
44
- <sort_order translate="label">
45
- <label>Sort order</label>
46
- <frontend_type>text</frontend_type>
47
- <sort_order>2</sort_order>
48
- <show_in_default>1</show_in_default>
49
- <show_in_website>1</show_in_website>
50
- <show_in_store>0</show_in_store>
51
- </sort_order>
52
- <title translate="label">
53
- <label>Title</label>
54
- <frontend_type>text</frontend_type>
55
- <sort_order>3</sort_order>
56
- <show_in_default>1</show_in_default>
57
- <show_in_website>1</show_in_website>
58
- <show_in_store>0</show_in_store>
59
- </title>
60
- <allowspecific translate="label">
61
- <label>Payment from applicable countries</label>
62
- <frontend_type>allowspecific</frontend_type>
63
- <sort_order>4</sort_order>
64
- <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
65
- <show_in_default>1</show_in_default>
66
- <show_in_website>1</show_in_website>
67
- <show_in_store>0</show_in_store>
68
- </allowspecific>
69
- <specificcountry translate="label">
70
- <label>Payment from Specific countries</label>
71
- <frontend_type>multiselect</frontend_type>
72
- <sort_order>5</sort_order>
73
- <source_model>adminhtml/system_config_source_country</source_model>
74
- <show_in_default>1</show_in_default>
75
- <show_in_website>1</show_in_website>
76
- <show_in_store>0</show_in_store>
77
- </specificcountry>
78
- <confid translate="label">
79
- <label>Payment configuration</label>
80
- <frontend_type>select</frontend_type>
81
- <sort_order>6</sort_order>
82
- <source_model>xpaymentsconnector/source_paymentconfiguration</source_model>
83
- <show_in_default>1</show_in_default>
84
- <show_in_website>1</show_in_website>
85
- <show_in_store>0</show_in_store>
86
- </confid>
87
- <use_iframe translate="label">
88
- <label>Use iFrame</label>
89
- <frontend_type>select</frontend_type>
90
- <source_model>adminhtml/system_config_source_yesno</source_model>
91
- <frontend_model>xpaymentsconnector/adminhtml_system_config_form_subselect</frontend_model>
92
- <sort_order>7</sort_order>
93
- <show_in_default>1</show_in_default>
94
- <show_in_website>1</show_in_website>
95
- <show_in_store>0</show_in_store>
96
- </use_iframe>
97
- <placedisplay translate="label">
98
- <label>Show credit card form at</label>
99
- <frontend_type>select</frontend_type>
100
- <source_model>xpaymentsconnector/adminhtml_system_config_source_placedisplay</source_model>
101
- <sort_order>8</sort_order>
102
- <show_in_default>1</show_in_default>
103
- <show_in_website>1</show_in_website>
104
- <show_in_store>0</show_in_store>
105
- </placedisplay>
106
- <use_authorize translate="label">
107
- <label>Use forced Authorize operation</label>
108
- <comment><![CDATA[Work only for non recurring product order.]]></comment>
109
- <frontend_type>select</frontend_type>
110
- <source_model>adminhtml/system_config_source_yesno</source_model>
111
- <sort_order>9</sort_order>
112
- <show_in_default>1</show_in_default>
113
- <show_in_website>1</show_in_website>
114
- <show_in_store>0</show_in_store>
115
- </use_authorize>
116
- <use_initialfee_authorize translate="label">
117
- <label>Use forced Authorize operation for recurring products</label>
118
- <frontend_type>select</frontend_type>
119
- <source_model>adminhtml/system_config_source_yesno</source_model>
120
- <sort_order>10</sort_order>
121
- <show_in_default>1</show_in_default>
122
- <show_in_website>1</show_in_website>
123
- <show_in_store>0</show_in_store>
124
- </use_initialfee_authorize>
125
-
126
- </fields>
127
- </xpayments>
128
- <savedcards translate="label" module="xpaymentsconnector">
129
- <label>Use saved credit cards (X-Payments)</label>
130
  <frontend_type>text</frontend_type>
131
  <sort_order>201</sort_order>
132
  <show_in_default>1</show_in_default>
@@ -158,128 +58,56 @@
158
  <show_in_website>1</show_in_website>
159
  <show_in_store>0</show_in_store>
160
  </title>
161
- </fields>
162
- </savedcards>
163
- <!-- @TODO: need process 'charge response' from 'x-payment server' -->
164
- <!--<prepaidpayments>
165
- <label>Prepaid Payments (X-Payments)</label>
166
- <frontend_type>text</frontend_type>
167
- <sort_order>201</sort_order>
168
- <show_in_default>1</show_in_default>
169
- <show_in_website>1</show_in_website>
170
- <show_in_store>0</show_in_store>
171
- <fields>
172
- <active translate="label">
173
- <label>Enabled</label>
174
- <frontend_type>select</frontend_type>
175
- <source_model>adminhtml/system_config_source_yesno</source_model>
176
- <sort_order>1</sort_order>
177
  <show_in_default>1</show_in_default>
178
  <show_in_website>1</show_in_website>
179
  <show_in_store>0</show_in_store>
180
- </active>
181
- <sort_order translate="label">
182
- <label>Sort order</label>
183
- <frontend_type>text</frontend_type>
184
- <sort_order>2</sort_order>
 
185
  <show_in_default>1</show_in_default>
186
  <show_in_website>1</show_in_website>
187
  <show_in_store>0</show_in_store>
188
- </sort_order>
189
- <title translate="label">
190
- <label>Title</label>
191
- <frontend_type>text</frontend_type>
192
- <sort_order>3</sort_order>
 
193
  <show_in_default>1</show_in_default>
194
  <show_in_website>1</show_in_website>
195
  <show_in_store>0</show_in_store>
196
- </title>
197
- </fields>
198
- </prepaidpayments>-->
199
- </groups>
200
- </payment>
201
- <xpaymentsconnector translate="label" module="xpaymentsconnector">
202
- <label>X-Payments connector</label>
203
- <tab>sales</tab>
204
- <frontend_type>text</frontend_type>
205
- <sort_order>995</sort_order>
206
- <show_in_default>1</show_in_default>
207
- <show_in_website>0</show_in_website>
208
- <show_in_store>0</show_in_store>
209
- <groups>
210
- <settings translate="label">
211
- <sort_order>1</sort_order>
212
- <show_in_default>1</show_in_default>
213
- <show_in_website>0</show_in_website>
214
- <show_in_store>0</show_in_store>
215
- <fields>
216
- <xpay_conf_bundle translate="label,comment">
217
- <label>X-Payments configuration bundle</label>
218
- <comment><![CDATA[Configuration bundle is generated by X-Payments for this shop. It should be obtained from this shop details page in X-Payments back-end.]]></comment>
219
- <frontend_type>text</frontend_type>
220
- <sort_order>10</sort_order>
221
- <show_in_default>1</show_in_default>
222
- <show_in_website>0</show_in_website>
223
- <show_in_store>0</show_in_store>
224
- </xpay_conf_bundle>
225
- <xpay_allowed_ip_addresses translate="label,comment">
226
- <label>Allowed X-Payments IP addresses</label>
227
- <comment><![CDATA[X-Payments sends callback requests to the store from specific IP addresses. To secure the data transfer and avoid fraudulent requests, specify these IP addresses here as a comma-separated list. Usually it is IP address of the server where X-Payments is installed.]]></comment>
228
- <frontend_type>text</frontend_type>
229
- <sort_order>60</sort_order>
230
- <show_in_default>1</show_in_default>
231
- <show_in_website>0</show_in_website>
232
- <show_in_store>0</show_in_store>
233
- </xpay_allowed_ip_addresses>
234
- <xpay_currency translate="label,comment">
235
- <label>Payment currency</label>
236
- <comment><![CDATA[All payments will be made using the currency specified here.]]></comment>
237
  <frontend_type>select</frontend_type>
238
- <source_model>adminhtml/system_config_source_currency</source_model>
239
- <sort_order>70</sort_order>
240
  <show_in_default>1</show_in_default>
241
- <show_in_website>0</show_in_website>
242
  <show_in_store>0</show_in_store>
243
- </xpay_currency>
244
- <xpay_minimum_payment_recurring_amount translate="label,comment">
245
- <label>Setup minimum payment amount for recurring orders and customer card authorization actions</label>
246
- <comment><![CDATA[This is minimal authorisation amount for recurring subscriptions ordered with start date in the future and customer card authorization actions.]]></comment>
247
- <sort_order>80</sort_order>
 
248
  <show_in_default>1</show_in_default>
249
- <show_in_website>0</show_in_website>
250
- <show_in_store>0</show_in_store>
251
- </xpay_minimum_payment_recurring_amount>
252
- <xpay_api_version>
253
- <label>API version</label>
254
- <sort_order>90</sort_order>
255
- <show_in_default>0</show_in_default>
256
- <show_in_website>0</show_in_website>
257
  <show_in_store>0</show_in_store>
258
- </xpay_api_version>
259
 
260
- </fields>
261
- <label>X-Payments Connector Settings</label>
262
- <frontend_type>text</frontend_type>
263
- <comment>
264
- <![CDATA[
265
- <div id="xp-connector-settings" style="display:none">
266
- <li>See how to connect <strong>X-Payments</strong> with <strong>Magento</strong></li>
267
- <li><iframe width="400" height="260" frameborder="0" allowfullscreen="" src="https://www.youtube.com/embed/2VRR0JW23qc"></iframe></li>
268
- <li><strong>Need help in settings of x-payments? <a href="http://www.x-payments.com/contact-us.html?utm_source=mage_shop&utm_medium=link&utm_campaign=mage_shop_link" target="_blank">Сontact us!</a></strong></li>
269
- </ol>
270
- </div>
271
- <script>
272
- document.observe('dom:loaded', function(){
273
- var bundleKey = $('xpaymentsconnector_settings_xpay_conf_bundle').getValue();
274
- if(bundleKey.trim() == ''){
275
- $('xp-connector-settings').show();
276
- }
277
- });
278
- </script>
279
- ]]>
280
- </comment>
281
- </settings>
282
- </groups>
283
- </xpaymentsconnector>
284
- </sections>
285
  </config>
1
  <?xml version="1.0"?>
2
+ <!-- vim: set ts=4 sw=4 sts=4 et: -->
3
  <!--
4
  /**
5
  * Magento
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
24
  <config>
25
+ <sections>
26
+ <payment>
27
+ <groups>
28
+ <xpayments1 translate="label" module="xpaymentsconnector">
29
+ <label>X-Payments connector</label>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
30
  <frontend_type>text</frontend_type>
31
  <sort_order>201</sort_order>
32
  <show_in_default>1</show_in_default>
58
  <show_in_website>1</show_in_website>
59
  <show_in_store>0</show_in_store>
60
  </title>
61
+ <allowspecific translate="label">
62
+ <label>Payment from applicable countries</label>
63
+ <frontend_type>allowspecific</frontend_type>
64
+ <sort_order>4</sort_order>
65
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
 
 
 
 
 
 
 
 
 
 
 
66
  <show_in_default>1</show_in_default>
67
  <show_in_website>1</show_in_website>
68
  <show_in_store>0</show_in_store>
69
+ </allowspecific>
70
+ <specificcountry translate="label">
71
+ <label>Payment from Specific countries</label>
72
+ <frontend_type>multiselect</frontend_type>
73
+ <sort_order>5</sort_order>
74
+ <source_model>adminhtml/system_config_source_country</source_model>
75
  <show_in_default>1</show_in_default>
76
  <show_in_website>1</show_in_website>
77
  <show_in_store>0</show_in_store>
78
+ </specificcountry>
79
+ <confid translate="label">
80
+ <label>Payment configuration</label>
81
+ <frontend_type>select</frontend_type>
82
+ <sort_order>6</sort_order>
83
+ <source_model>xpaymentsconnector/source_paymentconfiguration</source_model>
84
  <show_in_default>1</show_in_default>
85
  <show_in_website>1</show_in_website>
86
  <show_in_store>0</show_in_store>
87
+ </confid>
88
+ <use_authorize translate="label">
89
+ <label>Use forced Authorize operation</label>
90
+ <comment><![CDATA[Work only for non recurring product order.]]></comment>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
91
  <frontend_type>select</frontend_type>
92
+ <source_model>adminhtml/system_config_source_yesno</source_model>
93
+ <sort_order>9</sort_order>
94
  <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
  <show_in_store>0</show_in_store>
97
+ </use_authorize>
98
+ <use_initialfee_authorize translate="label">
99
+ <label>Use forced Authorize operation for recurring products</label>
100
+ <frontend_type>select</frontend_type>
101
+ <source_model>adminhtml/system_config_source_yesno</source_model>
102
+ <sort_order>10</sort_order>
103
  <show_in_default>1</show_in_default>
104
+ <show_in_website>1</show_in_website>
 
 
 
 
 
 
 
105
  <show_in_store>0</show_in_store>
106
+ </use_initialfee_authorize>
107
 
108
+ </fields>
109
+ </xpayments1>
110
+ </groups>
111
+ </payment>
112
+ </sections>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
113
  </config>
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-install-1.0.0.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.0-1.0.1.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.1-1.0.2.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.2-1.0.3.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.3-1.0.4.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.4-1.0.5.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.5-1.0.6.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.6-1.0.7.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.7-1.0.8.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.8-1.0.9.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.9-1.1.0.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.0-1.1.1.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.1-1.1.2.php CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.2-1.1.3.php CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -31,14 +31,14 @@ $installer->run("
31
  CREATE TABLE {$this->getTable('xpayment_quote_xpcdata')} (
32
  `data_id` int(11) unsigned NOT NULL auto_increment,
33
  `quote_id` int(11) NOT NULL default 0,
34
- `payment_method_code` varchar(255) NOT NULL,
35
- `txn_id` varchar(255) NOT NULL,
36
- `token` varchar(255) NOT NULL,
37
  `address_saved` BOOL default false,
38
  `recurring_order_id` int(11) NOT NULL default 0,
39
  `recurring_profile_id` int(11) NOT NULL default 0,
40
  `xpc_message` TEXT,
41
- `checkout_data` TEXT,
42
  PRIMARY KEY (`data_id`)
43
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
44
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
31
  CREATE TABLE {$this->getTable('xpayment_quote_xpcdata')} (
32
  `data_id` int(11) unsigned NOT NULL auto_increment,
33
  `quote_id` int(11) NOT NULL default 0,
34
+ `payment_method_code` varchar(255) NOT NULL,
35
+ `txn_id` varchar(255) NOT NULL,
36
+ `token` varchar(255) NOT NULL,
37
  `address_saved` BOOL default false,
38
  `recurring_order_id` int(11) NOT NULL default 0,
39
  `recurring_profile_id` int(11) NOT NULL default 0,
40
  `xpc_message` TEXT,
41
+ `checkout_data` TEXT,
42
  PRIMARY KEY (`data_id`)
43
  ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
44
 
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.1.3-1.8.0.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Used to store saved customer payment cards
25
+ */
26
+
27
+ $installer = $this;
28
+ $installer->startSetup();
29
+
30
+ $paymentConfTable = $installer->getTable('xpayment_configurations');
31
+
32
+ $installer->getConnection()
33
+ ->addColumn($paymentConfTable, 'can_save_cards', array(
34
+ 'nullable' => false,
35
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
36
+ 'length' => '1',
37
+ 'comment' => 'Possible to use for recharges or not'
38
+ ));
39
+
40
+ $installer->getConnection()
41
+ ->addColumn($paymentConfTable, 'save_cards', array(
42
+ 'nullable' => false,
43
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
44
+ 'length' => '1',
45
+ 'comment' => 'Use for recharges or not'
46
+ ));
47
+
48
+ $installer->getConnection()
49
+ ->addColumn($paymentConfTable, 'currency', array(
50
+ 'nullable' => false,
51
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
52
+ 'length' => '3',
53
+ 'comment' => 'Currency ISO code'
54
+ ));
55
+
56
+ $installer->getConnection()
57
+ ->addColumn($paymentConfTable, 'active', array(
58
+ 'nullable' => false,
59
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
60
+ 'length' => '1',
61
+ 'comment' => 'Is payment configuration active'
62
+ ));
63
+
64
+ $installer->getConnection()
65
+ ->addColumn($paymentConfTable, 'payment_method_data', array(
66
+ 'nullable' => false,
67
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
68
+ 'length' => '65536',
69
+ 'comment' => 'Payment method data'
70
+ ));
71
+
72
+ $fraudCheckDataTable = $this->getTable('xpayment_fraud_check_data');
73
+
74
+ $installer->getConnection()->modifyColumn($fraudCheckDataTable, 'errors', 'TEXT NOT NULL DEFAULT ""');
75
+ $installer->getConnection()->modifyColumn($fraudCheckDataTable, 'warnings', 'TEXT NOT NULL DEFAULT ""');
76
+ $installer->getConnection()->modifyColumn($fraudCheckDataTable, 'rules', 'TEXT NOT NULL DEFAULT ""');
77
+ $installer->getConnection()->modifyColumn($fraudCheckDataTable, 'data', 'TEXT NOT NULL DEFAULT ""');
78
+
79
+ $quoteXpcDataTable = $installer->getTable('xpaymentsconnector/quote_xpcdata');
80
+
81
+ $installer->getConnection()->addColumn($quoteXpcDataTable, 'backend_orderid', array(
82
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
83
+ 'comment' => 'Backend order ID'
84
+ ));
85
+
86
+ $installer->getConnection()->addColumn($quoteXpcDataTable, 'xpc_slot', array(
87
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
88
+ 'comment' => 'Slot index of the XPC payment method'
89
+ ));
90
+
91
+ $installer->getConnection()->dropColumn($quoteXpcDataTable, 'payment_method_code');
92
+
93
+ $usercardsTable = $installer->getTable('xpaymentsconnector/usercards');
94
+
95
+ $installer->getConnection()->addColumn($usercardsTable, 'confid', array(
96
+ 'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
97
+ 'comment' => 'Payment configuration ID'
98
+ ));
99
+
100
+ $quoteTable = $installer->getTable('sales/quote');
101
+
102
+ $installer->getConnection()->dropColumn($quoteTable, 'xp_callback_approve');
103
+
104
+ $paymentMethodTable = $installer->getTable('sales_flat_order_payment');
105
+
106
+ $installer->run('UPDATE ' . $paymentMethodTable . ' SET method = "xpayments1" WHERE method = "xpayments"');
107
+
108
+ $configTable = $installer->getTable('core_config_data');
109
+
110
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/active" WHERE path = "payment/xpayments/active"');
111
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/title" WHERE path = "payment/xpayments/title"');
112
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/sort_order" WHERE path = "payment/xpayments/sort_order"');
113
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/use_authorize" WHERE path = "payment/xpayments/use_authorize"');
114
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/use_initialfee_authorize" WHERE path = "payment/xpayments/use_initialfee_authorize"');
115
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/allowspecific" WHERE path = "payment/xpayments/allowspecific"');
116
+ $installer->run('UPDATE ' . $configTable . ' SET path = "payment/xpayments1/specificcountry" WHERE path = "payment/xpayments/specificcountry"');
117
+
118
+ $installer->run('UPDATE ' . $configTable . ' SET path = "xpaymentsconnector/settings/xpay_use_iframe" WHERE path = "payment/xpayments/use_iframe"');
119
+ $installer->run('UPDATE ' . $configTable . ' SET path = "xpaymentsconnector/settings/xpay_iframe_place" WHERE path = "payment/xpayments/placedisplay"');
120
+
121
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/xpaymentsconnector.xml CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  -->
@@ -24,14 +24,14 @@
24
 
25
  <adminhtml_customer_edit>
26
  <reference name="head">
27
- <action method="addItem">
28
  <type>js_css</type>
29
  <name>xpayment/settings.css</name>
30
  <params/>
31
  </action>
32
  </reference>
33
  <reference name="customer_edit_tabs">
34
- <action method="addTab">
35
  <name>customer_edit_tab_usercards</name>
36
  <block>xpaymentsconnector/adminhtml_customer_edit_tab_usercards</block>
37
  </action>
@@ -43,7 +43,7 @@
43
 
44
  <adminhtml_sales_order_create_index>
45
  <reference name="head">
46
- <action method="addItem">
47
  <type>js_css</type>
48
  <name>xpayment/settings.css</name>
49
  <params/>
@@ -53,12 +53,12 @@
53
 
54
  <adminhtml_sales_order_view>
55
  <reference name="head">
56
- <action method="addItem">
57
  <type>js</type>
58
  <name>xpayment/backend-xpayment.js</name>
59
  <params/>
60
  </action>
61
- <action method="addItem">
62
  <type>js_css</type>
63
  <name>xpayment/settings.css</name>
64
  <params/>
@@ -99,7 +99,51 @@
99
  <type>js_css</type>
100
  <name>xpayment/settings-xpc.css</name>
101
  </action>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
102
  </reference>
103
  </adminhtml_settings_xpc_index>
104
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
105
  </layout>
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  -->
24
 
25
  <adminhtml_customer_edit>
26
  <reference name="head">
27
+ <action method="addItem" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
28
  <type>js_css</type>
29
  <name>xpayment/settings.css</name>
30
  <params/>
31
  </action>
32
  </reference>
33
  <reference name="customer_edit_tabs">
34
+ <action method="addTab" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
35
  <name>customer_edit_tab_usercards</name>
36
  <block>xpaymentsconnector/adminhtml_customer_edit_tab_usercards</block>
37
  </action>
43
 
44
  <adminhtml_sales_order_create_index>
45
  <reference name="head">
46
+ <action method="addItem" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
47
  <type>js_css</type>
48
  <name>xpayment/settings.css</name>
49
  <params/>
53
 
54
  <adminhtml_sales_order_view>
55
  <reference name="head">
56
+ <action method="addItem" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
57
  <type>js</type>
58
  <name>xpayment/backend-xpayment.js</name>
59
  <params/>
60
  </action>
61
+ <action method="addItem" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
62
  <type>js_css</type>
63
  <name>xpayment/settings.css</name>
64
  <params/>
99
  <type>js_css</type>
100
  <name>xpayment/settings-xpc.css</name>
101
  </action>
102
+ <action method="addItem">
103
+ <type>js</type>
104
+ <name>xpayment/settings-xpc.js</name>
105
+ </action>
106
+ </reference>
107
+ <reference name="left">
108
+ <block type="xpaymentsconnector/adminhtml_settings_tabs" name="settings_xpc_tabs">
109
+ <block type="xpaymentsconnector/adminhtml_settings_tab_welcome" name="settings_xpc_tab_welcome" />
110
+ <block type="xpaymentsconnector/adminhtml_settings_tab_connection" name="settings_xpc_tab_connection" />
111
+ <block type="xpaymentsconnector/adminhtml_settings_tab_paymentMethods" name="settings_xpc_tab_paymentmethods" />
112
+ <block type="xpaymentsconnector/adminhtml_settings_tab_zeroAuth" name="settings_xpc_tab_zeroauth" />
113
+ <action method="addTab">
114
+ <name>welcome_section</name>
115
+ <block>settings_xpc_tab_welcome</block>
116
+ </action>
117
+ <action method="addTab">
118
+ <name>connection_section</name>
119
+ <block>settings_xpc_tab_connection</block>
120
+ </action>
121
+ <action method="addTab">
122
+ <name>paymentmethods_section</name>
123
+ <block>settings_xpc_tab_paymentmethods</block>
124
+ </action>
125
+ <action method="addTab">
126
+ <name>zeroauth_section</name>
127
+ <block>settings_xpc_tab_zeroauth</block>
128
+ </action>
129
+ </block>
130
+ <block type="xpaymentsconnector/adminhtml_settings_help" name="xpc_help"></block>
131
  </reference>
132
  </adminhtml_settings_xpc_index>
133
 
134
+ <adminhtml_addnewcard_index>
135
+ <reference name="head">
136
+ <action method="addItem">
137
+ <type>js_css</type>
138
+ <name>xpayment/add-new-card.css</name>
139
+ </action>
140
+ </reference>
141
+ <reference name="head">
142
+ <action method="addItem">
143
+ <type>js</type>
144
+ <name>xpayment/add-new-card.js</name>
145
+ </action>
146
+ </reference>
147
+ </adminhtml_addnewcard_index>
148
+
149
  </layout>
app/design/adminhtml/default/default/template/xpaymentsconnector/form/cc.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * Hint for the payment method when order is created in the admin backend.
25
+ * To simplify, the template name matches the one in the frontend.
26
+ */
27
+ ?>
28
+ <div class="messages warning-msg" id="redirect-xpc-warning">
29
+ <?php echo $this->__('After hitting the Submit Order button you\'ll be redirected to the payment form'); ?>
30
+ </div>
app/design/adminhtml/default/default/template/xpaymentsconnector/form/prepaidpayments.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
@@ -42,7 +42,7 @@
42
  <span class="input-box">
43
  <input disabled="" type="radio" <?php echo $checked;?> title="<?php echo "'".$prepaidCard->getData("card_type")."'"; ?> - credit card" class="input-radio x-payment-card validate-one-required-by-name" id="<?php echo $_code."_".$prepaidCard->getData("xp_card_id"); ?>" name="payment[xp_prepaid_payments]" value="<?php echo $prepaidCard->getData("xp_card_id");?>" />
44
  <label for="<?php echo $_code."_".$prepaidCard->getData("xp_card_id") ?>">Use card ( **<?php echo $prepaidCard->getData("last_4_cc_num");?> )</label>
45
- <span class="x-payment-card-logo <?php echo strtolower($prepaidCard->getData("card_type")) ?>" title="<?php echo $prepaidCard->getData("card_type");?>"></span>
46
  <span class="balance" style=""><?php echo Mage::helper('xpaymentsconnector')->__("Balance:"); ?>
47
  &nbsp;&nbsp;
48
  <?php echo Mage::helper('core')->currency($prepaidCard->getAmount()); ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
42
  <span class="input-box">
43
  <input disabled="" type="radio" <?php echo $checked;?> title="<?php echo "'".$prepaidCard->getData("card_type")."'"; ?> - credit card" class="input-radio x-payment-card validate-one-required-by-name" id="<?php echo $_code."_".$prepaidCard->getData("xp_card_id"); ?>" name="payment[xp_prepaid_payments]" value="<?php echo $prepaidCard->getData("xp_card_id");?>" />
44
  <label for="<?php echo $_code."_".$prepaidCard->getData("xp_card_id") ?>">Use card ( **<?php echo $prepaidCard->getData("last_4_cc_num");?> )</label>
45
+ <span class="xpc-card-logo <?php echo strtolower($prepaidCard->getData("card_type")) ?>" title="<?php echo $prepaidCard->getData("card_type");?>"></span>
46
  <span class="balance" style=""><?php echo Mage::helper('xpaymentsconnector')->__("Balance:"); ?>
47
  &nbsp;&nbsp;
48
  <?php echo Mage::helper('core')->currency($prepaidCard->getAmount()); ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/form/savedcards.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
@@ -51,8 +51,7 @@
51
  <?php echo $this->__('Use card - %s', $xpCardDataStr); ?>
52
  </label>
53
 
54
- <span class="x-payment-card-logo <?php echo strtolower($creditCard->getCardType()) ?>"
55
- title="<?php echo $creditCard->getCardType();?>"></span>
56
  </span>
57
 
58
  </li>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
51
  <?php echo $this->__('Use card - %s', $xpCardDataStr); ?>
52
  </label>
53
 
54
+ <span class="xpc-card-logo <?php echo strtolower($creditCard->getCardType()); ?>" title="<?php echo $creditCard->getCardType(); ?>"></span>
 
55
  </span>
56
 
57
  </li>
app/design/adminhtml/default/default/template/xpaymentsconnector/info.phtml CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -14,16 +15,33 @@
14
  *
15
  * @category Cdev
16
  * @package Cdev_XPaymentsConnector
17
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  * @version SVN: $Id: info.phtml 3624 2010-07-28 05:45:05Z max $
20
  */
21
  ?>
22
- <?php echo $this->getMethod()->getTitle(); ?><br />
23
- <?php if ($this->getInfo()->getLastTransId() == '') { ?>
24
- <?php echo Mage::helper('xpaymentsconnector')->__('Payment has not been processed yet.'); ?><br />
25
- <?php } else { ?>
26
- <?php echo Mage::helper('xpaymentsconnector')->__('X-Payments transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())); ?><br />
27
- <?php echo Mage::helper('xpaymentsconnector')->__('AVS status: %s', $this->htmlEscape($this->getInfo()->getCcAvsStatus())); ?><br />
28
- <a href="<?php echo $this->getXPaymentURL(); ?>"><?php echo Mage::helper('xpaymentsconnector')->__('Go to X-Payments payment page'); ?></a><br />
29
- <?php } ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
  /**
4
  * Magento
5
  *
15
  *
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  * @version SVN: $Id: info.phtml 3624 2010-07-28 05:45:05Z max $
21
  */
22
  ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Info_Cc
26
+ */
27
+ ?>
28
+
29
+ <?php echo $this->getMethod()->getTitle(); ?>
30
+ <br />
31
+
32
+ <?php if ($this->getInfo()->getLastTransId() == ''): ?>
33
+
34
+ <?php echo Mage::helper('xpaymentsconnector')->__('Payment has not been processed yet.'); ?>
35
+ <br />
36
+
37
+ <?php else: ?>
38
+
39
+ <?php echo Mage::helper('xpaymentsconnector')->__('X-Payments transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())); ?>
40
+ <br />
41
+
42
+ <?php echo Mage::helper('xpaymentsconnector')->__('AVS status: %s', $this->htmlEscape($this->getInfo()->getCcAvsStatus())); ?>
43
+ <br />
44
+ <a href="<?php echo $this->escapeUrl($this->getXPaymentURL()); ?>"><?php echo Mage::helper('xpaymentsconnector')->__('Go to X-Payments payment page'); ?></a>
45
+ <br />
46
+
47
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/info/cc.phtml CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/info/savedcards.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/order/pay.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * X-Payments payment form for backend order template
26
+ *
27
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_Pay
28
+ */
29
+ ?>
30
+
31
+ <form id="xpc-form-redirect" action="<?php echo $this->getFormAction(); ?>" method="post">
32
+ <?php foreach ($this->getFields() as $name => $value): ?>
33
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>" />
34
+ <?php endforeach; ?>
35
+ </form>
36
+
37
+ <script type="text/javascript">
38
+ //<![CDATA[
39
+ var paymentform = document.getElementById('xpc-form-redirect');
40
+ window.onload = function() {
41
+ paymentform.submit();
42
+ }
43
+ //]]>
44
+ </script>
app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
@@ -28,261 +28,260 @@
28
  */
29
  ?>
30
 
31
- <?php $xpaymentsOrderInfo = $this->getXpaymentsOrderInfo(); ?>
32
- <?php if($xpaymentsOrderInfo["success"]): ?>
33
- <?php $xpaymentOrdersInfoList = $xpaymentsOrderInfo["info"];?>
34
- <?php foreach($xpaymentOrdersInfoList as $orderIncrementId => $xpaymentOrderInfoData): ?>
35
- <?php $xpaymentOrdersState[$orderIncrementId] = $xpaymentOrderInfoData["payment"];?>
36
- <?php $xpaymentOrdertransactionsList = $xpaymentOrderInfoData["transactions"]; ?>
37
- <div class="entry-edit">
38
- <div class="entry-edit-head xp-transaction-head-block">
39
- <h4><?php echo $this->__("Transaction list for order %s",$orderIncrementId);?></h4>
40
- <span class="transaction-accordion">
41
- <span class="transaction-down" >
42
- <img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-down.png" ?>">
43
- </span>
44
- <span class="transaction-up" style="display: none">
45
- <img src="<?php echo Mage::getBaseUrl('js') . "xpayment/images/arrow-up.png" ?>">
46
- </span>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
47
  </span>
48
- </div>
49
-
50
- <div class="grid np" style="display: none">
51
- <div class="hor-scroll">
52
- <table cellspacing="0" id="xpayment-transaction-list" class="data order-tables">
53
- <colgroup>
54
- <col />
55
- <col />
56
- <col width="1">
57
- <col width="1">
58
- <col width="1">
59
- <col width="1">
60
- <col width="1">
61
- </colgroup><thead>
62
- <tr class="headings">
63
- <th><span class="nobr"><?php echo $this->__('Additional info'); ?></span></th>
64
- <th><span class="nobr"><?php echo $this->__('Date, time'); ?></span></th>
65
- <th><span class="nobr"><?php echo $this->__('Type'); ?></span></th>
66
- <th><span class="nobr"><?php echo $this->__('Result payment status'); ?></span></th>
67
- <th class="last"><span class="nobr"><?php echo $this->__('Transaction result'); ?></span></th>
68
- <th class="last"><span class="nobr"><?php echo $this->__('Total'); ?></span></th>
69
- </tr>
70
- </thead>
71
- <tbody>
72
- <?php $rowClass = "odd";?>
73
- <?php foreach($xpaymentOrdertransactionsList as $key => $transaction):?>
74
- <?php $rowClass = ($key%2==0)?"even":"odd"; ?>
75
- <tr class="border pointer <?php echo $rowClass?>">
76
- <td>
77
- <div class="item-container" >
78
- <?php if (!empty($transaction["fields"])): ?>
79
- <table cellspacing="0" class="form-list">
80
- <tbody>
81
- <?php foreach($transaction["fields"] as $field): ?>
82
- <tr>
83
- <td class="label"><label><?php echo $field["name"]?></label></td>
84
- <td class="value"><strong><?php echo $field["value"]?></strong></td>
85
- </tr>
86
- <?php endforeach; ?>
87
- </tbody>
88
- </table>
89
- <?php endif; ?>
90
- </div>
91
- </td>
92
- <td>
93
- <div class="item-container">
94
- <div class="item-text">
95
- <strong>
96
- <?php echo date("M d,Y H:i:s",$transaction["date"]);?>
97
- </strong>
98
- </div>
99
- </div>
100
- </td>
101
- <td class="a-center">
102
- <span class="price">
103
- <strong>
104
- <?php echo $transaction["action"];?>
105
- </strong>
106
- </span></td>
107
- <td class="a-center">
108
- <span class="price">
109
- <?php echo $transaction["payment_status"];?>
110
- </span>
111
- </td>
112
- <td class="a-center">
113
- <span class="price">
114
- <?php echo $transaction["status"];?>
115
- </span>
116
- </td>
117
- <td class="a-center">
118
- <span class="price">
119
- <strong>
120
- <?php echo $transaction["total"];?>
121
- </strong>
122
- </span>
123
- </td>
124
- </tr>
125
- <?php endforeach;?>
126
- </tbody>
127
- </table>
128
- </div>
129
- </div>
130
- </div>
131
- <br/>
132
- <?php endforeach;?>
133
- <?php if (!empty($xpaymentOrdersState)): ?>
134
- <p>
135
- <div class="entry-edit">
136
- <div class="entry-edit-head">
137
- <h4><?php echo $this->__('Order(s) state'); ?></h4>
138
- </div>
139
-
140
- <div class="grid">
141
- <div class="hor-scroll">
142
- <table cellspacing="0" class="data order-tables">
143
- <colgroup>
144
- <col>
145
- <col width="1">
146
- <col width="1">
147
- <col width="1">
148
- <col width="1">
149
- </colgroup>
150
- <thead>
151
- <tr class="headings">
152
- <th><span class="nobr"><?php echo $this->__('Order ID'); ?></span></th>
153
- <th><span class="nobr"><?php echo $this->__('Amount'); ?></span></th>
154
- <th><span class="nobr"><?php echo $this->__('Authorized'); ?></span></th>
155
- <th><span class="nobr"><?php echo $this->__('Captured'); ?></span></th>
156
- <th class="last"><span class="nobr"><?php echo $this->__('Refunds'); ?></span></th>
157
- <th class="last"><span class="nobr"><?php echo $this->__('Actions'); ?></span></th>
158
- </tr>
159
- </thead>
160
- <tbody class="even">
161
- <?php foreach ($xpaymentOrdersState as $orderIncrementId => $orderStateData): ?>
162
- <tr class="border">
163
- <td>
164
- <div class="item-text">
165
- <?php echo $orderIncrementId;?>
166
- </div>
167
- </td>
168
- <td>
169
- <div class="item-container" id="order_item_446">
170
- <div class="item-text">
171
- <?php if (!empty($orderStateData["message"])): ?>
172
- <h5 class="title">
173
- <span id="order_title">
174
- <?php echo $this->__($orderStateData["message"]); ?>
175
- </span></h5>
176
- <?php endif; ?>
177
- <span class="price">
178
- <?php echo Mage::helper('core')->currency($orderStateData["amount"], true, false); ?>
179
- </span>
180
- </div>
181
- </div>
182
- </td>
183
- <td class="a-center">
184
- <span class="price">
185
- <?php if($orderStateData["authorized"] > 0): ?>
186
- <?php echo Mage::helper('core')->currency($orderStateData["authorized"], true, false); ?>
187
- <?php endif;?>
188
- </span></td>
189
- <td class="a-center">
190
- <span class="price">
191
- <?php if($orderStateData["capturedAmount"] > 0): ?>
192
- <?php echo Mage::helper('core')->currency($orderStateData["capturedAmount"], true, false); ?>
193
- <?php endif;?>
194
- </span>
195
- </td>
196
- <td class="a-center">
197
- <span class="price">
198
- <?php if($orderStateData["refundedAmount"] > 0): ?>
199
- <?php echo Mage::helper('core')->currency($orderStateData["refundedAmount"], true, false); ?>
200
- <?php endif;?>
201
- </span>
202
- </td>
203
- <td>
204
- <div class="item-text">
205
- <?php
206
- $actionAmount = $this->getCurrentActionAmount($orderStateData);
207
- $cssFormId = "xp_fast_transactions_".$orderIncrementId;
208
- $amountValidatorName = "validate-transaction-amount_".$orderIncrementId;
209
- $requiredValidatorName = "required-entry_".$orderIncrementId;
210
- $currentUrl = Mage::helper('core/url')->getCurrentUrl();
211
- $formKey = Mage::getSingleton('core/session')->getFormKey();
212
- ?>
213
-
214
- <form method="post" id="<?php echo $cssFormId?>" class="xp_fast_transactions" action="<?php echo $currentUrl;?>" >
215
- <input type="hidden" name="form_key" value="<?php echo $formKey; ?>" />
216
- <input type="text"
217
- class="<?php echo $amountValidatorName." ".$requiredValidatorName;?> input-text transaction-amount"
218
- name="transaction_amount"
219
- value="<?php echo $actionAmount?>">
220
-
221
- <input type="hidden" name="orderid" value="<?php echo $orderIncrementId;?>">
222
- <input type="hidden" name="xpc_txnid" value="<?php echo $orderStateData['xpc_txnid'];?>">
223
- <input type="hidden" name="xpaction" class="xpaction" value="">
224
- <?php if($orderStateData["capturedAmountAvail"] > 0): ?>
225
- <input type="button"
226
- class="form-button xp-transaction-submit"
227
- name="capture"
228
- onclick="submitXpTransaction(
229
- 'capture',
230
- '<?php echo $cssFormId?>',
231
- '<?php echo $amountValidatorName?>',
232
- '<?php echo $requiredValidatorName?>')"
233
- value="Capture">
234
- </br>
235
- <?php endif;?>
236
- <?php if($orderStateData["voidedAmountAvail"] > 0): ?>
237
- <input type="button"
238
- class="form-button xp-transaction-submit"
239
- name="void"
240
- onclick="submitXpTransaction(
241
- 'void',
242
- '<?php echo $cssFormId?>',
243
- '<?php echo $amountValidatorName?>',
244
- '<?php echo $requiredValidatorName?>',
245
- '<?php echo $orderStateData["voidedAmountAvail"]?>')"
246
- class="form-button "
247
- value="Void (<?php echo Mage::helper('core')->currency($orderStateData["voidedAmountAvail"], true, false);?>)">
248
- <?php endif;?>
249
- <?php if($orderStateData["refundedAmountAvail"] > 0): ?>
250
- <input
251
- type="button"
252
- name="refund"
253
- class="form-button"
254
- onclick="submitXpTransaction(
255
- 'refund',
256
- '<?php echo $cssFormId?>',
257
- '<?php echo $amountValidatorName?>',
258
- '<?php echo $requiredValidatorName?>')"
259
- value="Refund">
260
- <?php endif;?>
261
- </form>
262
- </div>
263
- </td>
264
  </tr>
265
- <?php endforeach?>
266
- </tbody>
267
- </table>
268
- </div>
269
- </div>
270
- </div>
271
- </p>
272
- <?php endif?>
273
-
274
- <?php else: ?>
275
- <?php echo $xpaymentsOrderInfo["error_message"];?>
276
- <?php endif;?>
277
 
278
- <?php
 
 
279
 
280
- $fraudCheckData = Mage::getModel('xpaymentsconnector/fraudcheckdata')
281
- ->getCollection()
282
- ->addFieldToFilter('order_id', $this->getOrder()->getId());
283
- ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
284
 
285
- <?php foreach ($fraudCheckData as $data): ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
286
  <div class="entry-edit">
287
  <div class="entry-edit-head">
288
  <h4><?php echo $this->__($data->getData('service')); ?></h4>
@@ -320,7 +319,7 @@ $fraudCheckData = Mage::getModel('xpaymentsconnector/fraudcheckdata')
320
  <td class="label"><?php echo $this->__('Transaction ID'); ?></td>
321
  <td class="value">
322
  <?php if ($data->getData('url')): ?>
323
- <strong><a href="<?php echo $data->getData('url'); ?>" target="_blank"><?php echo $data->getData('transaction_id'); ?></a></strong>
324
  <?php else: ?>
325
  <strong><?php echo $data->getData('transaction_id'); ?></strong>
326
  <?php endif; ?>
@@ -367,3 +366,19 @@ $fraudCheckData = Mage::getModel('xpaymentsconnector/fraudcheckdata')
367
  </div>
368
  </div>
369
  <?php endforeach; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
28
  */
29
  ?>
30
 
31
+ <?php if ($this->getError()): ?>
32
+ <ul class="messages">
33
+ <li class="error-msg">
34
+ <?php echo $this->__($this->getError()); ?>
35
+ </li>
36
+ </ul>
37
+ <?php endif; ?>
38
+
39
+
40
+ <?php foreach ($this->getTransactions() as $orderId => $orderTransactions): ?>
41
+
42
+ <div class="entry-edit">
43
+
44
+ <div class="entry-edit-head xp-transaction-head-block pointer">
45
+ <h4><?php echo $this->__('Transaction list for order %s', $orderId); ?></h4>
46
+ <span class="transaction-accordion">
47
+ <span class="transaction-down" >
48
+ <img src="<?php echo $this->getArrowImg('down'); ?>">
49
+ </span>
50
+ <span class="transaction-up" style="display: none">
51
+ <img src="<?php echo $this->getArrowImg('up'); ?>">
52
+ </span>
53
+ </span>
54
+ </div>
55
+
56
+ <div class="grid np" style="display: none">
57
+ <div class="hor-scroll">
58
+
59
+ <?php if (!empty($orderTransactions)): ?>
60
+
61
+ <table cellspacing="0" id="xpayment-transaction-list" class="data order-tables">
62
+
63
+ <thead>
64
+ <tr class="headings">
65
+ <th><span class="nobr"><?php echo $this->__('Transaction ID'); ?></span></th>
66
+ <th><span class="nobr"><?php echo $this->__('Date, time'); ?></span></th>
67
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Amount'); ?></span></th>
68
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Type'); ?></span></th>
69
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Result payment status'); ?></span></th>
70
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Transaction result'); ?></span></th>
71
+ <th><span class="nobr last"><?php echo $this->__('Additional info'); ?></span></th>
72
+ </tr>
73
+ </thead>
74
+
75
+ <tbody>
76
+ <?php foreach($orderTransactions as $key => $transaction): ?>
77
+ <tr class="border pointer <?php echo $this->getRowClass($key); ?>">
78
+
79
+ <td>
80
+ <span class="price">
81
+ <strong><?php echo $this->__($transaction['txnid']); ?></strong>
82
  </span>
83
+ </td>
84
+
85
+ <td>
86
+ <div class="item-container">
87
+ <div class="item-text nobr" title="<?php echo $this->getTransactionDateTime($transaction); ?>">
88
+ <?php if (!empty($transaction['date'])): ?>
89
+ <strong><?php echo $this->getTransactionDate($transaction); ?></strong>
90
+ <?php echo $this->getTransactionTime($transaction); ?>
91
+ <?php else: ?>
92
+ <i><?php echo $this->__('Unknown'); ?></i>
93
+ <?php endif; ?>
94
+ </div>
95
+ </div>
96
+ </td>
97
+
98
+ <td class="a-center">
99
+ <span class="price">
100
+ <strong><?php echo $this->__($transaction['total']); ?></strong>
101
+ </span>
102
+ </td>
103
+
104
+ <td class="a-center">
105
+ <span class="price">
106
+ <strong><?php echo $this->__($transaction['action']); ?></strong>
107
+ </span>
108
+ </td>
109
+
110
+ <td class="a-center">
111
+ <span class="price">
112
+ <?php echo $this->__($transaction['payment_status']); ?>
113
+ </span>
114
+ </td>
115
+
116
+ <td class="a-center">
117
+ <span class="price">
118
+ <?php echo $this->__($transaction['status']); ?>
119
+ </span>
120
+ </td>
121
+
122
+ <td>
123
+ <div class="item-container" >
124
+ <?php if (!empty($transaction['fields'])): ?>
125
+ <table cellspacing="0" class="form-list">
126
+ <?php foreach($transaction['fields'] as $field): ?>
127
+ <tr>
128
+ <td class="label"><label><?php echo $field['name']; ?></label></td>
129
+ <td class="value"><strong><?php echo $field['value']; ?></strong></td>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
130
  </tr>
131
+ <?php endforeach; ?>
132
+ </table>
133
+ <?php endif; ?>
134
+ </div>
135
+ </td>
 
 
 
 
 
 
 
136
 
137
+ </tr>
138
+ <?php endforeach; ?>
139
+ </tbody>
140
 
141
+ </table>
142
+
143
+ <?php else: /* if (!empty($orderTransactions)): */ ?>
144
+
145
+ <?php echo $this->__('No payment transactions for this order'); ?>
146
+
147
+ <?php endif; /* if (!empty($transactions)): */ ?>
148
+
149
+ </div> <!-- class="hor-scroll" -->
150
+ </div> <!-- class="grid np" -->
151
+
152
+ </div> <!-- class="entry-edit" -->
153
+
154
+ <br />
155
+
156
+ <?php endforeach; /* foreach ($this->getTransactions() as $orderId => $orderTransactions): */ ?>
157
+
158
+
159
+ <?php foreach ($this->getOrderData() as $orderId => $data): ?>
160
 
161
+ <div class="entry-edit">
162
+ <div class="entry-edit-head">
163
+ <h4><?php echo $this->__('Order(s) state'); ?></h4>
164
+ </div>
165
+
166
+ <div class="grid">
167
+ <div class="hor-scroll">
168
+
169
+ <?php if (!empty($data)): ?>
170
+
171
+ <table cellspacing="0" class="data order-tables">
172
+
173
+ <thead>
174
+ <tr class="headings">
175
+ <th><span class="nobr"><?php echo $this->__('Order ID'); ?></span></th>
176
+ <th><span class="nobr"><?php echo $this->__('Payment status'); ?></span></th>
177
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Amount'); ?></span></th>
178
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Authorized'); ?></span></th>
179
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Captured'); ?></span></th>
180
+ <th class="a-center"><span class="nobr"><?php echo $this->__('Refunds'); ?></span></th>
181
+ <th class="last"><span class="nobr"><?php echo $this->__('Actions'); ?></span></th>
182
+ </tr>
183
+ </thead>
184
+
185
+ <tbody>
186
+ <tr class="border">
187
+
188
+ <td>
189
+ <div class="item-text"><?php echo $orderId; ?></div>
190
+ </td>
191
+
192
+ <td>
193
+ <div class="item-container">
194
+ <div class="item-text nobr">
195
+ <?php if (!empty($data['message'])): ?>
196
+ <strong><?php echo $this->__($data['message']); ?></strong>
197
+ <?php else: ?>
198
+ <strong><?php echo $this->__('Unknown'); ?></strong>
199
+ <?php endif; ?>
200
+ </div>
201
+ </div>
202
+ </td>
203
+
204
+ <td class="a-center">
205
+ <div class="item-container">
206
+ <div class="item-text">
207
+ <span class="price">
208
+ <?php echo Mage::helper('core')->currency($data['amount'], true, false); ?>
209
+ </span>
210
+ </div>
211
+ </div>
212
+ </td>
213
+
214
+ <td class="a-center">
215
+ <span class="price">
216
+ <?php if ($data['authorized'] > 0): ?>
217
+ <?php echo Mage::helper('core')->currency($data['authorized'], true, false); ?>
218
+ <?php endif; ?>
219
+ </span>
220
+ </td>
221
+
222
+ <td class="a-center">
223
+ <span class="price">
224
+ <?php if ($data['capturedAmount'] > 0): ?>
225
+ <?php echo Mage::helper('core')->currency($data['capturedAmount'], true, false); ?>
226
+ <?php endif; ?>
227
+ </span>
228
+ </td>
229
+
230
+ <td class="a-center">
231
+ <span class="price">
232
+ <?php if ($data['refundedAmount'] > 0): ?>
233
+ <?php echo Mage::helper('core')->currency($data['refundedAmount'], true, false); ?>
234
+ <?php endif; ?>
235
+ </span>
236
+ </td>
237
+
238
+ <td>
239
+ <div class="item-text">
240
+ <form method="post" id="<?php echo $this->getFormId($orderId); ?>" class="xp_fast_transactions" action="<?php echo $this->escapeUrl($this->getFormUrl()); ?>">
241
+
242
+ <input type="hidden" name="form_key" value="<?php echo $this->getFormKey(); ?>" />
243
+ <input type="hidden" name="orderid" value="<?php echo $orderId; ?>" />
244
+ <input type="hidden" name="xpc_txnid" value="<?php echo $data['xpc_txnid']; ?>" />
245
+ <input type="hidden" name="xpc_action" class="xpc_action" value="" />
246
+ <input type="text" name="transaction_amount" value="<?php echo $this->getActionAmount($orderId); ?>" class="<?php echo $this->getAmountInputClass($orderId); ?>" />
247
+
248
+ <?php if ($data['capturedAmountAvail'] > 0): ?>
249
+ <input type="button" name="capture" value="Capture" class="form-button xp-transaction-submit" onclick="<?php echo $this->getOnClick('capture', $orderId); ?>" />
250
+ </br>
251
+ <?php endif; ?>
252
+
253
+ <?php if ($data['voidedAmountAvail'] > 0): ?>
254
+ <input type="button" name="void" value="<?php echo $this->getVoidValue($data); ?>" class="form-button xp-transaction-submit" onclick="<?php echo $this->getOnClick('void', $orderId, $data['voidedAmountAvail']); ?>" />
255
+ <?php endif; ?>
256
+
257
+ <?php if ($data['refundedAmountAvail'] > 0): ?>
258
+ <input type="button" name="refund" value="Refund" class="form-button" onclick="<?php echo $this->getOnClick('refund', $orderId); ?>" />
259
+ <?php endif; ?>
260
+
261
+ </form>
262
+ </div>
263
+ </td>
264
+
265
+ </tr>
266
+ </tbody>
267
+
268
+ </table>
269
+
270
+ <?php else: /* if (!empty($orderData)): */ ?>
271
+
272
+ <?php echo $this->__('No payment data for this order'); ?>
273
+
274
+ <?php endif; /* if (!empty($orderData)): */ ?>
275
+
276
+ </div> <!-- class="hor-scroll" -->
277
+ </div> <!-- class="grid" -->
278
+
279
+ </div> <!-- class="entry-edit" -->
280
+
281
+ <?php endforeach; /* foreach ($this->getOrderData() as $orderId => $orderData): */ ?>
282
+
283
+
284
+ <?php foreach ($this->getFraudCheckData() as $data): ?>
285
  <div class="entry-edit">
286
  <div class="entry-edit-head">
287
  <h4><?php echo $this->__($data->getData('service')); ?></h4>
319
  <td class="label"><?php echo $this->__('Transaction ID'); ?></td>
320
  <td class="value">
321
  <?php if ($data->getData('url')): ?>
322
+ <strong><a href="<?php echo $this->escapeUrl($data->getData('url')); ?>" target="_blank"><?php echo $data->getData('transaction_id'); ?></a></strong>
323
  <?php else: ?>
324
  <strong><?php echo $data->getData('transaction_id'); ?></strong>
325
  <?php endif; ?>
366
  </div>
367
  </div>
368
  <?php endforeach; ?>
369
+
370
+ <?php if ($this->isPaymentRequired()): ?>
371
+
372
+ <div class="entry-edit">
373
+ <div class="entry-edit-head">
374
+ <h4><?php echo $this->__('Backend order'); ?></h4>
375
+ </div>
376
+
377
+ <div class="fieldset">
378
+ <?php echo $this->__('This order is not payed.'); ?>
379
+ <a href="<?php echo $this->escapeUrl($this->getBackendPaymentUrl()); ?>"><?php echo $this->__('Go to the payment page'); ?></a>
380
+ </div>
381
+
382
+ </div>
383
+
384
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/pdf/info.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/help.phtml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Help
26
+ */
27
+ ?>
28
+
29
+ <br/><br/>
30
+
31
+ <p>
32
+ <?php echo $this->__('Need help with X-Payments?'); ?>
33
+ <a href="<?php echo $this->escapeUrl($this->getContactUsUrl()); ?>" target="_blank"><?php echo $this->__('Contact us!'); ?></a>
34
+ </p>
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/connection.phtml ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_Connection
26
+ */
27
+ ?>
28
+
29
+ <?php if ($this->getErrorList()): ?>
30
+ <ul class="messages">
31
+ <?php foreach ($this->getErrorList() as $error): ?>
32
+ <li class="error-msg">
33
+ <?php echo $this->__($error); ?>
34
+ </li>
35
+ <?php endforeach; ?>
36
+ </ul>
37
+ <?php elseif (!$this->isWelcomeMode()): ?>
38
+ <ul class="messages">
39
+ <li class="success-msg">
40
+ <?php echo $this->__('Connection with X-Payments is OK. API version:'); ?>
41
+ <?php echo Mage::helper('settings_xpc')->getXpcConfig('xpay_api_version'); ?>
42
+ </li>
43
+ </ul>
44
+ <?php endif; ?>
45
+
46
+ <div class="entry-edit">
47
+ <div class="entry-edit-head">
48
+ <h4><?php echo $this->__('X-Payments configuration bundle'); ?></h4>
49
+ </div>
50
+ <fieldset>
51
+ <p>
52
+ <?php echo $this->__('Copy the Configuration bundle from Online Store Details page in your X-Payments dashboard, paste it here and click'); ?>
53
+ <strong><?php echo $this->__('Deploy.'); ?></strong>
54
+ <br/>
55
+ <?php echo $this->__('Connection will be completed automatically.'); ?>
56
+ </p>
57
+ <form action="<?php echo $this->escapeUrl($this->getUrl('adminhtml/settings_xpc/deploy')); ?>" method="post" name="deploy_form">
58
+ <?php echo $this->getBlockHtml('formkey'); ?>
59
+ <input type="text" name="bundle" id="xpc-bundle" />
60
+ <?php echo $this->getChildHtml('deployButton'); ?>
61
+ </form>
62
+ </fieldset>
63
+ </div>
64
+
65
+ <?php if (!$this->isWelcomeMode()): ?>
66
+
67
+ <div class="entry-edit">
68
+ <div class="entry-edit-head">
69
+ <h4><?php echo $this->__('Settings'); ?></h4>
70
+ </div>
71
+ <fieldset>
72
+ <form action="<?php echo $this->escapeUrl($this->getUrl('adminhtml/settings_xpc/update')); ?>" method="post" name="update_form">
73
+ <?php echo $this->getBlockHtml('formkey'); ?>
74
+ <table cellspacing="0" class="form-list">
75
+ <tr>
76
+ <td class="label">
77
+ <?php echo $this->__('X-Payments URL'); ?>
78
+ </td>
79
+ <td class="value">
80
+ <span id="xpay-url"><?php echo $this->escapeUrl(Mage::helper('settings_xpc')->getXpcConfig('xpay_url')); ?></span>
81
+ <br/>
82
+ <input type="checkbox" name="force_http" id="force-http-checkbox" value="1" <?php if (Mage::helper('settings_xpc')->getXpcConfig('xpay_force_http')): ?>checked="checked"<?php endif; ?> onclick="javascript: switchUrl(this); "/>
83
+ <label for="force-http-checkbox">
84
+ <?php echo $this->__('Use HTTP protocol'); ?>
85
+ </label>
86
+ <p class="note">
87
+ <?php echo $this->__('You should activate the Developer mode in X-Payments to be able to use this option.'); ?>
88
+ <br/>
89
+ <?php echo $this->__('Developer mode can be used to access X-Payments via HTTP (HTTPS is not required) and communicate with the store using a self-signed SSL certificate. To remind the user that Developer mode is on, special marks are displayed on the credit card form.'); ?>
90
+ <br/>
91
+ <span class="error">
92
+ <strong><?php echo $this->__('Important!'); ?></strong>
93
+ <?php echo $this->__('Never process real credit cards while in Developer mode. This results in PA-DSS non-compliance.'); ?>
94
+ </span>
95
+ </p>
96
+ </td>
97
+ </tr>
98
+ <tr>
99
+ <td class="label">
100
+ <?php echo $this->__('IP addresses for X-Payments callbacks'); ?>
101
+ </td>
102
+ <td class="value">
103
+ <input type="text" name="ip_address" class="input-text" value="<?php echo Mage::helper('settings_xpc')->getXpcConfig('xpay_allowed_ip_addresses'); ?>"/>
104
+ <p class="note">
105
+ <?php echo $this->__('X-Payments sends callback requests to the store from specific IP addresses. To secure the data transfer and avoid fraudulent requests, specify these IP addresses here as a comma-separated list. Usually it is the IP address of the server where X-Payments is installed.'); ?>
106
+ </p>
107
+ </td>
108
+ </tr>
109
+ <?php if ($this->isDisplayIframeOptions()): ?>
110
+ <tr>
111
+ <td class="label">
112
+ <?php echo $this->__('Use iframe'); ?>
113
+ </td>
114
+ <td class="value">
115
+ <select name="use_iframe" class="input-text" id="use-iframe-select">
116
+ <option value="1" <?php if (Mage::helper('settings_xpc')->isUseIframe()): ?>selected="selected"<?php endif; ?>><?php echo $this->__('Yes'); ?></option>
117
+ <option value="0" <?php if (!Mage::helper('settings_xpc')->isUseIframe()): ?>selected="selected"<?php endif; ?>><?php echo $this->__('No'); ?></option>
118
+ </select>
119
+ </td>
120
+ </tr>
121
+ <tr id="iframe-place-row">
122
+ <td class="label">
123
+ <?php echo $this->__('Show credit card form at'); ?>
124
+ </td>
125
+ <td class="value">
126
+ <select name="iframe_place" class="input-text"/>
127
+ <option value="payment" <?php if (Mage::helper('settings_xpc')->getIframePlace() == 'payment'): ?>selected="selected"<?php endif; ?>><?php echo $this->__('Payment Information step'); ?></option>
128
+ <option value="review" <?php if (Mage::helper('settings_xpc')->getIframePlace() == 'review'): ?>selected="selected"<?php endif; ?>><?php echo $this->__('Order Review step'); ?></option>
129
+ </select>
130
+ </td>
131
+ </tr>
132
+ <?php endif; ?>
133
+ </table>
134
+ <?php echo $this->getChildHtml('updateButton'); ?>
135
+ </form>
136
+ </fieldset>
137
+ </div>
138
+
139
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/payment_methods.phtml ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_PaymentMethods
26
+ */
27
+ ?>
28
+
29
+ <form action="<?php echo $this->escapeUrl($this->getUrl('adminhtml/settings_xpc/paymentmethods')); ?>" method="post" name="update_form" id="payment-methods-form">
30
+ <?php echo $this->getBlockHtml('formkey'); ?>
31
+ <input type="hidden" name="mode" value="" id="payment-method-form-mode" />
32
+
33
+ <div class="grid">
34
+ <table cellpadding="5" cellspacing="1">
35
+
36
+ <tr class="headings">
37
+ <th></th>
38
+ <th><?php echo $this->__('Payment method'); ?></th>
39
+ <th class="currency"><?php echo $this->__('Currency'); ?></th>
40
+ <?php if ($this->isCanSaveCards()): ?>
41
+ <th class="save-cards"><?php echo $this->__('Save cards'); ?></th>
42
+ <?php endif; ?>
43
+ </tr>
44
+
45
+ <?php foreach ($this->getPaymentMethods() as $pm): ?>
46
+ <tr class="<?php echo $pm['active_checkbox']['class']; ?>">
47
+ <td class="active">
48
+ <?php $this->printCheckbox($pm['active_checkbox']); ?>
49
+ </td>
50
+ <td <?php if (!$pm['confid']): ?>colspan="<?php echo $this->isCanSaveCards() ? '3' : '2'; ?>3"<?php endif; ?>>
51
+ <label for="<?php echo $pm['active_checkbox']['id']; ?>">
52
+ <?php echo $pm['name']; ?>
53
+ </label>
54
+ </td>
55
+ <?php if ($pm['confid']): ?>
56
+ <td class="currency"><?php echo $pm['currency']; ?></td>
57
+ <?php if ($this->isCanSaveCards()): ?>
58
+ <td class="save-cards">
59
+ <?php if ('Y' == $pm['can_save_cards']): ?>
60
+ <?php $this->printCheckbox($pm['savecard_checkbox']); ?>
61
+ <?php endif; ?>
62
+ </td>
63
+ <?php endif; ?>
64
+ <?php endif; ?>
65
+ </tr>
66
+ <?php endforeach; ?>
67
+
68
+ </table>
69
+ </div>
70
+
71
+ <?php foreach ($this->getPaymentMethods(false) as $pm): ?>
72
+ <div class="entry-edit" style="display: none;" id="<?php echo $pm['payment_method']['id']; ?>">
73
+ <div class="entry-edit-head">
74
+ <h4><?php echo $pm['name']; ?></h4>
75
+ </div>
76
+ <fieldset>
77
+ <table cellspacing="0" class="form-list">
78
+
79
+ <tr>
80
+ <td class="label"><?php echo $this->__('Title'); ?></td>
81
+ <td class="value">
82
+ <?php $this->printInputText($pm['payment_method']['title']); ?>
83
+ </td>
84
+ </tr>
85
+
86
+ <tr>
87
+ <td class="label"><?php echo $this->__('Use forced Authorize operation'); ?></td>
88
+ <td class="value">
89
+ <?php $this->printSelectBox($pm['payment_method']['use_authorize']); ?>
90
+ <p class="note">
91
+ <?php echo $this->__('Work only for non recurring product order.'); ?>
92
+ </p>
93
+ </td>
94
+ </tr>
95
+
96
+ <tr>
97
+ <td class="label"><?php echo $this->__('Use forced Authorize operation for recurring products'); ?></td>
98
+ <td class="value">
99
+ <?php $this->printSelectBox($pm['payment_method']['use_initialfee_authorize']); ?>
100
+ </td>
101
+ </tr>
102
+
103
+ <tr>
104
+ <td class="label"><?php echo $this->__('Sort order'); ?></td>
105
+ <td class="value">
106
+ <?php $this->printInputText($pm['payment_method']['sort_order']); ?>
107
+ </td>
108
+ </tr>
109
+
110
+ <tr>
111
+ <td class="label"><?php echo $this->__('Payment from applicable countries'); ?></td>
112
+ <td class="value">
113
+ <?php $this->printSelectBox($pm['payment_method']['allowspecific']); ?>
114
+ </td>
115
+ </tr>
116
+
117
+ <tr class="specificcountry hidden">
118
+ <td class="label"><?php echo $this->__('Payment from Specific countries'); ?></td>
119
+ <td class="value">
120
+ <?php $this->printSelectBox($pm['payment_method']['specificcountry']); ?>
121
+ </td>
122
+ </tr>
123
+
124
+ </table>
125
+ <?php echo $this->getChildHtml('updateButton'); ?>
126
+ </fieldset>
127
+ </div>
128
+ <?php endforeach; ?>
129
+
130
+ <div class="entry-edit" style="display: none;" id="payment-method-savedcards">
131
+ <div class="entry-edit-head">
132
+ <h4><?php echo $this->__('Use saved credit card'); ?></h4>
133
+ </div>
134
+ <fieldset>
135
+ <table cellspacing="0" class="form-list">
136
+
137
+ <tr>
138
+ <td class="label"><?php echo $this->__('Title'); ?></td>
139
+ <td class="value">
140
+ <input type="text" name="savedcards_title" value="<?php echo Mage::helper('settings_xpc')->getSavedCardsConfig('title'); ?>" class="input-text"/>
141
+ </td>
142
+ </tr>
143
+
144
+ <tr>
145
+ <td class="label"><?php echo $this->__('Sort order'); ?></td>
146
+ <td class="value">
147
+ <input type="text" name="savedcards_sort_order" value="<?php echo Mage::helper('settings_xpc')->getSavedCardsConfig('sort_order'); ?>" class="input-text"/>
148
+ </td>
149
+ </tr>
150
+
151
+ </table>
152
+ <?php echo $this->getChildHtml('updateButton'); ?>
153
+ </fieldset>
154
+ </div>
155
+
156
+
157
+ </form>
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/welcome.phtml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_Welcome
26
+ */
27
+ ?>
28
+
29
+ <div class="payment-description">
30
+
31
+ <div class="payment-logo">
32
+ <img src="<?php echo $this->escapeUrl(Mage::getBaseUrl('js') . 'xpayment/images/xpayment-logo.png'); ?>" alt="X-Payments Connector"/>
33
+ </div>
34
+
35
+ <div class="description-block">
36
+ <?php echo $this->getDescription(); ?>
37
+ </div>
38
+
39
+ <div class="pci-logo"></div>
40
+
41
+ </div>
42
+
43
+ <h3 class="connect-caption">
44
+ <?php echo $this->__('Connect to X-Payments. Complete 3 easy steps.'); ?>
45
+ </h3>
46
+
47
+ <div class="payment-step">
48
+
49
+ <div class="step">
50
+ <span class="step-number">1</span>
51
+ <p>
52
+ <?php echo $this->__('Open your X-Payments dashboard or'); ?>
53
+ </p>
54
+ <button onclick="javascript: window.open('<?php echo $this->escapeUrl($this->getTrialDemoUrl()); ?>');">
55
+ <?php echo $this->__('Start FREE Trial'); ?>
56
+ </button>
57
+ </div>
58
+
59
+ <img src="<?php echo $this->escapeUrl(Mage::getBaseUrl('js') . 'xpayment/images/step-arrow.png'); ?>" class="step-arrow" />
60
+
61
+ <div class="step">
62
+ <span class="step-number">2</span>
63
+ <p>
64
+ <?php echo $this->__('Configure your gateway in'); ?>
65
+ <strong style="white-space: nowrap;"><?php echo $this->__('X-Payments'); ?></strong>
66
+ </p>
67
+ <a href="<?php echo $this->escapeUrl($this->getUserManualGatewaysUrl()); ?>" target="_blank"><?php echo $this->__('See how'); ?></a>
68
+ </div>
69
+
70
+ <img src="<?php echo $this->escapeUrl(Mage::getBaseUrl('js') . 'xpayment/images/step-arrow.png'); ?>" class="step-arrow" />
71
+
72
+ <div class="step">
73
+ <span class="step-number">3</span>
74
+ <p>
75
+ <a href="javascript: void();" id="connect-link" title="<?php echo $this->__('Go to Connection settings tab'); ?>">
76
+ <?php echo $this->__('Connect'); ?>
77
+ <strong><?php echo $this->__('X-Payments'); ?></strong>
78
+ <?php echo $this->__('with'); ?>
79
+ <strong><?php echo $this->__('Magento'); ?></strong>
80
+ </a>
81
+ </p>
82
+ <a href="<?php echo $this->escapeUrl($this->getUserManualMagentoUrl()); ?>" target="_blank"><?php echo $this->__('See how'); ?></a>
83
+ </div>
84
+
85
+ </div>
86
+
87
+ <div class="video">
88
+ <iframe width="560" height="315" src="<?php echo $this->escapeUrl($this->getVideoUrl()); ?>" frameborder="0" allowfullscreen></iframe>
89
+ </div>
90
+
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/tabs/zero_auth.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Tab_ZeroAuth
26
+ */
27
+ ?>
28
+
29
+ <?php if (!Mage::helper('settings_xpc')->isCanSaveCards()): ?>
30
+ <ul class="messages">
31
+ <li class="error-msg">
32
+ <?php echo $this->__('X-Payments payment method is disabled, or saving credit cards is not activated'); ?>
33
+ </li>
34
+ </ul>
35
+ <?php endif; ?>
36
+
37
+ <div class="entry-edit">
38
+ <div class="entry-edit-head">
39
+ <h4><?php echo $this->__('Save credit card setup'); ?></h4>
40
+ </div>
41
+ <fieldset>
42
+ <form action="<?php echo $this->escapeUrl($this->getUrl('adminhtml/settings_xpc/zeroauth')); ?>" method="post" name="update_form" id="zero-auth-form">
43
+ <?php echo $this->getBlockHtml('formkey'); ?>
44
+ <table cellspacing="0" class="form-list">
45
+ <?php if (Mage::helper('settings_xpc')->isCanSaveCards()): ?>
46
+ <tr>
47
+ <td class="label">
48
+ <?php echo $this->__('Payment method'); ?>
49
+ </td>
50
+ <td class="value">
51
+ <select name="zero_auth_confid">
52
+ <?php foreach ($this->getPaymentMethodsList() as $confid => $name): ?>
53
+ <option value="<?php echo $confid;?>" <?php if ($this->isZeroAuthConfId($confid)): ?>selected="selected"<?php endif; ?>><?php echo $this->__($name); ?></option>
54
+ <?php endforeach; ?>
55
+ </select>
56
+ </td>
57
+ </tr>
58
+ <?php endif; ?>
59
+ <tr>
60
+ <td class="label">
61
+ <?php echo $this->__('Authorize amount for card setup'); ?>
62
+ </td>
63
+ <td class="value">
64
+ <input type="text" name="zero_auth_amount" value="<?php echo $this->getAmount(); ?>" class="input-text required-entry validate-float"/>
65
+ <p class="note">
66
+ <?php echo $this->__('Specify the amount to be used for credit cards authorization. Recommended 0.00, 0.01 or 1.00. Note: if you chose 0.00 make sure the payment gateway supports such authorization'); ?>
67
+ </p>
68
+ </td>
69
+ </tr>
70
+ <tr>
71
+ <td class="label">
72
+ <?php echo $this->__('Description of the card setup payment'); ?>
73
+ </td>
74
+ <td class="value">
75
+ <input type="text" name="zero_auth_description" value="<?php echo Mage::helper('settings_xpc')->getXpcConfig('xpay_zero_auth_description'); ?>" class="input-text"/>
76
+ <p class="note">
77
+ <?php echo $this->__('Description of card setup authorization. Your store will send it to your payment gateway. You and your customers will see it on the bank receipt.'); ?>
78
+ </p>
79
+ </td>
80
+ </tr>
81
+ </table>
82
+ <?php echo $this->getChildHtml('updateButton'); ?>
83
+ </form>
84
+ </fieldset>
85
+ </div>
86
+
app/design/adminhtml/default/default/template/xpaymentsconnector/settings/xpc.phtml CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
@@ -25,155 +25,48 @@
25
  * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc
26
  */
27
  ?>
28
- <?php if ($this->getRequiremenetsErrors()): ?>
29
 
30
- <h4><?php echo $this->__('Failed to meet environment requirements'); ?></h4>
31
-
32
- <ul>
33
- <?php foreach ($this->getRequiremenetsErrors() as $err): ?>
34
- <li class="error">
35
- <?php echo $this->__($err); ?>
36
- </li>
37
- <?php endforeach; ?>
38
- </ul>
39
-
40
- <br/>
41
-
42
- <?php endif; ?>
43
-
44
- <div class="xpayment-info">
45
-
46
- <div class="content-header">
47
- <table cellspacing="0">
48
  <tr>
49
- <td><h3><?php echo $this->__('X-Payments Connector'); ?></h3></td>
 
 
 
 
 
 
 
 
50
  </tr>
51
- </table>
52
- </div>
53
-
54
- <?php if ($this->getConfigurationErrors()): ?>
55
-
56
- <h4 class="sub-heading">
57
- <?php echo $this->__('X-Payments Connector is not configured yet. Please, check'); ?>
58
- <a href="<?php echo $this->getSystemConfigXpcUrl(); ?>" target="_blank"><?php echo $this->__('settings') ?></a>
59
- </h4>
60
-
61
- <div class="payment-description">
62
-
63
- <div class="payment-logo">
64
- <img src="<?php echo Mage::getBaseUrl('js') . 'xpayment/images/xpayment-logo.png'; ?>" alt="X-Payments Connector"/>
65
- </div>
66
-
67
- <div class="description-block">
68
- <p>
69
- <?php echo $this->getDescription(); ?>
70
- </p>
71
- </div>
72
 
 
 
 
 
 
73
  </div>
 
74
 
75
- <h4>
76
- <?php echo $this->__('Connect to X-Payments in 3 easy steps:'); ?>
77
- </h4>
78
-
79
- <div class="payment-step">
80
-
81
- <div class="step">
82
- <span class="step-number">1</span>
83
- <p>
84
- <?php echo $this->__('Open your'); ?>
85
- <a href="<?php echo $this->getTrialDemoUrl(); ?>" target="_blank"><?php echo $this->__('X-Payments'); ?></a>
86
- <?php echo $this->__('back-end (if you do not have it)'); ?>
87
- </p>
88
- <button onclick="javascript: window.open('<?php echo $this->getTrialDemoUrl(); ?>');">
89
- <?php echo $this->__('Start free Trial'); ?>
90
- </button>
91
- </div>
92
-
93
- <img src="<?php echo Mage::getBaseUrl('js') . 'xpayment/images/atep-arrow.png' ?>" class="step-arrow">
94
-
95
- <div class="step">
96
- <span class="step-number">2</span>
97
- <p>
98
- <?php echo $this->__('Configure payment methods at'); ?>
99
- <strong style="white-space: nowrap;"><?php echo $this->__('X-Payments'); ?></strong>
100
- </p>
101
- <a href="<?php echo $this->getUserManualUrl(); ?>" target="_blank"><?php echo $this->__('Read how to do that'); ?></a>
102
- </div>
103
-
104
- <img src="<?php echo Mage::getBaseUrl('js') . 'xpayment/images/atep-arrow.png' ?>" class="step-arrow">
105
-
106
- <div class="step">
107
- <span class="step-number">3</span>
108
- <p>
109
- <?php echo $this->__('Connect'); ?>
110
- <strong><?php echo $this->__('X-Payments'); ?></strong>
111
- <?php echo $this->__('with'); ?>
112
- <strong><?php echo $this->__('Magento'); ?></strong>
113
- </p>
114
- <a href="<?php echo $this->getUserVideoUrl(); ?>" target="_blank"><?php echo $this->__('See how to do that'); ?></a>
115
- </div>
116
 
 
 
 
117
  </div>
118
-
119
- <hr/>
120
-
 
 
121
  <?php endif; ?>
122
-
123
  </div>
124
 
125
- <br/>
126
-
127
- <h4><?php echo $this->__('Import payment methods'); ?></h4>
128
-
129
- <p><?php echo $this->__('To be able to use X-Payments payment methods you need to import them from X-Payments first.'); ?></p>
130
-
131
- <?php if ($this->isMethodsRequested()) { ?>
132
-
133
- <?php echo $this->__('The list of payment configurations imported from X-Payments'); ?>:<br/>
134
-
135
- <div class="grid">
136
- <table cellpadding="5" cellspacing="1">
137
- <tr class="headings">
138
- <th><?php echo $this->__('Payment method'); ?></th>
139
- <th><?php echo $this->__('Payment method ID'); ?></th>
140
- <th><?php echo $this->__('Auth'); ?></th>
141
- </tr>
142
-
143
- <?php foreach ($this->getPaymentMethods() as $pm) { ?>
144
-
145
- <tr>
146
- <td><?php echo $pm['name']; ?></td>
147
- <td><?php echo $pm['confid']; ?></td>
148
- <td><?php if ($pm['is_auth']) { ?><?php echo $this->__('Yes'); ?><?php } else { ?><?php echo $this->__('No'); ?><?php } ?></td>
149
- </tr>
150
-
151
- <?php } ?>
152
-
153
- </table>
154
- </div>
155
-
156
- <form action="<?php echo $this->getUrl('adminhtml/settings_xpc/clear'); ?>" method="post" name="clear_form">
157
- <?php echo $this->getBlockHtml('formkey'); ?>
158
- <?php echo $this->getChildHtml('clearButton'); ?>
159
- </form>
160
-
161
- <?php if ($this->isMethodsAlreadyImported()) { ?>
162
- <br/>
163
- <br/>
164
- <p><?php echo $this->__('Warning! Importing payment configurations from X-Payments will disable the X-Payments connector payment method!'); ?></p>
165
- <?php } ?>
166
-
167
- <?php } ?>
168
-
169
- <form action="<?php echo $this->getUrl('adminhtml/settings_xpc/request'); ?>" method="post" name="request_form">
170
- <?php echo $this->getBlockHtml('formkey'); ?>
171
- <?php echo $this->getChildHtml('requestButton'); ?>
172
- </form>
173
-
174
- <br/>
175
- <br/>
176
- <h4>
177
- <?php echo $this->__('Need help in settings of X-Payments?'); ?>
178
- <a href="<?php echo $this->getContactUsUrl(); ?>" target="_blank"><?php echo $this->__('Contact us!'); ?></a>
179
- </h4>
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
25
  * @see Cdev_XPaymentsConnector_Block_Adminhtml_Settings_Xpc
26
  */
27
  ?>
 
28
 
29
+ <div class="content-header">
30
+ <table cellspacing="0">
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  <tr>
32
+ <td style="width:50%;"><h3><?php echo $this->__('X-Payments Connector'); ?></h3></td>
33
+ <td class="form-buttons"<?php if (!$this->isShowStickyPanel()): ?> style="display: none;"<?php endif; ?>>
34
+ <?php if (!$this->isWelcomeMode()): ?>
35
+ <?php echo $this->getChildHtml('updateButton'); ?>
36
+ <?php echo $this->getChildHtml('importButton'); ?>
37
+ &nbsp;
38
+ <a href="<?php echo $this->escapeUrl($this->getAddNewPaymentMethodUrl()); ?>" target="_blank"><?php echo $this->__('Add payment method'); ?></a>
39
+ <?php endif; ?>
40
+ </td>
41
  </tr>
42
+ </table>
43
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
 
45
+ <div id="settings_xpc">
46
+
47
+ <?php if ($this->isWelcomeMode()): ?>
48
+ <div id="settings_xpc_tabs_welcome_section_content">
49
+ <?php echo $this->getChildHtml('welcomeSection'); ?>
50
  </div>
51
+ <?php endif; ?>
52
 
53
+ <div id="settings_xpc_tabs_connection_section_content">
54
+ <?php echo $this->getChildHtml('connectionSection'); ?>
55
+ </div>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
56
 
57
+ <?php if (!$this->isWelcomeMode()): ?>
58
+ <div id="settings_xpc_tabs_paymentmethods_section_content">
59
+ <?php echo $this->getChildHtml('paymentMethodsSection'); ?>
60
  </div>
61
+ <?php if ($this->isCanSaveCards()): ?>
62
+ <div id="settings_xpc_tabs_zeroauth_section_content">
63
+ <?php echo $this->getChildHtml('zeroAuthSection'); ?>
64
+ </div>
65
+ <?php endif; ?>
66
  <?php endif; ?>
67
+
68
  </div>
69
 
70
+ <script type="text/javascript">
71
+ var MAX_SLOTS = <?php echo Cdev_XPaymentsConnector_Helper_Settings_Data::MAX_SLOTS; ?>;
72
+ </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/add.phtml ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * Add new card
26
+ *
27
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Add
28
+ */
29
+ ?>
30
+
31
+ <div class="content-header">
32
+ <table cellspacing="0">
33
+ <tr>
34
+ <td><h3><?php echo $this->__('Add new payment card'); ?></h3></td>
35
+ </tr>
36
+ </table>
37
+ </div>
38
+
39
+ <div id="billing-address-block">
40
+ <strong><?php echo $this->__('Billing address'); ?></strong>
41
+ &nbsp;
42
+ <?php if ($this->isEmptyAddressList()): ?>
43
+ <?php echo $this->__('Address for this profile is not defined'); ?>
44
+ <?php elseif ($this->isSingleAddress()): ?>
45
+ <span id="single-address"><?php echo $this->__($this->getSingleAddress()); ?></span>
46
+ <?php else: ?>
47
+ <select name="id_address" id="billing-address">
48
+ <?php foreach ($this->getAddressList() as $id => $address): ?>
49
+ <option value="<?php echo $id; ?>" <?php if ($this->isCurrentAddress($id)): ?>selected="selected"<?php endif; ?>><?php echo $this->__($address); ?></option>
50
+ <?php endforeach; ?>
51
+ </select>
52
+ <?php endif; ?>
53
+ &nbsp;
54
+ <a href="<?php echo $this->escapeUrl($this->getAddressBookUrl()); ?>"><?php echo $this->__('Add new address'); ?></a>
55
+ </div>
56
+
57
+ <?php if (!$this->isEmptyAddressList() && !$this->getError()): ?>
58
+
59
+ <div id="iframe-container">
60
+ <iframe src="<?php echo $this->escapeUrl($this->getIframeUrl()); ?>" id="xpc-iframe"></iframe>
61
+ <div id="loading-container"></div>
62
+ <button type="submit" id="submit-button" /><?php echo $this->__('Save payment card'); ?></button>
63
+ &nbsp;
64
+ <a href="<?php echo $this->escapeUrl($this->getPaymentCardsUrl()); ?>"><?php echo $this->__('Back to payment cards'); ?></a>
65
+ </div>
66
+
67
+ <script type="text/javascript">
68
+ //<![CDATA[
69
+ var xpcData = <?php echo $this->getXpcData(); ?>;
70
+ //]]>
71
+ </script>
72
+
73
+ <?php elseif ($this->getError()): ?>
74
+
75
+ <div class="error">
76
+ <br/>
77
+ <?php echo $this->__($this->getError()); ?>
78
+ <br/><br/>
79
+ <a href="<?php echo $this->escapeUrl($this->getPaymentCardsUrl()); ?>"><?php echo $this->__('Back to payment cards'); ?></a>
80
+ </div>
81
+
82
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/iframe.phtml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * X-Payments payment form for add new card in backend
26
+ *
27
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Iframe
28
+ */
29
+ ?>
30
+
31
+ <?php if ($this->getError()): ?>
32
+
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ var msg = {
36
+ message: 'paymentFormSubmitError',
37
+ params: {
38
+ height: 0,
39
+ error: '<?php echo addslashes($this->__($this->getError())); ?>',
40
+ type: 1
41
+ }
42
+ };
43
+ window.parent.postMessage(JSON.stringify(msg), '*');
44
+ //]]>
45
+ </script>
46
+
47
+ <?php elseif ($this->isReturn()): ?>
48
+
49
+ <script type="text/javascript">
50
+ //<![CDATA[
51
+ window.parent.location.href = "<?php echo $this->escapeUrl($this->getPaymentCardsUrl()); ?>";
52
+ //]]>
53
+ </script>
54
+
55
+ <?php else: ?>
56
+
57
+ <form id="xpc-form-redirect" action="<?php echo $this->getFormAction(); ?>" method="post">
58
+ <?php foreach ($this->getFields() as $name => $value): ?>
59
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>" />
60
+ <?php endforeach; ?>
61
+ </form>
62
+
63
+ <script type="text/javascript">
64
+ //<![CDATA[
65
+ var paymentform = document.getElementById('xpc-form-redirect');
66
+ window.onload = function() {
67
+ paymentform.submit();
68
+ }
69
+ //]]>
70
+ </script>
71
+
72
+ <?php endif; ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/tab/js.phtml CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,17 +13,31 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
22
 
 
 
 
 
 
 
 
 
 
 
23
  <script type="text/javascript">
24
  function refreshUsercardsGrid(grid, gridMassAction, transport) {
25
- grid.reload();
26
- gridMassAction.unselectAll();
27
  }
28
- </script>
 
 
 
 
1
  <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
23
 
24
+ <?php
25
+
26
+ $params = array(
27
+ 'customer_id' => $this->getRequest()->getParam('id'),
28
+ );
29
+
30
+ $url = $this->getUrl('adminhtml/addnewcard/index', $params);
31
+
32
+ ?>
33
+
34
  <script type="text/javascript">
35
  function refreshUsercardsGrid(grid, gridMassAction, transport) {
36
+ grid.reload();
37
+ gridMassAction.unselectAll();
38
  }
39
+
40
+ customer_edit_tab_usercardsJsObject.doAddNew = function () {
41
+ window.location.href = '<?php echo $this->escapeUrl($url); ?>';
42
+ };
43
+ </script>
app/design/frontend/base/default/layout/xpaymentsconnector.xml CHANGED
@@ -14,94 +14,119 @@ vim: set ts=4 sw=4 sts=4 et:
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
24
- <layout version="1.0.0">
25
 
26
  <checkout_cart_index translate="label">
27
  <reference name="head">
28
- <action method="addItem">
29
  <type>js_css</type>
30
  <name>xpayment/settings.css</name>
31
- <params/>
32
  </action>
33
  </reference>
34
  </checkout_cart_index>
35
 
36
  <checkout_onepage_index translate="label">
 
37
  <reference name="head">
38
- <action method="addItem">
39
  <type>js_css</type>
40
  <name>xpayment/settings.css</name>
41
- <params/>
42
  </action>
43
- <action method="addItem">
44
  <type>js</type>
45
  <name>xpayment/checkout-submit.js</name>
46
- <params/>
47
  </action>
48
- <block type="core/template" name="xpc_data" template="xpaymentsconnector/xpc_data.phtml" />
 
 
49
  </reference>
50
  </checkout_onepage_index>
51
 
52
- <onestepcheckout_index_index>
 
53
  <reference name="head">
54
- <action method="addItem">
55
  <type>js_css</type>
56
  <name>xpayment/settings.css</name>
57
- <params/>
58
  </action>
59
- <action method="addItem">
60
  <type>js</type>
61
  <name>xpayment/checkout-submit.js</name>
62
- <params/>
63
  </action>
64
- <block type="core/template" name="xpc_data" template="xpaymentsconnector/xpc_data.phtml" />
 
 
65
  </reference>
66
  </onestepcheckout_index_index>
67
 
68
- <firecheckout_index_index>
 
69
  <reference name="head">
70
- <action method="addItem">
71
  <type>js_css</type>
72
  <name>xpayment/settings.css</name>
73
- <params/>
74
  </action>
75
- <action method="addItem">
76
  <type>js</type>
77
  <name>xpayment/checkout-submit.js</name>
78
- <params/>
79
  </action>
80
- <block type="core/template" name="xpc_data" template="xpaymentsconnector/xpc_data.phtml" />
 
 
81
  </reference>
82
- <reference name="checkout.onepage.review.info.items.after">
83
- <block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml" after="checkout.onepage.review.button"
 
 
 
84
  template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  </reference>
86
  </firecheckout_index_index>
87
 
88
  <checkout_onepage_review translate="label">
 
 
 
 
89
  <reference name="checkout.onepage.review.info.items.after">
90
- <block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
91
- template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
92
- <block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml" after="checkout.onepage.review.button"
93
- template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
 
 
94
  </reference>
95
  </checkout_onepage_review>
96
 
97
  <checkout_onepage_success>
98
  <reference name="content">
99
  <reference name="checkout.success">
100
- <action method="setTemplate">
101
- <template helper="xpaymentsconnector/data/getCheckoutSuccessTemplate">
102
- <name>xpaymentsconnector/checkout/success.phtml</name>
103
- <block>checkout.success</block>
104
- </template>
105
  </action>
106
  </reference>
107
  </reference>
@@ -110,46 +135,37 @@ vim: set ts=4 sw=4 sts=4 et:
110
  <xpaymentsconnector_processing_redirect>
111
  <reference name="root">
112
  <action method="setTemplate">
113
- <template>xpaymentsconnector/blank.phtml</template>
114
  </action>
115
  </reference>
116
  <reference name="content">
117
- <block type="xpaymentsconnector/redirect" name="xpaymentsconnector_redirect"
118
- template="xpaymentsconnector/redirect.phtml"/>
119
  </reference>
120
  </xpaymentsconnector_processing_redirect>
121
 
122
- <xpaymentsconnector_processing_redirectiframe>
123
- <reference name="root">
124
- <action method="setTemplate">
125
- <template>xpaymentsconnector/blank.phtml</template>
126
- </action>
127
- </reference>
128
- <reference name="content">
129
- <block type="xpaymentsconnector/redirect" name="xpaymentsconnector_redirect"
130
- template="xpaymentsconnector/redirectiframe.phtml"/>
131
- </reference>
132
- </xpaymentsconnector_processing_redirectiframe>
133
-
134
  <xpaymentsconnector_processing_return>
135
  <reference name="root">
136
  <action method="setTemplate">
137
- <template>xpaymentsconnector/blank.phtml</template>
138
  </action>
139
  </reference>
140
  <reference name="content">
141
- <block type="xpaymentsconnector/return" name="xpaymentsconnector_return"
142
- template="xpaymentsconnector/return.phtml"/>
143
  </reference>
144
  </xpaymentsconnector_processing_return>
145
 
146
 
147
  <customer_account>
148
  <reference name="head">
149
- <action method="addItem">
150
  <type>js_css</type>
151
  <name>xpayment/settings.css</name>
152
- <params/>
 
 
 
153
  </action>
154
  </reference>
155
  <reference name="customer_account_navigation">
@@ -165,7 +181,7 @@ vim: set ts=4 sw=4 sts=4 et:
165
  <label>Customer My Account credit cards list</label>
166
  <update handle="customer_account"/>
167
  <reference name="my.account.wrapper">
168
- <block type="xpaymentsconnector/customer_usercards" name="xpaymentsconnector_customer_usercards" template="xpaymentsconnector/customer/usercards/list.phtml" />
169
  </reference>
170
  <reference name="root">
171
  <action method="setHeaderTitle" translate="title" module="xpaymentsconnector"><title>My credit cards list</title></action>
@@ -176,7 +192,7 @@ vim: set ts=4 sw=4 sts=4 et:
176
  <label>Add new credit card to list (X-Payments)</label>
177
  <update handle="customer_account"/>
178
  <reference name="my.account.wrapper">
179
- <block type="xpaymentsconnector/customer_cardadd" name="xpaymentsconnector_customer_cardadd" template="xpaymentsconnector/customer/usercards/cardadd.phtml" />
180
  </reference>
181
  </xpaymentsconnector_customer_cardadd>
182
 
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  -->
24
+ <layout version="1.8.0">
25
 
26
  <checkout_cart_index translate="label">
27
  <reference name="head">
28
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
29
  <type>js_css</type>
30
  <name>xpayment/settings.css</name>
 
31
  </action>
32
  </reference>
33
  </checkout_cart_index>
34
 
35
  <checkout_onepage_index translate="label">
36
+ <block type="core/template" name="xpc_data" template="xpaymentsconnector/checkout/xpc_data.phtml"/>
37
  <reference name="head">
38
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
39
  <type>js_css</type>
40
  <name>xpayment/settings.css</name>
 
41
  </action>
42
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
43
  <type>js</type>
44
  <name>xpayment/checkout-submit.js</name>
 
45
  </action>
46
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
47
+ <block>xpc_data</block>
48
+ </action>
49
  </reference>
50
  </checkout_onepage_index>
51
 
52
+ <onestepcheckout_index_index translate="label">
53
+ <block type="core/template" name="xpc_data" template="xpaymentsconnector/checkout/xpc_data.phtml"/>
54
  <reference name="head">
55
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
56
  <type>js_css</type>
57
  <name>xpayment/settings.css</name>
 
58
  </action>
59
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
60
  <type>js</type>
61
  <name>xpayment/checkout-submit.js</name>
 
62
  </action>
63
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
64
+ <block>xpc_data</block>
65
+ </action>
66
  </reference>
67
  </onestepcheckout_index_index>
68
 
69
+ <aw_onestepcheckout_index_index translate="label">
70
+ <block type="core/template" name="xpc_data" template="xpaymentsconnector/checkout/xpc_data.phtml"/>
71
  <reference name="head">
72
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
73
  <type>js_css</type>
74
  <name>xpayment/settings.css</name>
 
75
  </action>
76
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
77
  <type>js</type>
78
  <name>xpayment/checkout-submit.js</name>
 
79
  </action>
80
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
81
+ <block>xpc_data</block>
82
+ </action>
83
  </reference>
84
+ </aw_onestepcheckout_index_index>
85
+
86
+ <firecheckout_index_index translate="label">
87
+ <block type="core/template" name="xpc_data" template="xpaymentsconnector/checkout/xpc_data.phtml"/>
88
+ <block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml" after="checkout.onepage.review.button"
89
  template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
90
+ <reference name="head">
91
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
92
+ <type>js_css</type>
93
+ <name>xpayment/settings.css</name>
94
+ </action>
95
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
96
+ <type>js</type>
97
+ <name>xpayment/checkout-submit.js</name>
98
+ </action>
99
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
100
+ <block>xpc_data</block>
101
+ </action>
102
+ </reference>
103
+ <reference name="checkout.onepage.review.info.items.after">
104
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
105
+ <block>xpayment_recurring_detail</block>
106
+ </action>
107
  </reference>
108
  </firecheckout_index_index>
109
 
110
  <checkout_onepage_review translate="label">
111
+ <block type="xpaymentsconnector/checkout_onepage_review_cc" name="xpc_review_cc" output="toHtml"
112
+ template="xpaymentsconnector/checkout/onepage/review/cc.phtml"/>
113
+ <block type="xpaymentsconnector/checkout_onepage_orderdetail" name="xpayment_recurring_detail" output="toHtml" after="checkout.onepage.review.button"
114
+ template="xpaymentsconnector/checkout/onepage/order-detail.phtml"/>
115
  <reference name="checkout.onepage.review.info.items.after">
116
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
117
+ <block>xpc_review_cc</block>
118
+ </action>
119
+ <action method="append" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
120
+ <block>xpayment_recurring_detail</block>
121
+ </action>
122
  </reference>
123
  </checkout_onepage_review>
124
 
125
  <checkout_onepage_success>
126
  <reference name="content">
127
  <reference name="checkout.success">
128
+ <action method="setTemplate" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
129
+ <template>xpaymentsconnector/checkout/success.phtml</template>
 
 
 
130
  </action>
131
  </reference>
132
  </reference>
135
  <xpaymentsconnector_processing_redirect>
136
  <reference name="root">
137
  <action method="setTemplate">
138
+ <template>xpaymentsconnector/checkout/blank.phtml</template>
139
  </action>
140
  </reference>
141
  <reference name="content">
142
+ <block type="xpaymentsconnector/checkout_redirect" name="xpaymentsconnector_checkout_redirect"
143
+ template="xpaymentsconnector/checkout/redirect.phtml"/>
144
  </reference>
145
  </xpaymentsconnector_processing_redirect>
146
 
 
 
 
 
 
 
 
 
 
 
 
 
147
  <xpaymentsconnector_processing_return>
148
  <reference name="root">
149
  <action method="setTemplate">
150
+ <template>xpaymentsconnector/checkout/blank.phtml</template>
151
  </action>
152
  </reference>
153
  <reference name="content">
154
+ <block type="xpaymentsconnector/checkout_return" name="xpaymentsconnector_checkout_return"
155
+ template="xpaymentsconnector/checkout/return.phtml"/>
156
  </reference>
157
  </xpaymentsconnector_processing_return>
158
 
159
 
160
  <customer_account>
161
  <reference name="head">
162
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
163
  <type>js_css</type>
164
  <name>xpayment/settings.css</name>
165
+ </action>
166
+ <action method="addItem" module="xpaymentsconnector" ifconfig="xpaymentsconnector/settings/xpay_is_configured">
167
+ <type>js</type>
168
+ <name>xpayment/add-new-card.js</name>
169
  </action>
170
  </reference>
171
  <reference name="customer_account_navigation">
181
  <label>Customer My Account credit cards list</label>
182
  <update handle="customer_account"/>
183
  <reference name="my.account.wrapper">
184
+ <block type="xpaymentsconnector/customer_usercards_list" name="xpaymentsconnector_customer_usercards_list" template="xpaymentsconnector/customer/usercards/list.phtml" />
185
  </reference>
186
  <reference name="root">
187
  <action method="setHeaderTitle" translate="title" module="xpaymentsconnector"><title>My credit cards list</title></action>
192
  <label>Add new credit card to list (X-Payments)</label>
193
  <update handle="customer_account"/>
194
  <reference name="my.account.wrapper">
195
+ <block type="xpaymentsconnector/customer_usercards_add" name="xpaymentsconnector_customer_usercards_add" template="xpaymentsconnector/customer/usercards/add.phtml" />
196
  </reference>
197
  </xpaymentsconnector_customer_cardadd>
198
 
app/design/frontend/base/default/template/xpaymentsconnector/cancel.phtml DELETED
@@ -1,49 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
- ?>
22
- <?php
23
- /**
24
- * @see Cdev_XPaymentsConnector_Block_Cancel
25
- */
26
- ?>
27
- <html>
28
- <head>
29
- <meta http-equiv="refresh" content="0; URL=<?php echo $this->getContinueShoppingUrl(); ?>" />
30
- <link href="<?php echo $this->getJsUrl("xpayment/settings.css"); ?>" type="text/css" rel="stylesheet">
31
- </head>
32
- <body>
33
-
34
- <div class="b-loader-wrap">
35
- <div id="ajax-loader">
36
- </div>
37
- </div>
38
- <div id="wait-message">
39
- <div class="page-head">
40
- <h3><?php echo Mage::helper('xpaymentsconnector')->__('The payment has been canceled') ?></h3>
41
- </div>
42
- <p><?php echo Mage::helper('xpaymentsconnector')->__('Please')?>&nbsp;
43
- <a href="<?php echo $this->getContinueShoppingUrl();?>">
44
- <?php echo Mage::helper('xpaymentsconnector')->__('continue shopping.');?>
45
- </a>
46
- </p>
47
- </div>
48
- </body>
49
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/xpaymentsconnector/{blank.phtml → checkout/blank.phtml} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,17 +13,17 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
22
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
23
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
24
  <head>
25
- <link href="<?php echo $this->getJsUrl("xpayment/settings.css"); ?>" type="text/css" rel="stylesheet">
26
  </head>
27
  <body>
28
  <?php echo $this->getChildHtml('content') ?>
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
23
  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
24
  <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
25
  <head>
26
+ <link href="<?php echo $this->escapeUrl($this->getJsUrl("xpayment/settings.css")); ?>" type="text/css" rel="stylesheet" />
27
  </head>
28
  <body>
29
  <?php echo $this->getChildHtml('content') ?>
app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/beforesuccess.phtml DELETED
@@ -1,94 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
- /**
22
- * @see Cdev_XPaymentsConnector_Block_Beforesuccess
23
- */
24
- ?>
25
-
26
- <html>
27
- <head>
28
- <link href="<?php echo $this->getJsUrl("xpayment/settings.css"); ?>" type="text/css" rel="stylesheet">
29
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
30
- <script>
31
- </script>
32
- </head>
33
-
34
- <body>
35
- <div id="wait-message">
36
- <strong>
37
- <?php echo Mage::helper('xpaymentsconnector')->__('Please wait, your order is being created ...'); ?>
38
- </strong>
39
- </div>
40
-
41
- <div class="b-loader-wrap">
42
- <div id="ajax-loader">
43
- </div>
44
- </div>
45
-
46
- <?php $formKey = Mage::getSingleton('core/session')->getFormKey();?>
47
-
48
- <script type="text/javascript">
49
- jQuery(document).ready(function () {
50
- var dataObj = {};
51
- /* if (jQuery("#checkout-agreements", window.parent.document).length) {
52
- jQuery("#checkout-agreements input", window.parent.document).each(function (obj, item) {
53
- dataObj[item.name] = item.value;
54
- });
55
- } else {
56
- <?php if ($this->getAgreements()): ?>
57
- <?php foreach($this->getAgreements() as $_a):?>
58
- dataObj['agreement[<?php echo $_a->getId()?>]'] = 1;
59
- <?php endforeach;?>
60
- <?php endif; ?>
61
- }
62
- */
63
- // window.location = "<?php echo $this->getCheckoutSuccessUrl();?>";
64
-
65
- dataObj["payment[method]"] = "<?php echo $this->getXpaymentsCode();?>";
66
- dataObj["form_key"] = "<?php echo $formKey;?>";
67
-
68
- jQuery.ajax({
69
- url: "<?php echo Mage::getUrl('checkout/onepage/saveorder'); ?>",
70
- type: "post",
71
- data: jQuery.param(dataObj),
72
- success: function (data) {
73
- var response = jQuery.parseJSON(data);
74
- if (response.success == true) {
75
- window.location = "<?php echo $this->getCheckoutSuccessUrl();?>";
76
- } else if (response.success == false) {
77
- if (response['error_messages']) {
78
- alert(response['error_messages']);
79
- }
80
- if (response['redirect'] != undefined) {
81
- window.parent.location = response['redirect'];
82
- } else {
83
- window.parent.location = "<?php echo Mage::getUrl();?>";
84
- }
85
- }
86
- },
87
- error: function () {
88
- }
89
- });
90
- });
91
- </script>
92
- </body>
93
-
94
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/order-detail.phtml CHANGED
@@ -14,10 +14,10 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/review/button.phtml CHANGED
@@ -14,10 +14,10 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
app/design/frontend/base/default/template/xpaymentsconnector/checkout/onepage/{xpayment-iframe.phtml → review/cc.phtml} RENAMED
@@ -14,27 +14,24 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
24
  <?php
25
  /**
26
- * Additional settings for "IFrame" variant of payment method (frontend)
27
  *
28
- * @see Cdev_XPaymentsConnector_Block_Checkout_Onepage_Settings
29
  */
30
  ?>
31
  <?php if ($this->isVisible()): ?>
32
 
33
- <div id="xpayment-iframe-block">
34
-
35
- <iframe id="xp-iframe" class="xp-iframe" src="" name="xp-iframe"></iframe>
36
- <div id="paymentstep-ajax-loader"></div>
37
-
38
  </div>
39
 
40
  <?php endif; ?>
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
24
  <?php
25
  /**
26
+ * Iframe block at checkout on the review step
27
  *
28
+ * @see Cdev_XPaymentsConnector_Block_Checkout_Onepage_Review_Cc
29
  */
30
  ?>
31
  <?php if ($this->isVisible()): ?>
32
 
33
+ <div id="payment-form-<?php echo $this->getMethodCode(); ?>" class="payment-form-xpayments">
34
+ <iframe id="xp-iframe-<?php echo $this->getMethodCode(); ?>" class="xp-iframe" src="" name="xp-iframe-<?php echo $this->getMethodCode(); ?>"></iframe>
 
 
 
35
  </div>
36
 
37
  <?php endif; ?>
app/design/frontend/base/default/template/xpaymentsconnector/{redirectiframe.phtml → checkout/redirect.phtml} RENAMED
@@ -13,20 +13,20 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
23
  <?php
24
  /**
25
- * @see Cdev_XPaymentsConnector_Block_Redirect
26
  */
27
  ?>
28
 
29
- <?php if ($this->checkToken()): ?>
30
 
31
  <form id="xpc-iframe-redirect" action="<?php echo $this->getFormAction(); ?>" method="post">
32
  <?php foreach ($this->getFormData() as $name => $value): ?>
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
23
  <?php
24
  /**
25
+ * @see Cdev_XPaymentsConnector_Block_Checkout_Redirect
26
  */
27
  ?>
28
 
29
+ <?php if ($this->prepareToken()): ?>
30
 
31
  <form id="xpc-iframe-redirect" action="<?php echo $this->getFormAction(); ?>" method="post">
32
  <?php foreach ($this->getFormData() as $name => $value): ?>
app/design/frontend/base/default/template/xpaymentsconnector/{return.phtml → checkout/return.phtml} RENAMED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,26 +13,25 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  /**
22
- * @see Cdev_XPaymentsConnector_Block_Return
23
  */
24
  ?>
25
-
26
  <script type="text/javascript">
27
-
28
  window.onload = function() {
29
 
30
  if (window.parent !== window) {
31
- window.parent.location = '<?php echo $this->getRedirectUrl(); ?>';
32
  } else {
33
- window.location = '<?php echo $this->getRedirectUrl(); ?>';
34
  }
35
  }
36
-
37
  </script>
1
  <?php
2
+ // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  /**
23
+ * @see Cdev_XPaymentsConnector_Block_Checkout_Return
24
  */
25
  ?>
 
26
  <script type="text/javascript">
27
+ //<![CDATA[
28
  window.onload = function() {
29
 
30
  if (window.parent !== window) {
31
+ window.parent.location = '<?php echo $this->escapeUrl($this->getRedirectUrl()); ?>';
32
  } else {
33
+ window.location = '<?php echo $this->escapeUrl($this->getRedirectUrl()); ?>';
34
  }
35
  }
36
+ //]]>
37
  </script>
app/design/frontend/base/default/template/xpaymentsconnector/checkout/success.phtml CHANGED
@@ -1,5 +1,5 @@
1
  <?php
2
- // vim: set ts=4 sw=4 sts=4 et:
3
  /**
4
  * Magento
5
  *
@@ -21,69 +21,66 @@
21
  *
22
  * @category design
23
  * @package base_default
24
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
  */
27
 
28
- $profiles = $this->getRecurringProfiles();
29
  ?>
 
30
  <div class="page-title">
31
- <h1>
32
- <?php if ($this->checkOrderSuccess()): ?>
33
- <?php echo $this->__('Your order has been received.') ?>
34
- <?php else: ?>
35
- <?php echo $this->__('Order incomplete.') ?>
36
- <?php endif; ?>
37
- </h1>
38
  </div>
 
39
  <?php echo $this->getMessagesBlock()->toHtml() ?>
40
- <?php if ($this->checkOrderSuccess()): ?>
41
- <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
42
- <?php endif; ?>
43
 
44
- <?php if ($this->getOrderId()):?>
45
- <?php if ($this->checkOrderSuccess()) :?>
46
- <?php if ($this->getCanViewOrder()) :?>
47
- <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
48
- <?php else :?>
49
- <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
50
- <?php endif;?>
51
- <?php endif;?>
52
- <?php if ($this->checkOrderSuccess()): ?>
53
- <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
54
- <?php endif;?>
55
- <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder() && $this->checkOrderSuccess()) :?>
 
 
 
 
56
  <p>
57
- <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
58
- <?php echo $this->getChildHtml() ?>
59
  </p>
60
- <?php endif;?>
61
- <?php endif;?>
62
 
63
- <?php if ($this->getAgreementRefId()): ?>
64
- <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
65
- <?php endif;?>
66
 
67
- <?php if ($profiles && $this->checkOrderSuccess()): ?>
 
 
 
 
 
68
 
69
- <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
70
- <ul class="disc">
71
- <?php foreach($profiles as $profile):?>
72
- <li>
73
- <?php echo $this->__('Payment profile #'); ?>
74
- <?php if ($this->getCanViewProfiles()): ?>
75
- <a href="<?php echo $this->escapeHtml($this->getProfileUrl($profile)); ?>"><?php echo $profile->getReferenceId(); ?></a>
76
- <?php else: ?>
77
- <?php echo $profile->getReferenceId(); ?>
78
- <?php endif; ?>
79
- : <?php echo $profile->getScheduleDescription(); ?>
80
- </li>
81
- <?php endforeach;?>
82
- </ul>
83
- <?php endif;?>
84
 
85
  <div class="buttons-set">
86
- <button type="button" class="button" title="<?php echo $this->getButtonLabel() ?>"
87
- onclick="window.location='<?php echo $this->getButtonUrl() ?>'">
88
- <span><span><?php echo $this->getButtonLabel() ?></span></span></button>
89
  </div>
1
  <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
  /**
4
  * Magento
5
  *
21
  *
22
  * @category design
23
  * @package base_default
24
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
25
  * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
26
  */
27
 
28
+ $profile = $this->getRecurringProfile();
29
  ?>
30
+
31
  <div class="page-title">
32
+ <h1>
33
+ <?php echo $this->__('Your order has been received.') ?>
34
+ </h1>
 
 
 
 
35
  </div>
36
+
37
  <?php echo $this->getMessagesBlock()->toHtml() ?>
 
 
 
38
 
39
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
40
+
41
+ <?php if ($this->getOrderId()): ?>
42
+
43
+ <p>
44
+ <?php echo $this->__('Your order # is: '); ?>
45
+ <?php if ($this->getCanViewOrder()): ?>
46
+ <a href="<?php echo $this->escapeUrl($this->getViewOrderUrl()); ?>"><?php echo $this->getOrderId(); ?></a>
47
+ <?php else: ?>
48
+ <?php echo $this->getOrderId(); ?>
49
+ <?php endif; ?>
50
+ </p>
51
+
52
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
53
+
54
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()): ?>
55
  <p>
56
+ <?php echo $this->__('Click <a href="%s" target="_blank">here to print</a> a copy of your order confirmation.', $this->escapeUrl($this->getPrintUrl())); ?>
57
+ <?php echo $this->getChildHtml(); ?>
58
  </p>
59
+ <?php endif; ?>
 
60
 
61
+ <?php endif; ?>
 
 
62
 
63
+ <?php if ($this->getAgreementRefId()): ?>
64
+ <p>
65
+ <?php echo $this->__('Your billing agreement # is: '); ?>
66
+ <a href="<?php echo $this->escapeUrl($this->getAgreementUrl()); ?>"><?php echo $this->getAgreementRefId(); ?></a>
67
+ </p>
68
+ <?php endif; ?>
69
 
70
+ <?php if ($profile): ?>
71
+ <p>
72
+ <?php echo $this->__('Your recurring payment profile # is: '); ?>
73
+ <?php if ($this->getCanViewProfiles()): ?>
74
+ <a href="<?php echo $this->escapeUrl($this->getProfileUrl($profile)); ?>"><?php echo $profile->getReferenceId(); ?></a>
75
+ <?php else: ?>
76
+ <?php echo $profile->getReferenceId(); ?>
77
+ <?php endif; ?>
78
+ : <?php echo $profile->getScheduleDescription(); ?>
79
+ </p>
80
+ <?php endif; ?>
 
 
 
 
81
 
82
  <div class="buttons-set">
83
+ <button type="button" class="button" title="<?php echo $this->__('Continue shopping'); ?>" onclick="window.location='<?php echo $this->escapeUrl($this->getUrl()); ?>'">
84
+ <span><span><?php echo $this->__('Continue shopping'); ?></span></span>
85
+ </button>
86
  </div>
app/design/frontend/base/default/template/xpaymentsconnector/{xpc_data.phtml → checkout/xpc_data.phtml} RENAMED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -24,6 +24,7 @@
24
  * X-Payments Connector data via JSON
25
  */
26
  ?>
 
27
  <script type="text/javascript">
28
  //<![CDATA[
29
  xpcData = <?php echo Mage::helper('xpaymentsconnector')->getXpcJsonData(); ?>;
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
24
  * X-Payments Connector data via JSON
25
  */
26
  ?>
27
+ <div id="paymentstep-ajax-loader"></div>
28
  <script type="text/javascript">
29
  //<![CDATA[
30
  xpcData = <?php echo Mage::helper('xpaymentsconnector')->getXpcJsonData(); ?>;
app/design/frontend/base/default/template/xpaymentsconnector/customer/cardaddsuccess.phtml DELETED
@@ -1,59 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
- /**
22
- * @see Cdev_XPaymentsConnector_Block_Customer_Success
23
- */
24
- ?>
25
-
26
- <html>
27
- <head>
28
- <link href="<?php echo $this->getJsUrl("xpayment/settings.css"); ?>" type="text/css" rel="stylesheet">
29
- <script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js">
30
- <script>
31
- </script>
32
- </head>
33
-
34
- <body>
35
- <div id="wait-message">
36
- <strong>
37
- <?php
38
- $resultMessage = $this->getData("result_message");
39
- echo Mage::helper('xpaymentsconnector')->__($resultMessage);
40
- ?>
41
- </strong>
42
- </div>
43
-
44
- <div class="b-loader-wrap">
45
- <div id="ajax-loader">
46
- </div>
47
- </div>
48
-
49
-
50
- <script type="text/javascript">
51
- jQuery(document).ready(function(){
52
- setTimeout(function() {
53
- window.parent.location = "<?php echo Mage::getUrl("xpaymentsconnector/customer/usercards");?>";
54
- }, 1500);
55
- });
56
- </script>
57
- </body>
58
-
59
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/add.phtml ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * @see Cdev_XPaymentsConnector_Block_Customer_Usercards_Add
26
+ */
27
+ ?>
28
+
29
+ <div class="page-title">
30
+ <h1><?php echo Mage::helper('xpaymentsconnector')->__('Payment cards') ?></h1>
31
+ </div>
32
+
33
+ <?php if (!$this->getError()): ?>
34
+
35
+ <div id="new-card-block">
36
+ <div id="xpayment-iframe-block">
37
+ <div class="iframe-block" id="iframe-container">
38
+ <iframe src="<?php echo $this->escapeUrl($this->getIframeUrl()); ?>" id="xpc-iframe" class="xp-iframe"></iframe>
39
+ <div id="loading-container"></div>
40
+ </div>
41
+ <div id="default-billing-addres">
42
+ <li class="item">
43
+ <h3><?php echo $this->__('Default Billing Address') ?></h3>
44
+ <address>
45
+ <?php echo $this->getDefaultAddressHtml(); ?>
46
+ </address>
47
+ <p><a href="<?php echo $this->escapeUrl($this->getEditAddressUrl()); ?>"><?php echo $this->__('Change Billing Address'); ?></a></p>
48
+ </li>
49
+ </div>
50
+ <div class="clearfix"></div>
51
+ <button type="submit" id="submit-button" class="button" /><?php echo $this->__('Save payment card'); ?></button>
52
+ </div>
53
+ </div>
54
+
55
+ <script type="text/javascript">
56
+ //<![CDATA[
57
+ var xpcData = <?php echo $this->getXpcData(); ?>;
58
+ //]]>
59
+ </script>
60
+
61
+ <?php else: ?>
62
+
63
+ <div class="error">
64
+ <?php echo $this->__($this->getError()); ?>
65
+ </div>
66
+
67
+ <?php endif; ?>
68
+
69
+ <div class="buttons-set">
70
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()); ?>"><small>&laquo; </small><?php echo $this->__('Back'); ?></a></p>
71
+ </div>
app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/cardadd.phtml DELETED
@@ -1,139 +0,0 @@
1
- <?php
2
- // vim: set ts=2 sw=2 sts=2 et:
3
- /**
4
- * Magento
5
- *
6
- * NOTICE OF LICENSE
7
- *
8
- * This source file is subject to the Open Software License (OSL 3.0)
9
- * that is bundled with this package in the file LICENSE.txt.
10
- * It is also available through the world-wide-web at this URL:
11
- * http://opensource.org/licenses/osl-3.0.php
12
- * If you did not receive a copy of the license and are unable to
13
- * obtain it through the world-wide-web, please send an email
14
- * to license@magentocommerce.com so we can send you a copy immediately.
15
- *
16
- * @author Qualiteam Software info@qtmsoft.com
17
- * @category Cdev
18
- * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
- */
22
- ?>
23
- <?php
24
- /**
25
- * @see Cdev_XPaymentsConnector_Block_Customer_Cardadd
26
- */
27
- ?>
28
- <?php
29
- $xpayUrl = $this->getXpayUrl();
30
- ?>
31
-
32
- <div class="page-title">
33
- <h1><?php echo Mage::helper('xpaymentsconnector')->__('Add new credit card to list (X-Payments)') ?></h1>
34
- </div>
35
-
36
- <?php
37
- $result = $this->getAuthorizeIframeUrl();
38
- ?>
39
- <div id="new-card-block">
40
- <?php if($result['success']):?>
41
- <div id="xpayment-iframe-block">
42
- <div class="iframe-block">
43
- <?php if (!empty($this->getDefaultAddressHtml())): ?>
44
- <iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $result['iframe_url'];?>"
45
- src="<?php echo $result['iframe_url'];?>" name="xp-iframe">
46
- </iframe>
47
- <?php endif; ?>
48
- </div>
49
- <div id="default-billing-addres">
50
- <li class="item">
51
- <h3><?php echo $this->__('Default Billing Address') ?></h3>
52
- <address>
53
- <?php echo $this->getDefaultAddressHtml() ?>
54
- </address>
55
- <p><a href="<?php echo $this->getAddressEditUrl() ?>"><?php echo $this->__('Change Billing Address') ?></a></p>
56
- </li>
57
- </div>
58
- <button onclick="cardAuthorizeSubmit();" id="create-card-button" class="button" title="Add new card" type="button"><span><span>Create card</span></span></button>
59
- <span style="display:none;" id="card-add-please-wait" class="please-wait">
60
- <img class="v-middle" title="<?php echo $this->__("Submit card information...");?>" alt="<?php echo $this->__("Submit card information...");?>"
61
- src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>">&nbsp;<?php echo $this->__("Submit card information...");?>
62
- </span>
63
- </div>
64
- <?php elseif(isset($result['error_message'])): ?>
65
- <?php echo $result['error_message'] ?>
66
- <?php endif;?>
67
- </div>
68
-
69
-
70
-
71
-
72
- <div class="buttons-set">
73
- <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
74
- </div>
75
-
76
- <script type="text/javascript">
77
- /*process iframe session expired*/
78
- var redirectUrl = '<?php echo $this->getUrl('xpaymentsconnector/customer/usercards');?>';
79
- var eventUrlPath = '<?php echo $xpayUrl; ?>';
80
- Event.observe(window, 'message', function (event) {
81
- var eventUrl = event.origin;
82
- if (eventUrl == eventUrlPath) {
83
- var jsonEventData = JSON.parse(event.data);
84
-
85
- if (jsonEventData.params.height) {
86
- $('xp-iframe').setStyle({'height': jsonEventData.params.height +'px'});
87
- }
88
-
89
- if (jsonEventData.message = "paymentFormSubmitError") {
90
- if (jsonEventData.params.type != undefined && jsonEventData.params.type == "2") {
91
- Foobar = function () {
92
- this.callBack = function () {
93
- window.location.replace(redirectUrl);
94
- };
95
- }
96
- Foobar.prototype = {
97
- Init: function () {
98
- var self = this;
99
- var errorMessage = jsonEventData.params.error + " (X-Payments)";
100
- console.log(jsonEventData);
101
- alert(errorMessage);
102
- self.callBack.call();
103
-
104
- }
105
- };
106
- var foobar = new Foobar();
107
- foobar.Init();
108
- }
109
- if (jsonEventData.params.type != undefined && jsonEventData.params.type == "4") {
110
- var errorMessage = jsonEventData.params.error + " (X-Payments)";
111
- alert(errorMessage);
112
- }
113
- }
114
- }
115
- });
116
-
117
-
118
- function cardAuthorizeSubmit() {
119
-
120
- var message = {
121
- message: 'submitPaymentForm',
122
- params: {}
123
- };
124
- $("create-card-button").hide();
125
- $("card-add-please-wait").show()
126
- var messageJson = JSON.stringify(message);
127
- var xpcShown = $('xp-iframe');
128
- xpcShown.contentWindow.postMessage(messageJson, '*');
129
- window.addEventListener("message", receiveMessage, false);
130
-
131
-
132
- }
133
-
134
- function receiveMessage(event)
135
- {
136
- $("create-card-button").show();
137
- $("card-add-please-wait").hide()
138
- }
139
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/iframe.phtml ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ ?>
23
+ <?php
24
+ /**
25
+ * X-Payments payment form for add new card in frontend
26
+ *
27
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Iframe
28
+ */
29
+ ?>
30
+
31
+ <?php if ($this->getError()): ?>
32
+
33
+ <script type="text/javascript">
34
+ //<![CDATA[
35
+ var msg = {
36
+ message: 'paymentFormSubmitError',
37
+ params: {
38
+ height: 0,
39
+ error: '<?php echo addslashes($this->__($this->getError())); ?>',
40
+ type: 1
41
+ }
42
+ };
43
+ window.parent.postMessage(JSON.stringify(msg), '*');
44
+ //]]>
45
+ </script>
46
+
47
+ <?php elseif ($this->isReturn()): ?>
48
+
49
+ <script type="text/javascript">
50
+ //<![CDATA[
51
+ window.parent.location.href = "<?php echo $this->escapeUrl($this->getPaymentCardsUrl()); ?>";
52
+ //]]>
53
+ </script>
54
+
55
+ <?php else: ?>
56
+
57
+ <form id="xpc-form-redirect" action="<?php echo $this->getFormAction(); ?>" method="post">
58
+ <?php foreach ($this->getFields() as $name => $value): ?>
59
+ <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>" />
60
+ <?php endforeach; ?>
61
+ </form>
62
+
63
+ <script type="text/javascript">
64
+ //<![CDATA[
65
+ var paymentform = document.getElementById('xpc-form-redirect');
66
+ window.onload = function() {
67
+ paymentform.submit();
68
+ }
69
+ //]]>
70
+ </script>
71
+
72
+ <?php endif; ?>
app/design/frontend/base/default/template/xpaymentsconnector/customer/usercards/list.phtml CHANGED
@@ -1,4 +1,5 @@
1
  <?php
 
2
  /**
3
  * Magento
4
  *
@@ -12,107 +13,98 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
22
  <?php
23
  /**
24
- * @see Cdev_XPaymentsConnector_Block_Customer_Usercards
25
  */
26
  ?>
27
- <?php $_items = $this->getItems(); ?>
28
- <?php $cardUsageOptions = $this->getCardsUsageOptions();?>
29
  <div class="page-title">
30
- <h1><?php echo $this->__('Edit payment cards list (X-Payments)') ?></h1>
31
  </div>
 
32
  <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
33
  <?php echo $this->getChildHtml('pager'); ?>
34
- <form id="credit-card-list-form" method="post" action="<?php echo Mage::getUrl("xpaymentsconnector/customer/usercards");?>">
35
- <?php if(count($_items)): ?>
36
- <table class="data-table" id="my-credit-cards-table">
37
- <col width="1" />
38
- <col width="1" />
39
- <col />
40
- <col width="1" />
41
- <col width="1" />
42
- <thead>
43
- <tr>
44
- <th><a id="select-all-cards" href="#" onclick="addRelatedCard(event)">Select all</a>
45
- /
46
- <a id="unselect-all-cards" href="#" onclick="removeRelatedCard(event)">Unselect all</a></th>
47
- <th><?php echo $this->__('Card id #') ?></th>
48
- <th><?php echo $this->__('Card number') ?></th>
49
- <th><?php echo $this->__('Usage card type'); ?></th>
50
- <th><?php echo $this->__('Card type'); ?></th>
51
- </tr>
52
- </thead>
53
- <tbody>
54
- <?php $_odd = ''; ?>
55
- <?php foreach ($_items as $_item): ?>
56
- <tr>
57
- <td><input type="checkbox" class="checkbox related-checkbox"
58
- value="<?php echo $_item->getXpCardId();?>" name="card[]"></td>
59
- <td><?php echo $_item->getXpCardId();?></td>
60
- <td>
61
- <?php
62
- $xpCardDataStr = Mage::helper('xpaymentsconnector')->prepareCardDataString($_item->getData());
63
- echo $xpCardDataStr;
64
- ?>
65
- </td>
66
- <td><?php echo $cardUsageOptions[$_item->getUsageType()];?></td>
67
- <td>
68
- <span class="x-payment-card-logo-list <?php echo strtolower($_item->getCardType()) ?>"
69
- title="<?php echo $_item->getCardType();?>">
70
- </span>
71
- </td>
72
- </tr>
73
- <?php endforeach; ?>
74
- </tbody>
75
- </table>
76
- <input type="hidden" name="action" value="remove">
77
 
78
- <script type="text/javascript">decorateTable('my-credit-cards-table')</script>
79
- <?php else: ?>
80
- <p><?php echo $this->__('You have no saved credit cards yet.'); ?></p>
81
- <?php endif; ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
82
  <?php echo $this->getChildHtml('pager'); ?>
 
83
  <div class="buttons-set">
84
- <p class="back-link">
85
- <a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>">
86
- <small>&laquo; </small><?php echo $this->__('Back') ?>
87
- </a>
88
- </p>
89
- <?php if(count($_items)): ?>
90
- <button class="button" title="Save" type="submit"><span><span>Remove</span></span></button>
91
- <?php endif; ?>
92
- <button onclick="window.location='<?php echo $this->getAddCardUrl();?>'"
93
- class="button" title="Add new card" type="button"><span><span>Add new card</span></span></button>
 
 
 
94
  </div>
95
- </form>
 
96
 
97
- <script type="text/javascript">
98
- //<![CDATA[
99
-
100
- function addRelatedCard(event){
101
- Event.stop(event)
102
- var checkboxes = $$('.related-checkbox');
103
- var values = [];
104
- for(var i=0;i<checkboxes.length;i++){
105
- checkboxes[i].checked = true;
106
- }
107
- }
108
- function removeRelatedCard(event){
109
- Event.stop(event)
110
- var checkboxes = $$('.related-checkbox');
111
- var values = [];
112
- for(var i=0;i<checkboxes.length;i++){
113
- checkboxes[i].checked = false;
114
- }
115
- }
116
- //]]>
117
- </script>
118
 
 
1
  <?php
2
+ // vim: set ts=2 sw=2 sts=2 et:
3
  /**
4
  * Magento
5
  *
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
23
  <?php
24
  /**
25
+ * @see Cdev_XPaymentsConnector_Block_Customer_Usercards_List
26
  */
27
  ?>
 
 
28
  <div class="page-title">
29
+ <h1><?php echo $this->__('Payment cards') ?></h1>
30
  </div>
31
+
32
  <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
33
  <?php echo $this->getChildHtml('pager'); ?>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
34
 
35
+ <?php if ($this->getCards()->getSize()): ?>
36
+ <form id="credit-card-list-form" method="post" action="<?php echo $this->escapeUrl($this->getFormUrl()); ?>">
37
+
38
+ <table class="data-table" id="my-credit-cards-table">
39
+ <col width="1" />
40
+ <col width="1" />
41
+ <col />
42
+ <col width="1" />
43
+ <col width="1" />
44
+ <thead>
45
+ <tr>
46
+ <th>
47
+ <a id="select-all-cards" href="javascript: void(0);" class="select-all-link"><?php echo $this->__('Select all'); ?></a>
48
+ /
49
+ <a id="unselect-all-cards" href="javascript: void(0);" class="select-all-link unselect"><?php echo $this->__('Unselect all'); ?></a>
50
+ </th>
51
+ <th><?php echo $this->__('Card id #') ?></th>
52
+ <th><?php echo $this->__('Card number') ?></th>
53
+ <th><?php echo $this->__('Usage card type'); ?></th>
54
+ <th><?php echo $this->__('Card type'); ?></th>
55
+ </tr>
56
+ </thead>
57
+ <tbody>
58
+ <?php foreach ($this->getCards() as $card): ?>
59
+ <tr>
60
+ <td>
61
+ <input type="checkbox" class="checkbox related-checkbox" value="<?php echo $card->getXpCardId(); ?>" name="card[]" />
62
+ </td>
63
+ <td><?php echo $card->getXpCardId(); ?></td>
64
+ <td><?php echo $this->getCardString($card); ?></td>
65
+ <td><?php echo $this->getCardUsageType($card); ?></td>
66
+ <td>
67
+ <span class="xpc-card-logo-list <?php echo strtolower($card->getCardType()); ?>" title="<?php echo $card->getCardType(); ?>"></span>
68
+ </td>
69
+ </tr>
70
+ <?php endforeach; ?>
71
+ </tbody>
72
+ </table>
73
+
74
+ <script type="text/javascript">decorateTable('my-credit-cards-table');</script>
75
+
76
  <?php echo $this->getChildHtml('pager'); ?>
77
+
78
  <div class="buttons-set">
79
+ <p class="back-link">
80
+ <a href="<?php echo $this->escapeUrl($this->getBackUrl()); ?>">
81
+ <small>&laquo;&nbsp;</small><?php echo $this->__('Back') ?>
82
+ </a>
83
+ </p>
84
+ <button class="button" type="submit" title="<?php echo $this->__('Remove'); ?>">
85
+ <span><span><?php echo $this->__('Remove'); ?></span></span>
86
+ </button>
87
+ <?php if (Mage::helper('settings_xpc')->isZeroAuthMethodConfigured()): ?>
88
+ <button class="button" type="button" title="<?php echo $this->__('Add new card'); ?>" onclick="javascript: window.location='<?php echo $this->escapeUrl($this->getAddCardUrl()); ?>'">
89
+ <span><span><?php echo $this->__('Add new card'); ?></span></span>
90
+ </button>
91
+ <?php endif; ?>
92
  </div>
93
+ </form>
94
+ <?php else: ?>
95
 
96
+ <p><?php echo $this->__('You have no saved credit cards yet.'); ?></p>
97
+ <div class="buttons-set">
98
+ <p class="back-link">
99
+ <a href="<?php echo $this->escapeUrl($this->getBackUrl()); ?>">
100
+ <small>&laquo;&nbsp;</small><?php echo $this->__('Back') ?>
101
+ </a>
102
+ </p>
103
+ <?php if (Mage::helper('settings_xpc')->isZeroAuthMethodConfigured()): ?>
104
+ <button class="button" type="button" title="<?php echo $this->__('Add new card'); ?>" onclick="javascript: window.location='<?php echo $this->escapeUrl($this->getAddCardUrl()); ?>'">
105
+ <span><span><?php echo $this->__('Add new card'); ?></span></span>
106
+ </button>
107
+ <?php endif; ?>
108
+ </div>
 
 
 
 
 
 
 
 
109
 
110
+ <?php endif; ?>
app/design/frontend/base/default/template/xpaymentsconnector/failure.phtml DELETED
@@ -1,39 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
- ?>
22
- <?php
23
- /**
24
- * @see Cdev_XPaymentsConnector_Block_Failure
25
- */
26
- ?>
27
- <html>
28
- <meta http-equiv="refresh" content="0; URL=<?php echo $this->getContinueShoppingUrl()?>" />
29
- <body>
30
- <div class="page-head">
31
- <h3><?php echo Mage::helper('xpaymentsconnector')->__('Error occured') ?></h3>
32
- </div>
33
- <p><?php echo Mage::helper('xpaymentsconnector')->__('Please')?>&nbsp;
34
- <a href="<?php echo $this->getContinueShoppingUrl();?>">
35
- <?php echo Mage::helper('xpaymentsconnector')->__('continue shopping.');?>
36
- </a>
37
- </p>
38
- </body>
39
- </html>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/design/frontend/base/default/template/xpaymentsconnector/form/cc.phtml CHANGED
@@ -14,34 +14,29 @@
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
- * @author Qualiteam Software info@qtmsoft.com
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
24
  <?php
25
  /**
 
 
26
  * @see Cdev_XPaymentsConnector_Block_Form_Cc
27
  */
28
  ?>
29
  <?php if ($this->isVisible()): ?>
30
 
31
- <ul id="payment_form_xpayments">
32
- <li>
33
- <div id="xpayment-iframe-block">
34
-
35
- <iframe id="xp-iframe" class="xp-iframe" src="" name="xp-iframe"></iframe>
36
- <div id="paymentstep-ajax-loader"></div>
37
-
38
- </div>
39
- </li>
40
- </ul>
41
 
42
  <script type="text/javascript">
43
  //<![CDATA[
44
- document.fire('xpc:iframeBlockLoaded');
45
  //]]>
46
  </script>
47
 
14
  * obtain it through the world-wide-web, please send an email
15
  * to license@magentocommerce.com so we can send you a copy immediately.
16
  *
17
+ * @author Qualiteam Software <info@x-cart.com>
18
  * @category Cdev
19
  * @package Cdev_XPaymentsConnector
20
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
21
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
22
  */
23
  ?>
24
  <?php
25
  /**
26
+ * Iframe block at checkout on the payment step
27
+ *
28
  * @see Cdev_XPaymentsConnector_Block_Form_Cc
29
  */
30
  ?>
31
  <?php if ($this->isVisible()): ?>
32
 
33
+ <div id="payment-form-<?php echo $this->getMethodCode(); ?>" class="payment-form-xpayments">
34
+ <iframe id="xp-iframe-<?php echo $this->getMethodCode(); ?>" class="xp-iframe" src="" name="xp-iframe-<?php echo $this->getMethodCode(); ?>"></iframe>
35
+ </div>
 
 
 
 
 
 
 
36
 
37
  <script type="text/javascript">
38
  //<![CDATA[
39
+ document.fire('xpc:checkoutChanged');
40
  //]]>
41
  </script>
42
 
app/design/frontend/base/default/template/xpaymentsconnector/form/savedcards.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
@@ -44,7 +44,7 @@
44
  <label for="<?php echo $_code.'_'.$creditCard->getXpCardId() ?>">
45
  <?php echo $this->__('Use card - %s', $xpCardDataStr); ?>
46
  </label>
47
- <span class="x-payment-card-logo <?php echo strtolower($creditCard->getCardType()) ?>"
48
  title="<?php echo $creditCard->getCardType();?>">
49
  </span>
50
  </span>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
44
  <label for="<?php echo $_code.'_'.$creditCard->getXpCardId() ?>">
45
  <?php echo $this->__('Use card - %s', $xpCardDataStr); ?>
46
  </label>
47
+ <span class="xpc-card-logo <?php echo strtolower($creditCard->getCardType()); ?>"
48
  title="<?php echo $creditCard->getCardType();?>">
49
  </span>
50
  </span>
app/design/frontend/base/default/template/xpaymentsconnector/info/cc.phtml CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
  ?>
app/design/frontend/base/default/template/xpaymentsconnector/info/prepaidpayments.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
app/design/frontend/base/default/template/xpaymentsconnector/info/savedcards.phtml CHANGED
@@ -12,10 +12,10 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
  ?>
app/design/frontend/base/default/template/xpaymentsconnector/redirect.phtml DELETED
@@ -1,55 +0,0 @@
1
- <?php
2
- /**
3
- * Magento
4
- *
5
- * NOTICE OF LICENSE
6
- *
7
- * This source file is subject to the Open Software License (OSL 3.0)
8
- * that is bundled with this package in the file LICENSE.txt.
9
- * It is also available through the world-wide-web at this URL:
10
- * http://opensource.org/licenses/osl-3.0.php
11
- * If you did not receive a copy of the license and are unable to
12
- * obtain it through the world-wide-web, please send an email
13
- * to license@magentocommerce.com so we can send you a copy immediately.
14
- *
15
- * @author Qualiteam Software info@qtmsoft.com
16
- * @category Cdev
17
- * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
- * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
- */
21
- ?>
22
- <?php
23
- /**
24
- * @see Cdev_XPaymentsConnector_Block_Redirect
25
- */
26
- ?>
27
-
28
- <div class="b-loader-wrap">
29
- <div id="ajax-loader">
30
- </div>
31
- </div>
32
-
33
- <p id="wait-message">
34
- <strong>
35
- <?php echo Mage::helper('xpaymentsconnector')->__('You are being redirected to the payment form. Please wait a few seconds.'); ?>
36
- </strong>
37
- </p>
38
- <form name="xpaymentsconnector_checkout" id="xpaymentsconnector_checkout" action="<?php echo $this->getFormAction();?>" method="POST">
39
- <?php if (is_array($this->getFormData())): ?>
40
- <?php foreach ($this->getFormData() as $name => $value): ?>
41
- <input type="hidden" name="<?php echo $name; ?>" value="<?php echo $value; ?>" />
42
- <?php endforeach; ?>
43
- <?php endif; ?>
44
- </form>
45
-
46
- <script type="text/javascript">
47
- //<![CDATA[
48
- var paymentform = document.getElementById('xpaymentsconnector_checkout');
49
- if (paymentform) {
50
- window.onload = function() {
51
- paymentform.submit();
52
- }
53
- }
54
- //]]>
55
- </script>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/etc/modules/Cdev_XPaymentsConnector.xml CHANGED
@@ -15,7 +15,7 @@
15
  *
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  * @version SVN: $Id: Cdev_XPaymentsConnector.xml 3624 2010-07-28 05:45:05Z max $
21
  */
15
  *
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  * @version SVN: $Id: Cdev_XPaymentsConnector.xml 3624 2010-07-28 05:45:05Z max $
21
  */
app/locale/en_US/Cdev_XPaymentsConnector.csv CHANGED
@@ -64,7 +64,6 @@
64
  "X-Payments connector control","X-Payments connector control"
65
  "System","System"
66
  "The test transaction has been completed successfully.","The test transaction has been completed successfully."
67
- "Test transaction failed. Please check the X-Payment Connector settings and try again. If all options is ok review your X-Payments settings and make sure you have properly defined shopping cart properties.","Test transaction failed. Please check the X-Payment Connector settings and try again. If all options is ok review your X-Payments settings and make sure you have properly defined shopping cart properties."
68
  "Payment methods have been successfully imported.","Payment methods have been successfully imported."
69
  "There are no payment configurations for this store.","There are no payment configurations for this store."
70
  "An error has occured during requesting payment methods from X-Payments. See log files for details.","An error has occured during requesting payment methods from X-Payments. See log files for details."
@@ -137,7 +136,7 @@
137
  "Return to checkout","Return to checkout"
138
  "Order incomplete.","Order incomplete."
139
  "Please specify billing address for this credit card.","Please specify billing address for this credit card."
140
-
141
 
142
 
143
 
64
  "X-Payments connector control","X-Payments connector control"
65
  "System","System"
66
  "The test transaction has been completed successfully.","The test transaction has been completed successfully."
 
67
  "Payment methods have been successfully imported.","Payment methods have been successfully imported."
68
  "There are no payment configurations for this store.","There are no payment configurations for this store."
69
  "An error has occured during requesting payment methods from X-Payments. See log files for details.","An error has occured during requesting payment methods from X-Payments. See log files for details."
136
  "Return to checkout","Return to checkout"
137
  "Order incomplete.","Order incomplete."
138
  "Please specify billing address for this credit card.","Please specify billing address for this credit card."
139
+ "X-Payments Pending Payment","Authorized"
140
 
141
 
142
 
js/xpayment/add-new-card.css ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ vim: set ts=2 sw=2 sts=2 et:
3
+ * X-Payments Connector Settings
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
+ * @category Cdev
17
+ * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ #iframe-container {
23
+ width: 320px;
24
+ }
25
+
26
+ #xpc-iframe {
27
+ height: 0;
28
+ width: 100%;
29
+ border: 0;
30
+ }
31
+
32
+ #loading-container {
33
+ background: url("images/loader.gif") 50% 50% no-repeat;
34
+ height: 55px;
35
+ width: 100%;
36
+ }
js/xpayment/add-new-card.js ADDED
@@ -0,0 +1,188 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // vim: set ts=2 sw=2 sts=2 et:
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+
23
+ /**
24
+ * IFRAME actions
25
+ */
26
+ var XPC_IFRAME_DO_NOTHING = 0;
27
+ var XPC_IFRAME_CHANGE_METHOD = 1;
28
+ var XPC_IFRAME_CLEAR_INIT_DATA = 2;
29
+ var XPC_IFRAME_ALERT = 3;
30
+ var XPC_IFRAME_TOP_MESSAGE = 4;
31
+
32
+
33
+ /**
34
+ * Submit payment in X-Payments
35
+ */
36
+ function sendSubmitMessage()
37
+ {
38
+ var message = {
39
+ message: 'submitPaymentForm',
40
+ params: {}
41
+ };
42
+
43
+ message = JSON.stringify(message);
44
+
45
+ $('xpc-iframe').contentWindow.postMessage(message, '*');
46
+ }
47
+
48
+ document.observe('dom:loaded', function () {
49
+
50
+ /**
51
+ * X-Payments iframe is ready.
52
+ */
53
+ document.observe('xpc:ready', function (event) {
54
+
55
+ console.log('xpc:ready', event.memo);
56
+
57
+ $('loading-container').hide();
58
+
59
+ var iframe = $('xpc-iframe');
60
+
61
+ if (event.memo.height) {
62
+ // the iframe is hidden and shown in case of the error
63
+ var height = event.memo.height;
64
+ iframe.setStyle( {'height': height + 'px'} );
65
+ }
66
+ });
67
+
68
+ /**
69
+ * Payment form is submitted from X-Payments.
70
+ */
71
+ document.observe('xpc:showMessage', function (event) {
72
+
73
+ console.log('xpc:showMessage', event.memo);
74
+
75
+ alert(event.memo.text);
76
+ });
77
+
78
+ /**
79
+ * Payment form is submitted from X-Payments.
80
+ */
81
+ document.observe('xpc:paymentFormSubmit', function (event) {
82
+
83
+ console.log('xpc:paymentFormSubmit', event.memo);
84
+
85
+ sendSubmitMessage();
86
+ });
87
+
88
+ /**
89
+ * Error in submitting payment form from X-Payments.
90
+ */
91
+ document.observe('xpc:paymentFormSubmitError', function (event) {
92
+
93
+ console.log('xpc:paymentFormSubmitError', event.memo);
94
+
95
+ if (event.memo.message) {
96
+ document.fire('xpc:showMessage', {text: event.memo.message});
97
+ } else if (event.memo.error) {
98
+ document.fire('xpc:showMessage', {text: event.memo.error});
99
+ }
100
+
101
+ if (event.memo.height) {
102
+ $('xpc-iframe').setStyle( {'height': event.memo.height + 'px'} );
103
+ }
104
+
105
+ type = parseInt(event.memo.type);
106
+
107
+ if (XPC_IFRAME_CLEAR_INIT_DATA == type) {
108
+
109
+ document.fire('xpc:clearInitData');
110
+
111
+ } else if (XPC_IFRAME_CHANGE_METHOD == type) {
112
+
113
+ document.fire('xpc:changeMethod');
114
+ }
115
+ });
116
+
117
+
118
+ /**
119
+ * Clear init data and reload iframe.
120
+ */
121
+ document.observe('xpc:clearInitData', function (event) {
122
+
123
+ console.log('xpc:clearInitData', event.memo);
124
+
125
+ // Anyway this will create a new token
126
+ window.location.reload();
127
+ });
128
+
129
+ /**
130
+ * Clear init data and return to payment cards page.
131
+ */
132
+ document.observe('xpc:changeMethod', function (event) {
133
+
134
+ console.log('xpc:changeMethod', event.memo);
135
+
136
+ // Anyway this will create a new token
137
+ window.location.href = xpcData.url.paymentCards;
138
+ });
139
+
140
+ /**
141
+ * Check and re-trigger event from X-Payments iframe
142
+ */
143
+ Event.observe(window, 'message', function (event) {
144
+
145
+ var found = false;
146
+
147
+ for (var i in xpcData.origins) {
148
+ if (event.origin == xpcData.origins[i]) {
149
+ found = true;
150
+ break;
151
+ }
152
+ }
153
+
154
+ if (found) {
155
+
156
+ var data = JSON.parse(event.data)
157
+
158
+ document.fire('xpc:' + data.message, data.params);
159
+ }
160
+ });
161
+
162
+ var submitButton = $('submit-button');
163
+ if (submitButton) {
164
+ Event.observe($('submit-button'), 'click', function() {
165
+ sendSubmitMessage();
166
+ });
167
+ }
168
+
169
+ var addressSelect = $('billing-address');
170
+ if (addressSelect) {
171
+ Event.observe(addressSelect, 'change', function() {
172
+ window.location.href = url.replace('ADDRESSID', addressSelect.value);
173
+ });
174
+ }
175
+
176
+ var selectAlls = $$('.select-all-link');
177
+ var checkboxes = $$('.related-checkbox');
178
+ if (selectAlls && checkboxes) {
179
+ selectAlls.each( function(elm) {
180
+ elm.observe('click', function (event) {
181
+ var isChecked = !this.hasClassName('unselect');
182
+ checkboxes.each( function (elm) {
183
+ elm.checked = isChecked;
184
+ });
185
+ });
186
+ })
187
+ }
188
+ });
js/xpayment/backend-xpayment.js CHANGED
@@ -1,3 +1,4 @@
 
1
  /**
2
  * Magento
3
  *
@@ -11,46 +12,58 @@
11
  * obtain it through the world-wide-web, please send an email
12
  * to license@magentocommerce.com so we can send you a copy immediately.
13
  *
14
- * @author Qualiteam Software info@qtmsoft.com
15
  * @category Cdev
16
  * @package Cdev_XPaymentsConnector
17
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
18
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
  */
20
 
21
 
22
  /**
23
- *
24
- * @param formName
25
- * @param amountValidatorName
26
- * @param requiredValidatorName
27
  */
28
- function submitXpTransaction(action,formName,amountValidatorName,requiredValidatorName,amount) {
29
- Validation.add(amountValidatorName,'Please enter a valid amount. For example 100.00.',function(v){
30
- return Validation.get('IsEmpty').test(v) || /^([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/.test(v);
31
- });
32
- Validation.add(requiredValidatorName,'This is a required field.',function(v){
33
- return !Validation.get('IsEmpty').test(v);
34
- });
 
 
 
 
 
35
 
36
- var xpTransactionForm = new varienForm(formName);
37
- $(formName).down('.xpaction').value = action;
38
- if (action == "void") {
39
- $(formName).down('.transaction-amount').value = amount;
40
- xpTransactionForm.submit();
41
- } else {
42
- if (xpTransactionForm.validator.validate()) {
43
- xpTransactionForm.submit();
44
  }
45
- }
46
 
 
 
47
 
 
 
 
 
 
 
 
 
48
  };
49
 
50
  document.observe("dom:loaded", function () {
51
 
52
  $$('.xp-transaction-head-block').each(function(element) {
53
- element.on("click", function(event) {
 
 
54
  var grid = $(this).up('.entry-edit');
55
 
56
  if ( $(grid).down('.grid').getStyle('display') === 'none'){
1
+ // vim: set ts=2 sw=2 sts=2 et:
2
  /**
3
  * Magento
4
  *
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
 
23
  /**
24
+ * Submit secondary X-Payments transaction
 
 
 
25
  */
26
+ function submitXpcTransaction(action, formId, amountValidatorName, requiredValidatorName, amount)
27
+ {
28
+ // Amount field validation
29
+ Validation.add(
30
+ amountValidatorName,
31
+ 'Please enter a valid amount. For example 100.00.',
32
+ function (v) {
33
+ var regex = /^([1-9]{1}[0-9]{0,2}(\,[0-9]{3})*(\.[0-9]{0,2})?|[1-9]{1}\d*(\.[0-9]{0,2})?|0(\.[0-9]{0,2})?|(\.[0-9]{1,2})?)$/;
34
+ return Validation.get('IsEmpty').test(v)
35
+ || regex.test(v);
36
+ }
37
+ );
38
 
39
+ // Required fields validation
40
+ Validation.add(
41
+ requiredValidatorName,
42
+ 'This is a required field.',
43
+ function (v) {
44
+ return !Validation.get('IsEmpty').test(v);
 
 
45
  }
46
+ );
47
 
48
+ var form = new varienForm(formId);
49
+ $(formId).down('.xpc_action').value = action;
50
 
51
+ if (action == 'void') {
52
+ $(formId).down('.transaction-amount').value = amount;
53
+ form.submit();
54
+ } else {
55
+ if (form.validator.validate()) {
56
+ form.submit();
57
+ }
58
+ }
59
  };
60
 
61
  document.observe("dom:loaded", function () {
62
 
63
  $$('.xp-transaction-head-block').each(function(element) {
64
+
65
+ element.on('click', function(event) {
66
+
67
  var grid = $(this).up('.entry-edit');
68
 
69
  if ( $(grid).down('.grid').getStyle('display') === 'none'){
js/xpayment/checkout-submit.js CHANGED
@@ -13,10 +13,10 @@
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
- * @author Qualiteam Software info@qtmsoft.com
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
@@ -29,6 +29,7 @@ var XPC_IFRAME_CLEAR_INIT_DATA = 2;
29
  var XPC_IFRAME_ALERT = 3;
30
  var XPC_IFRAME_TOP_MESSAGE = 4;
31
 
 
32
 
33
  /**
34
  * Submit payment in X-Payments
@@ -42,7 +43,7 @@ function sendSubmitMessage()
42
 
43
  message = JSON.stringify(message);
44
 
45
- $('xp-iframe').contentWindow.postMessage(message, '*');
46
  }
47
 
48
  /**
@@ -50,21 +51,41 @@ function sendSubmitMessage()
50
  */
51
  function isXpcMethod()
52
  {
53
- var block = $$('input:checked[type=radio][name=payment[method]][value=xpayments]');
54
 
55
  return Boolean(block.length);
56
  }
57
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  document.observe('dom:loaded', function () {
59
 
60
  /**
61
  * Redirect or reload iframe
62
  */
63
- document.observe('xpc:redirectIframe', function (event) {
64
 
65
- console.log('xpc:redirectIframe', event.memo);
66
 
67
- var iframe = $('xp-iframe');
68
 
69
  if (typeof event.memo == 'string') {
70
 
@@ -80,31 +101,19 @@ document.observe('dom:loaded', function () {
80
  } else {
81
 
82
  // Redirect iframe to the payment page
83
- var src = xpcData.url.redirectIframe;
84
  }
85
 
86
- iframe.setStyle( {'height' : '0px'} );
 
 
87
  $('paymentstep-ajax-loader').setStyle({'display' : 'block'});
88
 
89
- if (!xpcData.displayOnReviewStep) {
90
- $('payment_form_xpayments').setStyle( {'height' : 'auto'} );
91
- }
92
 
93
  iframe.setAttribute('src', src);
94
  });
95
 
96
- /**
97
- * Block with X-Payments iframe is loaded.
98
- */
99
- document.observe('xpc:iframeBlockLoaded', function (event) {
100
-
101
- console.log('xpc:iframeBlockLoaded', event.memo);
102
-
103
- if (isXpcMethod()) {
104
- document.fire('xpc:redirectIframe');
105
- }
106
- });
107
-
108
  /**
109
  * Checkout is changed. Probably we should do something with X-Payments iframe
110
  */
@@ -113,10 +122,20 @@ document.observe('dom:loaded', function () {
113
  console.log('xpc:checkoutChanged', event.memo);
114
 
115
  if (
116
- $('xpayment-iframe-block')
117
  && typeof xpcData != 'undefined'
118
  ) {
119
- document.fire('xpc:iframeBlockLoaded');
 
 
 
 
 
 
 
 
 
 
120
  }
121
  });
122
 
@@ -145,7 +164,7 @@ document.observe('dom:loaded', function () {
145
  }
146
 
147
  new Ajax.Request(
148
- xpcData.url.checkAgreements,
149
  {
150
  method: 'Post',
151
  parameters: params,
@@ -163,7 +182,7 @@ document.observe('dom:loaded', function () {
163
  if (xpcData.useIframe) {
164
  sendSubmitMessage();
165
  } else {
166
- window.location.href = xpcData.url.redirectIframeUnsetOrder;
167
  }
168
 
169
  }
@@ -185,32 +204,6 @@ document.observe('dom:loaded', function () {
185
  }
186
  });
187
 
188
- /**
189
- * Place order via One Step Checkout.
190
- */
191
- document.observe('xpc:oneStepCheckoutPlaceOrder', function (event) {
192
-
193
- console.log('xpc:oneStepCheckoutPlaceOrder', event.memo);
194
-
195
- var data = $('onestepcheckout-form').serialize(true);
196
-
197
- // Save checkout data
198
- new Ajax.Request(
199
- xpcData.url.saveCheckoutData,
200
- {
201
- method: 'Post',
202
- parameters: data,
203
- onComplete: function(response) {
204
- if (200 == response.status) {
205
- sendSubmitMessage();
206
- } else {
207
- document.fire('xpc:showMessage', {text: 'Error processing request'});
208
- }
209
- }
210
- }
211
- );
212
- });
213
-
214
  /**
215
  * X-Payments iframe is ready.
216
  */
@@ -220,7 +213,7 @@ document.observe('dom:loaded', function () {
220
 
221
  $('paymentstep-ajax-loader').hide();
222
 
223
- var iframe = $('xp-iframe');
224
 
225
  if (
226
  event.memo.height
@@ -247,6 +240,8 @@ document.observe('dom:loaded', function () {
247
  }
248
 
249
  iframe.setStyle( {'height': height + 'px'} );
 
 
250
  });
251
 
252
  /**
@@ -256,24 +251,37 @@ document.observe('dom:loaded', function () {
256
 
257
  console.log('xpc:setCheckoutMethod', event.memo);
258
 
 
 
 
 
 
 
 
 
 
 
 
259
  if (typeof event.memo == 'boolean' && event.memo) {
260
- var src = xpcData.url.setMethodRegister;
261
  } else {
262
- var src = xpcData.url.setMethodGuest;
263
  }
264
 
265
  if (isXpcMethod()) {
266
 
267
  // Reload iframe
268
- document.fire('xpc:redirectIframe', src);
269
 
270
  } else {
271
 
272
- // Set checkout method in backgraud
273
  new Ajax.Request(src);
274
 
275
- // Remove iframe srs, so it's reloaded when shown
276
- $('xp-iframe').setAttribute('src', '');
 
 
277
  }
278
  });
279
 
@@ -284,7 +292,6 @@ document.observe('dom:loaded', function () {
284
 
285
  console.log('xpc:showMessage', event.memo);
286
 
287
- // TODO: This is better via some jQuery popup widget
288
  alert(event.memo.text);
289
  });
290
 
@@ -312,7 +319,7 @@ document.observe('dom:loaded', function () {
312
  }
313
 
314
  if (event.memo.height) {
315
- $('xp-iframe').setStyle( {'height': event.memo.height + 'px'} );
316
  }
317
 
318
  type = parseInt(event.memo.type);
@@ -325,10 +332,9 @@ document.observe('dom:loaded', function () {
325
 
326
  } else if (XPC_IFRAME_CHANGE_METHOD == type) {
327
 
328
- document.fire('xpc:clearInitData');
329
  document.fire('xpc:goToPaymentSection');
330
- document.fire('xpc:changeMethod');
331
  document.fire('xpc:enableCheckout');
 
332
 
333
  } else {
334
 
@@ -337,6 +343,8 @@ document.observe('dom:loaded', function () {
337
  document.fire('xpc:goToPaymentSection');
338
  document.fire('xpc:enableCheckout');
339
  }
 
 
340
  });
341
 
342
 
@@ -347,7 +355,7 @@ document.observe('dom:loaded', function () {
347
 
348
  console.log('xpc:clearInitData', event.memo);
349
 
350
- document.fire('xpc:redirectIframe', xpcData.url.redirectIframeUnsetOrder);
351
  });
352
 
353
 
@@ -407,8 +415,51 @@ document.observe('dom:loaded', function () {
407
  if ($('co-payment-form')) {
408
  checkout.setLoadWaiting(false);
409
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
410
  });
411
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
412
 
413
  /**
414
  * Change payment method.
@@ -417,8 +468,13 @@ document.observe('dom:loaded', function () {
417
 
418
  console.log('xpc:changeMethod', event.memo);
419
 
420
- window.location.href = xpcData.url.changeMethod;
421
 
 
 
 
 
 
422
  });
423
 
424
 
@@ -427,7 +483,17 @@ document.observe('dom:loaded', function () {
427
  */
428
  Event.observe(window, 'message', function (event) {
429
 
430
- if (event.origin == xpcData.xpOrigin) {
 
 
 
 
 
 
 
 
 
 
431
  var data = JSON.parse(event.data)
432
 
433
  document.fire('xpc:' + data.message, data.params);
@@ -463,6 +529,69 @@ document.observe('dom:loaded', function () {
463
  document.fire('xpc:setCheckoutMethod', elm.checked);
464
  });
465
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
466
  }
467
 
468
  // This is for Firecheckout
@@ -492,10 +621,15 @@ document.observe('dom:loaded', function () {
492
  return;
493
  }
494
 
 
 
 
 
 
495
  // Save original "save" URL
496
  this.urls.savedSave = this.urls.save;
497
 
498
- this.urls.save = xpcData.url.saveCheckoutData;
499
 
500
  parentMethod(urlSuffix, forceSave);
501
 
@@ -507,7 +641,7 @@ document.observe('dom:loaded', function () {
507
  if (xpcData.useIframe) {
508
  sendSubmitMessage();
509
  } else {
510
- window.location.href = xpcData.url.redirectIframeUnsetOrder;
511
  }
512
 
513
  } else {
13
  * obtain it through the world-wide-web, please send an email
14
  * to license@magentocommerce.com so we can send you a copy immediately.
15
  *
16
+ * @author Qualiteam Software <info@x-cart.com>
17
  * @category Cdev
18
  * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
20
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
  */
22
 
29
  var XPC_IFRAME_ALERT = 3;
30
  var XPC_IFRAME_TOP_MESSAGE = 4;
31
 
32
+ var disabledButtons = [];
33
 
34
  /**
35
  * Submit payment in X-Payments
43
 
44
  message = JSON.stringify(message);
45
 
46
+ getXpcIframe().contentWindow.postMessage(message, '*');
47
  }
48
 
49
  /**
51
  */
52
  function isXpcMethod()
53
  {
54
+ var block = $$('input:checked[type=radio][name=payment[method]][value^=xpayments]');
55
 
56
  return Boolean(block.length);
57
  }
58
 
59
+ function getCurrentXpcMethod()
60
+ {
61
+ var code = '';
62
+
63
+ var block = $$('input:checked[type=radio][name=payment[method]][value^=xpayments]');
64
+
65
+ if (block.length) {
66
+ code = block[0].value;
67
+ }
68
+
69
+ return code;
70
+ }
71
+
72
+ function getXpcIframe()
73
+ {
74
+ var iframeId = $('xp-iframe-' + getCurrentXpcMethod());
75
+
76
+ return $(iframeId);
77
+ }
78
+
79
  document.observe('dom:loaded', function () {
80
 
81
  /**
82
  * Redirect or reload iframe
83
  */
84
+ document.observe('xpc:redirect', function (event) {
85
 
86
+ console.log('xpc:redirect', event.memo);
87
 
88
+ var iframe = getXpcIframe();
89
 
90
  if (typeof event.memo == 'string') {
91
 
101
  } else {
102
 
103
  // Redirect iframe to the payment page
104
+ var src = xpcData.url[getCurrentXpcMethod()].redirect;
105
  }
106
 
107
+ document.fire('xpc:disableButtons');
108
+
109
+ $$('.xp-iframe').each( function(elm) { elm.setStyle( {'height' : '0'} )});
110
  $('paymentstep-ajax-loader').setStyle({'display' : 'block'});
111
 
112
+ $('payment-form-' + getCurrentXpcMethod()).setStyle( {'height' : 'auto'} );
 
 
113
 
114
  iframe.setAttribute('src', src);
115
  });
116
 
 
 
 
 
 
 
 
 
 
 
 
 
117
  /**
118
  * Checkout is changed. Probably we should do something with X-Payments iframe
119
  */
122
  console.log('xpc:checkoutChanged', event.memo);
123
 
124
  if (
125
+ $$('.xp-iframe').length
126
  && typeof xpcData != 'undefined'
127
  ) {
128
+
129
+ if (isXpcMethod()) {
130
+
131
+ // Process redirect to the payment page
132
+ document.fire('xpc:redirect');
133
+
134
+ } else {
135
+
136
+ // Hide iframe with CC form for non X-Payments payment methods
137
+ $$('.xp-iframe').each( function(elm) { elm.setStyle( {'height' : '0'} )});
138
+ }
139
  }
140
  });
141
 
164
  }
165
 
166
  new Ajax.Request(
167
+ xpcData.url[getCurrentXpcMethod()].checkAgreements,
168
  {
169
  method: 'Post',
170
  parameters: params,
182
  if (xpcData.useIframe) {
183
  sendSubmitMessage();
184
  } else {
185
+ window.location.href = xpcData.url[getCurrentXpcMethod()].dropTokenAndRedirect;
186
  }
187
 
188
  }
204
  }
205
  });
206
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
207
  /**
208
  * X-Payments iframe is ready.
209
  */
213
 
214
  $('paymentstep-ajax-loader').hide();
215
 
216
+ var iframe = getXpcIframe();
217
 
218
  if (
219
  event.memo.height
240
  }
241
 
242
  iframe.setStyle( {'height': height + 'px'} );
243
+
244
+ document.fire('xpc:enableButtons');
245
  });
246
 
247
  /**
251
 
252
  console.log('xpc:setCheckoutMethod', event.memo);
253
 
254
+ currentXpcMethod = getCurrentXpcMethod();
255
+ if (!currentXpcMethod) {
256
+ // For non X-Payments payment method use the first slot
257
+ currentXpcMethod = 'xpayments1';
258
+ }
259
+
260
+ if (typeof xpcData.url[currentXpcMethod] == 'undefined') {
261
+ // Just in case check the URL
262
+ return;
263
+ }
264
+
265
  if (typeof event.memo == 'boolean' && event.memo) {
266
+ var src = xpcData.url[currentXpcMethod].setMethodRegister;
267
  } else {
268
+ var src = xpcData.url[currentXpcMethod].setMethodGuest;
269
  }
270
 
271
  if (isXpcMethod()) {
272
 
273
  // Reload iframe
274
+ document.fire('xpc:redirect', src);
275
 
276
  } else {
277
 
278
+ // Set checkout method in background
279
  new Ajax.Request(src);
280
 
281
+ // Remove iframes src, so they're reloaded when shown
282
+ $$('.xp-iframe').each( function(elm) {
283
+ elm.setAttribute('src', '');
284
+ });
285
  }
286
  });
287
 
292
 
293
  console.log('xpc:showMessage', event.memo);
294
 
 
295
  alert(event.memo.text);
296
  });
297
 
319
  }
320
 
321
  if (event.memo.height) {
322
+ getXpcIframe().setStyle( {'height': event.memo.height + 'px'} );
323
  }
324
 
325
  type = parseInt(event.memo.type);
332
 
333
  } else if (XPC_IFRAME_CHANGE_METHOD == type) {
334
 
 
335
  document.fire('xpc:goToPaymentSection');
 
336
  document.fire('xpc:enableCheckout');
337
+ document.fire('xpc:changeMethod');
338
 
339
  } else {
340
 
343
  document.fire('xpc:goToPaymentSection');
344
  document.fire('xpc:enableCheckout');
345
  }
346
+
347
+ document.fire('xpc:enableButtons');
348
  });
349
 
350
 
355
 
356
  console.log('xpc:clearInitData', event.memo);
357
 
358
+ document.fire('xpc:redirect', xpcData.url[getCurrentXpcMethod()].dropTokenAndRedirect);
359
  });
360
 
361
 
415
  if ($('co-payment-form')) {
416
  checkout.setLoadWaiting(false);
417
  }
418
+
419
+ $('paymentstep-ajax-loader').hide();
420
+ });
421
+
422
+ /**
423
+ * Disable buttons at checkout while form is loading.
424
+ */
425
+ document.observe('xpc:disableButtons', function (event) {
426
+
427
+ console.log('xpc:disableButtons', event.memo);
428
+
429
+ // Continue button at Onepage Checkout
430
+ if ('undefined' != typeof $$('#payment-buttons-container button')[0]) {
431
+ disabledButtons.push($$('#payment-buttons-container button')[0]);
432
+ }
433
+
434
+ // Place order button
435
+ if ('undefined' != typeof $$('#review-buttons-container button')[0]) {
436
+ disabledButtons.push($$('#review-buttons-container button')[0]);
437
+ }
438
+
439
+ if (disabledButtons.length) {
440
+ disabledButtons.each(function(e) { e.disable(); });
441
+ }
442
  });
443
 
444
+ /**
445
+ * Enable disabled buttons at checkout after the form loaded.
446
+ */
447
+ document.observe('xpc:enableButtons', function (event) {
448
+
449
+ console.log('xpc:enableButtons', event.memo);
450
+
451
+ if (disabledButtons.length) {
452
+ disabledButtons.each(
453
+ function(e) {
454
+ if ('undefined' != typeof e) {
455
+ e.enable();
456
+ }
457
+ }
458
+ );
459
+ }
460
+
461
+ disabledButtons = [];
462
+ });
463
 
464
  /**
465
  * Change payment method.
468
 
469
  console.log('xpc:changeMethod', event.memo);
470
 
471
+ var pm = $$('input[type=radio][name=payment[method]]:not([value*=xpayments])');
472
 
473
+ if (pm.length) {
474
+ pm[0].click();
475
+ } else {
476
+ window.location.href = xpcData.url[getCurrentXpcMethod()].changeMethod;
477
+ }
478
  });
479
 
480
 
483
  */
484
  Event.observe(window, 'message', function (event) {
485
 
486
+ var found = false;
487
+
488
+ for (var i in xpcData.origins) {
489
+ if (event.origin == xpcData.origins[i]) {
490
+ found = true;
491
+ break;
492
+ }
493
+ }
494
+
495
+ if (found) {
496
+
497
  var data = JSON.parse(event.data)
498
 
499
  document.fire('xpc:' + data.message, data.params);
529
  document.fire('xpc:setCheckoutMethod', elm.checked);
530
  });
531
  }
532
+
533
+ $('onestepcheckout-form').submit = $('onestepcheckout-form').submit.wrap(
534
+ function (parentMethod) {
535
+
536
+ if (isXpcMethod()) {
537
+
538
+ var data = $('onestepcheckout-form').serialize(true);
539
+
540
+ // Save checkout data
541
+ new Ajax.Request(
542
+ xpcData.url[getCurrentXpcMethod()].saveCheckoutData,
543
+ {
544
+ method: 'Post',
545
+ parameters: data,
546
+ onComplete: function(response) {
547
+ if (200 == response.status) {
548
+ sendSubmitMessage();
549
+ } else {
550
+ document.fire('xpc:showMessage', {text: 'Error processing request'});
551
+ }
552
+ }
553
+ }
554
+ );
555
+
556
+ } else {
557
+
558
+ return parentMethod();
559
+ }
560
+
561
+ }
562
+ );
563
+ }
564
+
565
+ // This is for One Step Checkout by AheadWorks
566
+ if ($('aw-onestepcheckout-general-form')) {
567
+
568
+ // Checkout is loaded
569
+ document.fire('xpc:checkoutChanged', 'loaded');
570
+
571
+ $('aw-onestepcheckout-general-form').on('change', '.radio', function() {
572
+
573
+ // Shipping or payment method changed
574
+ document.fire('xpc:checkoutChanged', 'paymentOrShipping');
575
+ });
576
+
577
+ AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest = AWOnestepcheckoutForm.prototype._sendPlaceOrderRequest.wrap(
578
+ function(parentMethod) {
579
+
580
+ if (isXpcMethod()) {
581
+
582
+ if (xpcData.useIframe) {
583
+ sendSubmitMessage();
584
+ } else {
585
+ window.location.href = xpcData.url[getCurrentXpcMethod()].dropTokenAndRedirect;
586
+ }
587
+
588
+ } else {
589
+
590
+ return parentMethod();
591
+ }
592
+ }
593
+ );
594
+
595
  }
596
 
597
  // This is for Firecheckout
621
  return;
622
  }
623
 
624
+ // Validate form
625
+ if (!this.validate()) {
626
+ return;
627
+ }
628
+
629
  // Save original "save" URL
630
  this.urls.savedSave = this.urls.save;
631
 
632
+ this.urls.save = xpcData.url[getCurrentXpcMethod()].saveCheckoutData;
633
 
634
  parentMethod(urlSuffix, forceSave);
635
 
641
  if (xpcData.useIframe) {
642
  sendSubmitMessage();
643
  } else {
644
+ window.location.href = xpcData.url[getCurrentXpcMethod()].dropTokenAndRedirect;
645
  }
646
 
647
  } else {
js/xpayment/images/card_types.png CHANGED
Binary file
js/xpayment/images/pci_dss_compliance.png ADDED
Binary file
js/xpayment/images/{atep-arrow.png → step-arrow.png} RENAMED
File without changes
js/xpayment/settings-xpc.css CHANGED
@@ -12,54 +12,58 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
- .xpayment-info h4 a,
23
- .xpayment-info h4 a:hover {
24
- font-weight: bold;
25
- }
26
-
27
- .xpayment-info .payment-step {
28
- padding-bottom: 64px;
29
- }
30
-
31
- .sub-heading {
32
- margin: 0 0 15px;
33
- }
34
-
35
  .payment-description {
36
- margin: 0 0 28px;
37
- padding: 19px 31px 24px;
38
  border: 2px dashed #d6d6d6;
39
  border-radius: 7px;
40
- overflow: hidden;
41
- max-width: 1321px;
 
42
  }
43
 
44
  .payment-description .payment-logo {
 
 
45
  float: left;
46
- margin: 0 46px 0 0;
47
- max-width: 130px;
48
  }
49
 
50
  .payment-description .payment-logo img {
51
- display: inline-block;
52
- vertical-align: top;
53
- max-width: 100%;
 
 
 
 
 
 
 
 
54
  }
55
 
56
  .payment-description .description-block {
57
- padding: 10px 0 0;
58
- overflow: hidden;
 
 
 
 
59
  }
60
 
61
  .payment-step {
62
  padding: 28px 0 0;
 
 
63
  }
64
 
65
  .payment-step .step {
@@ -97,3 +101,71 @@
97
  .payment-step p {
98
  margin: 0 0 20px;
99
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
 
 
 
 
 
 
 
 
 
 
 
 
 
22
  .payment-description {
23
+ margin: 39px auto 20px;
24
+ padding: 20px;
25
  border: 2px dashed #d6d6d6;
26
  border-radius: 7px;
27
+ box-shadow: 0 0 5px 0 rgba(2, 3, 3, 0.1);
28
+ max-width: 800px;
29
+ position: relative;
30
  }
31
 
32
  .payment-description .payment-logo {
33
+ height: 62px;
34
+ width: 150px;
35
  float: left;
36
+ padding-top: 11px;
37
+ padding-right: 25px;
38
  }
39
 
40
  .payment-description .payment-logo img {
41
+ width: 150px;
42
+ height: 62px;
43
+ }
44
+
45
+ .payment-description .pci-logo {
46
+ background: url(images/pci_dss_compliance.png);
47
+ width: 100px;
48
+ height: 48px;
49
+ position: absolute;
50
+ right: -37px;
51
+ top: -28px;
52
  }
53
 
54
  .payment-description .description-block {
55
+ font-size: 14px;
56
+ }
57
+
58
+ h3.connect-caption {
59
+ margin: 0 auto;
60
+ text-align: center;
61
  }
62
 
63
  .payment-step {
64
  padding: 28px 0 0;
65
+ width: 624px;
66
+ margin: 0 auto;
67
  }
68
 
69
  .payment-step .step {
101
  .payment-step p {
102
  margin: 0 0 20px;
103
  }
104
+
105
+ #connect-link {
106
+ text-decoration: none;
107
+ border-bottom: 1px dotted;
108
+ color: #2f2f2f;
109
+ }
110
+
111
+ .video {
112
+ margin: 50px auto;
113
+ width: 560px;
114
+ }
115
+
116
+ /**
117
+ * Connection settings
118
+ */
119
+ #xpc-bundle {
120
+ width: 500px;
121
+ }
122
+
123
+ #settings_xpc td.value,
124
+ #settings_xpc p.note {
125
+ width: auto;
126
+ }
127
+
128
+ /**
129
+ * Payment methods
130
+ */
131
+ #payment-methods-form label {
132
+ cursor: pointer;
133
+ display: inline-block;
134
+ width: 100%;
135
+ }
136
+
137
+ #payment-methods-form tr.disabled {
138
+ background-color: #ececec;
139
+ }
140
+
141
+ #payment-methods-form tr.disabled label {
142
+ color: #555;
143
+ }
144
+
145
+ tr.specificcountry.hidden {
146
+ display: none;
147
+ }
148
+
149
+ button.gray,
150
+ button.gray:hover {
151
+ border-color: #ccc #aaa #aaa #ccc;
152
+ background-color: #fff;
153
+ background-image: url(../../skin/adminhtml/default/default/images/btn_back_bg.gif);
154
+ color: #555;
155
+ }
156
+
157
+ td.active,
158
+ td.save-cards,
159
+ th.save-cards,
160
+ td.currency,
161
+ th.currency {
162
+ text-align: center;
163
+ }
164
+
165
+ td.actions {
166
+ padding: 15px !important;
167
+ }
168
+
169
+ td.actions button {
170
+ margin-right: 15px;
171
+ }
js/xpayment/settings-xpc.js ADDED
@@ -0,0 +1,218 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ // vim: set ts=2 sw=2 sts=2 et:
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
+ * @category Cdev
17
+ * @packageCdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
+ * @licensehttp://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Show/hide row for iframe place
24
+ */
25
+ function switchIframePlaceRow(event)
26
+ {
27
+ var useIframeSelect = Event.element(event);
28
+
29
+ if (useIframeSelect.value == 1){
30
+ iframePlaceRow.show();
31
+ } else {
32
+ iframePlaceRow.hide();
33
+ }
34
+ }
35
+
36
+ /**
37
+ * Switch URL from HTTPS to HTTP
38
+ */
39
+ function switchUrl(elm)
40
+ {
41
+ if (typeof elm == 'undefined' || !$('xpay-url')) {
42
+ return;
43
+ }
44
+
45
+ var url = $('xpay-url').innerText;
46
+
47
+ if (elm.checked) {
48
+ $('xpay-url').update(url.replace('https:', 'http:'));
49
+ } else {
50
+ $('xpay-url').update(url.replace('http:', 'https:'));
51
+ }
52
+ }
53
+
54
+ /**
55
+ * Show/hide sticky buttons for the payment methods form
56
+ */
57
+ function switchButtons()
58
+ {
59
+ var formButtons = $$('.form-buttons');
60
+
61
+ if (!formButtons) {
62
+ return;
63
+ }
64
+
65
+ var paymentMethodsContent = $('settings_xpc_tabs_paymentmethods_section_content');
66
+
67
+ if (
68
+ paymentMethodsContent
69
+ && paymentMethodsContent.visible()
70
+ ) {
71
+ formButtons.each( function (elm) { elm.show(); });
72
+ } else {
73
+ formButtons.each( function (elm) { elm.hide() });
74
+ }
75
+ }
76
+
77
+ /**
78
+ * Submit payment methods form by the sticky button
79
+ */
80
+ function submitPaymentMethodsForm(elm)
81
+ {
82
+ $('payment-method-form-mode').value = elm.value;
83
+ $('payment-methods-form').submit();
84
+ }
85
+
86
+ /**
87
+ * Disable payment configuration row
88
+ */
89
+ function disableRow(elm)
90
+ {
91
+ $(elm).up('tr').addClassName('disabled');
92
+ $(elm).disable();
93
+ }
94
+
95
+ /**
96
+ * Enable payment configuration row
97
+ */
98
+ function enableRow(elm)
99
+ {
100
+ $(elm).up('tr').removeClassName('disabled');
101
+ $(elm).enable();
102
+ }
103
+
104
+ /**
105
+ * Show/hide payment method block
106
+ */
107
+ function switchPaymentMethod(elm)
108
+ {
109
+ var paymentMethodId = elm.id.replace('active-checkbox', 'payment-method');
110
+ var saveCardId = elm.id.replace('active-checkbox', 'savecard-checkbox');
111
+
112
+ if (elm.checked) {
113
+ $(paymentMethodId).show();
114
+
115
+ if ($(saveCardId) && $(saveCardId).checked) {
116
+ $('payment-method-savedcards').show();
117
+ }
118
+
119
+ } else {
120
+ $(paymentMethodId).hide();
121
+ }
122
+ }
123
+
124
+ /**
125
+ * Process changes in checkboxes on payment methods form
126
+ */
127
+ function processFormChange(event, elm)
128
+ {
129
+
130
+ if (elm && $(elm).hasClassName('pm-active')) {
131
+
132
+ $$('input[class^="pm-disable"]')[0].checked = false;
133
+
134
+ } else if ($$('input[class^="pm-disable"]')[0].checked) {
135
+
136
+ $$('input[class^="pm-active"]').each( function(elm) { elm.checked = false; });
137
+ }
138
+
139
+ var count = $$('input:checked[class^="pm-active"]').size();
140
+
141
+ if (count >= MAX_SLOTS) {
142
+
143
+ $$('input:not(:checked)[class^="pm-active"]').each( function(elm) { disableRow($(elm));});
144
+
145
+ } else {
146
+
147
+ $$('input[class^="pm-active"]').each( function(elm) { enableRow($(elm));});
148
+ }
149
+
150
+ $('payment-method-savedcards').hide();
151
+
152
+ $$('input[class^="pm-active"]').each( function(elm) { switchPaymentMethod(elm); });
153
+ }
154
+
155
+ /**
156
+ * Show/hide list of allowed countries for payment method
157
+ */
158
+ function switchCountries(elm)
159
+ {
160
+ if (elm.value == 1) {
161
+ $(elm).up('tr').next('tr.specificcountry').removeClassName('hidden');
162
+ } else {
163
+ $(elm).up('tr').next('tr.specificcountry').addClassName('hidden');
164
+ }
165
+ }
166
+
167
+ document.observe('dom:loaded', function() {
168
+
169
+ var connectLink = $('connect-link');
170
+
171
+ if (connectLink) {
172
+ Event.observe(connectLink, 'click', function() { $('settings_xpc_tabs_connection_section').click(); });
173
+ }
174
+
175
+ var useIframeSelect = $('use-iframe-select');
176
+ var iframePlaceRow = $('iframe-place-row');
177
+
178
+ if (
179
+ useIframeSelect
180
+ && iframePlaceRow
181
+ && useIframeSelect.value == 0
182
+ ) {
183
+ iframePlaceRow.hide();
184
+ }
185
+
186
+ if (useIframeSelect) {
187
+ Event.observe(useIframeSelect, 'change', switchIframePlaceRow.bind(this));
188
+ }
189
+
190
+ var paymentMethodsForm = $('payment-methods-form');
191
+
192
+ if (paymentMethodsForm) {
193
+ paymentMethodsForm.on('change', 'input', function (event, elm) { processFormChange(event, elm); });
194
+ }
195
+
196
+ var allowSpecificBoxes = $$('.allowspecific');
197
+
198
+ if (allowSpecificBoxes) {
199
+ allowSpecificBoxes.invoke('observe' ,'change', function (event) { switchCountries(this); });
200
+ allowSpecificBoxes.each( function(elm) { switchCountries(elm); });
201
+ }
202
+
203
+ var tabLinks = $$('.tab-item-link');
204
+
205
+ if (tabLinks) {
206
+ tabLinks.invoke('observe', 'click', function (event) { switchButtons(); });
207
+ }
208
+
209
+ var zeroAuthForm = new varienForm('zero-auth-form', true);
210
+ Validation.add('validate-float', 'Amount is not correct', function(value) {
211
+ return Validation.get('IsEmpty').test(value) || !isNaN(value)
212
+ });
213
+
214
+ if (paymentMethodsForm) {
215
+ processFormChange();
216
+ }
217
+
218
+ });
js/xpayment/settings.css CHANGED
@@ -12,44 +12,22 @@
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
- * @author Qualiteam Software info@qtmsoft.com
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
- * @copyright (c) 2010-2016 Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  iframe.xp-iframe {
23
  text-align: center;
24
- height: 0px;
25
  overflow: hidden;
26
- border: 0px;
27
  width: 100%;
28
  margin: 0 auto;
29
  }
30
 
31
- #xpayment-iframe-block {
32
- padding-bottom: 10px;
33
- border-left: 1px solid #d9dde3;
34
- border-right: 1px solid #d9dde3;
35
- }
36
-
37
- #checkout-payment-method-load #xpayment-iframe-block {
38
- padding-bottom: 10px;
39
- border: 0px;
40
- }
41
-
42
- * {
43
- margin: 0;
44
- padding: 0;
45
- }
46
-
47
- .b-loader-wrap {
48
- position: fixed;
49
- width: 100%;
50
- height: 100%;
51
- }
52
-
53
  #ajax-loader {
54
  background: url("images/loader.gif") 50% 50% no-repeat;
55
  height: 213px;
@@ -68,18 +46,20 @@ iframe.xp-iframe {
68
  #paymentstep-ajax-loader {
69
  background: url("images/loader.gif") 50% 50% no-repeat;
70
  height: 55px;
71
- margin-bottom: 0;
72
- margin-right: 0;
 
73
  text-align: center;
74
  z-index: 100000;
75
  display: none;
76
  }
77
 
78
- #payment_form_xpayments {
79
- height: 0px;
 
80
  }
81
 
82
- #payment_form_xpayments > li {
83
  padding-left: 20px;
84
  }
85
 
@@ -110,7 +90,7 @@ iframe.xp-iframe {
110
  }
111
 
112
  #payment_form_savedcards.adminhtml-payment-form > li {
113
- padding-left: 0px;
114
  margin-left: -2px;
115
  }
116
 
@@ -127,7 +107,7 @@ iframe.xp-iframe {
127
  }
128
 
129
  #payment_form_prepaidpayments.adminhtml-payment-form > li {
130
- padding-left: 0px;
131
  margin-left: -2px;
132
  }
133
 
@@ -135,274 +115,77 @@ iframe.xp-iframe {
135
  margin-left: 20px;
136
  }
137
 
138
-
139
-
140
- .x-payment-card-logo.mc {
141
- background-attachment: scroll;
142
- background-clip: border-box;
143
- background-color: rgba(0, 0, 0, 0);
144
- background-image: url("images/card_types.png");
145
- background-origin: padding-box;
146
- background-repeat: no-repeat;
147
-
148
- background-position: 2px -1px;
149
- background-size:40px auto;
150
- width: 40px;
151
- height: 20px;
152
- position: absolute;
153
- top: 0;
154
- right: 0;
155
- }
156
- .x-payment-card-logo.visa {
157
- background-attachment: scroll;
158
- background-clip: border-box;
159
- background-color: rgba(0, 0, 0, 0);
160
- background-image: url("images/card_types.png");
161
- background-origin: padding-box;
162
- background-repeat: no-repeat;
163
-
164
- background-position: 2px -21px;
165
- background-size:40px auto;
166
- width: 40px;
167
- height: 20px;
168
- position: absolute;
169
- top: 0;
170
- right: 0;
171
- }
172
- .x-payment-card-logo.jcb {
173
- background-attachment: scroll;
174
- background-clip: border-box;
175
- background-color: rgba(0, 0, 0, 0);
176
- background-image: url("images/card_types.png");
177
- background-origin: padding-box;
178
- background-repeat: no-repeat;
179
-
180
- background-position: 6px -41px;
181
- background-size:40px auto;
182
- width: 40px;
183
- height: 20px;
184
- position: absolute;
185
- top: 0;
186
- right: 0;
187
- }
188
- .x-payment-card-logo.amex {
189
- background-attachment: scroll;
190
- background-clip: border-box;
191
- background-color: rgba(0, 0, 0, 0);
192
- background-image: url("images/card_types.png");
193
- background-origin: padding-box;
194
- background-repeat: no-repeat;
195
-
196
- background-position: 6px -61px;
197
- background-size: 40px auto;
198
- width: 40px;
199
- height: 20px;
200
- position: absolute;
201
- top: 0;
202
- right: 0;
203
- }
204
- .x-payment-card-logo.dc {
205
  background-attachment: scroll;
206
  background-clip: border-box;
207
  background-color: rgba(0, 0, 0, 0);
208
  background-image: url("images/card_types.png");
209
  background-origin: padding-box;
210
  background-repeat: no-repeat;
211
-
212
- background-position: 2px -81px;
213
  background-size: 40px auto;
214
  width: 40px;
215
  height: 20px;
216
  position: absolute;
217
  top: 0;
218
  right: 0;
 
219
  }
220
- .x-payment-card-logo.dicl {
221
- background-attachment: scroll;
222
- background-clip: border-box;
223
- background-color: rgba(0, 0, 0, 0);
224
- background-image: url("images/card_types.png");
225
- background-origin: padding-box;
226
- background-repeat: no-repeat;
227
 
228
- background-position: 2px -101px;
229
- background-size:40px auto;
230
- width: 40px;
231
- height: 20px;
232
- position: absolute;
233
- top: 0;
234
- right: 0;
235
- }
236
- .x-payment-card-logo.sw {
237
- background-attachment: scroll;
238
- background-clip: border-box;
239
- background-color: rgba(0, 0, 0, 0);
240
  background-image: url("images/card_types.png");
241
  background-origin: padding-box;
242
  background-repeat: no-repeat;
243
-
244
- background-position: 2px -121px;
245
- background-size:40px auto;
246
- width: 40px;
247
- height: 20px;
248
- position: absolute;
249
- top: 0;
250
- right: 0;
251
- }
252
- .x-payment-card-logo.cup {
253
- background-attachment: scroll;
254
- background-clip: border-box;
255
- background-color: rgba(0, 0, 0, 0);
256
- background-image: url("images/card_types.png");
257
- background-origin: padding-box;
258
- background-repeat: no-repeat;
259
-
260
- background-position: 4px -141px;
261
- background-size:40px auto;
262
- width: 40px;
263
- height: 20px;
264
- position: absolute;
265
- top: 0;
266
- right: 0;
267
- }
268
- .x-payment-card-logo.bc {
269
- background-attachment: scroll;
270
- background-clip: border-box;
271
- background-color: rgba(0, 0, 0, 0);
272
- background-image: url("images/card_types.png");
273
- background-origin: padding-box;
274
- background-repeat: no-repeat;
275
-
276
- background-position: 2px -161px;
277
- background-size:40px auto;
278
- width: 40px;
279
- height: 20px;
280
- position: absolute;
281
- top: 0;
282
- right: 0;
283
- }
284
-
285
- /* list*/
286
-
287
- .x-payment-card-logo-list.mc{
288
- margin-left:5px;
289
- background-image: url("images/card_types.png");
290
- background-color: rgba(0, 0, 0, 0);
291
- background-origin: padding-box;
292
- background-repeat: no-repeat;
293
- background-size:45px auto;
294
- background-position: 2px 1px;
295
  display: inline-block;
296
  width: 40px;
297
  height: 22px;
298
-
299
  }
300
 
301
- .x-payment-card-logo-list.visa{
302
- margin-left:5px;
303
- background-image: url("images/card_types.png");
304
- background-color: rgba(0, 0, 0, 0);
305
- background-origin: padding-box;
306
- background-repeat: no-repeat;
307
- background-size:45px auto;
308
- background-position: 2px -21px;
309
- display: inline-block;
310
- width: 40px;
311
- height: 22px;
312
-
313
  }
314
 
315
- .x-payment-card-logo-list.jcb {
316
- margin-left:5px;
317
- background-image: url("images/card_types.png");
318
- background-color: rgba(0, 0, 0, 0);
319
- background-origin: padding-box;
320
- background-repeat: no-repeat;
321
- background-size:45px auto;
322
- background-position: 6px -42px;
323
- display: inline-block;
324
- width: 40px;
325
- height: 22px;
326
-
327
  }
328
 
329
- .x-payment-card-logo-list.amex {
330
- margin-left:5px;
331
- background-image: url("images/card_types.png");
332
- background-color: rgba(0, 0, 0, 0);
333
- background-origin: padding-box;
334
- background-repeat: no-repeat;
335
- background-size:45px auto;
336
- background-position: 8px -66px;
337
- display: inline-block;
338
- width: 40px;
339
- height: 22px;
340
 
 
 
 
341
  }
342
- .x-payment-card-logo-list.dc {
343
- margin-left:5px;
344
- background-image: url("images/card_types.png");
345
- background-color: rgba(0, 0, 0, 0);
346
- background-origin: padding-box;
347
- background-repeat: no-repeat;
348
- background-size:45px auto;
349
- background-position: 2px -90px;
350
- display: inline-block;
351
- width: 40px;
352
- height: 22px;
353
 
 
 
 
 
 
354
  }
355
- .x-payment-card-logo-list.dicl {
356
- margin-left:5px;
357
- background-image: url("images/card_types.png");
358
- background-color: rgba(0, 0, 0, 0);
359
- background-origin: padding-box;
360
- background-repeat: no-repeat;
361
- background-size:45px auto;
362
- background-position: 2px -112px;
363
- display: inline-block;
364
- width: 40px;
365
- height: 22px;
366
 
 
 
 
367
  }
368
- .x-payment-card-logo-list.sw {
369
- margin-left:5px;
370
- background-image: url("images/card_types.png");
371
- background-color: rgba(0, 0, 0, 0);
372
- background-origin: padding-box;
373
- background-repeat: no-repeat;
374
- background-size:45px auto;
375
- background-position: 2px -134px;
376
- display: inline-block;
377
- width: 40px;
378
- height: 22px;
379
 
 
 
 
380
  }
381
- .x-payment-card-logo-list.cup {
382
- margin-left:5px;
383
- background-image: url("images/card_types.png");
384
- background-color: rgba(0, 0, 0, 0);
385
- background-origin: padding-box;
386
- background-repeat: no-repeat;
387
- background-size:45px auto;
388
- background-position: 4px -157px;
389
- display: inline-block;
390
- width: 40px;
391
- height: 22px;
392
 
 
 
 
393
  }
394
- .x-payment-card-logo-list.bc {
395
- margin-left:5px;
396
- background-image: url("images/card_types.png");
397
- background-color: rgba(0, 0, 0, 0);
398
- background-origin: padding-box;
399
- background-repeat: no-repeat;
400
- background-size:45px auto;
401
- background-position: 2px -179px;
402
- display: inline-block;
403
- width: 40px;
404
- height: 22px;
405
 
 
 
 
406
  }
407
 
408
  /* admin cards list */
@@ -523,5 +306,9 @@ iframe.xp-iframe {
523
  }
524
  /* end(settings for "X-Payments Connector Settings" part) */
525
 
526
-
 
 
 
 
527
 
12
  * obtain it through the world-wide-web, please send an email
13
  * to license@magentocommerce.com so we can send you a copy immediately.
14
  *
15
+ * @author Qualiteam Software <info@x-cart.com>
16
  * @category Cdev
17
  * @package Cdev_XPaymentsConnector
18
+ * @copyright (c) 2010-present Qualiteam software Ltd <info@x-cart.com>. All rights reserved
19
  * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
  */
21
 
22
  iframe.xp-iframe {
23
  text-align: center;
24
+ height: 0;
25
  overflow: hidden;
26
+ border: 0;
27
  width: 100%;
28
  margin: 0 auto;
29
  }
30
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
31
  #ajax-loader {
32
  background: url("images/loader.gif") 50% 50% no-repeat;
33
  height: 213px;
46
  #paymentstep-ajax-loader {
47
  background: url("images/loader.gif") 50% 50% no-repeat;
48
  height: 55px;
49
+ width: 100%;
50
+ top: 50%;
51
+ position: fixed;
52
  text-align: center;
53
  z-index: 100000;
54
  display: none;
55
  }
56
 
57
+ .payment-form-xpayments {
58
+ height: 0;
59
+ font-size: 0;
60
  }
61
 
62
+ .payment-form-xpayments > li {
63
  padding-left: 20px;
64
  }
65
 
90
  }
91
 
92
  #payment_form_savedcards.adminhtml-payment-form > li {
93
+ padding-left: 0;
94
  margin-left: -2px;
95
  }
96
 
107
  }
108
 
109
  #payment_form_prepaidpayments.adminhtml-payment-form > li {
110
+ padding-left: 0;
111
  margin-left: -2px;
112
  }
113
 
115
  margin-left: 20px;
116
  }
117
 
118
+ .xpc-card-logo {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
119
  background-attachment: scroll;
120
  background-clip: border-box;
121
  background-color: rgba(0, 0, 0, 0);
122
  background-image: url("images/card_types.png");
123
  background-origin: padding-box;
124
  background-repeat: no-repeat;
 
 
125
  background-size: 40px auto;
126
  width: 40px;
127
  height: 20px;
128
  position: absolute;
129
  top: 0;
130
  right: 0;
131
+ background-position: 0 0%;
132
  }
 
 
 
 
 
 
 
133
 
134
+ .xpc-card-logo-list {
 
 
 
 
 
 
 
 
 
 
 
135
  background-image: url("images/card_types.png");
136
  background-origin: padding-box;
137
  background-repeat: no-repeat;
138
+ background-size: 45px auto;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
139
  display: inline-block;
140
  width: 40px;
141
  height: 22px;
 
142
  }
143
 
144
+ .xpc-card-logo.mc,
145
+ .xpc-card-logo-list.mc {
146
+ background-position: 0 10%;
 
 
 
 
 
 
 
 
 
147
  }
148
 
149
+ .xpc-card-logo.visa,
150
+ .xpc-card-logo-list.visa {
151
+ background-position: 0 20%;
 
 
 
 
 
 
 
 
 
152
  }
153
 
154
+ .xpc-card-logo.jcb,
155
+ .xpc-card-logo-list.jcb {
156
+ background-position: 0 30%;
157
+ }
 
 
 
 
 
 
 
158
 
159
+ .xpc-card-logo.amex,
160
+ .xpc-card-logo-list.amex {
161
+ background-position: 0 40%;
162
  }
 
 
 
 
 
 
 
 
 
 
 
163
 
164
+ .xpc-card-logo.dc,
165
+ .xpc-card-logo.dicl,
166
+ .xpc-card-logo-list.dc,
167
+ .xpc-card-logo-list.dicl {
168
+ background-position: 0 50%;
169
  }
 
 
 
 
 
 
 
 
 
 
 
170
 
171
+ .xpc-card-logo.paypal,
172
+ .xpc-card-logo-list.paypal {
173
+ background-position: 0 60%;
174
  }
 
 
 
 
 
 
 
 
 
 
 
175
 
176
+ .xpc-card-logo.sw,
177
+ .xpc-card-logo-list.sw, {
178
+ background-position: 0 70%;
179
  }
 
 
 
 
 
 
 
 
 
 
 
180
 
181
+ .xpc-card-logo.cup,
182
+ .xpc-card-logo-list.cup {
183
+ background-position: 0 80%;
184
  }
 
 
 
 
 
 
 
 
 
 
 
185
 
186
+ .xpc-card-logo.bc,
187
+ .xpc-card-logo.bc-list {
188
+ background-position: 0 90%;
189
  }
190
 
191
  /* admin cards list */
306
  }
307
  /* end(settings for "X-Payments Connector Settings" part) */
308
 
309
+ #redirect-xpc-warning {
310
+ background-position-x: 5px !important;
311
+ background-position-y: 5px !important;
312
+ padding: 5px 25px;
313
+ }
314
 
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CDev_XPaymentsConnector</name>
4
- <version>1.7.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
@@ -11,35 +11,37 @@
11
  This extension integrates Magento with X-Payments - a PA-DSS certified payment module.</description>
12
  <notes>What's new?&#xD;
13
  &#xD;
14
- - Invoice for payment made using a saved credit card is now created automatically.&#xD;
15
- &#xD;
16
- - X-Payments Connector settings page moved to admin controller. Potential 404 error fixed.&#xD;
17
- &#xD;
18
- - Auto-detect of API version added. Test connection button removed, so connection between Magento store and X-Payments is tested automatically.&#xD;
19
- &#xD;
20
- - Fixed issue with product attributes being reset after a product is added to the cart.&#xD;
21
- &#xD;
22
- - Corrected recurring profiles creation. Fixed several issues with Recurring profiles and nominal items.&#xD;
23
- &#xD;
24
- - "Allowed IP address" for X-Payments callback handling improved.&#xD;
25
- &#xD;
26
- - Improved customer registration at checkout for OneStepCheckout module by Idev.&#xD;
27
- &#xD;
28
- - Corrected password setting during customer registration at checkout.&#xD;
29
- &#xD;
30
- - Corrected saving credit cards at customer profile.&#xD;
31
- &#xD;
32
- - "My payment cards" section is now removed correctly if "Use saved card" payment method is not active.&#xD;
33
- &#xD;
34
- - Compatibility with SUPEE-8788 vulnerability&#xD;
35
- &#xD;
36
- - NoFraud service support added&#xD;
37
- &#xD;
38
- - other minor bug-fixes and improvements in code and corrections to text labels.</notes>
 
 
39
  <authors><author><name>Alexander Mulin</name><user>xpayments</user><email>alex.mulin@x-payments.com</email></author></authors>
40
- <date>2016-10-31</date>
41
- <time>14:06:47</time>
42
- <contents><target name="magecommunity"><dir name="Cdev"><dir name="XPaymentsConnector"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Renderer"><file name="Cardnumber.php" hash="208d21b744e56583b868038a0410b4f7"/><file name="Cardtype.php" hash="a2428e2e572e4d4a8cec6fd4b9519807"/><file name="Txnid.php" hash="27ef7dcdcb042b270758dbed42888e93"/></dir><dir name="Tab"><file name="Usercards.php" hash="958a1e10005ee9109e85d7e9ca448251"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Xporderstate.php" hash="bf18faf8efa855d23a098c0a79d3da43"/></dir></dir><file name="View.php" hash="8e26bb4e8c69e388aaec6a5b3709ca9c"/></dir></dir><dir name="Settings"><file name="Xpc.php" hash="d255424fb7efede011fa0ae347d533f5"/></dir><dir name="System"><dir name="Config"><dir name="Form"><file name="Subselect.php" hash="4386558bb6ea49f56fb72e04cb1ed7a1"/></dir></dir></dir><dir name="Usercards"><file name="Grid.php" hash="98675f504e5ad16f25fa56b1222fb233"/></dir></dir><file name="Beforesuccess.php" hash="6a2d9e8742024b527efa9b64bb8c2d1d"/><file name="Cancel.php" hash="a119a76eb7b3d829df844a1450ebbf4d"/><dir name="Checkout"><dir name="Onepage"><file name="Orderdetail.php" hash="bd289826d2bf55ea59437ec98dabe0dd"/><file name="Settings.php" hash="366aa9c1ecb505be9b141c33e4f48983"/><file name="Success.php" hash="08efe39f353822c763bf0893a7f50090"/></dir></dir><dir name="Customer"><file name="Cardadd.php" hash="4fbb08e3a63034d4f4e3132f6a462902"/><file name="Success.php" hash="626854ad5b66983245ca05fec3139d10"/><file name="Usercards.php" hash="dacb606ccd0fe69666db059189406242"/></dir><file name="Failure.php" hash="4bc8bca872e68e55995c8996704a684d"/><dir name="Form"><file name="Cc.php" hash="4098182e7fcd53c3393736ca8a3b952e"/><file name="Container.php" hash="135a20a2537d890a7f304c09d28a3fa2"/><file name="Prepaidpayments.php" hash="6d24537b07085cf3cd497838be5ae641"/><file name="Savedcards.php" hash="fef05cb7cb4968a7a1f25adacbfa291d"/></dir><dir name="Info"><file name="Cc.php" hash="535973175a08d886d887743841c2259f"/><file name="Prepaidpayments.php" hash="27e8370e77323ef3d4509883317da43e"/><file name="Savedcards.php" hash="0ecab8333c35cc2c23c7460cd182f3f8"/></dir><dir name="Recurring"><dir name="Profile"><file name="View.php" hash="dd064d6997e107a12bd67666358961c1"/></dir></dir><file name="Redirect.php" hash="d06d3d1971637ec51f1663a0e5d06249"/><file name="Return.php" hash="7e69b6d4db495181f130874e3955d4ba"/><file name="Success.php" hash="557dcdaf4997f652c7949846bfe75f43"/></dir><dir name="Helper"><file name="Data.php" hash="2751c4c0ea2f01a3f0a8ed23223ca870"/></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Placedisplay.php" hash="ce97cc70fad01ae856186ed84f96a091"/></dir></dir></dir></dir><file name="Fraudcheckdata.php" hash="55e3d4d8cd9922656370750d06db29c9"/><dir name="Mysql4"><dir name="Fraudcheckdata"><file name="Collection.php" hash="1cfe63c0fdd6e32f84b65a509297ed1f"/></dir><file name="Fraudcheckdata.php" hash="bbb6193b99c15a83c77840b5e40b610a"/><dir name="Paymentconfiguration"><file name="Collection.php" hash="e639637d93fced47e15feff45dde7040"/></dir><file name="Paymentconfiguration.php" hash="27933b2a1a1b48f79c086fa2a1a055dc"/><dir name="Quote"><dir name="Xpcdata"><file name="Collection.php" hash="ae6baceed692aed2da612097d7e48a62"/></dir><file name="Xpcdata.php" hash="ecd2a442867bb59d716910be0327e4c0"/></dir><dir name="Usercards"><file name="Collection.php" hash="6181af181afe7ca149a4f4def81ab2c3"/></dir><file name="Usercards.php" hash="6987664f7d934a01a20cd4b2360410ec"/></dir><file name="Observer.php" hash="d90c8ed40aca74010998e3b040d0d8b0"/><dir name="Payment"><file name="Cc.php" hash="4cc153ad9e7c3376b2cee0c826aff29c"/><file name="Prepaidpayments.php" hash="d95213d1d1a1ca0a75f21331e20c6112"/><dir name="Recurring"><file name="Profile.php" hash="81d78bf46f16921f315d25a1882f689c"/></dir><file name="Savedcards.php" hash="e95aaf3421eb394d2cfefce2b4f4fcd4"/></dir><file name="Paymentconfiguration.php" hash="8f59c00bb689cba01419643291f84c5a"/><dir name="Quote"><dir name="Address"><dir name="Total"><dir name="Nominal"><dir name="Recurring"><file name="Discount.php" hash="de7bad92f97b7ae18c0ea14553b20b6e"/><dir name="Initialfee"><file name="Tax.php" hash="c34e0dfc1cda64509c20095d48280d30"/></dir></dir></dir><file name="Nominal.php" hash="151e80f6a973925ba5e75d53185b9a17"/></dir></dir><file name="Xpcdata.php" hash="fca39568010bbcce0c88a5069cf7ef4a"/></dir><file name="Quote.php" hash="f9ce2d25eac3ffe894586370f2b7e875"/><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="ab2f07180d0f9e6b07739dcd9a72aaaf"/></dir></dir><dir name="Source"><file name="Paymentconfiguration.php" hash="e43240d7f8c5ce6c79a11cd22fdf1654"/></dir><file name="Usercards.php" hash="d60af463fad1d64a44e3132e6dd8145d"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerController.php" hash="2afbf9ce68581c095b1c0908c338bf8b"/><dir name="Sales"><dir name="Order"><file name="FraudController.php" hash="b3dfee2e445d0ef0946c0c617a58ae7c"/></dir></dir><dir name="Settings"><file name="XpcController.php" hash="b4f3258f36018e63d2712c7b180fd83b"/></dir></dir><file name="CustomerController.php" hash="826b6c20bac3e7cda40d777f299185a0"/><file name="ProcessingController.php" hash="7da853c09b9c13bee733bcba6677f41a"/></dir><dir name="etc"><file name="adminhtml.xml" hash="38134239e74d0a020fb7ae2e8a83304a"/><file name="config.xml" hash="7d1a38e617473b73a6d8ecd2b34bcb76"/><file name="system.xml" hash="f1fb265a300efb04a2d715d5489b0ec9"/></dir><dir name="sql"><dir name="xpaymentsconnector_setup"><file name="mysql4-install-1.0.0.php" hash="54fd2b472da6f22807d7ce9d55f76f68"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="ecfbe69f2a44d954419a5ba8e6a33601"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="38f97b9ad495e37cd5616b63244003d8"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="52b4b083d68c400a2d15b7ab24432d31"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="9f504310fbd5760dbc4121575d58c1ff"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="bc258c44475f4820820b34e25a692e11"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="673e6984f3629a287cf750c62ad409d3"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="adde05f2858ab60250b0d66d88f7ccf1"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="ded44ef94cce61a6bbe76e97190e0508"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="e4ff2a01393423ea4a82226c1c160e83"/><file name="mysql4-upgrade-1.0.9-1.1.0.php" hash="f8332f7edb571e682dca101fb0a5f0d8"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="ff155b7f421d73c4962c373c88bc3ca0"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="07611a099e3057b57ec75d30e1b3cf17"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="fcca09f1a92b89c23741adcbe28bb674"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="xpayment"><file name="backend-xpayment.js" hash="0a21df00e9499cbdbf1f83866d5da7f7"/><file name="checkout-submit.js" hash="5b993541002979e0e050bff8688e6e42"/><dir name="images"><file name="arrow-down.png" hash="a0beb6cd0ca4dd686ee5bf772432176e"/><file name="arrow-up.png" hash="df40115c816a7e08016c04120ac22e53"/><file name="atep-arrow.png" hash="99b20583434330394fb2302b9b9f7331"/><file name="btn_bg_fraud.png" hash="028ca5db7bdc7a5327e5cafa8747e079"/><file name="card_types.png" hash="d35ba97c55e2cc1273a0dd1d7862d84c"/><file name="loader.gif" hash="e67d85a8d2d4021514815d0ff4d65173"/><file name="xpayment-logo.png" hash="a46be1bc2589a988172a104c11bed332"/></dir><file name="settings-xpc.css" hash="65f93e043e6710b0755e43f403fb6aa7"/><file name="settings.css" hash="75fd8264d825def2a1c8538d052b9b25"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Cdev_XPaymentsConnector.csv" hash="38e98f8fd9a7ce64b0dd18ae6c00a481"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cdev_XPaymentsConnector.xml" hash="d45ede4b1566ecf143546c1c9b2330c7"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="xpaymentsconnector"><dir><dir name="form"><file name="prepaidpayments.phtml" hash="4dbfedd5c45d0238a77e2856d151165d"/><file name="savedcards.phtml" hash="2657b09d08dda25c96f787edf00dcb21"/></dir><dir name="info"><file name="cc.phtml" hash="87b0d497ce0c26cc7f9508da5d392d27"/><file name="prepaidpayments.phtml" hash="46668fa9790f7567512a320ca6192846"/><file name="savedcards.phtml" hash="e947d6efe2602959be9a9723a1f5a470"/></dir><dir name="order"><dir name="view"><dir name="tab"><file name="xporderstate.phtml" hash="47dc7e8b7e946cf8e5ffb0257d8a19e5"/></dir></dir></dir><dir name="pdf"><file name="info.phtml" hash="ff4c8de6adb0c26a14bdb67b84002591"/></dir><dir name="settings"><file name="xpc.phtml" hash="390a08b88913d55281e889b1bde16a61"/></dir><dir name="usercards"><dir name="tab"><file name="js.phtml" hash="066a4fbebce98147eb69e37a37797187"/></dir></dir></dir><file name="info.phtml" hash="18765aeb9490d25c6cb72d90355815c1"/></dir></dir><dir name="layout"><file name="xpaymentsconnector.xml" hash="fb87962a843d476eb48c7a7b85d442fa"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a1d80c783123430a9821084154e74d3a"/><file name="cancel.phtml" hash="b7b95521b4bce46fa00a7d48799d2159"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="e93a3c562ffa3bb11e1ccc85c60e9305"/><file name="order-detail.phtml" hash="d0f638fba56e1a38bf47060e540034c0"/><dir name="review"><file name="button.phtml" hash="e2b28eda13695bff1107e32382f1d944"/></dir><file name="xpayment-iframe.phtml" hash="01d055a10a706e16dcd6cb1cc3e162c3"/></dir><file name="success.phtml" hash="6051fdfd2efbfc936b8b7beb573c233d"/></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="ed7746e9d604ffb8d047fd8086c12531"/><dir name="usercards"><file name="cardadd.phtml" hash="d57f1f395a42ce0adb7f531b0f01c246"/><file name="list.phtml" hash="18e4d3d87d1ad121392deaeff263194b"/></dir></dir><file name="failure.phtml" hash="ff9a3cab106068011e2fc5617bb5c9db"/><dir name="form"><file name="cc.phtml" hash="5aa9052f7b789c20b9a5ba5d424d636b"/><file name="savedcards.phtml" hash="40815a71bfbcb61bb6975042159da4d3"/></dir><dir name="info"><file name="cc.phtml" hash="c47bcbf6bc0373cebe15beabfc6214c9"/><file name="prepaidpayments.phtml" hash="4e8fec0502e991c6634233e3ba15202d"/><file name="savedcards.phtml" hash="e97d1c1356bf89eff3a969d430872136"/></dir><file name="redirect.phtml" hash="295b92ed99297c0349225e97b895110d"/><file name="redirectiframe.phtml" hash="8e9b635f16fbe7deb271759714eb856d"/><file name="return.phtml" hash="ae55cad4282970013ab72f746002fded"/><file name="xpc_data.phtml" hash="e1d2b67adc37e07bce05d2f2ef8f610f"/></dir></dir><dir name="layout"><file name="xpaymentsconnector.xml" hash="0e2680e432b27aa30b72d260ae6210a2"/></dir></dir></dir></dir></target></contents>
43
  <compatible/>
44
- <dependencies><required><php><min>5.3.0</min><max>7.0.9</max></php></required></dependencies>
45
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>CDev_XPaymentsConnector</name>
4
+ <version>1.8.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL 3.0</license>
7
  <channel>community</channel>
11
  This extension integrates Magento with X-Payments - a PA-DSS certified payment module.</description>
12
  <notes>What's new?&#xD;
13
  &#xD;
14
+ 1) Magento admin back-end&#xD;
15
+ - Major improvement and revamp of connection and configuration - instead of multiple configuration pages admin user can do whole X-Payments connection and configuration on the same page now.&#xD;
16
+ - Now you can configure up to 3 payment gateways supported by X-Payments in your Magento checkout.&#xD;
17
+ - Admin user can save credit cards into customer profiles on behalf of customers.&#xD;
18
+ - Admin can enter a new credit card to pay for a new order created in Magento back-end.&#xD;
19
+ - &#x201C;Saving credit card&#x201D; setup is now available to Magento admin user.&#xD;
20
+ - &#x201C;X-Payments Order State&#x201D; page redesigned. This page allows to do partial refunds/voids and capture authorized funds.&#xD;
21
+ - Now the access to the X-Payments Connector features can be partially or completely restricted with the help of the Magento&#x2019;s Roles and Permissions.&#xD;
22
+ - Added support of the Developer Mode (Use HTTP protocol) for the. testing/development environment which do not have valid SSL certificate.&#xD;
23
+ &#xD;
24
+ 2) Customer front-end&#xD;
25
+ - Checkout can have up to three X-Payments payment methods.&#xD;
26
+ - Saving credit cards by customers has been revamped and improved.&#xD;
27
+ - Support of the One step Checkout module by Ahead Works (beta).&#xD;
28
+ - Automatically unset used coupon for the declined payments.&#xD;
29
+ - Corrected free shipping calculation for the FireCheckout extension.&#xD;
30
+ - Increased speed of the callback requests processing, which makes checkout. faster.&#xD;
31
+ - Corrected store operation if the extension is switched off.&#xD;
32
+ &#xD;
33
+ 3) Code re-factoring (for the developers who extend the module features)&#xD;
34
+ - Decomposed common extension helper. Now the different features such as API communication, preparing cart data, address processing and the module settings are separated by the different sequestered helpers.&#xD;
35
+ - Reworked functionality which was handled by the observer. Instead it was changed according to the MVC design. E.g. request to charge the card again is executed by special API request from the certain controller.&#xD;
36
+ - Corrected and simplified the inheritance tree. Internal quote model is used to transport data during the payment processing, and it doesn&#x2019;t affect the quote class extensions made by other modules.&#xD;
37
+ - Removed the unused legacy code. Code-style is improved&#xD;
38
+ - Corrected version in the internal config file. &#xD;
39
+ - Other minor bug-fixes and improvements.&#xD;
40
+ </notes>
41
  <authors><author><name>Alexander Mulin</name><user>xpayments</user><email>alex.mulin@x-payments.com</email></author></authors>
42
+ <date>2017-04-28</date>
43
+ <time>13:21:24</time>
44
+ <contents><target name="magecommunity"><dir name="Cdev"><dir name="XPaymentsConnector"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><dir name="Edit"><dir name="Renderer"><file name="Cardnumber.php" hash="aaa40254a1b52d301f685237a5236a63"/><file name="Cardtype.php" hash="ddedf8207c0c01e576f7612de0298b66"/><file name="Txnid.php" hash="4abe68a1ee9286ad11e852441c860d08"/></dir><dir name="Tab"><file name="Usercards.php" hash="338ae39eae4d32f8be53e61bb7fc32ad"/></dir></dir></dir><dir name="Sales"><dir name="Order"><file name="Pay.php" hash="3ea7ea845356e1b7dbee7f23e975391c"/><dir name="View"><dir name="Tab"><file name="Xporderstate.php" hash="227b12fa8235c66aac15a2ebe66a99c1"/></dir></dir><file name="View.php" hash="d061d2ba0f31b311b88cfe33102da053"/></dir></dir><dir name="Settings"><file name="Help.php" hash="846a5274e57954e3a88feb8968617ead"/><dir name="Tab"><file name="Connection.php" hash="6290fff818f73a5039477f25e6a8acd6"/><file name="PaymentMethods.php" hash="db92f73ce1539109e1ed7644e7029d92"/><file name="Welcome.php" hash="6e31f739b5e7ee2eeb0a05953f3996b8"/><file name="ZeroAuth.php" hash="138dd6ec97485473ff611b095d06eb8e"/></dir><file name="Tab.php" hash="83eab5a75ae26be7d42026e7c45cd4f9"/><file name="Tabs.php" hash="3dffcbd26112d9395893f3844693b7de"/><file name="Xpc.php" hash="e2984fdc1910dc4de164407a62ad8230"/></dir><dir name="Usercards"><file name="Add.php" hash="d37c99d20229ff99e59bc2b87f24e6cd"/><file name="Grid.php" hash="da0b87349dc121a009b9ab64652fe9ba"/><file name="Iframe.php" hash="2cf7d0840339e8c7bf9c4adbc78d3969"/></dir></dir><dir name="Checkout"><dir name="Onepage"><file name="Orderdetail.php" hash="78dac8d8c6fca33640812973a92aa690"/><dir name="Review"><file name="Cc.php" hash="4250b4eaa9f220912a0be949bd9a9135"/></dir><file name="Success.php" hash="fb5aa9b8ae9422984e4f308085615965"/></dir><file name="Redirect.php" hash="36ab6fe76bb1be00144f1864ee6ebaff"/><file name="Return.php" hash="fb06e7b45aa467af0f0a3fb821ebdee7"/></dir><dir name="Customer"><dir name="Usercards"><file name="Add.php" hash="c0d718c85085af9e71089a3954f4a680"/><file name="Iframe.php" hash="d910b54614e93a4c00729c221a2d1a34"/><file name="List.php" hash="2a0c2cbe1fcf7a4cd362867f7dc8582c"/></dir></dir><dir name="Form"><file name="Cc.php" hash="abb21204c6bd54f17ca8f59456e06453"/><file name="Savedcards.php" hash="3165da4531d2878af73072cfadf76ace"/></dir><dir name="Info"><file name="Cc.php" hash="34a4ab8b987706aac6dc01cc5a303170"/><file name="Prepaidpayments.php" hash="17621a3dcfa5bc6f6f86e8c95033466e"/><file name="Savedcards.php" hash="6ae9e49561755ce92d7fd0930aadfda3"/></dir><dir name="Recurring"><dir name="Profile"><file name="View.php" hash="99f8f97567ada3edc6fd64ac29a17b83"/></dir></dir></dir><dir name="Helper"><file name="Abstract.php" hash="2e42ec3ecf8f4ec144350039b607c8d9"/><dir name="Address"><file name="Data.php" hash="f6db4d33d974dade9b7823d6b8b5d0a5"/></dir><dir name="Api"><file name="Data.php" hash="2a502e1747e5de5d7db24283c5187c6f"/></dir><dir name="Cart"><file name="Data.php" hash="bfae3d1ba405bc4eed326a7b33e3f290"/></dir><file name="Data.php" hash="a215685c6e7d188b912fc65ae4cfc9f9"/><dir name="Settings"><file name="Data.php" hash="2a19d5c2bb40cfc61b2744d512006d5f"/></dir></dir><dir name="Model"><dir name="Adminhtml"><dir name="System"><dir name="Config"><dir name="Source"><file name="Placedisplay.php" hash="e8d7d8c93a02eb373f0301a4ef087a1f"/></dir></dir></dir></dir><file name="Fraudcheckdata.php" hash="67ec2c9416b758da8a595e1b9f4d1cfc"/><dir name="Mysql4"><dir name="Coupon"><file name="Usage.php" hash="550bbc526828c943cd94c1014f62f480"/></dir><dir name="Fraudcheckdata"><file name="Collection.php" hash="65be31250429aac5c657e0d6905c8b7a"/></dir><file name="Fraudcheckdata.php" hash="4e21b50a5f7df50409c9098fe330df84"/><dir name="Paymentconfiguration"><file name="Collection.php" hash="4f8029d4d23c5f31fb877b4d28250798"/></dir><file name="Paymentconfiguration.php" hash="2289772e650bde075a581a57e90ccdb4"/><dir name="Quote"><dir name="Xpcdata"><file name="Collection.php" hash="6cec9e95afd39e87012cb896c84a26a6"/></dir><file name="Xpcdata.php" hash="743b47d77181eac0060ae18b7b3091c7"/></dir><dir name="Usercards"><file name="Collection.php" hash="d408cb3f3bac4fd7f8f982b9271311b4"/></dir><file name="Usercards.php" hash="76b2c6211e494a589f62b2e7efd9fcf2"/></dir><file name="Observer.php" hash="4417002f7f3e4decedf952ec6084e47e"/><dir name="Payment"><file name="Abstract.php" hash="73fc353305d5247f9d63b517a4719584"/><file name="Cc.php" hash="89d80674e8c775384ade29b7af84b1e3"/><file name="Cc1.php" hash="b75ec36b087723a37e05889072a75e6c"/><file name="Cc2.php" hash="e8b83d62206e400bed6ad961222509ec"/><file name="Cc3.php" hash="6998dec58c419d666382c2e793446a40"/><dir name="Recurring"><file name="Profile.php" hash="136d1c070a47b4df2b8387d812457975"/></dir><file name="Savedcards.php" hash="215f9fd4bf2c2bd81aed18879a8390a7"/></dir><file name="Paymentconfiguration.php" hash="20745abddc071a2a1a67f04dc9407297"/><dir name="Quote"><dir name="Address"><dir name="Total"><dir name="Nominal"><dir name="Recurring"><file name="Discount.php" hash="e00831a19d3dc3984a988442f898045d"/><dir name="Initialfee"><file name="Tax.php" hash="df2e35cd60fb9b072a4a45582c4baf4a"/></dir></dir></dir><file name="Nominal.php" hash="67d677b941e01156e25bde52afd3452f"/></dir></dir><file name="Xpcdata.php" hash="18e4eed0bd2ded95eeb9fce580cd75e9"/></dir><file name="Quote.php" hash="b6f245417906a61b3383f565e1690358"/><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="4b42debdef8853eafb2a2fad69648374"/></dir></dir><dir name="Source"><file name="Paymentconfiguration.php" hash="93eacabe0c8db27ee32f6e939d2a6d25"/></dir><file name="Usercards.php" hash="928d309bc2e3964891a32e6355b3d98a"/></dir><dir name="Transport"><file name="ApiResponse.php" hash="9798265b06eae6292ac9cf8f892911ed"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="AddnewcardController.php" hash="8dc065cdb27a8f2f2bfd153b5489fdc0"/><file name="CustomerController.php" hash="89bb3462fde3308a6ec2b8a8b963fe81"/><dir name="Sales"><dir name="Order"><file name="CreateController.php" hash="369a5e97490e1fe5011490f195b47ef4"/><file name="PaymentController.php" hash="8e487447f5253983e93e1c9eed957114"/></dir></dir><dir name="Settings"><file name="XpcController.php" hash="9c26442bc3de95f3e36af321968f2d31"/></dir></dir><file name="CustomerController.php" hash="87866f3feb3bd2fcd2b9915689dbc5ea"/><file name="ProcessingController.php" hash="236beafeed2b2b9a7cf36e156397f152"/></dir><dir name="etc"><file name="adminhtml.xml" hash="ae219070bda0fec0797fbe400fa74d8f"/><file name="config.xml" hash="2b90273abc6ba0ca928c99f05decfc91"/><file name="system.xml" hash="5ea77283425202f6ee5f8f1581bb9583"/></dir><dir name="sql"><dir name="xpaymentsconnector_setup"><file name="mysql4-install-1.0.0.php" hash="65499bf19d3160b294943ba66c35806a"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="947960c070b098218808b95b8773d410"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="fabef89153591eeae3933ec8f478de51"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="cdf4d24d4bbd68aad2cf0ed586aa5710"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="d7f8ad91db27cfb83bec9e2162751b9c"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="ed59d38aa5fa9c70eb5ac5399e7430b8"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="d69cf11809ff724fd43eab4e6450cf94"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="afe29b79e383b2bf8d91035fc0ba5939"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="36914c857f46f3cf1f921f18ca7aa435"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="eecb339e90a5eb1033425d0d9c5ab60a"/><file name="mysql4-upgrade-1.0.9-1.1.0.php" hash="404757e176b56a089aa0d8c3a0384a51"/><file name="mysql4-upgrade-1.1.0-1.1.1.php" hash="50406b4966e81d44d914134aed88bf3e"/><file name="mysql4-upgrade-1.1.1-1.1.2.php" hash="69ff2db057f6e102b3219f10b5ad1e88"/><file name="mysql4-upgrade-1.1.2-1.1.3.php" hash="411047613212e6dce7df98798fdbee9d"/><file name="mysql4-upgrade-1.1.3-1.8.0.php" hash="f60fc38a73442b853614035c37aa9a88"/></dir></dir></dir></dir></target><target name="mage"><dir name="js"><dir name="xpayment"><file name="add-new-card.css" hash="50e744658fb135d4f2e22eae5c78feb5"/><file name="add-new-card.js" hash="5ef66621ba2c45e0591f65220a0babe4"/><file name="backend-xpayment.js" hash="9cdcb40212f976fbb6626e79f565b819"/><file name="checkout-submit.js" hash="37922beb46d42d89124ccb4c914101e4"/><dir name="images"><file name="arrow-down.png" hash="a0beb6cd0ca4dd686ee5bf772432176e"/><file name="arrow-up.png" hash="df40115c816a7e08016c04120ac22e53"/><file name="btn_bg_fraud.png" hash="028ca5db7bdc7a5327e5cafa8747e079"/><file name="card_types.png" hash="0e50345d855268c0396a740fcf37df92"/><file name="loader.gif" hash="e67d85a8d2d4021514815d0ff4d65173"/><file name="pci_dss_compliance.png" hash="db4e8b0e5eaa6779db9a73e66c136670"/><file name="step-arrow.png" hash="99b20583434330394fb2302b9b9f7331"/><file name="xpayment-logo.png" hash="a46be1bc2589a988172a104c11bed332"/></dir><file name="settings-xpc.css" hash="9a15cbafff63e93950d4fd839c0c5a03"/><file name="settings-xpc.js" hash="f8474c94344434fadda42a7d04cd8335"/><file name="settings.css" hash="1e0235171cd10198ce9334e67467a8c3"/></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="Cdev_XPaymentsConnector.csv" hash="9c4ff78f5c159b2e98f2db51fcbc864c"/></dir></target><target name="mageetc"><dir name="modules"><file name="Cdev_XPaymentsConnector.xml" hash="6553887d9368d89585de4508b02eb0f7"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="xpaymentsconnector"><dir><dir name="form"><file name="cc.phtml" hash="a082a166647d2e850937aa4a1721cc9b"/><file name="prepaidpayments.phtml" hash="d2af544b65ae496be0f6465f7500549b"/><file name="savedcards.phtml" hash="377bdc79eb740329be215d933a204f6f"/></dir><dir name="info"><file name="cc.phtml" hash="2c0647d013182c158f0615e6788f57b1"/><file name="prepaidpayments.phtml" hash="63a15ae6dd0e3d1f7aa56bda95813dc9"/><file name="savedcards.phtml" hash="93de9ff106a72972861e93bd010bdf9a"/></dir><dir name="order"><file name="pay.phtml" hash="b5753ed33f7998acc097023089d7ad43"/><dir name="view"><dir name="tab"><file name="xporderstate.phtml" hash="d0d3795d3ad9e428bd3ae013f6fc495d"/></dir></dir></dir><dir name="pdf"><file name="info.phtml" hash="14dfc11d70bfc47614fe345e7d542e25"/></dir><dir name="settings"><file name="help.phtml" hash="701542e3a4cfc1fe4b8da81f118ceeee"/><dir name="tabs"><file name="connection.phtml" hash="2dc816bdf75caef351e4edf3b101b8bd"/><file name="payment_methods.phtml" hash="04ff2cb22cac2bb1184e0f90504a9352"/><file name="welcome.phtml" hash="28f15bb1031ff1e4ccddb3cd925091bc"/><file name="zero_auth.phtml" hash="8fc3b0b30090b39742d93941b039b8b8"/></dir><file name="xpc.phtml" hash="eded46dbbb2657a2ac9df2658acc4c42"/></dir><dir name="usercards"><file name="add.phtml" hash="eb3d93c62f542192ca041be2d223e6c5"/><file name="iframe.phtml" hash="b6cb88eeec648a31b77c4bff38bcfc09"/><dir name="tab"><file name="js.phtml" hash="a5f221fa7e8772352b14867947871fd8"/></dir></dir></dir><file name="info.phtml" hash="1f1dde8ac842af5e77460ad8316063a2"/></dir></dir><dir name="layout"><file name="xpaymentsconnector.xml" hash="3f2143b8c10a6284569b8ec6b31c427b"/></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="xpaymentsconnector"><dir name="checkout"><file name="blank.phtml" hash="7eec31175dc5516d73ef00b5634ba645"/><dir name="onepage"><file name="order-detail.phtml" hash="f5b8746678af65f95e0eb7fa1a8fad8b"/><dir name="review"><file name="button.phtml" hash="a1e2d615c019950d32b99c7cfc85da23"/><file name="cc.phtml" hash="fc8579a2877de308de4d75c105ff8137"/></dir></dir><file name="redirect.phtml" hash="99583bd93ed8b839b9758eebfb04f2f3"/><file name="return.phtml" hash="8468d24da3aaf06b44278315ace4cc8d"/><file name="success.phtml" hash="a2a2097281d67372887770b7810846df"/><file name="xpc_data.phtml" hash="b68322c7b86436fa83d241bb1ef43a26"/></dir><dir name="customer"><dir name="usercards"><file name="add.phtml" hash="8e5740f2f7f864c990b62852afd7e212"/><file name="iframe.phtml" hash="f5517759de042157921daf82764cf2ca"/><file name="list.phtml" hash="81f636155dc0605369b689838be81b5a"/></dir></dir><dir name="form"><file name="cc.phtml" hash="d8e0f65ce865838bfce9a6a603dc20f3"/><file name="savedcards.phtml" hash="c7909e538d7b3f65699005dcc26a0338"/></dir><dir name="info"><file name="cc.phtml" hash="3be1a8d0af0f362bed14f8a596319eda"/><file name="prepaidpayments.phtml" hash="7981ab636d54ccc28d678161a1bd1f26"/><file name="savedcards.phtml" hash="94b4f35db16f7814c39a9e64a8e2f055"/></dir></dir></dir><dir name="layout"><file name="xpaymentsconnector.xml" hash="7de99a56ac04621483eb4c6cf177b2b0"/></dir></dir></dir></dir></target></contents>
45
  <compatible/>
46
+ <dependencies><required><php><min>5.5.0</min><max>7.2.0</max></php></required></dependencies>
47
  </package>