CDev_XPaymentsConnector - Version 1.2.0

Version Notes

Version number: 1.2.0

Download this release

Release Info

Developer Valerii Demidov
Extension CDev_XPaymentsConnector
Version 1.2.0
Comparing to
See all releases


Version 1.2.0

Files changed (91) hide show
  1. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardtype.php +35 -0
  2. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Txnid.php +39 -0
  3. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Tab/Usercards.php +84 -0
  4. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php +118 -0
  5. app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php +134 -0
  6. app/code/community/Cdev/XPaymentsConnector/Block/Beforesuccess.php +59 -0
  7. app/code/community/Cdev/XPaymentsConnector/Block/Cancel.php +59 -0
  8. app/code/community/Cdev/XPaymentsConnector/Block/Checkout/Onepage/Settings.php +52 -0
  9. app/code/community/Cdev/XPaymentsConnector/Block/Control.php +207 -0
  10. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Account/Navigation.php +47 -0
  11. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php +66 -0
  12. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Success.php +37 -0
  13. app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards.php +104 -0
  14. app/code/community/Cdev/XPaymentsConnector/Block/Failure.php +58 -0
  15. app/code/community/Cdev/XPaymentsConnector/Block/Form/Cc.php +35 -0
  16. app/code/community/Cdev/XPaymentsConnector/Block/Form/Prepaidpayments.php +52 -0
  17. app/code/community/Cdev/XPaymentsConnector/Block/Form/Savedcards.php +69 -0
  18. app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php +86 -0
  19. app/code/community/Cdev/XPaymentsConnector/Block/Info/Prepaidpayments.php +39 -0
  20. app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php +34 -0
  21. app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php +45 -0
  22. app/code/community/Cdev/XPaymentsConnector/Block/Redirect.php +105 -0
  23. app/code/community/Cdev/XPaymentsConnector/Block/Success.php +59 -0
  24. app/code/community/Cdev/XPaymentsConnector/Helper/Data.php +517 -0
  25. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration.php +54 -0
  26. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration/Collection.php +81 -0
  27. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards.php +44 -0
  28. app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards/Collection.php +40 -0
  29. app/code/community/Cdev/XPaymentsConnector/Model/Observer.php +431 -0
  30. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php +1931 -0
  31. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Prepaidpayments.php +89 -0
  32. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Recurring/Profile.php +81 -0
  33. app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php +210 -0
  34. app/code/community/Cdev/XPaymentsConnector/Model/Paymentconfiguration.php +45 -0
  35. app/code/community/Cdev/XPaymentsConnector/Model/Quote.php +36 -0
  36. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php +87 -0
  37. app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Discount.php +45 -0
  38. app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php +204 -0
  39. app/code/community/Cdev/XPaymentsConnector/Model/Source/Paymentconfiguration.php +60 -0
  40. app/code/community/Cdev/XPaymentsConnector/Model/Usercards.php +56 -0
  41. app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/CustomerController.php +44 -0
  42. app/code/community/Cdev/XPaymentsConnector/controllers/ControlController.php +194 -0
  43. app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php +151 -0
  44. app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php +577 -0
  45. app/code/community/Cdev/XPaymentsConnector/etc/config.xml +414 -0
  46. app/code/community/Cdev/XPaymentsConnector/etc/system.xml +257 -0
  47. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-install-1.0.0.php +54 -0
  48. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.0-1.0.1.php +41 -0
  49. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.1-1.0.2.php +40 -0
  50. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.2-1.0.3.php +37 -0
  51. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.3-1.0.4.php +36 -0
  52. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.4-1.0.5.php +41 -0
  53. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.5-1.0.6.php +35 -0
  54. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.6-1.0.7.php +35 -0
  55. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.7-1.0.8.php +43 -0
  56. app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.8-1.0.9.php +37 -0
  57. app/design/adminhtml/default/default/layout/xpaymentsconnector.xml +75 -0
  58. app/design/adminhtml/default/default/template/xpaymentsconnector/control.phtml +119 -0
  59. app/design/adminhtml/default/default/template/xpaymentsconnector/form/prepaidpayments.phtml +56 -0
  60. app/design/adminhtml/default/default/template/xpaymentsconnector/form/savedcards.phtml +51 -0
  61. app/design/adminhtml/default/default/template/xpaymentsconnector/info.phtml +29 -0
  62. app/design/adminhtml/default/default/template/xpaymentsconnector/info/cc.phtml +41 -0
  63. app/design/adminhtml/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml +45 -0
  64. app/design/adminhtml/default/default/template/xpaymentsconnector/info/savedcards.phtml +54 -0
  65. app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml +185 -0
  66. app/design/adminhtml/default/default/template/xpaymentsconnector/pdf/info.phtml +22 -0
  67. app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/tab/js.phtml +28 -0
  68. app/design/frontend/default/default/layout/xpaymentsconnector.xml +130 -0
  69. app/design/frontend/default/default/template/xpaymentsconnector/blank.phtml +30 -0
  70. app/design/frontend/default/default/template/xpaymentsconnector/cancel.phtml +49 -0
  71. app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/beforesuccess.phtml +77 -0
  72. app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/review/button.phtml +65 -0
  73. app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/settings.phtml +56 -0
  74. app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml +77 -0
  75. app/design/frontend/default/default/template/xpaymentsconnector/customer/cardaddsuccess.phtml +59 -0
  76. app/design/frontend/default/default/template/xpaymentsconnector/customer/usercards/cardadd.phtml +111 -0
  77. app/design/frontend/default/default/template/xpaymentsconnector/customer/usercards/list.phtml +103 -0
  78. app/design/frontend/default/default/template/xpaymentsconnector/failure.phtml +39 -0
  79. app/design/frontend/default/default/template/xpaymentsconnector/form/cc.phtml +60 -0
  80. app/design/frontend/default/default/template/xpaymentsconnector/form/savedcards.phtml +44 -0
  81. app/design/frontend/default/default/template/xpaymentsconnector/info/cc.phtml +47 -0
  82. app/design/frontend/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml +45 -0
  83. app/design/frontend/default/default/template/xpaymentsconnector/info/savedcards.phtml +55 -0
  84. app/design/frontend/default/default/template/xpaymentsconnector/redirect.phtml +55 -0
  85. app/etc/modules/Cdev_XPaymentsConnector.xml +30 -0
  86. app/locale/en_US/Cdev_XPaymentsConnector.csv +121 -0
  87. js/xpayment/checkout-submit.js +77 -0
  88. js/xpayment/images/card_types.png +0 -0
  89. js/xpayment/images/loader.gif +0 -0
  90. js/xpayment/settings.css +426 -0
  91. package.xml +20 -0
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Cardtype.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
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
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Renderer/Txnid.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Customer/Edit/Tab/Usercards.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Adminhtml customer X-Payments 'Payment cards' tab
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Adminhtml_Customer_Edit_Tab_Usercards
27
+ extends Cdev_XPaymentsConnector_Block_Adminhtml_Usercards_Grid
28
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
29
+ {
30
+
31
+
32
+ public function __construct()
33
+ {
34
+ parent::__construct();
35
+ $this->setId('customer_edit_tab_usercards');
36
+ }
37
+
38
+ /**
39
+ * Return Tab label
40
+ *
41
+ * @return string
42
+ */
43
+ public function getTabLabel()
44
+ {
45
+ return $this->__('Payment cards');
46
+ }
47
+
48
+ /**
49
+ * Return Tab title
50
+ *
51
+ * @return string
52
+ */
53
+ public function getTabTitle()
54
+ {
55
+ return $this->__('Payment cards');
56
+ }
57
+
58
+ /**
59
+ * Can show tab in tabs
60
+ *
61
+ * @return boolean
62
+ */
63
+ public function canShowTab()
64
+ {
65
+ return true;
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
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Sales/Order/View/Tab/Xporderstate.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Adminhtml order 'X-Payments Order State' tab
24
+ */
25
+
26
+ 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
+ /**
42
+ * Retrieve order model instance
43
+ *
44
+ * @return Mage_Sales_Model_Order
45
+ */
46
+ public function getOrder()
47
+ {
48
+ return Mage::registry('current_order');
49
+ }
50
+
51
+ /**
52
+ * Retrieve source model instance
53
+ *
54
+ * @return Mage_Sales_Model_Order
55
+ */
56
+ public function getSource()
57
+ {
58
+ return $this->getOrder();
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)) {
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
+
90
+ if(!$this->transactionStatus){
91
+ $xpaymentsConnect = Mage::helper("xpaymentsconnector")->__("Can't get information about the order from X-Payments server. More information is available in log files.");
92
+ $result["success"] = false;
93
+ $result["error_message"] = $xpaymentsConnect;
94
+ }else{
95
+ if(!$this->isHidden()){
96
+ $result["success"] = true;
97
+ $result["info"] = $this->transactionInfo;
98
+ }
99
+
100
+ }
101
+
102
+ return $result;
103
+ }
104
+
105
+
106
+ public function isHidden()
107
+ {
108
+ $currentPaymentCode = $this->getOrder()->getPayment()->getMethodInstance()->getCode();
109
+ $isXpaymentsMethod = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($currentPaymentCode);
110
+ if($isXpaymentsMethod){
111
+ list($this->transactionStatus, $this->transactionInfo)
112
+ = Mage::getModel("xpaymentsconnector/payment_cc")->requestPaymentInfo($this->txnid,false,true);
113
+ }
114
+
115
+ return !$isXpaymentsMethod;
116
+
117
+ }
118
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Adminhtml/Usercards/Grid.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ *
48
+ * @return Mage_Adminhtml_Block_Promo_Quote_Edit_Tab_Coupons_Grid
49
+ */
50
+ protected function _prepareMassaction()
51
+ {
52
+ $this->setMassactionIdField('xp_card_id');
53
+ $this->getMassactionBlock()->setFormFieldName('ids');
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
+ }
66
+
67
+ /**
68
+ * Add columns to grid
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);
76
+ $cardTypes = $collection->getColumnValues('card_type');
77
+ $cardsTypeOptions = array_combine($cardTypes,$cardTypes);
78
+
79
+ $cardUsageOptions = Mage::getModel("xpaymentsconnector/usercards")->getCardsUsageOptions();
80
+
81
+ $this->addColumn('xp_card_id', array(
82
+ 'header' => Mage::helper('xpaymentsconnector')->__('Card id'),
83
+ 'index' => 'xp_card_id',
84
+ 'type' => 'text',
85
+ 'width' => '1',
86
+ ));
87
+
88
+ $this->addColumn('txnId', array(
89
+ 'header' => Mage::helper('xpaymentsconnector')->__('X-Payments order url'),
90
+ 'index' => 'txnId',
91
+ 'type' => 'text',
92
+ 'renderer' => 'xpaymentsconnector/adminhtml_customer_edit_renderer_txnid',
93
+ 'escape' => true
94
+ ));
95
+
96
+ $this->addColumn('last_4_cc_num', array(
97
+ 'header' => Mage::helper('xpaymentsconnector')->__('Card number (last 4 digits)'),
98
+ 'index' => 'last_4_cc_num',
99
+ 'type' => 'text',
100
+ 'width' => '1',
101
+ 'escape' => true,
102
+
103
+ ));
104
+
105
+ $this->addColumn('card_type', array(
106
+ 'header' => Mage::helper('xpaymentsconnector')->__('Card type'),
107
+ 'index' => 'card_type',
108
+ 'type' => 'options',
109
+ 'escape' => true,
110
+ 'renderer' => 'xpaymentsconnector/adminhtml_customer_edit_renderer_cardtype',
111
+ 'options' => $cardsTypeOptions
112
+ ));
113
+
114
+ $this->addColumn('usage_type', array(
115
+ 'header' => Mage::helper('xpaymentsconnector')->__('Usage card type'),
116
+ 'index' => 'usage_type',
117
+ 'type' => 'options',
118
+ 'escape' => true,
119
+ 'width' => '1',
120
+ 'options' => $cardUsageOptions
121
+ ));
122
+
123
+ $this->addColumn('amount', array(
124
+ 'header' => Mage::helper('xpaymentsconnector')->__('Amount'),
125
+ 'type' => 'price',
126
+ 'currency_code' => (string)Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE),
127
+ 'index' => 'amount',
128
+ ));
129
+
130
+ return parent::_prepareColumns();
131
+ }
132
+
133
+
134
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Beforesuccess.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ /**
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 _construct()
40
+ {
41
+ parent::_construct();
42
+
43
+ $this->setTemplate('xpaymentsconnector/checkout/onepage/beforesuccess.phtml');
44
+ }
45
+
46
+ public function getSaveOrderUrl(){
47
+ return Mage::getUrl("checkout/onepage/saveorder");
48
+ }
49
+
50
+ public function getCheckoutSuccessUrl(){
51
+ return Mage::getUrl("checkout/onepage/success");
52
+ }
53
+
54
+ public function getXpaymentsCode(){
55
+ $xpaymentPaymentCode = Mage::getModel("xpaymentsconnector/payment_cc")->getCode();
56
+ return $xpaymentPaymentCode;
57
+ }
58
+
59
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Cancel.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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/Settings.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Additional settings for "IFrame" variant of payment method (frontend)
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Checkout_Onepage_Settings extends Mage_Core_Block_Template
27
+ {
28
+ public function getIframeUrl(){
29
+
30
+ $xpaymentFormData = Mage::helper('payment')->getMethodInstance("xpayments")->getFormFields();
31
+ $xpaymentFormUrl = Mage::helper('payment')->getMethodInstance("xpayments")->getUrl();
32
+
33
+ Mage::helper("xpaymentsconnector")->prepareOrderKey();
34
+ $token = Mage::helper("xpaymentsconnector")->getIframeToken();
35
+ $iframeUrlDataArray = array('target' => $xpaymentFormData['target'], 'token' => $token);
36
+ $iframeUrl = $xpaymentFormUrl . "?" . http_build_query($iframeUrlDataArray);
37
+ return $iframeUrl;
38
+ }
39
+
40
+ public function isXpaymentMethod(){
41
+
42
+ $paymentCode = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
43
+ if($paymentCode == "xpayments"){
44
+ return true;
45
+ }
46
+ else{
47
+ return false;
48
+ }
49
+ }
50
+
51
+
52
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Control.php ADDED
@@ -0,0 +1,207 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * X-Payments connector control page block
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_Block_Control extends Mage_Adminhtml_Block_Template
30
+ {
31
+ /**
32
+ * Constructor
33
+ *
34
+ * @return void
35
+ * @access public
36
+ * @see ____func_see____
37
+ * @since 1.0.0
38
+ */
39
+ public function __construct()
40
+ {
41
+ parent::__construct();
42
+ $this->setTemplate('xpaymentsconnector/control.phtml');
43
+ }
44
+
45
+ /**
46
+ * Prepare layout
47
+ *
48
+ * @return void
49
+ * @access protected
50
+ * @see ____func_see____
51
+ * @since 1.0.0
52
+ */
53
+ protected function _prepareLayout()
54
+ {
55
+ parent::_prepareLayout();
56
+
57
+ $this->setChild(
58
+ 'testButton',
59
+ $this->getLayout()->createBlock('adminhtml/widget_button')
60
+ ->setData(
61
+ array(
62
+ 'type' => 'submit',
63
+ 'label' => Mage::helper('adminhtml')->__('Test module'),
64
+ 'class' => 'task'
65
+ )
66
+ )
67
+ );
68
+
69
+ $this->setChild(
70
+ 'requestButton',
71
+ $this->getLayout()->createBlock('adminhtml/widget_button')
72
+ ->setData(
73
+ array(
74
+ 'type' => 'submit',
75
+ 'label' => Mage::helper('adminhtml')->__('Import payment methods from X-Payments'),
76
+ 'class' => 'task'
77
+ )
78
+ )
79
+ );
80
+
81
+ $this->setChild(
82
+ 'clearButton',
83
+ $this->getLayout()->createBlock('adminhtml/widget_button')
84
+ ->setData(
85
+ array(
86
+ 'type' => 'submit',
87
+ 'label' => Mage::helper('adminhtml')->__('Clear'),
88
+ 'class' => 'task'
89
+ )
90
+ )
91
+ );
92
+
93
+
94
+ }
95
+
96
+ /**
97
+ * Check - payment configuration is requested or not
98
+ *
99
+ * @return boolean
100
+ * @access public
101
+ * @see ____func_see____
102
+ * @since 1.0.0
103
+ */
104
+ public function isMethodsRequested()
105
+ {
106
+ return 0 < count($this->getPaymentMethods());
107
+ }
108
+
109
+ /**
110
+ * Get requested payment configurations
111
+ *
112
+ * @return array
113
+ * @access public
114
+ * @see ____func_see____
115
+ * @since 1.0.0
116
+ */
117
+ public function getPaymentMethods()
118
+ {
119
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
120
+
121
+ return ($list && count($list)) ? $list : array();
122
+ }
123
+
124
+ /**
125
+ * Check - is payment configurations is already imported into DB or not
126
+ *
127
+ * @return boolean
128
+ * @access public
129
+ * @see ____func_see____
130
+ * @since 1.0.0
131
+ */
132
+ public function isMethodsAlreadyImported()
133
+ {
134
+ return 0 < count($this->getPaymentMethods());
135
+ }
136
+
137
+ /**
138
+ * Get system requiremenets errors list
139
+ *
140
+ * @return array
141
+ * @access public
142
+ * @see ____func_see____
143
+ * @since 1.0.0
144
+ */
145
+ public function getRequiremenetsErrors()
146
+ {
147
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
148
+
149
+ $result = $api->checkRequirements();
150
+
151
+ $list = array();
152
+ if ($result & $api::REQ_CURL) {
153
+ $list[] = 'PHP extension cURL is not installed on your server';
154
+ }
155
+
156
+ if ($result & $api::REQ_OPENSSL) {
157
+ $list[] = 'PHP extension OpenSSL is not installed on your server';
158
+ }
159
+
160
+ if ($result & $api::REQ_DOM) {
161
+ $list[] = 'PHP extension DOM is not installed on your server';
162
+ }
163
+
164
+ return $list;
165
+ }
166
+
167
+ /**
168
+ * Get module configuration errors list
169
+ *
170
+ * @return array
171
+ * @access public
172
+ * @see ____func_see____
173
+ * @since 1.0.0
174
+ */
175
+ public function getConfigurationErrors()
176
+ {
177
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
178
+
179
+ $result = $api->getConfigurationErrors();
180
+
181
+ $list = array();
182
+
183
+ if ($result & $api::CONF_CART_ID) {
184
+ $list[] = 'Store ID is empty or has an incorrect value';
185
+ }
186
+
187
+ if ($result & $api::CONF_URL) {
188
+ $list[] = 'X-Payments URL is empty or has an incorrect value';
189
+ }
190
+
191
+ if ($result & $api::CONF_PUBLIC_KEY) {
192
+ $list[] = 'Public key is empty';
193
+ }
194
+
195
+ if ($result & $api::CONF_PRIVATE_KEY) {
196
+ $list[] = 'Private key is empty';
197
+ }
198
+
199
+ if ($result & $api::CONF_PRIVATE_KEY_PASS) {
200
+ $list[] = 'Private key password is empty';
201
+ }
202
+
203
+ return $list;
204
+ }
205
+
206
+ }
207
+
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Account/Navigation.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Remove account link "My Payment Cards"
24
+ */
25
+ class Cdev_XPaymentsConnector_Block__Customer_Account_Navigation extends Mage_Customer_Block_Account_Navigation
26
+ {
27
+ /**
28
+ * @return $this
29
+ */
30
+ public function removeLink()
31
+ {
32
+ $IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
33
+ if (!$IsSaveCardsPaymentActive) {
34
+ unset($this->_links["customer_usercards"]);
35
+ }
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * @return mixed
41
+ */
42
+ protected function _toHtml()
43
+ {
44
+ $this->removeLink();
45
+ return parent::_toHtml();
46
+ }
47
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Cardadd.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+
29
+ /**
30
+ * Enter description here...
31
+ *
32
+ * @return string
33
+ */
34
+ public function getBackUrl()
35
+ {
36
+ if ($this->getRefererUrl()) {
37
+ return $this->getRefererUrl();
38
+ }
39
+ return $this->getUrl('customer/account/usercards/');
40
+ }
41
+
42
+ /**
43
+ * @return string (url)
44
+ */
45
+ public function getIframeUrl(){
46
+
47
+ // update standart iframe handshake request
48
+ $refId = "authorization";
49
+ $updateSendData = array();
50
+ $updateSendData["returnUrl"] = Mage::getUrl('xpaymentsconnector/customer/cardadd', array('order_refid' => $refId,'_secure' => true));
51
+ $updateSendData["callbackUrl"] = Mage::getUrl('xpaymentsconnector/customer/cardadd', array('order_refid' => $refId, '_secure' => true));
52
+ $updateSendData["refId"] = $refId;
53
+
54
+ $xpaymentFormData = Mage::helper('payment')->getMethodInstance("xpayments")->getFormFields();
55
+ $xpaymentFormUrl = Mage::helper('payment')->getMethodInstance("xpayments")->getUrl();
56
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
57
+
58
+ $result = $api->sendIframeHandshakeRequest($updateSendData,$isCardAuthorizePayment = true);
59
+
60
+ $iframeUrlDataArray = array('target' => $xpaymentFormData['target'], 'token' => $result['response']['token']);
61
+ $iframeUrl = $xpaymentFormUrl . "?" . http_build_query($iframeUrlDataArray);
62
+ return $iframeUrl;
63
+ }
64
+
65
+
66
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Success.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Customer/Usercards.php ADDED
@@ -0,0 +1,104 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Failure.php ADDED
@@ -0,0 +1,58 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+
app/code/community/Cdev/XPaymentsConnector/Block/Form/Cc.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
22
+ /**
23
+ * "Credit Card (X-Payments)" form block
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Form_Cc extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ protected function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('xpaymentsconnector/form/cc.phtml');
33
+ }
34
+
35
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Form/Prepaidpayments.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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 ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * "Use saved credit cards (X-Payments)" form block
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Form_Savedcards extends Mage_Payment_Block_Form
27
+ {
28
+
29
+ protected function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('xpaymentsconnector/form/savedcards.phtml');
33
+ }
34
+
35
+ public function getUserCreditCardsList(){
36
+ if($customer = Mage::getSingleton('customer/session')->isLoggedIn()) {
37
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
38
+ $customerId = $customerData->getId();
39
+ $userCardsCollection = Mage::getModel("xpaymentsconnector/usercards")
40
+ ->getCollection()
41
+ ->addFilter('user_id',$customerId)
42
+ ->addFilter('usage_type',Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD);
43
+ return $userCardsCollection;
44
+ }else{
45
+ return false;
46
+ }
47
+
48
+ }
49
+
50
+
51
+ public function getAdminhtmlUserCreditCardsList(){
52
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
53
+ $customerId = $quote->getData("customer_id");
54
+
55
+ if($customerId){
56
+ $userCardsCollection = Mage::getModel("xpaymentsconnector/usercards")
57
+ ->getCollection()
58
+ ->addFilter('user_id',$customerId)
59
+ ->addFilter('usage_type',Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD);
60
+ return $userCardsCollection;
61
+ }
62
+ else{
63
+ return false;
64
+ }
65
+
66
+ }
67
+
68
+
69
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Info/Cc.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment additional info block
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_Block_Info_Cc extends Mage_Payment_Block_Info
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/info/cc.phtml');
43
+ }
44
+
45
+ /**
46
+ * Get payment method code
47
+ *
48
+ * @return string
49
+ * @access public
50
+ * @see ____func_see____
51
+ * @since 1.0.0
52
+ */
53
+ public function getMethodCode()
54
+ {
55
+ return $this->getInfo()->getMethodInstance()->getCode();
56
+ }
57
+
58
+ /**
59
+ * Get PDF version
60
+ *
61
+ * @return string
62
+ * @access public
63
+ * @see ____func_see____
64
+ * @since 1.0.0
65
+ */
66
+ public function toPdf()
67
+ {
68
+ $this->setTemplate('xpaymentsconnector/pdf/info.phtml');
69
+
70
+ return $this->toHtml();
71
+ }
72
+
73
+ /**
74
+ * Get X-Payments payment URL
75
+ *
76
+ * @return string
77
+ * @access public
78
+ * @see ____func_see____
79
+ * @since 1.0.0
80
+ */
81
+ public function getXPaymentURL()
82
+ {
83
+ return preg_replace('/\/+$/Ss', '', $this->getMethod()->getConfig('xpay_url'))
84
+ . '/admin.php?target=payment&amp;txnid=' . $this->getInfo()->getLastTransId();
85
+ }
86
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Info/Prepaidpayments.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * "Prepaid Payments (X-Payments)" info block
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Info_Prepaidpayments extends Mage_Payment_Block_Info
27
+ {
28
+
29
+ protected function _construct()
30
+ {
31
+ parent::_construct();
32
+ $this->setTemplate('xpaymentsconnector/info/prepaidpayments.phtml');
33
+ }
34
+ }
35
+
36
+
37
+
38
+
39
+
app/code/community/Cdev/XPaymentsConnector/Block/Info/Savedcards.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Credit card generic payment info
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Block_Info_Savedcards extends Mage_Payment_Block_Info
27
+ {
28
+ protected function _construct()
29
+ {
30
+ parent::_construct();
31
+ $this->setTemplate('xpaymentsconnector/info/savedcards.phtml');
32
+ }
33
+
34
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Recurring/Profile/View.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Rewrite recurring profile view
24
+ */
25
+ class Cdev_XPaymentsConnector_Block_Recurring_Profile_View extends Mage_Sales_Block_Recurring_Profile_View
26
+ {
27
+ /**
28
+ * Prepare profile payments info
29
+ */
30
+ public function prepareFeesInfo()
31
+ {
32
+ parent::prepareFeesInfo();
33
+ $orderItemInfo = $this->_profile->getData("order_item_info");
34
+ $discountAmount = $orderItemInfo["discount_amount"];
35
+ if($discountAmount){
36
+ $discountNominalModel = Mage::getModel("xpaymentsconnector/quote_address_total_nominal_recurring_discount");
37
+ $this->_addInfo(array(
38
+ 'label' => $discountNominalModel->getLabel(),
39
+ 'value' => Mage::helper('core')->formatCurrency(-$discountAmount, false),
40
+ 'is_amount' => true,
41
+ ));
42
+ }
43
+ }
44
+
45
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Redirect.php ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Redirect to X-Payments block
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_Block_Redirect extends Mage_Core_Block_Template
30
+ {
31
+ /**
32
+ * Get checkout session object
33
+ *
34
+ * @return object
35
+ * @access protected
36
+ * @see ____func_see____
37
+ * @since 1.0.0
38
+ */
39
+ public $paymentMethod = Null;
40
+ protected function _getCheckout()
41
+ {
42
+ return Mage::getSingleton('checkout/session');
43
+ }
44
+
45
+ /**
46
+ * Get order
47
+ *
48
+ * @return Mage_Sales_Model_Order or null
49
+ * @access protected
50
+ * @see ____func_see____
51
+ * @since 1.0.0
52
+ */
53
+ protected function _getOrder()
54
+ {
55
+ $order = null;
56
+
57
+ if ($this->getOrder()) {
58
+ $order = $this->getOrder();
59
+
60
+ } else {
61
+ $orderIncrementId = $this->_getCheckout()->getLastRealOrderId();
62
+ if ($orderIncrementId) {
63
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderIncrementId);
64
+ }
65
+
66
+ }
67
+
68
+ return $order;
69
+ }
70
+
71
+ /**
72
+ * Get form action (URL)
73
+ *
74
+ * @return string
75
+ * @access public
76
+ * @see ____func_see____
77
+ * @since 1.0.0
78
+ */
79
+ public function getFormAction()
80
+ {
81
+ if(is_null($this->paymentMethod)){
82
+ $this->paymentMethod = Mage::getModel("xpaymentsconnector/payment_cc");
83
+ }
84
+
85
+ return $this->paymentMethod->getUrl();
86
+ }
87
+
88
+ /**
89
+ * Get form data
90
+ *
91
+ * @return array
92
+ * @access public
93
+ * @see ____func_see____
94
+ * @since 1.0.0
95
+ */
96
+ public function getFormData()
97
+ {
98
+ if(is_null($this->paymentMethod)){
99
+ $this->paymentMethod = Mage::getModel("xpaymentsconnector/payment_cc");
100
+ }
101
+ return $this->paymentMethod->getFormFields();
102
+ }
103
+
104
+
105
+ }
app/code/community/Cdev/XPaymentsConnector/Block/Success.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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/Data.php ADDED
@@ -0,0 +1,517 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Common helper
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Helper_Data extends Mage_Payment_Helper_Data
31
+ {
32
+ const DAY_TIME_STAMP = 86400;
33
+ const WEEK_TIME_STAMP = 604800;
34
+ const SEMI_MONTH_TIME_STAMP = 1209600;
35
+
36
+ const STATE_XPAYMENT_PENDING_PAYMENT = "xp_pending_payment";
37
+ const XPAYMENTS_LOG_FILE = "xpayments.log";
38
+
39
+
40
+
41
+
42
+ /**
43
+ * This function return 'IncrementId' for feature order.
44
+ * Xpayment Prepare Order Mas(xpayment_prepare_order):
45
+ * - prepare_order_id (int)
46
+ * - xpayment_response
47
+ * - token
48
+ * return
49
+ * @return bool or int
50
+ */
51
+ public function getOrderKey(){
52
+ $xpaymentPrepareOrderData = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
53
+ if($xpaymentPrepareOrderData && isset($xpaymentPrepareOrderData["prepare_order_id"])){
54
+ return $xpaymentPrepareOrderData["prepare_order_id"];
55
+ }
56
+ return false;
57
+ }
58
+
59
+
60
+ /**
61
+ * This function create 'IncrementId' for feature order.
62
+ * Xpayment Prepare Order Mas(xpayment_prepare_order):
63
+ * - prepare_order_id (int)
64
+ * - xpayment_response
65
+ * - token
66
+ * return
67
+ * @return bool or int
68
+ */
69
+ public function prepareOrderKey()
70
+ {
71
+ $xpaymentPrepareOrder = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
72
+ if(!isset($xpaymentPrepareOrder["prepare_order_id"])){
73
+ $isRecurringOrder = $this->checkIsRecurringOrder();
74
+ if($isRecurringOrder){
75
+ $useStartDateParam = $this->checkStartDateData();
76
+ if ($useStartDateParam["success"]) {
77
+ $xpaymentPrepareOrder["prepare_order_id"] = "subscription";
78
+ Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order",$xpaymentPrepareOrder);
79
+ return;
80
+ }
81
+ }
82
+ $storeId = Mage::app()->getStore()->getStoreId();
83
+ $prepareOrderId = Mage::getSingleton('eav/config')
84
+ ->getEntityType('order')
85
+ ->fetchNewIncrementId($storeId);
86
+
87
+ $xpaymentPrepareOrder["prepare_order_id"] = $prepareOrderId;
88
+ Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order", $xpaymentPrepareOrder);
89
+
90
+ }
91
+
92
+ }
93
+
94
+ /**
95
+ * This function return saved X-Payments response data.
96
+ * Xpayment Prepare Order Mas(xpayment_prepare_order):
97
+ * - prepare_order_id (int)
98
+ * - xpayment_response
99
+ * - token
100
+ * return
101
+ * @return bool or int
102
+ */
103
+ public function getXpaymentResponse(){
104
+ $xpaymentPrepareOrder = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
105
+ if($xpaymentPrepareOrder && isset($xpaymentPrepareOrder["xpayment_response"])){
106
+ return $xpaymentPrepareOrder["xpayment_response"];
107
+ }
108
+ return false;
109
+ }
110
+
111
+ /**
112
+ * This function return 'token' for X-Payments i-frame Url.
113
+ * Xpayment Prepare Order Mas(xpayment_prepare_order):
114
+ * - prepare_order_id (int)
115
+ * - xpayment_response
116
+ * - token
117
+ * return
118
+ * @return bool or int
119
+ */
120
+ public function getIframeToken()
121
+ {
122
+ $xpaymentPrepareOrder = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
123
+ if ($xpaymentPrepareOrder && isset($xpaymentPrepareOrder["token"]) && !empty($xpaymentPrepareOrder["token"])) {
124
+ return $xpaymentPrepareOrder["token"];
125
+ } else {
126
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
127
+ $result = $api->sendIframeHandshakeRequest();
128
+ $xpaymentPrepareOrder["token"] = $result['response']['token'];
129
+ Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order", $xpaymentPrepareOrder);
130
+ return $xpaymentPrepareOrder["token"];
131
+ }
132
+
133
+ }
134
+
135
+ /**
136
+ * @param array $unsetParams
137
+ */
138
+ public function unsetXpaymentPrepareOrder($unsetParams = array()){
139
+ if(!empty($unsetParams)){
140
+ $xpaymentPrepareOrder = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
141
+ foreach($unsetParams as $param){
142
+ if( is_array($xpaymentPrepareOrder) && isset($xpaymentPrepareOrder[$param])){
143
+ unset($xpaymentPrepareOrder[$param]);
144
+ }
145
+ }
146
+ Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order",$xpaymentPrepareOrder);
147
+ return;
148
+ }
149
+ Mage::getSingleton("checkout/session")->unsetData("xpayment_prepare_order");
150
+ }
151
+
152
+ /**
153
+ * Save X-Payments response data after card data send.
154
+ * @param array $responseData
155
+ */
156
+ public function savePaymentResponse($responseData = array())
157
+ {
158
+ $xpaymentPrepareOrder = Mage::getSingleton("checkout/session")->getData("xpayment_prepare_order");
159
+ $xpaymentPrepareOrder["xpayment_response"] = $responseData;
160
+ Mage::getSingleton("checkout/session")->setData("xpayment_prepare_order", $xpaymentPrepareOrder);
161
+ }
162
+
163
+ public function getReviewButtonTemplate($name, $block)
164
+ {
165
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
166
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
167
+ if ($quote) {
168
+ $payment = $quote->getPayment();
169
+ if ($payment && $payment->getMethod() == "xpayments" && $useIframe) {
170
+ return $name;
171
+ }
172
+ }
173
+
174
+ if ($blockObject = Mage::getSingleton('core/layout')->getBlock($block)) {
175
+ return $blockObject->getTemplate();
176
+ }
177
+
178
+ return '';
179
+ }
180
+
181
+ public function isNeedToSaveUserCard(){
182
+ $result = (bool) Mage::getSingleton("checkout/session")->getData("user_card_save");
183
+ return $result;
184
+ }
185
+
186
+ public function isRegisteredUser()
187
+ {
188
+ $currentCustomerState = Mage::getSingleton('checkout/type_onepage')->getCheckoutMethod();
189
+ $registerMethod = Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER;
190
+ $customerMethod = Mage_Checkout_Model_Type_Onepage::METHOD_CUSTOMER;
191
+ if (($currentCustomerState == $registerMethod) || ($currentCustomerState == $customerMethod)) {
192
+ return true;
193
+ } else {
194
+ return false;
195
+ }
196
+ }
197
+
198
+ public function isXpaymentsMethod($currentPaymentCode){
199
+ $xpaymentPaymentCode = Mage::getModel("xpaymentsconnector/payment_cc")->getCode();
200
+ $saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
201
+ $prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
202
+ $usePaymetCodes = array($xpaymentPaymentCode,$saveCardsPaymentCode,$prepaidpayments);
203
+ if (in_array($currentPaymentCode, $usePaymetCodes)){
204
+ return true;
205
+ }else{
206
+ return false;
207
+ }
208
+ }
209
+
210
+ /**
211
+ * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
212
+ * @param bool $isFirstRecurringOrder
213
+ * @return int
214
+ */
215
+ public function createOrder(Mage_Payment_Model_Recurring_Profile $recurringProfile,$isFirstRecurringOrder = false){
216
+
217
+ $orderItemInfo = $recurringProfile->getData("order_item_info");
218
+
219
+ if(!is_array($orderItemInfo)){
220
+ $orderItemInfo = unserialize($orderItemInfo);
221
+ }
222
+ $initialFeeAmount = $orderItemInfo["recurring_initial_fee"];
223
+ $orderSubtotal = ($isFirstRecurringOrder) ? $orderItemInfo["row_total"]+$initialFeeAmount : $orderItemInfo["row_total"];
224
+
225
+ //check is set related orders
226
+ $useDiscount = current($recurringProfile->getChildOrderIds()) > 0;
227
+ $discountAmount = ($useDiscount) ? 0 : $orderItemInfo["discount_amount"];
228
+
229
+ $taxAmount = $recurringProfile->getData("tax_amount");
230
+ $shippingAmount = $recurringProfile->getData("shipping_amount");
231
+
232
+ $productItemInfo = new Varien_Object;
233
+ $productItemInfo->setDiscountAmount($discountAmount);
234
+ $productItemInfo->setPaymentType(Mage_Sales_Model_Recurring_Profile::PAYMENT_TYPE_REGULAR);
235
+ $productItemInfo->setTaxAmount($taxAmount);
236
+ $productItemInfo->setShippingAmount($shippingAmount);
237
+ $productItemInfo->setPrice($orderSubtotal);
238
+
239
+ Mage::dispatchEvent('before_recurring_profile_order_create', array('profile' => $recurringProfile,'product_item_info'=>$productItemInfo));
240
+ $order = $recurringProfile->createOrder($productItemInfo);
241
+ if($isFirstRecurringOrder){
242
+ if($orderKey = $this->getOrderKey()){
243
+ $order->setIncrementId($orderKey);
244
+ }
245
+ }
246
+ Mage::dispatchEvent('before_recurring_profile_order_save', array('order' => $order));
247
+
248
+ $order->save();
249
+ $recurringProfile->addOrderRelation($order->getId());
250
+
251
+ return $order->getId();
252
+ }
253
+
254
+ /**
255
+ * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
256
+ * @return int
257
+ */
258
+ public function getCurrentBillingPeriodTimeStamp(Mage_Payment_Model_Recurring_Profile $recurringProfile){
259
+ $periodUnit = $recurringProfile->getData("period_unit"); //day
260
+ $periodFrequency = $recurringProfile->getData("period_frequency");
261
+ //$masPeriodUnits = $recurringProfile->getAllPeriodUnits();
262
+ $billingTimeStamp = 0;
263
+ switch ($periodUnit){
264
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_DAY:
265
+ $billingTimeStamp = self::DAY_TIME_STAMP;
266
+ break;
267
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_WEEK;
268
+ $billingTimeStamp = self::WEEK_TIME_STAMP;
269
+ break;
270
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_SEMI_MONTH;
271
+ $billingTimeStamp = self::SEMI_MONTH_TIME_STAMP;
272
+ break;
273
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_MONTH;
274
+ $startDateTime = strtotime($recurringProfile->getStartDatetime());
275
+ $lastSuccessTransactionDate = strtotime($recurringProfile->getXpSuccessTransactionDate());
276
+ $lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
277
+ $nextMonth = mktime(date("H",$lastActionDate), date("i",$lastActionDate) ,date("s",$lastActionDate) , date("m",$lastActionDate)+1, date("d",$lastActionDate), date("Y",$lastActionDate));
278
+ $billingTimeStamp = $nextMonth - $lastActionDate;
279
+
280
+ break;
281
+ case Mage_Payment_Model_Recurring_Profile::PERIOD_UNIT_YEAR;
282
+ $startDateTime = strtotime($recurringProfile->getStartDatetime());
283
+ $lastSuccessTransactionDate = strtotime($recurringProfile->getXpSuccessTransactionDate());
284
+ $lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
285
+ $nextYear = mktime(date("H",$lastActionDate), date("i",$lastActionDate) ,date("s",$lastActionDate) , date("m",$lastActionDate), date("d",$lastActionDate), date("Y",$lastActionDate)+1);
286
+ $billingTimeStamp = $nextYear - $lastActionDate;
287
+
288
+ break;
289
+ }
290
+
291
+ $billingPeriodTimeStamp = round($billingTimeStamp / $periodFrequency);
292
+
293
+ return $billingPeriodTimeStamp;
294
+
295
+ }
296
+
297
+ /**
298
+ * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
299
+ * @return array
300
+ */
301
+ public function getProfileOrderCardData(Mage_Payment_Model_Recurring_Profile $recurringProfile){
302
+ $txnId = $recurringProfile->getReferenceId();
303
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($txnId,"txnid");
304
+ return $cardData;
305
+ }
306
+
307
+ /**
308
+ * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
309
+ * @param bool $result
310
+ * @param timestamp $newTransactionDate
311
+ */
312
+ public function updateCurrentBillingPeriodTimeStamp(Mage_Payment_Model_Recurring_Profile $recurringProfile, bool $result,$newTransactionDate = null){
313
+ if(!$result){
314
+ $currentCycleFailureCount = $recurringProfile->getXpCycleFailureCount();
315
+ //add failed attempt
316
+ $currentCycleFailureCount++;
317
+ $recurringProfile->setXpCycleFailureCount($currentCycleFailureCount);
318
+ $maxPaymentFailure = $recurringProfile->getSuspensionThreshold();
319
+ if($currentCycleFailureCount > $maxPaymentFailure){
320
+ $recurringProfile->cancel();
321
+ }
322
+ }else{
323
+ $recurringProfile->setXpCycleFailureCount(0);
324
+
325
+ // update date of success transaction
326
+ $newTransactionDate = new Zend_Date($newTransactionDate);
327
+ $recurringProfile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
328
+
329
+ // update count of success transaction
330
+ $currentSuccessCycles = $recurringProfile->getXpCountSuccessTransaction();
331
+ $currentSuccessCycles++;
332
+ $recurringProfile->setXpCountSuccessTransaction($currentSuccessCycles);
333
+ }
334
+
335
+ $recurringProfile->save();
336
+
337
+ }
338
+
339
+ public function checkIsRecurringOrder(){
340
+ $checkoutSession = Mage::getSingleton('checkout/session');
341
+ $quoteItem = current($checkoutSession->getQuote()->getAllItems());
342
+ if($quoteItem){
343
+ $isRecurringOreder = (bool) $quoteItem->getProduct()->getIsRecurring();
344
+ return $isRecurringOreder;
345
+ }
346
+
347
+ return false;
348
+ }
349
+
350
+ /**
351
+ * update recurring profile for deferred pay.
352
+ * @param Mage_Payment_Model_Recurring_Profile $recurringProfile
353
+ * @return bool
354
+ */
355
+ public function payDeferredSubscription(Mage_Payment_Model_Recurring_Profile $recurringProfile)
356
+ {
357
+ $orderItemInfo = $recurringProfile->getData("order_item_info");
358
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
359
+ $infoBuyRequest = unserialize($orderItemInfo["info_buyRequest"]);
360
+ $startDateTime = $infoBuyRequest["recurring_profile_start_datetime"];
361
+
362
+ if (!empty($startDateTime)) {
363
+ $dateTimeStamp = strtotime($startDateTime);
364
+ $zendDate = new Zend_Date($dateTimeStamp);
365
+ $currentZendDate = new Zend_Date(time());
366
+
367
+ if ($zendDate->getTimestamp() > $currentZendDate->getTimestamp()) {
368
+ //set start date time
369
+ $recurringProfile->setStartDatetime($zendDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
370
+
371
+ $initialFeeAmount = $orderItemInfo["recurring_initial_fee"];
372
+ if ($initialFeeAmount) {
373
+ $grandTotal = $initialFeeAmount;
374
+ } else {
375
+ $grandTotal = floatval(Mage::getStoreConfig("xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount"));
376
+ }
377
+
378
+
379
+ $paymentMethodCode = $recurringProfile->getData("method_code");
380
+
381
+ $cardData = NULL;
382
+ switch ($paymentMethodCode) {
383
+ case(Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode()):
384
+
385
+ $paymentCardNumber = $recurringProfile->getQuote()->getPayment()->getData("xp_payment_card");
386
+
387
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber);
388
+ $cardData = $cardData->getData();
389
+
390
+ $response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest(NULL, NULL, $grandTotal, $cardData);
391
+
392
+
393
+ $recurringProfile->setReferenceId($cardData["txnId"]);
394
+ if ($response["success"]) {
395
+ $recurringProfile->activate();
396
+ } else {
397
+ Mage::getSingleton("checkout/session")->addError($response["error_message"]);
398
+ $recurringProfile->cancel();
399
+ }
400
+ return true;
401
+
402
+ break;
403
+ case(Mage::getModel("xpaymentsconnector/payment_cc")->getCode()):
404
+ if ($useIframe) {
405
+ $cardData = $this->getXpaymentResponse();
406
+ $recurringProfile->setReferenceId($cardData["txnId"]);
407
+ //check transaction state
408
+ list($status, $response) = Mage::getModel("xpaymentsconnector/payment_cc")->requestPaymentInfo($cardData["txnId"]);
409
+
410
+ if (
411
+ $status
412
+ && in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
413
+ ) {
414
+ Mage::getSingleton("checkout/session")->setData("user_card_save",true);
415
+ Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($cardData, Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
416
+ $recurringProfile->activate();
417
+ } else {
418
+ $this->addRecurringTransactionError($response);
419
+ $recurringProfile->cancel();
420
+ }
421
+ return true;
422
+
423
+ }else{
424
+ $cardData = $this->getXpaymentResponse();
425
+
426
+ //check transaction state
427
+ list($status, $response) = Mage::getModel("xpaymentsconnector/payment_cc")->requestPaymentInfo($cardData["txnId"]);
428
+ if (
429
+ $status
430
+ && in_array($response['status'], array(Cdev_XPaymentsConnector_Model_Payment_Cc::AUTH_STATUS, Cdev_XPaymentsConnector_Model_Payment_Cc::CHARGED_STATUS))
431
+ ) {
432
+ // save user card
433
+ Mage::getSingleton("checkout/session")->setData("user_card_save",true);
434
+ Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
435
+
436
+ $recurringProfile->setReferenceId($cardData["txnId"]);
437
+ $recurringProfile->activate();
438
+ $recurringProfile->save();
439
+ return true;
440
+ }else{
441
+ $recurringProfile->cancel();
442
+ }
443
+ }
444
+ break;
445
+ }
446
+
447
+ }
448
+ }
449
+ return false;
450
+ }
451
+
452
+ public function checkStartDateData(){
453
+ $result = array();
454
+ $quoteItem = current(Mage::getSingleton("checkout/session")->getQuote()->getAllItems());
455
+ $productAdditionalInfo = unserialize($quoteItem->getProduct()->getCustomOption('info_buyRequest')->getValue());
456
+ $dateTimeStamp = strtotime($productAdditionalInfo["recurring_profile_start_datetime"]);
457
+ if ($dateTimeStamp) {
458
+ $userSetTime = new Zend_Date($productAdditionalInfo["recurring_profile_start_datetime"]);
459
+ $currentZendDate = new Zend_Date(time());
460
+ if ($userSetTime->getTimestamp() > $currentZendDate->getTimestamp()) {
461
+ $result["success"] = true;
462
+ $recurringProfileData = $quoteItem->getProduct()->getData("recurring_profile");
463
+ $initAmount = $recurringProfileData["init_amount"];
464
+ $defaultMinimumPayment = floatval(Mage::getStoreConfig("xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount"));
465
+ $minimumPaymentAmount = ($initAmount) ? $initAmount : $defaultMinimumPayment;
466
+ $result["minimal_payment_amount"] = $minimumPaymentAmount;
467
+ return $result;
468
+ } else {
469
+ $result["success"] = false;
470
+ return $result;
471
+ }
472
+ } else {
473
+ $result["success"] = false;
474
+ return $result;
475
+ }
476
+
477
+ }
478
+
479
+ public function getRecurringProfileState(){
480
+ $maxPaymentFailureMessage = $this->__('This profile has run out of maximal limit of unsuccessful payment attempts.');
481
+
482
+ if (Mage::app()->getStore()->isAdmin()) {
483
+ Mage::getSingleton('adminhtml/session')->addNotice($maxPaymentFailureMessage);
484
+ }else{
485
+ Mage::getSingleton('core/session')->addNotice($maxPaymentFailureMessage);
486
+ }
487
+ }
488
+
489
+ public function addRecurringTransactionError($response = array()){
490
+ $this->unsetXpaymentPrepareOrder();
491
+ if(!empty($response)){
492
+ if (!empty($response["error_message"])) {
493
+ $errorMessage = $this->__('%s. The subscription has been canceled.', $response["error_message"]);
494
+ Mage::getSingleton("checkout/session")->addError($errorMessage);
495
+ } else {
496
+ $transactionStatusLabel = Mage::getModel("xpaymentsconnector/payment_cc")->getTransactionStatusLabels();
497
+ $errorMessage = $this->__("Transaction status is '%s'. The subscription has been canceled.", $transactionStatusLabel[$response['status']]);
498
+ Mage::getSingleton("checkout/session")->addError($errorMessage);
499
+ }
500
+ }else{
501
+ $errorMessage = $this->__('The subscription has been canceled.');
502
+ Mage::getSingleton("checkout/session")->addError($errorMessage);
503
+ }
504
+ }
505
+
506
+ public function setRecurringProductDiscount(){
507
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
508
+ $items = $quote->getAllVisibleItems();
509
+ foreach($items as $item){
510
+ $discount = $item->getDiscountAmount();
511
+ $profile = $item->getProduct()->getRecurringProfile();
512
+ $profile["discount_amount"] = $discount;
513
+ $item->getProduct()->setRecurringProfile($profile)->save();
514
+ }
515
+ }
516
+
517
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration RDBS-specific model
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Model_Mysql4_Paymentconfiguration extends Mage_Core_Model_Mysql4_Abstract
31
+ {
32
+ /**
33
+ * Primary key is auto incremented field
34
+ *
35
+ * @var boolean
36
+ * @access protected
37
+ * @see ____var_see____
38
+ * @since 1.0.0
39
+ */
40
+ protected $_isPkAutoIncrement = false;
41
+
42
+ /**
43
+ * Internal constructor
44
+ *
45
+ * @return void
46
+ * @access protected
47
+ * @see ____func_see____
48
+ * @since 1.0.0
49
+ */
50
+ protected function _construct()
51
+ {
52
+ $this->_init('xpaymentsconnector/paymentconfiguration', 'confid');
53
+ }
54
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Paymentconfiguration/Collection.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration RDMS-specific collection model
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Model_Mysql4_Paymentconfiguration_Collection extends Varien_Data_Collection_Db
31
+ {
32
+ /**
33
+ * Payment configuration table name (cache)
34
+ *
35
+ * @var string
36
+ * @access protected
37
+ * @see ____var_see____
38
+ * @since 1.0.0
39
+ */
40
+ protected $_paymentconfigurationTable;
41
+
42
+ /**
43
+ * Constructor
44
+ *
45
+ * @return void
46
+ * @access public
47
+ * @see ____func_see____
48
+ * @since 1.0.0
49
+ */
50
+ public function __construct()
51
+ {
52
+ $resources = Mage::getSingleton('core/resource');
53
+
54
+ parent::__construct($resources->getConnection('paymentconfigurations_read'));
55
+
56
+ $this->_paymentconfigurationTable = $resources->getTableName('xpaymentsconnector/paymentconfiguration');
57
+
58
+ $this->_select->from(
59
+ array('paymentconfiguration' => $this->_paymentconfigurationTable),
60
+ array('*')
61
+ );
62
+ $this->setItemObjectClass(
63
+ Mage::getConfig()->getModelClassName('xpaymentsconnector/paymentconfiguration')
64
+ );
65
+
66
+ $this->setOrder('name', self::SORT_ORDER_ASC);
67
+ }
68
+
69
+ /**
70
+ * Get data as option array
71
+ *
72
+ * @return array
73
+ * @access public
74
+ * @see ____func_see____
75
+ * @since 1.0.0
76
+ */
77
+ public function toOptionArray()
78
+ {
79
+ return $this->_toOptionArray('confid', 'name');
80
+ }
81
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration RDBS-specific model
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Model_Mysql4_Usercards extends Mage_Core_Model_Mysql4_Abstract
31
+ {
32
+ /**
33
+ * Internal constructor
34
+ *
35
+ * @return void
36
+ * @access protected
37
+ * @see ____func_see____
38
+ * @since 1.0.0
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_init('xpaymentsconnector/usercards', 'xp_card_id');
43
+ }
44
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Mysql4/Usercards/Collection.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration RDMS-specific collection model
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Model_Mysql4_Usercards_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
31
+ {
32
+ /**
33
+ * Initialize collection
34
+ *
35
+ */
36
+ public function _construct()
37
+ {
38
+ $this->_init('xpaymentsconnector/usercards');
39
+ }
40
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Observer.php ADDED
@@ -0,0 +1,431 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Class Cdev_XPaymentsConnector_Model_Observer
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_Model_Observer extends Mage_CatalogInventory_Model_Observer {
27
+
28
+ public function preDispatchCheckout($observer)
29
+ {
30
+
31
+ Mage::getSingleton("checkout/session")->unsetData("user_card_save");
32
+
33
+ //set recurring product discount
34
+ $isRecurrnigProduct = Mage::helper("xpaymentsconnector")->checkIsRecurringOrder();
35
+ if ($isRecurrnigProduct) {
36
+ Mage::helper("xpaymentsconnector")->setRecurringProductDiscount();
37
+ $useStartDateParam = Mage::helper("xpaymentsconnector")->checkStartDateData();
38
+ if ($useStartDateParam["success"]) {
39
+ $currency_symbol = Mage::app()->getLocale()->currency(Mage::app()->getStore()->getCurrentCurrencyCode())->getSymbol();
40
+ $noticeMessage = Mage::helper("xpaymentsconnector")
41
+ ->__("To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s",
42
+ $useStartDateParam["minimal_payment_amount"], $currency_symbol);
43
+ Mage::getSingleton("core/session")->addNotice($noticeMessage);
44
+ }
45
+ }
46
+
47
+ }
48
+
49
+ public function paymentMethodIsActive($observer){
50
+ $event = $observer->getEvent();
51
+ $method = $event->getMethodInstance();
52
+ $result = $event->getResult();
53
+ $saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
54
+ $prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
55
+
56
+ if (($method->getCode() == $saveCardsPaymentCode)||($method->getCode() == $prepaidpayments)) {
57
+ $quote = $event->getQuote();
58
+ if($quote){
59
+ $customerId = $quote->getData("customer_id");
60
+ $isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD;
61
+ if($method->getCode() == $prepaidpayments){
62
+ $isBalanceCard = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
63
+ }
64
+ if ($customerId) {
65
+ $cardsCount = Mage::getModel("xpaymentsconnector/usercards")
66
+ ->getCollection()
67
+ ->addFieldToFilter('user_id', $customerId)
68
+ ->addFieldToFilter('usage_type', $isBalanceCard)
69
+ ->count();
70
+ if ($cardsCount == 0) {
71
+ $result->isAvailable = false;
72
+ }
73
+ }
74
+ else{
75
+ $result->isAvailable = false;
76
+ }
77
+ }
78
+ }
79
+ }
80
+
81
+ public function postDispatchSavePayment($observer){
82
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
83
+ $paymentMethodCode = $quote->getPayment()->getMethodInstance()->getCode();
84
+
85
+ $isXpayments = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentMethodCode);
86
+ if ($isXpayments) {
87
+ Mage::helper("xpaymentsconnector")->prepareOrderKey();
88
+ }
89
+ if ($paymentMethodCode == "xpayments"){
90
+ $saveCard = Mage::app()->getRequest()->getPost("savecard");
91
+ if($saveCard){
92
+ Mage::getSingleton("checkout/session")->setData("user_card_save",$saveCard);
93
+ }
94
+ }else{
95
+ Mage::getSingleton("checkout/session")->unsetData("user_card_save");
96
+ }
97
+ }
98
+
99
+ /**
100
+ * Dispatch: checkout_type_onepage_save_order_after
101
+ * @param $observer
102
+ */
103
+
104
+ public function updateOrder($observer)
105
+ {
106
+ $event = $observer->getEvent();
107
+ $order = $event->getOrder();
108
+ $refId = Mage::helper("xpaymentsconnector")->getOrderKey();
109
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
110
+ $xpaymentPaymentCode = Mage::getModel("xpaymentsconnector/payment_cc")->getCode();
111
+ $saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
112
+
113
+ if ($paymentMethod == $xpaymentPaymentCode) {
114
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
115
+
116
+ $request = Mage::helper("xpaymentsconnector")->getXpaymentResponse();
117
+
118
+
119
+ if ($useIframe) {
120
+ /*update order table*/
121
+ $order->setData('xpc_txnid', $request['txnId']);
122
+ $order->setData("xp_card_data", serialize($request));
123
+ $order->save();
124
+
125
+ $result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($order->getId(), $request['txnId']);
126
+ if ($result["success"]) {
127
+ /* save credit card to user profile */
128
+ $response = Mage::helper("xpaymentsconnector")->getXpaymentResponse();
129
+ Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($response);
130
+ /* end (save payment card) */
131
+ } else {
132
+ Mage::getSingleton("checkout/session")->addError($result["error_message"]);
133
+ }
134
+ }
135
+
136
+ } elseif ($paymentMethod == $saveCardsPaymentCode) {
137
+ $response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest($order->getId());
138
+ if ($response["success"]) {
139
+ $result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($order->getId(), $response["response"]['transaction_id']);
140
+ if (!$result["success"]) {
141
+ Mage::getSingleton("checkout/session")->addError($result["error_message"]);
142
+ }
143
+ } else {
144
+ Mage::getSingleton("checkout/session")->addError($response["error_message"]);
145
+ }
146
+ }
147
+
148
+
149
+ }
150
+
151
+ public function orderSuccessAction($observer)
152
+ {
153
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder();
154
+ }
155
+
156
+ /**
157
+ * Set custom 'IncrementId' for x-payments order.
158
+ * @param $observer
159
+ */
160
+ public function salesOrderSaveBefore($observer){
161
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
162
+ if($useIframe){
163
+ $orderModel = $observer->getData("data_object");
164
+ $paymentCode = $orderModel->getPayment()->getMethodInstance()->getCode();
165
+ if(Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentCode)){
166
+ $orderModel->setCanSendNewEmailFlag(false);
167
+ $incrementId = Mage::helper("xpaymentsconnector")->getOrderKey();
168
+ $orderModel->setIncrementId($incrementId);
169
+ }
170
+ }
171
+ }
172
+
173
+ public function postdispatchAdminhtmlSalesOrderCreateSave($observer){
174
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
175
+ $incrementId = $quote->getData("reserved_order_id");
176
+ $order = Mage::getModel('sales/order')->load($incrementId, 'increment_id');
177
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
178
+ $admSession = Mage::getSingleton('adminhtml/session');
179
+ $saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
180
+ $prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
181
+
182
+ if($paymentMethod == $saveCardsPaymentCode){
183
+ $xpCreditCards = $admSession->getData("xp_payment_card");
184
+ $grandTotal = $quote->getData("grand_total");
185
+ $response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest($order->getId(),$xpCreditCards,$grandTotal);
186
+ if($response["success"]){
187
+ Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($order->getId(),$response["response"]['transaction_id']);
188
+ }else{
189
+ Mage::getSingleton("adminhtml/session")->addError($response["error_message"]);
190
+ }
191
+
192
+ }elseif($paymentMethod == $prepaidpayments){
193
+ $xpPrepaidPaymentsCard = $admSession->getData("xp_prepaid_payments");
194
+ $currentUserCard = Mage::getModel("xpaymentsconnector/usercards")->load($xpPrepaidPaymentsCard);
195
+ $order->setData("xpc_txnid",$currentUserCard->getData("txnId"));
196
+ $order->getPayment()->setTransactionId($currentUserCard->getData("txnId"));
197
+ $order->getPayment()->setLastTransId($currentUserCard->getData("txnId"));
198
+ $order->setData("xp_card_data",serialize($currentUserCard->getData()));
199
+ $order->setState(
200
+ Mage_Sales_Model_Order::STATE_PROCESSING,
201
+ (bool)Mage_Sales_Model_Order::STATE_PROCESSING,
202
+ Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
203
+ );
204
+ $order->save();
205
+ }
206
+ $admSession->unsetData("xp_payment_card");
207
+ $admSession->unsetData("xp_prepaid_payments");
208
+
209
+ }
210
+
211
+ public function predispatchAdminhtmlSalesOrderCreateSave($observer){
212
+ $quote = Mage::getSingleton('adminhtml/session_quote')->getQuote();
213
+ $paymentMethod = $quote->getPayment()->getMethodInstance()->getCode();
214
+ $prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
215
+ if($paymentMethod == $prepaidpayments){
216
+ $admSession = Mage::getSingleton('adminhtml/session');
217
+ $xpPrepaidPaymentsCard = $admSession->getData("xp_prepaid_payments");
218
+ $currentUserCard = Mage::getModel("xpaymentsconnector/usercards")->load($xpPrepaidPaymentsCard);
219
+ $grandTotal = $quote->getData("grand_total");
220
+ $cardAmount = $currentUserCard->getAmount();
221
+ if($cardAmount < $grandTotal){
222
+ $errorMessage = Mage::helper("xpaymentsconnector")
223
+ ->__("You can't make an order using card (**%s) worth over %s",
224
+ $currentUserCard->getData("last_4_cc_num"),
225
+ Mage::helper('core')->currency($cardAmount));
226
+ $admSession->addError($errorMessage);
227
+ /*redirect to last page*/
228
+ Mage::app()->getResponse()->setRedirect($_SERVER['HTTP_REFERER']);
229
+ Mage::app()->getResponse()->sendResponse();
230
+ exit;
231
+ }else{
232
+ $cardBalance = $cardAmount - $grandTotal;
233
+ if($cardBalance == 0){
234
+ $currentUserCard->delete();
235
+ }else{
236
+ $currentUserCard->setAmount($cardBalance)->save();
237
+ }
238
+
239
+ }
240
+ }
241
+ }
242
+
243
+ public function adminhtmlSavePaymentCard(){
244
+ $payment = Mage::app()->getRequest()->getPost("payment");
245
+ $saveCardsPaymentCode = Mage::getModel("xpaymentsconnector/payment_savedcards")->getCode();
246
+ $prepaidpayments = Mage::getModel("xpaymentsconnector/payment_prepaidpayments")->getCode();
247
+
248
+ if($payment){
249
+ if($payment["method"] == $saveCardsPaymentCode){
250
+ if($payment["xp_payment_card"]){
251
+ $admSession = Mage::getSingleton('adminhtml/session');
252
+ $admSession->setData("xp_payment_card",$payment["xp_payment_card"]);
253
+ }
254
+ }elseif($payment["method"] == $prepaidpayments){
255
+ if($payment["xp_prepaid_payments"]){
256
+ $admSession = Mage::getSingleton('adminhtml/session');
257
+ $admSession->setData("xp_prepaid_payments",$payment["xp_prepaid_payments"]);
258
+ }
259
+ }
260
+ }
261
+ }
262
+
263
+ public function unsetXpaymentSelectedCard(){
264
+ $admSession = Mage::getSingleton('adminhtml/session');
265
+ $admSession->unsetData("xp_payment_card");
266
+ $admSession->unsetData("xp_prepaid_payments");
267
+ }
268
+
269
+ public function orderInvoiceSaveBefore($observer){
270
+ $invoice = $observer->getEvent()->getInvoice();
271
+ $order = $invoice->getOrder();
272
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
273
+ if(Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentCode)){
274
+ $txnid = $order->getData("xpc_txnid");
275
+ $invoice->setTransactionId($txnid);
276
+ }
277
+ }
278
+
279
+ public function invoiceVoid($observer){
280
+
281
+ $invoice = $observer->getInvoice();
282
+ $order = $invoice->getOrder();
283
+ $paymentCode = $order->getPayment()->getMethodInstance()->getCode();
284
+ if(Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentCode)){
285
+ $data = array(
286
+ 'txnId' => $order->getData("xpc_txnid"),
287
+ 'amount' => number_format($invoice->getGrandTotal(), 2, '.',''),
288
+ );
289
+ Mage::getModel("xpaymentsconnector/payment_cc")->authorizedTransactionRequest('void', $data);
290
+ }
291
+ }
292
+
293
+ public function createOrdersByCustomerSubscriptions($observer){
294
+ $xpaymentsHelper = Mage::helper("xpaymentsconnector");
295
+ $recurringProfileList = Mage::getModel('sales/recurring_profile')
296
+ ->getCollection()
297
+ ->addFieldToFilter("state",Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
298
+ if($recurringProfileList->getSize() > 0){
299
+ foreach($recurringProfileList as $profile){
300
+ $startDateTime = strtotime($profile->getStartDatetime());
301
+ $lastSuccessTransactionDate = strtotime($profile->getXpSuccessTransactionDate());
302
+ $lastActionDate = ($startDateTime > $lastSuccessTransactionDate) ? $startDateTime : $lastSuccessTransactionDate;
303
+
304
+ $profilePeriodValue = $xpaymentsHelper->getCurrentBillingPeriodTimeStamp($profile);
305
+ $newTransactionDate = $lastActionDate+$profilePeriodValue;
306
+
307
+ $currentDateObj = new Zend_Date(time());
308
+ $currentDateStamp = $currentDateObj->getTimestamp();
309
+
310
+ //var_dump("current = ".date("Y-m-d H:m:s",$currentDateStamp),"start = ".date("Y-m-d H:m:s",$startDateTime),"last = ".date("Y-m-d H:m:s",$lastActionDate),"new = ".date("Y-m-d H:m:s",$newTransactionDate),"profile_id = ".$profile->getProfileId());die;
311
+
312
+ $timePassed = $currentDateStamp - $lastActionDate;
313
+
314
+ if ($timePassed >= $profilePeriodValue) {
315
+ // check by count of success transaction
316
+ $currentSuccessCycles = $profile->getXpCountSuccessTransaction();
317
+ $periodMaxCycles = $profile->getPeriodMaxCycles();
318
+
319
+ if($periodMaxCycles >= $currentSuccessCycles){
320
+ $orderItemInfo = $profile->getData("order_item_info");
321
+ if(!is_array($orderItemInfo)){
322
+ $orderItemInfo = unserialize($orderItemInfo);
323
+ }
324
+ $grandTotal = $orderItemInfo["nominal_row_total"];
325
+ $initialFeeAmount = $orderItemInfo["recurring_initial_fee"];
326
+
327
+ // add discount for grand total amount
328
+ $useDiscount = current($profile->getChildOrderIds()) > 0;
329
+ $discountAmount = ($useDiscount) ? $orderItemInfo["discount_amount"] : 0;
330
+
331
+ $orderId = $xpaymentsHelper->createOrder($profile);
332
+ $cardData = $xpaymentsHelper->getProfileOrderCardData($profile);
333
+
334
+ $response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest($orderId, NULL,$grandTotal - $initialFeeAmount + $discountAmount , $cardData);
335
+
336
+ if ($response["success"]) {
337
+ $result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($orderId, $response["response"]['transaction_id']);
338
+ $xpaymentsHelper->updateCurrentBillingPeriodTimeStamp($profile, $result["success"],$newTransactionDate);
339
+ if (!$result["success"]) {
340
+ Mage::log($result["error_message"], null, $xpaymentsHelper::XPAYMENTS_LOG_FILE,true);
341
+ }
342
+
343
+ } else {
344
+ $xpaymentsHelper->updateCurrentBillingPeriodTimeStamp($profile, $response["success"],$newTransactionDate);
345
+ Mage::log($response["error_message"], null, $xpaymentsHelper::XPAYMENTS_LOG_FILE,true);
346
+ }
347
+
348
+ }else{
349
+ // Subscription is completed
350
+ $profile->cancel();
351
+
352
+ }
353
+ }
354
+
355
+ }
356
+
357
+ }
358
+
359
+
360
+ }
361
+
362
+ /**
363
+ * Add redirect for buying recurring product by xpayments method(without iframe)
364
+ * @param $observer
365
+ */
366
+ public function addRedirectForXpaymentMethod($observer){
367
+ $profiles = $observer->getData("recurring_profiles");
368
+ if(!empty($profiles)){
369
+ $profile = current($profiles);
370
+ $currentPaymentMethodCode = $profile->getData("method_code");
371
+ $xpaymentPaymentCode = Mage::getModel("xpaymentsconnector/payment_cc")->getCode();
372
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
373
+ if(($currentPaymentMethodCode == $xpaymentPaymentCode) && !$useIframe){
374
+ $redirectUrl = Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
375
+ Mage::getSingleton("checkout/session")->setRedirectUrl($redirectUrl);
376
+ }
377
+
378
+ }
379
+
380
+ }
381
+
382
+ /**
383
+ * Set discount for recurring product(for ajax cart item quantity update)
384
+ * Remove X-Payments token
385
+ * @param $observer
386
+ */
387
+ public function updateCartItem($observer){
388
+ $unsetParams = array("token");
389
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder($unsetParams);
390
+
391
+ //set recurring product discount
392
+ Mage::helper("xpaymentsconnector")->setRecurringProductDiscount();
393
+ }
394
+
395
+ /**
396
+ * Remove X-Payments token
397
+ * @param $observer
398
+ */
399
+ public function checkoutCartAdd($observer){
400
+ $unsetParams = array("token");
401
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder($unsetParams);
402
+ }
403
+
404
+ /**
405
+ * Remove X-Payments token and prepare order number.
406
+ * @param $observer
407
+ */
408
+ public function postdispatchCartDelete($observer){
409
+ $unsetParams = array("token","prepare_order_id");
410
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder($unsetParams);
411
+ }
412
+
413
+ /**
414
+ * Set discount for recurring product
415
+ * @param $observer
416
+ */
417
+ public function preDispatchCartIndex($observer){
418
+ $unsetXpPrepareOrder = Mage::app()->getRequest()->getParam("unset_xp_prepare_order");
419
+ if(isset($unsetXpPrepareOrder)){
420
+ $unsetParams = array("token");
421
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder($unsetParams);
422
+ }
423
+
424
+
425
+
426
+ //set recurring product discount
427
+ Mage::helper("xpaymentsconnector")->setRecurringProductDiscount();
428
+
429
+ }
430
+
431
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Cc.php ADDED
@@ -0,0 +1,1931 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+
23
+ /**
24
+ * Processor
25
+ *
26
+ * @package Cdev_XPaymentsConnector
27
+ * @see ____class_see____
28
+ * @since 1.0.0
29
+ */
30
+
31
+ function xpc_curl_headers_collector()
32
+ {
33
+ static $headers = '';
34
+ $args = func_get_args();
35
+ if (count($args) == 1) {
36
+ $return = '';
37
+ if ($args[0] == true) {
38
+ $return = $headers;
39
+ }
40
+ $headers = '';
41
+ return $return;
42
+ }
43
+
44
+ if (trim($args[1]) != '') {
45
+ $headers .= $args[1];
46
+ }
47
+
48
+ return strlen($args[1]);
49
+
50
+ }
51
+
52
+
53
+ class Cdev_XPaymentsConnector_Model_Payment_Cc extends Mage_Payment_Model_Method_Abstract
54
+ implements Mage_Payment_Model_Recurring_Profile_MethodInterface
55
+ {
56
+ // Configuration settings
57
+ const XPATH_CART_ID = 'xpaymentsconnector/settings/xpay_cart_id';
58
+ const XPATH_URL = 'xpaymentsconnector/settings/xpay_url';
59
+ const XPATH_PUBLIC_KEY = 'xpaymentsconnector/settings/xpay_public_key';
60
+ const XPATH_PRIVATE_KEY = 'xpaymentsconnector/settings/xpay_private_key';
61
+ const XPATH_PRIVATE_KEY_PASS = 'xpaymentsconnector/settings/xpay_private_key_pass';
62
+ const XPATH_IP_ADDRESSES = 'xpaymentsconnector/settings/xpay_allowed_ip_addresses';
63
+ const XPATH_CURRENCY = 'xpaymentsconnector/settings/xpay_currency';
64
+ const XPATH_CONF_BUNDLE = 'xpaymentsconnector/settings/xpay_conf_bundle';
65
+
66
+ // Error codes
67
+ const REQ_CURL = 1;
68
+ const REQ_OPENSSL = 2;
69
+ const REQ_DOM = 4;
70
+
71
+ // COnfiguration errors codes
72
+ const CONF_CART_ID = 1;
73
+ const CONF_URL = 2;
74
+ const CONF_PUBLIC_KEY = 4;
75
+ const CONF_PRIVATE_KEY = 8;
76
+ const CONF_PRIVATE_KEY_PASS = 16;
77
+
78
+ // Salt block length
79
+ const SALT_LENGTH = 32;
80
+
81
+ // Salt generator start character code
82
+ const SALT_BEGIN = 33;
83
+
84
+ // Salt generator end character code
85
+ const SALT_END = 255;
86
+
87
+ // Encryption check length
88
+ const CHUNK_LENGTH = 128;
89
+
90
+ // Root-level tag for all XML messages
91
+ const TAG_ROOT = 'data';
92
+
93
+ // Value of the "type" attribute for list items in XML
94
+ const TYPE_CELL = 'cell';
95
+
96
+ // Payment statuses
97
+ const NEW_STATUS = 1;
98
+ const AUTH_STATUS = 2;
99
+ const DECLINED_STATUS = 3;
100
+ const CHARGED_STATUS = 4;
101
+
102
+ // Payment actions
103
+ const NEW_ACTION = 1;
104
+ const AUTH_ACTION = 2;
105
+ const CHARGED_ACTION = 3;
106
+ const DECLINED_ACTION = 4;
107
+ const REFUND_ACTION = 5;
108
+ const PART_REFUND_ACTION = 6;
109
+
110
+ // Transaction types
111
+ const TRAN_TYPE_AUTH = 'auth';
112
+ const TRAN_TYPE_CAPTURE = 'capture';
113
+ const TRAN_TYPE_CAPTURE_PART = 'capturePart';
114
+ const TRAN_TYPE_CAPTURE_MULTI = 'captureMulti';
115
+ const TRAN_TYPE_VOID = 'void';
116
+ const TRAN_TYPE_VOID_PART = 'voidPart';
117
+ const TRAN_TYPE_VOID_MULTI = 'voidMulti';
118
+ const TRAN_TYPE_REFUND = 'refund';
119
+ const TRAN_TYPE_PART_REFUND = 'refundPart';
120
+ const TRAN_TYPE_REFUND_MULTI = 'refundMulti';
121
+ const TRAN_TYPE_GET_INFO = 'getInfo';
122
+ const TRAN_TYPE_ACCEPT = 'accept';
123
+ const TRAN_TYPE_DECLINE = 'decline';
124
+ const XP_API = '1.2';
125
+ const XP_API_NEW = '1.2'; // change to 1.3 in a feature
126
+
127
+ /**
128
+ * unique internal payment method identifier
129
+ *
130
+ * @var string [a-z0-9_]
131
+ **/
132
+ protected $_code = 'xpayments';
133
+
134
+
135
+ protected $_isGateway = false;
136
+ protected $_canUseForMultishipping = false;
137
+ protected $_canUseInternal = false;
138
+
139
+ protected $_paymentMethod = 'cc';
140
+ protected $_defaultLocale = 'en';
141
+
142
+ protected $_canUseCheckout = true;
143
+
144
+ protected $_canRefund = true;
145
+ protected $_canRefundInvoicePartial = true;
146
+
147
+ protected $_canCapturePartial = true;
148
+ protected $_canCapture = true;
149
+
150
+ /**
151
+ * Payment method info block
152
+ *
153
+ * @var string
154
+ * @access protected
155
+ * @see ____var_see____
156
+ * @since 1.0.0
157
+ */
158
+ protected $_infoBlockType = 'xpaymentsconnector/info_cc';
159
+
160
+ /**
161
+ * Payment method form block
162
+ *
163
+ * @var string
164
+ * @access protected
165
+ * @see ____var_see____
166
+ * @since 1.0.1
167
+ */
168
+ protected $_formBlockType = 'xpaymentsconnector/form_cc';
169
+
170
+ /**
171
+ * Order (cache)
172
+ *
173
+ * @var Mage_Sales_Model_Order
174
+ * @access protected
175
+ * @see ____var_see____
176
+ * @since 1.0.0
177
+ */
178
+ protected $_order = null;
179
+
180
+ /**
181
+ * Get order
182
+ *
183
+ * @return Mage_Sales_Model_Order
184
+ * @access public
185
+ * @see ____func_see____
186
+ * @since 1.0.0
187
+ */
188
+ public function getOrder()
189
+ {
190
+ if (!$this->_order) {
191
+ $this->_order = $this->getInfoInstance()->getOrder();
192
+ }
193
+
194
+ return $this->_order;
195
+ }
196
+
197
+ /**
198
+ * Get redirect URL for order placing procedure
199
+ *
200
+ * @return string
201
+ * @access public
202
+ * @see ____func_see____
203
+ * @since 1.0.0
204
+ */
205
+ public function getOrderPlaceRedirectUrl() {
206
+
207
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
208
+ if(!$useIframe){
209
+ return Mage::getUrl('xpaymentsconnector/processing/redirect', array('_secure' => true));
210
+ }else{
211
+ return false;
212
+ }
213
+
214
+ }
215
+
216
+
217
+ /**
218
+ * Get payment method type
219
+ *
220
+ * @return string
221
+ * @access public
222
+ * @see ____func_see____
223
+ * @since 1.0.0
224
+ */
225
+ public function getPaymentMethodType()
226
+ {
227
+ return $this->_paymentMethod;
228
+ }
229
+
230
+ /**
231
+ * Check - can method Authorize transaction or not
232
+ *
233
+ * @return boolean
234
+ * @access public
235
+ * @see ____func_see____
236
+ * @since 1.0.0
237
+ */
238
+ public function canAuthorize()
239
+ {
240
+ return (bool)$this->getPaymentConfiguration()->getData('is_auth');
241
+ }
242
+
243
+ /**
244
+ * Check - can method Capture transaction or not
245
+ *
246
+ * @return boolean
247
+ * @access public
248
+ * @see ____func_see____
249
+ * @since 1.0.0
250
+ */
251
+ public function canCapture()
252
+ {
253
+ $order = $this->getOrder();
254
+ list($status, $response) = $this->requestPaymentInfo($order->getData("xpc_txnid"));
255
+ if($status){
256
+ if($response["status"] == self::CHARGED_STATUS){
257
+ return false;
258
+ }
259
+ elseif($response["status"] == self::AUTH_ACTION){
260
+ return true;
261
+ }
262
+ }else{
263
+ return false;
264
+ }
265
+ }
266
+
267
+ /**
268
+ * Check - can method Refund transaction or not
269
+ *
270
+ * @return boolean
271
+ * @access public
272
+ * @see ____func_see____
273
+ * @since 1.0.0
274
+ */
275
+ public function canRefund()
276
+ {
277
+ return (bool)$this->getPaymentConfiguration()->getData('is_refund');
278
+ }
279
+
280
+ /**
281
+ * Check - can method Partial refund transaction or not
282
+ *
283
+ * @return boolean
284
+ * @access public
285
+ * @see ____func_see____
286
+ * @since 1.0.0
287
+ */
288
+ public function canRefundPartialPerInvoice()
289
+ {
290
+ return (bool)$this->getPaymentConfiguration()->getData('is_part_refund');
291
+ }
292
+
293
+ /**
294
+ * Check - can method Void transaction or not
295
+ *
296
+ * @param Varien_Object $payment Payment
297
+ *
298
+ * @return boolean
299
+ * @access public
300
+ * @see ____func_see____
301
+ * @since 1.0.0
302
+ */
303
+ public function canVoid(Varien_Object $payment)
304
+ {
305
+ return (bool)$this->getPaymentConfiguration()->getData('is_void');
306
+ }
307
+
308
+ /**
309
+ * Get redirect form URL
310
+ *
311
+ * @return string
312
+ * @access public
313
+ * @see ____func_see____
314
+ * @since 1.0.0
315
+ */
316
+ public function getUrl()
317
+ {
318
+ return preg_replace('/\/+$/Ss', '', $this->getConfig('xpay_url'))
319
+ . '/payment.php';
320
+ }
321
+
322
+ /**
323
+ * Get redirect form fields list
324
+ *
325
+ * @return array
326
+ * @access public
327
+ * @see ____func_see____
328
+ * @since 1.0.0
329
+ */
330
+ public function getFormFields()
331
+ {
332
+ return array(
333
+ 'target' => 'main',
334
+ 'action' => 'start',
335
+ 'token' => Mage::getSingleton('checkout/session')->getData('xpayments_token'),
336
+ );
337
+ }
338
+
339
+ /**
340
+ * Get module configuration setting value
341
+ *
342
+ * @param string $name Configuration setting name
343
+ *
344
+ * @return mixed
345
+ * @access public
346
+ * @see ____func_see____
347
+ * @since 1.0.0
348
+ */
349
+ public function getConfig($name)
350
+ {
351
+ static $required1 = array(
352
+ 'store_id',
353
+ 'url',
354
+ 'public_key',
355
+ 'private_key',
356
+ 'private_key_password',
357
+ );
358
+ $required1 = unserialize(base64_decode(Mage::getStoreConfig(self::XPATH_CONF_BUNDLE)));
359
+ //print_r($required1);
360
+
361
+ static $keys = array(
362
+ // 'xpay_cart_id' => $required1['store_id'],
363
+ // 'xpay_url' => $required1['url'],
364
+ // 'xpay_public_key' => $required1['public_key'],
365
+ // 'xpay_private_key' => $required1['private_key'],
366
+ // 'xpay_private_key_pass' => $required1['private_key_password'],
367
+ 'xpay_allowed_ip_addresses' => self::XPATH_IP_ADDRESSES,
368
+ 'xpay_currency' => self::XPATH_CURRENCY,
369
+ 'xpay_conf_bundle' => self::XPATH_CONF_BUNDLE,
370
+
371
+ );
372
+ switch ($name) {
373
+ case 'xpay_cart_id' :
374
+ return $required1['store_id'];
375
+ case 'xpay_url' :
376
+ return $required1['url'];
377
+ case 'xpay_public_key' :
378
+ return $required1['public_key'];
379
+ case 'xpay_private_key' :
380
+ return $required1['private_key'];
381
+ case 'xpay_private_key_pass' :
382
+ return $required1['private_key_password'];
383
+ }
384
+ return isset($keys[$name]) ? Mage::getStoreConfig($keys[$name]) : null;
385
+
386
+
387
+ }
388
+
389
+ /**
390
+ * Check - module is configured
391
+ *
392
+ * @return boolean
393
+ * @access public
394
+ * @see ____func_see____
395
+ * @since 1.0.0
396
+ */
397
+ public function isConfigured()
398
+ {
399
+ return 0 === $this->getConfigurationErrors();
400
+ }
401
+
402
+ /**
403
+ * Get configuration errors code
404
+ *
405
+ * @return integer
406
+ * @access public
407
+ * @see ____func_see____
408
+ * @since 1.0.0
409
+ */
410
+ public function getConfigurationErrors()
411
+ {
412
+ $result = 0;
413
+
414
+ // Check shopping cart id
415
+ if (
416
+ !$this->getConfig('xpay_cart_id')
417
+ || !preg_match('/^[\da-f]{32}$/Ss', $this->getConfig('xpay_cart_id'))
418
+ ) {
419
+ $result = $result | self::CONF_CART_ID;
420
+ }
421
+
422
+ // Check URL
423
+ if (!$this->getConfig('xpay_url')) {
424
+ $result = $result | self::CONF_URL;
425
+ }
426
+
427
+ $parsed_url = @parse_url($this->getConfig('xpay_url'));
428
+
429
+ if (!$parsed_url || !isset($parsed_url['scheme']) || $parsed_url['scheme'] != 'https') {
430
+ $result = $result | self::CONF_URL;
431
+ }
432
+
433
+ // Check public key
434
+ if (!$this->getConfig('xpay_public_key')) {
435
+ $result = $result | self::CONF_PUBLIC_KEY;
436
+ }
437
+
438
+ // Check private key
439
+ if (!$this->getConfig('xpay_private_key')) {
440
+ $result = $result | self::CONF_PRIVATE_KEY;
441
+ }
442
+
443
+ // Check private key password
444
+ if (!$this->getConfig('xpay_private_key_pass')) {
445
+ $result = $result | self::CONF_PRIVATE_KEY_PASS;
446
+ }
447
+
448
+ return $result;
449
+ }
450
+
451
+ /**
452
+ * Check - module requirements is passed or not
453
+ *
454
+ * @return boolean
455
+ * @access public
456
+ * @see ____func_see____
457
+ * @since 1.0.0
458
+ */
459
+ public function checkRequirements()
460
+ {
461
+ $code = 0;
462
+
463
+ if (!function_exists('curl_init')) {
464
+ $code = $code | self::REQ_CURL;
465
+ }
466
+
467
+ if (
468
+ !function_exists('openssl_pkey_get_public') || !function_exists('openssl_public_encrypt')
469
+ || !function_exists('openssl_get_privatekey') || !function_exists('openssl_private_decrypt')
470
+ || !function_exists('openssl_free_key')
471
+ ) {
472
+ $code = $code | self::REQ_OPENSSL;
473
+ }
474
+
475
+ if (!class_exists('DOMDocument')) {
476
+ $code = $code | self::REQ_DOM;
477
+ }
478
+
479
+ return $code;
480
+ }
481
+
482
+ /**
483
+ * Send Handshake request
484
+ *
485
+ * @param Mage_Sales_Model_Order $order Order
486
+ *
487
+ * @return string Payment token
488
+ * @access public
489
+ * @see ____func_see____
490
+ * @since 1.0.0
491
+ */
492
+ public function sendHandshakeRequest(Mage_Sales_Model_Order $order)
493
+ {
494
+ $refId = $order->getIncrementId();
495
+
496
+ // Prepare cart
497
+ $cart = $this->prepareCart($order, $refId);
498
+
499
+ // Data to send to X-Payments
500
+ $data = array(
501
+ 'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
502
+ 'refId' => $refId,
503
+ 'cart' => $cart,
504
+ 'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/return', array('order_id' => $refId,'_secure' => true)),
505
+ 'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback', array('order_id' => $refId,'_secure' => true)),
506
+ 'template' => 'default',
507
+ 'saveCard' => 'Y',
508
+ 'api_version' => self::XP_API_NEW
509
+ );
510
+
511
+ list($status, $response) = $this->request('payment', 'init', $data);
512
+
513
+ if ($status && (!isset($response['token']) || !is_string($response['token']))) {
514
+
515
+ Mage::log(serialize($response), null, Cdev_XPaymentsConnector_Helper_Data::XPAYMENTS_LOG_FILE,true);
516
+
517
+ $this->getAPIError('Transaction token can not be found or has wrong type');
518
+ $status = false;
519
+ }
520
+
521
+ if ($status) {
522
+ Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
523
+ }
524
+
525
+ return $status;
526
+ }
527
+
528
+ /**
529
+ * Send Payment info request
530
+ *
531
+ * @param string $txn_id X-Payments transaction id
532
+ * @param boolean $refresh Refresh data flag
533
+ * @param boolean $withAdditionalInf info class
534
+ *
535
+ * @return array (Operation status & response array)
536
+ * @access public
537
+ * @see ____func_see____
538
+ * @since 1.0.0
539
+ */
540
+ public function requestPaymentInfo($txn_id, $refresh = false,$withAdditionalInfo = false)
541
+ {
542
+
543
+ if($withAdditionalInfo){
544
+ $data = array(
545
+ 'txnId' => $txn_id,
546
+ );
547
+ $infoClass = "get_additional_info";
548
+ }else{
549
+ $data = array(
550
+ 'txnId' => $txn_id,
551
+ 'refresh' => $refresh ? 1 : 0
552
+ );
553
+ $infoClass = "get_info";
554
+ }
555
+
556
+ list($status, $response) = $this->request('payment', $infoClass, $data);
557
+ $checkResponse = (!$withAdditionalInfo)?$response:$response["payment"];
558
+
559
+ if ($status) {
560
+ if (!is_array($response) || !isset($checkResponse['status'])) {
561
+ $this->getAPIError('GetInfo request. Server response has not status');
562
+ $status = false;
563
+
564
+ } elseif (!isset($checkResponse['message'])) {
565
+ $this->getAPIError('GetInfo request. Server response has not message');
566
+ $status = false;
567
+
568
+ } elseif (!isset($checkResponse['transactionInProgress'])) {
569
+ $this->getAPIError('GetInfo request. Server response has not transaction progress status');
570
+ $status = false;
571
+
572
+ } elseif (!isset($checkResponse['isFraudStatus'])) {
573
+ $this->getAPIError('GetInfo request. Server response has not fraud filter status');
574
+ $status = false;
575
+
576
+ } elseif (!isset($checkResponse['currency']) || strlen($checkResponse['currency']) != 3) {
577
+ $this->getAPIError('GetInfo request. Server response has not currency code or currency code has wrong format');
578
+ $status = false;
579
+
580
+ } elseif (!isset($checkResponse['amount'])) {
581
+ $this->getAPIError('GetInfo request. Server response has not payment amount');
582
+ $status = false;
583
+
584
+ } elseif (!isset($checkResponse['capturedAmount'])) {
585
+ $this->getAPIError('GetInfo request. Server response has not captured amount');
586
+ $status = false;
587
+
588
+ } elseif (!isset($checkResponse['capturedAmountAvail'])) {
589
+ $this->getAPIError('GetInfo request. Server response has not available for capturing amount');
590
+ $status = false;
591
+
592
+ } elseif (!isset($checkResponse['refundedAmount'])) {
593
+ $this->getAPIError('GetInfo request. Server response has not refunded amount');
594
+ $status = false;
595
+
596
+ } elseif (!isset($checkResponse['refundedAmountAvail'])) {
597
+ $this->getAPIError('GetInfo request. Server response has not available for refunding amount');
598
+ $status = false;
599
+
600
+ } elseif (!isset($checkResponse['voidedAmount'])) {
601
+ $this->getAPIError('GetInfo request. Server response has not voided amount');
602
+ $status = false;
603
+
604
+ } elseif (!isset($checkResponse['voidedAmountAvail'])) {
605
+ $this->getAPIError('GetInfo request. Server response has not available for cancelling amount');
606
+ $status = false;
607
+
608
+ }
609
+ }
610
+
611
+ return array($status, $response);
612
+ }
613
+
614
+ /**
615
+ * Send test request
616
+ *
617
+ * @return boolean
618
+ * @access public
619
+ * @see ____func_see____
620
+ * @since 1.0.0
621
+ */
622
+ public function sendTestRequest()
623
+ {
624
+ srand();
625
+
626
+ $hash_code = strval(rand(0, 1000000));
627
+
628
+ // Make test request
629
+ list($status, $response) = $this->request(
630
+ 'connect',
631
+ 'test',
632
+ array('testCode' => $hash_code)
633
+ );
634
+
635
+ // Compare MD5 hashes
636
+ if ($status && md5($hash_code) !== $response['hashCode']) {
637
+ $this->getAPIError('Test connection data is not valid');
638
+ $status = false;
639
+ }
640
+
641
+ return $status;
642
+ }
643
+
644
+ /**
645
+ * Send Get payment configurations request
646
+ *
647
+ * @return array Payment configurations list
648
+ * @access public
649
+ * @see ____func_see____
650
+ * @since 1.0.0
651
+ */
652
+ public function requestPaymentMethods()
653
+ {
654
+ $result = array();
655
+
656
+ // Call the "api.php?target=payment_confs&action=get" URL
657
+ list($status, $response) = $this->request(
658
+ 'payment_confs',
659
+ 'get',
660
+ array()
661
+ );
662
+
663
+ // Check status
664
+ if ($status && (!isset($response['payment_module']) || !is_array($response['payment_module']))) {
665
+ $status = false;
666
+ }
667
+
668
+ return $status ? $response['payment_module'] : false;
669
+ }
670
+
671
+ /**
672
+ * Request
673
+ *
674
+ * @param string $target Request target
675
+ * @param string $action Request action
676
+ * @param array $data Data
677
+ *
678
+ * @return array (Operation status & response array)
679
+ * @access protected
680
+ * @see ____func_see____
681
+ * @since 1.0.0
682
+ */
683
+ protected function request($target, $action, array $data = array())
684
+ {
685
+
686
+ // Check requirements
687
+ if (!$this->isConfigured()) {
688
+ return $this->getAPIError('Module is not configured');
689
+ }
690
+
691
+ if ($this->checkRequirements() != 0) {
692
+ return $this->getAPIError('Check module requirements is failed');
693
+ }
694
+
695
+ $data['target'] = $target;
696
+ $data['action'] = $action;
697
+ if(!isset($data['api_version'])){
698
+ $data['api_version'] = self::XP_API;
699
+ }
700
+
701
+
702
+ // Convert array to XML
703
+ $xml = $this->convertHash2XML($data);
704
+
705
+ if (!$xml) {
706
+ return $this->getAPIError('Data is not valid');
707
+ }
708
+
709
+ // Encrypt
710
+ $xml = $this->encrypt($xml);
711
+ if (!$xml) {
712
+ return $this->getAPIError('Data is not encrypted');
713
+ }
714
+
715
+ // HTTPS request
716
+ $post = array(
717
+ 'cart_id' => $this->getConfig('xpay_cart_id'),
718
+ 'request' => $xml
719
+ );
720
+
721
+ $https = new Varien_Http_Client(
722
+ $this->getConfig('xpay_url') . '/api.php',
723
+ array(
724
+ 'timeout' => 15,
725
+ )
726
+ );
727
+
728
+
729
+ /*update*/
730
+ $ch = curl_init();
731
+
732
+ curl_setopt($ch, CURLOPT_URL, $this->getConfig('xpay_url') . '/api.php');
733
+ curl_setopt($ch, CURLOPT_HEADER, false);
734
+ curl_setopt($ch, CURLOPT_TIMEOUT, 15000);
735
+ curl_setopt($ch, CURLOPT_POST, true);
736
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
737
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
738
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, false);
739
+ curl_setopt($ch, CURLOPT_HEADERFUNCTION, 'xpc_curl_headers_collector');
740
+ curl_setopt($ch, CURLOPT_SSLVERSION, 3);
741
+
742
+ $body = curl_exec($ch);
743
+ $errno = curl_errno($ch);
744
+ $error = curl_error($ch);
745
+
746
+ // Check raw data
747
+ if (substr($body, 0, 3) !== 'API') {
748
+
749
+ if (substr(strstr($body, 'API'), 0, 3) !== 'API') {
750
+
751
+ return $this->getAPIError(
752
+ 'Response is not valid.' . "\n"
753
+ //. 'Response headers: ' . var_export($headers, true) . "\n"
754
+ . 'Response: ' . $body . "\n"
755
+ );
756
+
757
+ } else {
758
+
759
+ $body = strstr($body, 'API');
760
+
761
+ }
762
+
763
+ }
764
+
765
+ // Decrypt
766
+ list($responseStatus, $response) = $this->decrypt($body);
767
+
768
+ if (!$responseStatus) {
769
+ return $this->getAPIError('Response is not decrypted (Error: ' . $response . ')');
770
+ }
771
+
772
+ // Convert XML to array
773
+ $response = $this->convertXML2Hash($response);
774
+
775
+ if (!is_array($response)) {
776
+ return $this->getAPIError('Unable to convert response into XML');
777
+ }
778
+
779
+ // The 'Data' tag must be set in response
780
+ if (!isset($response[self::TAG_ROOT])) {
781
+ return $this->getAPIError('Response does not contain any data');
782
+ }
783
+
784
+ // Process errors
785
+ if ($this->processAPIError($response)) {
786
+ return array(false, 'X-Payments internal error');
787
+ }
788
+
789
+ return array(true, $response[self::TAG_ROOT]);
790
+ }
791
+
792
+ /**
793
+ * Decrypt separate XML block
794
+ *
795
+ * @param string $body Encrypted XML data
796
+ *
797
+ * @return array
798
+ * @access public
799
+ * @see ____func_see____
800
+ * @since 1.0.0
801
+ */
802
+ public function decryptXML($body)
803
+ {
804
+ // Check raw data
805
+ if (substr($body, 0, 3) !== 'API') {
806
+ return $this->getAPIError(
807
+ 'Encrypted XML data is not valid.' . "\n"
808
+ );
809
+ }
810
+
811
+ // Decrypt
812
+ list($responseStatus, $response) = $this->decrypt($body);
813
+
814
+ if (!$responseStatus) {
815
+ return $this->getAPIError('Encrypted XML data is not decrypted (Error: ' . $response . ')');
816
+ }
817
+
818
+ // Convert XML to array
819
+ $response = $this->convertXML2Hash($response);
820
+
821
+ if (!is_array($response)) {
822
+ return $this->getAPIError('Unable to convert encrypted data into XML');
823
+ }
824
+
825
+ // The 'Data' tag must be set in response
826
+ if (!isset($response[self::TAG_ROOT])) {
827
+ return $this->getAPIError('Encrypted XML data does not contain any data');
828
+ }
829
+
830
+ return $response[self::TAG_ROOT];
831
+ }
832
+
833
+ /**
834
+ * Get API error response and save error message into log
835
+ *
836
+ * @param string $msg Error message
837
+ *
838
+ * @return array
839
+ * @access protected
840
+ * @see ____func_see____
841
+ * @since 1.0.0
842
+ */
843
+ protected function getAPIError($msg)
844
+ {
845
+ Mage::log(
846
+ sprintf('XPayments connector error: %s', $msg),
847
+ Zend_Log::ERR
848
+ );
849
+
850
+ return array(false, $msg);
851
+ }
852
+
853
+ /**
854
+ * Process API error
855
+ *
856
+ * @param array $response Prepared response
857
+ *
858
+ * @return boolean Has reponse any error(s) or not
859
+ * @access protected
860
+ * @see ____func_see____
861
+ * @since 1.0.0
862
+ */
863
+ protected function processAPIError(array $response)
864
+ {
865
+ $error = false;
866
+
867
+ if (isset($response['error']) && $response['error']) {
868
+ $this->getAPIError(
869
+ 'X-Payments error (code: ' . $response['error'] . '): '
870
+ . (isset($response['error_message']) ? $response['error_message'] : 'Unknown')
871
+ );
872
+ $error = true;
873
+ }
874
+
875
+ return $error;
876
+ }
877
+
878
+ /**
879
+ * Check - force use authorization request or not
880
+ *
881
+ * @return boolean
882
+ * @access protected
883
+ * @see ____func_see____
884
+ * @since 1.0.0
885
+ */
886
+ protected function isForceAuth()
887
+ {
888
+
889
+ $isRecurrnigProduct = Mage::helper("xpaymentsconnector")->checkIsRecurringOrder();
890
+ if ($isRecurrnigProduct) {
891
+ $useStartDateParam = Mage::helper("xpaymentsconnector")->checkStartDateData();
892
+ if ($useStartDateParam["success"]) {
893
+ $useInitialFeeAuthorize = Mage::getStoreConfig('payment/xpayments/use_initialfee_authorize');
894
+ return (bool)$useInitialFeeAuthorize;
895
+ }
896
+ }
897
+
898
+ $useAuthorize = Mage::getStoreConfig('payment/xpayments/use_authorize');
899
+ return (bool)$useAuthorize;
900
+ }
901
+
902
+ /**
903
+ * Prepare cart for Handshake request
904
+ *
905
+ * @param Mage_Sales_Model_Order $order Order
906
+ * @param mixed $refId Unique reference id
907
+ *
908
+ * @return array
909
+ * @access protected
910
+ * @see ____func_see____
911
+ * @since 1.0.0
912
+ */
913
+ protected function prepareCart(Mage_Sales_Model_Order $order, $refId)
914
+ {
915
+ $memail = explode(',', Mage::getStoreConfig($order::XML_PATH_EMAIL_COPY_TO, $this->getStoreId()));
916
+ $memail = array_shift($memail);
917
+
918
+ if (!$memail) {
919
+ $users = Mage::getModel('admin/user')->getCollection();
920
+ foreach ($users as $user) {
921
+ $memail = $user->getData('email');
922
+ break;
923
+ }
924
+ unset($users, $user);
925
+ }
926
+
927
+ $forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
928
+
929
+ $result = array(
930
+ 'billingAddress' => array(
931
+ 'email' => $order->getCustomerEmail(),
932
+ ),
933
+ 'shippingAddress' => array(
934
+ 'email' => $order->getCustomerEmail(),
935
+ ),
936
+ 'items' => array(),
937
+ 'currency' => $this->getCurrency($refId),
938
+ 'shippingCost' => 0.00,
939
+ 'taxCost' => 0.00,
940
+ 'discount' => 0.00,
941
+ 'totalCost' => 0.00,
942
+ 'description' => 'Order #' . $refId,
943
+ 'merchantEmail' => $memail,
944
+ 'forceTransactionType' => $forceTransactionType,
945
+ 'login' => $order->getCustomerEmail(),
946
+ );
947
+
948
+ $namePrefixes = array(
949
+ 'billing' => 'getBillingAddress',
950
+ 'shipping' => 'getShippingAddress',
951
+ );
952
+
953
+ $addressFields = array(
954
+ 'firstname' => 'firstname',
955
+ 'lastname' => 'lastname',
956
+ 'address' => 'street',
957
+ 'city' => 'city',
958
+ 'state' => 'region_id',
959
+ 'country' => 'country_id',
960
+ 'zipcode' => 'postcode',
961
+ 'phone' => 'telephone',
962
+ 'fax' => 'telephone',
963
+ );
964
+
965
+ // Prepare shipping and billing address
966
+ foreach ($namePrefixes as $prefix => $mn) {
967
+
968
+ $addressIndex = $prefix . 'Address';
969
+ $getter = $order->$mn();
970
+
971
+ if (!$getter && $prefix == 'shipping') {
972
+
973
+ // If shipping address is forbidden
974
+ $getter = $order->getBillingAddress();
975
+ }
976
+
977
+ foreach ($addressFields as $field => $fn) {
978
+ $result[$addressIndex][$field] = $getter->getData($fn);
979
+
980
+ if ('region_id' == $fn) {
981
+ $result[$addressIndex][$field] = Mage::getModel('directory/region')->load($result[$addressIndex][$field])->getCode();
982
+ }
983
+
984
+ if (
985
+ !$result[$addressIndex][$field]
986
+ && in_array($field, array('state', 'address', 'city','zipcode'))
987
+ ) {
988
+ $result[$addressIndex][$field] = 'n/a';
989
+ }
990
+ }
991
+
992
+ $result[$addressIndex]['name'] = trim(
993
+ $getter->getData('firstname') . ' ' . $getter->getData('lastname')
994
+ );
995
+ }
996
+
997
+ // Set products
998
+ foreach ($order->getItemsCollection() as $product) {
999
+ $result['items'][] = array(
1000
+ 'sku' => $product->getData('sku'),
1001
+ 'name' => $product->getData('name'),
1002
+ 'price' => number_format($product->getPrice(), 2, '.',''),
1003
+ 'quantity' => intval($product->getData('qty_ordered')),
1004
+ );
1005
+ }
1006
+
1007
+ // Set costs
1008
+ $result['shippingCost'] = number_format($order->getData('shipping_amount'), 2, '.','');
1009
+ $result['taxCost'] = number_format($order->getData('tax_amount'), 2, '.','');
1010
+ $result['totalCost'] = number_format($order->getGrandTotal(), 2, '.','');
1011
+
1012
+ return $result;
1013
+ }
1014
+
1015
+ /**
1016
+ * Get currency code
1017
+ *
1018
+ * @param mixed $refId Order increment id
1019
+ *
1020
+ * @return string
1021
+ * @access public
1022
+ * @see ____func_see____
1023
+ * @since 1.0.0
1024
+ */
1025
+ public function getCurrency($refId = null)
1026
+ {
1027
+ return strtoupper($this->getConfig('xpay_currency'));
1028
+ }
1029
+
1030
+ /**
1031
+ * Convert hash to XML
1032
+ *
1033
+ * @param array $data Hash
1034
+ * @param integer $level Parentness level
1035
+ *
1036
+ * @return string
1037
+ * @access protected
1038
+ * @see ____func_see____
1039
+ * @since 1.0.0
1040
+ */
1041
+ protected function convertHash2XML(array $data, $level = 0)
1042
+ {
1043
+ $xml = '';
1044
+
1045
+ foreach ($data as $name => $value) {
1046
+
1047
+ if ($this->isAnonymousArray($value)) {
1048
+ foreach ($value as $item) {
1049
+ $xml .= $this->writeXMLTag($item, $name, $level, self::TYPE_CELL);
1050
+ }
1051
+ } else {
1052
+ $xml .= $this->writeXMLTag($value, $name, $level);
1053
+ }
1054
+
1055
+ }
1056
+
1057
+ return $xml;
1058
+ }
1059
+
1060
+ /**
1061
+ * Check - argument is plain array or not
1062
+ *
1063
+ * @param array $data Array
1064
+ *
1065
+ * @return boolean
1066
+ * @access protected
1067
+ * @see ____func_see____
1068
+ * @since 1.0.0
1069
+ */
1070
+ protected function isAnonymousArray($data)
1071
+ {
1072
+ return is_array($data)
1073
+ && 1 > count(preg_grep('/^\d+$/', array_keys($data), PREG_GREP_INVERT));
1074
+ }
1075
+
1076
+ /**
1077
+ * Write XML tag
1078
+ *
1079
+ * @param mixed $data Data
1080
+ * @param string $name Tag name
1081
+ * @param integer $level Parentness level
1082
+ * @param string $type Tag type
1083
+ *
1084
+ * @return string
1085
+ * @access protected
1086
+ * @see ____func_see____
1087
+ * @since 1.0.0
1088
+ */
1089
+ protected function writeXMLTag($data, $name, $level = 0, $type = '')
1090
+ {
1091
+ $xml = '';
1092
+ $indent = str_repeat(' ', $level);
1093
+
1094
+ // Open tag
1095
+ $xml .= $indent . '<' . $name . (empty($type) ? '' : ' type="' . $type . '"') . '>';
1096
+
1097
+ // Sublevel tags or tag value
1098
+ if (is_array($data)) {
1099
+ $xml .= "\n" . $this->convertHash2XML($data, $level + 1) . $indent;
1100
+
1101
+ } elseif (function_exists('iconv')) {
1102
+ $trn = iconv('UTF-8', 'UTF-8//IGNORE', $data);
1103
+ $data = false === $trn ? $data : $trn;
1104
+ $data = str_replace(
1105
+ array("\n", "\t", "\r", "\f",),
1106
+ array(' ', ' ', '', '',),
1107
+ $data
1108
+ );
1109
+ $xml .= $data;
1110
+
1111
+ } else {
1112
+ $data = str_replace(
1113
+ array("\n", "\t", "\r", "\f",),
1114
+ array(' ', ' ', '', '',),
1115
+ $data
1116
+ );
1117
+ $xml .= $data;
1118
+ }
1119
+
1120
+ // Close tag
1121
+ $xml .= '</' . $name . '>' . "\n";
1122
+
1123
+ return $xml;
1124
+ }
1125
+
1126
+ /**
1127
+ * Convert XML-to-hash
1128
+ *
1129
+ * @param string $xml XML string
1130
+ *
1131
+ * @return array or string
1132
+ * @access protected
1133
+ * @see ____func_see____
1134
+ * @since 1.0.0
1135
+ */
1136
+ protected function convertXML2Hash($xml)
1137
+ {
1138
+ $data = array();
1139
+
1140
+ while (
1141
+ !empty($xml)
1142
+ && preg_match('/<([\w\d]+)(?:\s*type=["\'](\w+)["\']\s*)?' . '>(.*)<\/\1>/Us', $xml, $matches)
1143
+ ) {
1144
+
1145
+ // Sublevel tags or tag value
1146
+ if (self::TYPE_CELL === $matches[2]) {
1147
+ $data[$matches[1]][] = $this->convertXML2Hash($matches[3]);
1148
+
1149
+ } else {
1150
+ $data[$matches[1]] = $this->convertXML2Hash($matches[3]);
1151
+ }
1152
+
1153
+ // Exclude parsed part from XML
1154
+ $xml = str_replace($matches[0], '', $xml);
1155
+
1156
+ }
1157
+
1158
+ return empty($data) ? $xml : $data;
1159
+ }
1160
+
1161
+ /**
1162
+ * Encrypt data
1163
+ *
1164
+ * @param string $data Data
1165
+ *
1166
+ * @return string
1167
+ * @access protected
1168
+ * @see ____func_see____
1169
+ * @since 1.0.0
1170
+ */
1171
+ protected function encrypt($data)
1172
+ {
1173
+ // Preprocess
1174
+ srand(time());
1175
+ $salt = '';
1176
+ for ($i = 0; $i < self::SALT_LENGTH; $i++) {
1177
+ $salt .= chr(rand(self::SALT_BEGIN, self::SALT_END));
1178
+ }
1179
+
1180
+ $lenSalt = strlen($salt);
1181
+
1182
+ $crcType = 'MD5';
1183
+ $crc = md5($data, true);
1184
+
1185
+ $crc = str_repeat(' ', 8 - strlen($crcType)) . $crcType . $crc;
1186
+ $lenCRC = strlen($crc);
1187
+
1188
+ $lenData = strlen($data);
1189
+
1190
+ $data = str_repeat('0', 12 - strlen((string)$lenSalt)) . $lenSalt . $salt
1191
+ . str_repeat('0', 12 - strlen((string)$lenCRC)) . $lenCRC . $crc
1192
+ . str_repeat('0', 12 - strlen((string)$lenData)) . $lenData . $data;
1193
+
1194
+ // Encrypt
1195
+ $key = openssl_pkey_get_public($this->getConfig('xpay_public_key'));
1196
+ if (!$key) {
1197
+ return false;
1198
+ }
1199
+
1200
+ $data = str_split($data, self::CHUNK_LENGTH);
1201
+ $crypttext = null;
1202
+ foreach ($data as $k => $chunk) {
1203
+ if (!openssl_public_encrypt($chunk, $crypttext, $key)) {
1204
+ return false;
1205
+ }
1206
+
1207
+ $data[$k] = $crypttext;
1208
+ }
1209
+
1210
+ // Postprocess
1211
+ $data = array_map('base64_encode', $data);
1212
+
1213
+ return 'API' . implode("\n", $data);
1214
+ }
1215
+
1216
+ /**
1217
+ * Decrypt
1218
+ *
1219
+ * @param string $data Encrypted data
1220
+ *
1221
+ * @return string
1222
+ * @access protected
1223
+ * @see ____func_see____
1224
+ * @since 1.0.0
1225
+ */
1226
+ protected function decrypt($data)
1227
+ {
1228
+
1229
+ // Decrypt
1230
+ $res = openssl_get_privatekey(
1231
+ $this->getConfig('xpay_private_key'),
1232
+ $this->getConfig('xpay_private_key_pass')
1233
+ );
1234
+ if (!$res) {
1235
+ return array(false, 'Private key is not initialized');
1236
+ }
1237
+
1238
+ $data = substr($data, 3);
1239
+
1240
+ $data = explode("\n", $data);
1241
+ $data = array_map('base64_decode', $data);
1242
+ foreach ($data as $k => $s) {
1243
+ if (!openssl_private_decrypt($s, $newsource, $res)) {
1244
+ return array(false, 'Can not decrypt chunk');
1245
+ }
1246
+
1247
+ $data[$k] = $newsource;
1248
+ }
1249
+
1250
+ openssl_free_key($res);
1251
+
1252
+ $data = implode('', $data);
1253
+
1254
+ // Postprocess
1255
+ $lenSalt = substr($data, 0, 12);
1256
+ if (!preg_match('/^\d+$/Ss', $lenSalt)) {
1257
+ return array(false, 'Salt length prefix has wrong format');
1258
+ }
1259
+
1260
+ $lenSalt = intval($lenSalt);
1261
+ $data = substr($data, 12 + intval($lenSalt));
1262
+
1263
+ $lenCRC = substr($data, 0, 12);
1264
+ if (!preg_match('/^\d+$/Ss', $lenCRC) || $lenCRC < 9) {
1265
+ return array(false, 'CRC length prefix has wrong format');
1266
+ }
1267
+
1268
+ $lenCRC = intval($lenCRC);
1269
+ $crcType = trim(substr($data, 12, 8));
1270
+ if ($crcType !== 'MD5') {
1271
+ return array(false, 'CRC hash is not MD5');
1272
+ }
1273
+ $crc = substr($data, 20, $lenCRC - 8);
1274
+
1275
+ $data = substr($data, 12 + $lenCRC);
1276
+
1277
+ $lenData = substr($data, 0, 12);
1278
+ if (!preg_match('/^\d+$/Ss', $lenData)) {
1279
+ return array(false, 'Data block length prefix has wrong format');
1280
+ }
1281
+
1282
+ $data = substr($data, 12, intval($lenData));
1283
+
1284
+ $currentCRC = md5($data, true);
1285
+ if ($currentCRC !== $crc) {
1286
+ return array(false, 'Original CRC and calculated CRC is not equal');
1287
+ }
1288
+
1289
+ return array(true, $data);
1290
+ }
1291
+
1292
+ /**
1293
+ * Get payment configuration model
1294
+ *
1295
+ * @return Cdev_XPaymentsConnector_Model_Paymentconfiguration
1296
+ * @access protected
1297
+ * @see ____func_see____
1298
+ * @since 1.0.0
1299
+ */
1300
+ protected function getPaymentConfiguration()
1301
+ {
1302
+ return Mage::getModel('xpaymentsconnector/paymentconfiguration')
1303
+ ->load($this->getConfigData('confid'));
1304
+ }
1305
+
1306
+ /**
1307
+ * Check method availability
1308
+ *
1309
+ * @param Mage_Sales_Model_Quote $quote Quote
1310
+ *
1311
+ * @return boolean
1312
+ * @access public
1313
+ * @see ____func_see____
1314
+ * @since 1.0.0
1315
+ */
1316
+ public function isAvailable($quote = null)
1317
+ {
1318
+ return $this->isConfigured()
1319
+ && 0 === $this->checkRequirements()
1320
+ && '1' != Mage::getStoreConfig('advanced/modules_disable_output/Cdev_XPaymentsConnector')
1321
+ && parent::isAvailable($quote);
1322
+ }
1323
+
1324
+ /**
1325
+ * Send Handshake request
1326
+ *
1327
+ * @param bool $useDefaultTemplate
1328
+ * @param bool $isCardAuthorizePayment
1329
+ * @param array $updateSendData
1330
+ *
1331
+ * @param Mage_Sales_Model_Order $order Order
1332
+ *
1333
+ * @return string Payment token
1334
+ * @access public
1335
+ * @see ____func_see____
1336
+ * @since 1.0.0
1337
+ *
1338
+ * @return array
1339
+ */
1340
+ public function sendIframeHandshakeRequest($updateSendData = array(),$isCardAuthorizePayment = false)
1341
+ {
1342
+ $xPaymentDataResponse = array();
1343
+ $checkoutData = Mage::getSingleton('checkout/session');
1344
+ $refId = Mage::helper("xpaymentsconnector")->getOrderKey();
1345
+
1346
+ $xPaymentDataResponse["order_refid"] = $refId;
1347
+ $result = array();
1348
+ $cart = array();
1349
+
1350
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
1351
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
1352
+ $cart = $this->iframePrepareCart($checkoutData, $customer,$isCardAuthorizePayment);
1353
+ }else {
1354
+ $cart = $this->iframePrepareCart($checkoutData, false, $isCardAuthorizePayment);
1355
+ }
1356
+
1357
+ // Data to send to X-Payments
1358
+ $sendData = array(
1359
+ 'confId' => intval($this->getPaymentConfiguration()->getData('confid')),
1360
+ 'refId' => $refId,
1361
+ 'cart' => $cart,
1362
+ 'returnUrl' => Mage::getUrl('xpaymentsconnector/processing/iframereturn', array('order_refid' => $refId,'_secure' => true)),
1363
+ 'callbackUrl' => Mage::getUrl('xpaymentsconnector/processing/callback', array('order_refid' => $refId,'_secure' => true)),
1364
+ );
1365
+
1366
+
1367
+ foreach($updateSendData as $sendDataKey => $sendDataValue){
1368
+ $sendData[$sendDataKey] = $updateSendData[$sendDataKey];
1369
+ }
1370
+
1371
+ list($status, $response) = $this->request('payment', 'init', $sendData);
1372
+
1373
+
1374
+ $xPaymentDataResponse["status"] = $status;
1375
+ $xPaymentDataResponse["response"] = $response;
1376
+
1377
+
1378
+ //****************stop*****************//
1379
+
1380
+
1381
+ if (!$status || (!isset($response['token']) || !is_string($response['token']))) {
1382
+ $result['success'] = false;
1383
+ $result['error_message'] = Mage::helper('core')->__("Transaction token can not be found or has wrong type");
1384
+ return $result;
1385
+ }
1386
+
1387
+
1388
+ $checkoutData->setData("xpayment",$xPaymentDataResponse);
1389
+
1390
+ if ($status) {
1391
+ Mage::getSingleton('checkout/session')->setData('xpayments_token', $response['token']);
1392
+ }
1393
+
1394
+ return $xPaymentDataResponse;
1395
+ }
1396
+
1397
+ public function sendAgainTransactionRequest($order_id = NULL,$paymentCardNumber = NULL,$grandTotal = NULL, $cardData = NULL){
1398
+
1399
+
1400
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
1401
+ if(is_null($paymentCardNumber)){
1402
+ $paymentCardNumber = $quote->getPayment()->getData("xp_payment_card");
1403
+ }
1404
+ if(is_null($grandTotal)){
1405
+ $grandTotal = $quote->getGrandTotal();
1406
+ }
1407
+
1408
+ if(is_null($cardData)){
1409
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber);
1410
+ if($cardData){
1411
+ $cardData = $cardData->getData();
1412
+ }
1413
+ }
1414
+
1415
+ $data = array(
1416
+ 'txnId' => $cardData["txnId"],
1417
+ 'amount' => number_format($grandTotal, 2, '.','')
1418
+ );
1419
+ $order = NULL;
1420
+ if(!is_null($order_id)){
1421
+ $order = Mage::getModel('sales/order')->load($order_id);
1422
+ $orderIcrementId = $order->getIncrementId();
1423
+ $data['description'] = 'Order #' . $orderIcrementId;
1424
+ }else{
1425
+ $xpOrderKey = Mage::helper("xpaymentsconnector")->getOrderKey();;
1426
+ $data['description'] = 'Order(i-frame) #' . $xpOrderKey;
1427
+ }
1428
+
1429
+
1430
+ list($status, $response) = $this->request('payment', 'recharge', $data);
1431
+
1432
+ $xPaymentDataResponse["status"] = $status;
1433
+ $xPaymentDataResponse["response"] = $response;
1434
+
1435
+ if($order){
1436
+ $order->setData("xp_card_data",serialize($cardData));
1437
+ $order->save();
1438
+
1439
+ if ($status && (!isset($response['transaction_id']) || !is_string($response['transaction_id']))) {
1440
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder();
1441
+ $order->cancel();
1442
+ $errorMessage = Mage::helper('xpaymentsconnector')->__("Transaction token can not found or has wrong type. The order has been canceled.");
1443
+ $order->addStatusToHistory(
1444
+ $order::STATE_CANCELED,
1445
+ $errorMessage
1446
+ );
1447
+
1448
+ $order->save();
1449
+ $result["success"] = false;
1450
+ $result["error_message"] = $errorMessage;
1451
+
1452
+ return $result;
1453
+ }
1454
+
1455
+ }
1456
+
1457
+
1458
+ $xPaymentDataResponse["success"] = true;
1459
+
1460
+ return $xPaymentDataResponse;
1461
+
1462
+ }
1463
+
1464
+ /**
1465
+ * Prepare cart for Handshake request
1466
+ *
1467
+ * @param Mage_Sales_Model_Order $order Order
1468
+ * @param mixed $refId Unique reference id
1469
+ *
1470
+ * @return array
1471
+ * @access protected
1472
+ * @see ____func_see____
1473
+ * @since 1.0.0
1474
+ */
1475
+ protected function iframePrepareCart($checkoutData,$customer,$isCardAuthorizePayment = false)
1476
+ {
1477
+ $refId = Mage::helper("xpaymentsconnector")->getOrderKey();
1478
+ $customerEmail = "";
1479
+
1480
+ $billingAddress = $checkoutData->getQuote()->getBillingAddress();
1481
+ $shippingAddress = $checkoutData->getQuote()->getShippingAddress();
1482
+ $quote = $checkoutData->getQuote();
1483
+ $result = array();
1484
+ /*initial fee check*/
1485
+ $quoteItem = current($checkoutData->getQuote()->getAllItems());
1486
+ $totalCost = 0;
1487
+ $forceTransactionType = ($this->isForceAuth()) ? 'A' : 'S';
1488
+ $minimalPayment = false;
1489
+ $cardAuthorizeAmount = 0;
1490
+
1491
+ $result['description'] = 'Order(i-frame) #' . $refId;
1492
+ if ($quoteItem && $quoteItem->getProduct()->getIsRecurring()) {
1493
+ $useStartDateParam = Mage::helper("xpaymentsconnector")->checkStartDateData();
1494
+ if ($useStartDateParam["success"]) {
1495
+ $minimalPayment = $useStartDateParam["minimal_payment_amount"];
1496
+
1497
+ $result['shippingCost'] = number_format(0, 2, '.', '');
1498
+ $result['taxCost'] = number_format(0, 2, '.', '');
1499
+ $result['totalCost'] = number_format($minimalPayment, 2, '.', '');
1500
+ $description = "Recurring profile subscription.";
1501
+ $result['description'] = $description;
1502
+
1503
+ } else {
1504
+ $totalCost = $quoteItem->getData("nominal_row_total");
1505
+ $result['shippingCost'] = number_format($quoteItem->getData("shipping_amount"), 2, '.', '');
1506
+ $result['taxCost'] = number_format($quoteItem->getData("tax_amount"), 2, '.', '');
1507
+ $result['totalCost'] = number_format($totalCost, 2, '.', '');
1508
+ }
1509
+
1510
+ } elseif ($isCardAuthorizePayment) {
1511
+ $cardAuthorizeAmount = floatval(Mage::getStoreConfig("xpaymentsconnector/settings/xpay_minimum_payment_recurring_amount"));
1512
+ $result['shippingCost'] = number_format(0, 2, '.', '');
1513
+ $result['taxCost'] = number_format(0, 2, '.', '');
1514
+ $result['totalCost'] = number_format($cardAuthorizeAmount, 2, '.', '');
1515
+ } else {
1516
+ // Set costs
1517
+ $totalCost = $quote->getGrandTotal();
1518
+ $result['shippingCost'] = number_format($checkoutData->getData("shippingCost"), 2, '.', '');
1519
+ $result['taxCost'] = number_format($checkoutData->getData("taxCost"), 2, '.', '');
1520
+ $result['totalCost'] = number_format($totalCost, 2, '.', '');
1521
+ }
1522
+
1523
+ if(!$customer){
1524
+ $customerEmail = $billingAddress->getEmail();
1525
+ } else{
1526
+ $customerEmail = $customer->getEmail();
1527
+ }
1528
+
1529
+
1530
+ $result['billingAddress'] = array(
1531
+ 'email' => $customerEmail,
1532
+ );
1533
+ $result['shippingAddress'] = array(
1534
+ 'email' => $customerEmail,
1535
+ );
1536
+ $result['items'] = array();
1537
+ $result['currency'] = $this->getCurrency();
1538
+ $result['discount'] = 0.00;
1539
+ $result['merchantEmail'] = $customerEmail;
1540
+ $result['forceTransactionType'] = $forceTransactionType;
1541
+ $result['login'] = $customerEmail;
1542
+
1543
+ $namePrefixes = array(
1544
+ 'billing' => $billingAddress,
1545
+ 'shipping' => $shippingAddress,
1546
+ );
1547
+
1548
+ $addressFields = array(
1549
+ 'firstname' => 'firstname',
1550
+ 'lastname' => 'lastname',
1551
+ 'address' => 'street',
1552
+ 'city' => 'city',
1553
+ 'state' => 'region_id',
1554
+ 'country' => 'country_id',
1555
+ 'zipcode' => 'postcode',
1556
+ 'phone' => 'telephone',
1557
+ 'fax' => 'telephone',
1558
+ );
1559
+
1560
+ // Prepare shipping and billing address
1561
+ $shippingIsEmpty = true;
1562
+ foreach ($namePrefixes as $prefix => $data) {
1563
+
1564
+ $addressIndex = $prefix . 'Address';
1565
+ foreach ($addressFields as $field => $fn) {
1566
+ $result[$addressIndex][$field] = $data->getData($fn);
1567
+ if(($field == "firstname" || $field == "lastname") && $isCardAuthorizePayment){
1568
+ $result[$addressIndex][$field] = $customer->getData($field);
1569
+ }
1570
+ if(($prefix == "shipping") && $result[$addressIndex][$field]){
1571
+ $shippingIsEmpty = false;
1572
+ }
1573
+
1574
+ if ('region_id' == $fn) {
1575
+ $result[$addressIndex][$field] = Mage::getModel('directory/region')->load($result[$addressIndex][$field])->getCode();
1576
+ }
1577
+
1578
+ if (!$result[$addressIndex][$field] /*&& in_array($field, array('state', 'address', 'city','zipcode'))*/)
1579
+ {
1580
+ $result[$addressIndex][$field] = 'n/a';
1581
+ }
1582
+ }
1583
+
1584
+ $result[$addressIndex]['name'] = trim(
1585
+ $data->getData('firstname') . ' ' . $data->getData('lastname')
1586
+ );
1587
+ }
1588
+
1589
+ if($shippingIsEmpty){
1590
+ $result["shippingAddress"] = $result["billingAddress"];
1591
+ }
1592
+
1593
+ $cartItems = $quote->getAllVisibleItems();
1594
+
1595
+ // Set products
1596
+ foreach ($cartItems as $item) {
1597
+ $productId = $item->getProductId();
1598
+ $product = Mage::getModel('catalog/product')->load($productId);
1599
+ $price = ($minimalPayment) ? $minimalPayment : $product->getPrice();
1600
+ $quantity = ($minimalPayment) ? 1 :$item->getQty();
1601
+ $result['items'][] = array(
1602
+ 'sku' => $product->getData('sku'),
1603
+ 'name' => $product->getData('name'),
1604
+ 'price' => number_format($price, 2, '.',''),
1605
+ 'quantity' => intval($quantity),
1606
+ );
1607
+ }
1608
+
1609
+ if($isCardAuthorizePayment){
1610
+ $result['items'][] = array(
1611
+ 'sku' => "000000",
1612
+ 'name' => 'Card Authorize',
1613
+ 'price' => number_format($cardAuthorizeAmount, 2, '.',''),
1614
+ 'quantity' => intval(1),
1615
+ );
1616
+ }
1617
+
1618
+ return $result;
1619
+ }
1620
+
1621
+
1622
+ public function updateOrderByXpaymentResponse($orderId,$txnid){
1623
+ $result = array();
1624
+ $order = Mage::getModel('sales/order')->load($orderId);
1625
+ $order->setData('xpc_txnid', $txnid);
1626
+ /* update order by xpyament response state */
1627
+ list($status, $response) = $this->requestPaymentInfo($txnid);
1628
+ if (
1629
+ $status
1630
+ && in_array($response['status'], array(self::AUTH_STATUS, self::CHARGED_STATUS))
1631
+ ) {
1632
+ // TODO - save message - $response['message']
1633
+
1634
+ // TODO - process faud status
1635
+ /*
1636
+ if ($response['isFraudStatus']) {
1637
+ }
1638
+ */
1639
+ /**/
1640
+ if ($response['amount'] != number_format($order->getGrandTotal(), 2, '.','')) {
1641
+
1642
+ // Total wrong
1643
+ Mage::log(
1644
+ 'Order total amount doesn\'t match: Order total = ' . number_format($order->getGrandTotal(), 2, '.','')
1645
+ . ', X-Payments amount = ' . $response['amount'],
1646
+ Zend_Log::ERR
1647
+ );
1648
+ Mage::throwException('Transaction amount doesn\'t match.');
1649
+
1650
+ } elseif ($response['currency'] != $this->getCurrency()) {
1651
+
1652
+ // Currency wrong
1653
+ Mage::log(
1654
+ 'Order currency doesn\'t match: Order currency = ' . $this->getCurrency()
1655
+ . ', X-Payments currency = ' . $response['currency'],
1656
+ Zend_Log::ERR
1657
+ );
1658
+ Mage::throwException('Transaction currency doesn\'t match.');
1659
+
1660
+ } else {
1661
+
1662
+ $order->getPayment()->setTransactionId($txnid);
1663
+ $order->getPayment()->setLastTransId($txnid);
1664
+ if (isset($response['advinfo']) && isset($response['advinfo']['AVS'])) {
1665
+ $order->getPayment()->setCcAvsStatus($response['advinfo']['AVS']);
1666
+ }
1667
+
1668
+ if ($response['status'] == self::AUTH_ACTION) {
1669
+ $order->setState(
1670
+ Mage_Sales_Model_Order::STATE_PROCESSING,
1671
+ (bool)$order->getPayment()->getMethodInstance()->getConfigData('order_status'),
1672
+ Mage::helper('xpaymentsconnector')->__('preauthorize: Customer returned successfully')
1673
+ );
1674
+ $order->setStatus(Cdev_XPaymentsConnector_Helper_Data::STATE_XPAYMENT_PENDING_PAYMENT);
1675
+ }else{
1676
+ $order->setState(
1677
+ Mage_Sales_Model_Order::STATE_PROCESSING,
1678
+ (bool)$order->getPayment()->getMethodInstance()->getConfigData('order_status'),
1679
+ Mage::helper('xpaymentsconnector')->__('preauthorize: Customer returned successfully')
1680
+ );
1681
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
1682
+ }
1683
+ $order->save();
1684
+ $order->sendNewOrderEmail();
1685
+ }
1686
+ $result["success"] = true;
1687
+ return $result;
1688
+ }else{
1689
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder();
1690
+ $order->cancel();
1691
+ $order->addStatusToHistory(
1692
+ $order::STATE_CANCELED,
1693
+ Mage::helper('xpaymentsconnector')->__('charge: Callback request')
1694
+ );
1695
+ $order->save();
1696
+
1697
+ $result["success"] = false;
1698
+ if(!empty($response["error_message"])){
1699
+ $result["error_message"] = Mage::helper('xpaymentsconnector')->__('%s. The order has been canceled.',$response["error_message"]);
1700
+ }else{
1701
+ $transactionStatusLabel = $this->getTransactionStatusLabels();
1702
+ $result["error_message"] = Mage::helper('xpaymentsconnector')->__('Transaction status is "%s". The order has been canceled.',$transactionStatusLabel[$response['status']]);
1703
+ }
1704
+
1705
+ return $result;
1706
+ }
1707
+ /*end ( update order) */
1708
+
1709
+ }
1710
+
1711
+ /**
1712
+ * @param array $cardData
1713
+ * @param int $usageType
1714
+ * @return Mage_Core_Model_Abstract
1715
+ */
1716
+ public function saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::SIMPLE_CARD){
1717
+
1718
+ if(Mage::getSingleton('customer/session')->isLoggedIn()){
1719
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
1720
+ try
1721
+ {
1722
+ if (Mage::helper("xpaymentsconnector")->isNeedToSaveUserCard()) {
1723
+ $usercards = Mage::getModel("xpaymentsconnector/usercards");
1724
+ $usercards->setData(array(
1725
+ "user_id" => $customer->getId(),
1726
+ "txnId" => $cardData['txnId'],
1727
+ "last_4_cc_num" => $cardData['last_4_cc_num'],
1728
+ "card_type" => $cardData['card_type'],
1729
+ "usage_type" => $usageType)
1730
+ );
1731
+ return $usercards->save();
1732
+ }
1733
+ }
1734
+ catch(Exception $e)
1735
+ {
1736
+ echo $e->getMessage;exit;
1737
+ }
1738
+ }
1739
+
1740
+ }
1741
+
1742
+ public function authorizedTransactionRequest($action,$data){
1743
+ $data["target"] = "payment";
1744
+ list($status, $response) = $this->request('payment', $action, $data);
1745
+
1746
+ //****************stop*****************//
1747
+ if ( $status && (!empty($response['error_message']))) {
1748
+ Mage::throwException(Mage::helper('sales')->__($response['error_message']));
1749
+ }
1750
+
1751
+ }
1752
+
1753
+
1754
+ /**
1755
+ * Capture payment abstract method
1756
+ *
1757
+ * @param Varien_Object $payment
1758
+ * @param float $amount
1759
+ *
1760
+ * @return Mage_Payment_Model_Abstract
1761
+ */
1762
+ public function capture(Varien_Object $payment, $amount)
1763
+ {
1764
+ if (!$this->canCapture()) {
1765
+ Mage::throwException(Mage::helper('payment')->__('Capture action is not available.'));
1766
+ }
1767
+
1768
+ $order = $this->getOrder();
1769
+ $data = array(
1770
+ 'txnId' => $order->getData("xpc_txnid"),
1771
+ 'amount' => number_format($amount, 2, '.', ''),
1772
+ );
1773
+
1774
+ $this->authorizedTransactionRequest('capture', $data);
1775
+
1776
+
1777
+ return $this;
1778
+ }
1779
+
1780
+ /**
1781
+ * Refund specified amount for payment
1782
+ *
1783
+ * @param Varien_Object $payment
1784
+ * @param float $amount
1785
+ *
1786
+ * @return Mage_Payment_Model_Abstract
1787
+ */
1788
+ public function refund(Varien_Object $payment, $amount)
1789
+ {
1790
+
1791
+ if (!$this->canRefund()) {
1792
+ Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
1793
+ }
1794
+
1795
+ /*processing during create invoice*/
1796
+ $order = $this->getOrder();
1797
+ /*processing during capture invoice*/
1798
+ $data = array(
1799
+ 'txnId' => $order->getData("xpc_txnid"),
1800
+ 'amount' => number_format($amount, 2, '.', ''),
1801
+ );
1802
+
1803
+ $this->authorizedTransactionRequest('refund', $data);
1804
+
1805
+
1806
+ return $this;
1807
+ }
1808
+
1809
+ /**
1810
+ * Validate data
1811
+ *
1812
+ * @param Mage_Payment_Model_Recurring_Profile $profile
1813
+ * @throws Mage_Core_Exception
1814
+ */
1815
+ public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
1816
+
1817
+ }
1818
+
1819
+ /**
1820
+ * Submit to the gateway
1821
+ *
1822
+ * @param Mage_Payment_Model_Recurring_Profile $profile
1823
+ * @param Mage_Payment_Model_Info $paymentInfo
1824
+ */
1825
+ public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo)
1826
+ {
1827
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
1828
+ if($useIframe){
1829
+ $payDeferredSubscription = Mage::helper("xpaymentsconnector")->payDeferredSubscription($profile);
1830
+ if(!$payDeferredSubscription){
1831
+ $this->createFirstRecurringOrder($profile);
1832
+ }
1833
+
1834
+ }else{
1835
+ $updateSendData = array();
1836
+ $updateSendData['template'] = 'default';
1837
+ $xpaymentResponse = $this->sendIframeHandshakeRequest($updateSendData);
1838
+
1839
+ if(isset($xpaymentResponse["success"]) && !$xpaymentResponse["success"]){
1840
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
1841
+ }
1842
+ }
1843
+
1844
+ }
1845
+
1846
+ /**
1847
+ * Fetch details
1848
+ *
1849
+ * @param string $referenceId
1850
+ * @param Varien_Object $result
1851
+ */
1852
+ public function getRecurringProfileDetails($referenceId, Varien_Object $result){
1853
+ // TODO
1854
+ }
1855
+
1856
+ /**
1857
+ * Check whether can get recurring profile details
1858
+ *
1859
+ * @return bool
1860
+ */
1861
+ public function canGetRecurringProfileDetails(){
1862
+ return false;
1863
+ }
1864
+
1865
+ /**
1866
+ * Update data
1867
+ *
1868
+ * @param Mage_Payment_Model_Recurring_Profile $profile
1869
+ */
1870
+ public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
1871
+ // TODO
1872
+ }
1873
+
1874
+ /**
1875
+ * Manage status
1876
+ *
1877
+ * @param Mage_Payment_Model_Recurring_Profile $profile
1878
+ */
1879
+ public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile){
1880
+ return false;
1881
+
1882
+ }
1883
+
1884
+ /**
1885
+ * @return array
1886
+ */
1887
+ public function getTransactionStatusLabels(){
1888
+ $statuses = array(
1889
+ self::NEW_STATUS => "New",
1890
+ self::AUTH_STATUS => "Authorized",
1891
+ self::DECLINED_STATUS => "Declined",
1892
+ self::CHARGED_STATUS => "Charged",
1893
+ );
1894
+ return $statuses;
1895
+ }
1896
+
1897
+ /**
1898
+ *
1899
+ * @param Mage_Payment_Model_Recurring_Profile $profile
1900
+ */
1901
+ public function createFirstRecurringOrder(Mage_Payment_Model_Recurring_Profile $profile){
1902
+ $cardData = Mage::helper("xpaymentsconnector")->getXpaymentResponse();
1903
+ $orderId = Mage::helper("xpaymentsconnector")->createOrder($profile,$isFirstRecurringOrder = true);
1904
+
1905
+ /*update order by card data*/
1906
+ $order = Mage::getModel('sales/order')->load($orderId);
1907
+ $order->setData("xp_card_data", serialize($cardData));
1908
+ $order->save();
1909
+
1910
+ $profile->setReferenceId($cardData["txnId"]);
1911
+ $result = $this->updateOrderByXpaymentResponse($orderId, $cardData["txnId"]);
1912
+
1913
+ if (!$result["success"]) {
1914
+ Mage::getSingleton("checkout/session")->addError($result["error_message"]);
1915
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
1916
+ } else {
1917
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
1918
+ // additional subscription profile setting for success transaction
1919
+ $newTransactionDate = new Zend_Date(time());
1920
+ $profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
1921
+ $profile->setXpCountSuccessTransaction(1);
1922
+ //save user card
1923
+ Mage::getSingleton("checkout/session")->setData("user_card_save",true);
1924
+ $this->saveUserCard($cardData,$usageType = Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD);
1925
+
1926
+ }
1927
+ return $profile;
1928
+ }
1929
+
1930
+ }
1931
+
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Prepaidpayments.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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 ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * DISCLAIMER
16
+ *
17
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
18
+ * versions in the future. If you wish to customize Magento for your
19
+ * needs please refer to http://www.magentocommerce.com for more information.
20
+ *
21
+ * @category Mage
22
+ * @package Mage_Payment
23
+ * @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
25
+ */
26
+
27
+ /**
28
+ * Recurring payment profile
29
+ * Extends from Mage_Core_Abstract for a reason: to make descendants have its own resource
30
+ */
31
+ class Cdev_XPaymentsConnector_Model_Payment_Recurring_Profile extends Mage_Payment_Model_Recurring_Profile
32
+ {
33
+
34
+ public function exportScheduleInfo()
35
+ {
36
+ $result = array(
37
+ new Varien_Object(array(
38
+ 'title' => Mage::helper('payment')->__('Billing Period'),
39
+ 'schedule' => $this->_renderSchedule('period_unit', 'period_frequency', 'period_max_cycles',"init_amount"),
40
+ ))
41
+ );
42
+ $trial = $this->_renderSchedule('trial_period_unit', 'trial_period_frequency', 'trial_period_max_cycles');
43
+ if ($trial) {
44
+ $result[] = new Varien_Object(array(
45
+ 'title' => Mage::helper('payment')->__('Trial Period'),
46
+ 'schedule' => $trial,
47
+ ));
48
+ }
49
+ return $result;
50
+ }
51
+
52
+ protected function _renderSchedule($periodKey, $frequencyKey, $cyclesKey,$initKey = null)
53
+ {
54
+ $result = array();
55
+
56
+ $period = $this->_getData($periodKey);
57
+ $frequency = (int)$this->_getData($frequencyKey);
58
+ if (!$period || !$frequency) {
59
+ return $result;
60
+ }
61
+ if (self::PERIOD_UNIT_SEMI_MONTH == $period) {
62
+ $frequency = '';
63
+ }
64
+
65
+ $result[] = Mage::helper('payment')->__('%s %s cycle.', $frequency, $this->getPeriodUnitLabel($period));
66
+
67
+ $cycles = (int)$this->_getData($cyclesKey);
68
+
69
+ if ($cycles) {
70
+ $result[] = Mage::helper('payment')->__('Repeats %s time(s).', $cycles);
71
+ } else {
72
+ $result[] = Mage::helper('payment')->__('Repeats until suspended or canceled.');
73
+ }
74
+ $init = $this->_getData($initKey);
75
+ if($init){
76
+ $result[] = Mage::helper('xpaymentsconnector')->__('Initial Fee %s.', Mage::helper('core')->currency($init,true,false));
77
+ }
78
+
79
+ return $result;
80
+ }
81
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Payment/Savedcards.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+
49
+
50
+ /**
51
+ * Get order
52
+ *
53
+ * @return Mage_Sales_Model_Order
54
+ * @access public
55
+ * @see ____func_see____
56
+ * @since 1.0.0
57
+ */
58
+ public function getOrder()
59
+ {
60
+ if (!$this->_order) {
61
+ $this->_order = $this->getInfoInstance()->getOrder();
62
+ }
63
+
64
+ return $this->_order;
65
+ }
66
+
67
+ /**
68
+ * Capture payment abstract method
69
+ *
70
+ * @param Varien_Object $payment
71
+ * @param float $amount
72
+ *
73
+ * @return Mage_Payment_Model_Abstract
74
+ */
75
+ public function capture(Varien_Object $payment, $amount)
76
+ {
77
+
78
+ if (!$this->canCapture()) {
79
+ Mage::throwException(Mage::helper('payment')->__('Capture action is not available.'));
80
+ }
81
+
82
+ $order = $this->getOrder();
83
+ $data = array(
84
+ 'txnId' => $order->getData("xpc_txnid"),
85
+ 'amount' => number_format($amount, 2, '.', ''),
86
+ );
87
+
88
+ Mage::getModel("xpaymentsconnector/payment_cc")->authorizedTransactionRequest('capture', $data);
89
+
90
+
91
+ return $this;
92
+ }
93
+
94
+
95
+ public function refund(Varien_Object $payment, $amount)
96
+ {
97
+
98
+ if (!$this->canRefund()) {
99
+ Mage::throwException(Mage::helper('payment')->__('Refund action is not available.'));
100
+ }
101
+
102
+ /*processing during create invoice*/
103
+ $order = $this->getOrder();
104
+ /*processing during capture invoice*/
105
+ $data = array(
106
+ 'txnId' => $order->getData("xpc_txnid"),
107
+ 'amount' => number_format($amount, 2, '.', ''),
108
+ );
109
+
110
+ Mage::getModel("xpaymentsconnector/payment_cc")->authorizedTransactionRequest('refund', $data);
111
+
112
+ return $this;
113
+ }
114
+
115
+
116
+ /**
117
+ * Validate data
118
+ *
119
+ * @param Mage_Payment_Model_Recurring_Profile $profile
120
+ * @throws Mage_Core_Exception
121
+ */
122
+ public function validateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
123
+
124
+ }
125
+
126
+ /**
127
+ * Submit to the gateway
128
+ *
129
+ * @param Mage_Payment_Model_Recurring_Profile $profile
130
+ * @param Mage_Payment_Model_Info $paymentInfo
131
+ */
132
+ public function submitRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile, Mage_Payment_Model_Info $paymentInfo){
133
+
134
+ $orderItemInfo = $profile->getData("order_item_info");
135
+ $payDeferredSubscription = Mage::helper("xpaymentsconnector")->payDeferredSubscription($profile);
136
+ if(!$payDeferredSubscription){
137
+ $grandTotal = $orderItemInfo["nominal_row_total"];
138
+
139
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
140
+ $paymentCardNumber = $quote->getPayment()->getData("xp_payment_card");
141
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber);
142
+ $txnid = $cardData->getData("txnId");
143
+ if($txnid){
144
+ $profile->setReferenceId($txnid);
145
+ $orderId = Mage::helper("xpaymentsconnector")->createOrder($profile,$isFirstRecurringOrder = true);
146
+ $response = Mage::getModel("xpaymentsconnector/payment_cc")->sendAgainTransactionRequest($orderId, NULL, $grandTotal);
147
+
148
+ if ($response["success"]) {
149
+ $result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($orderId, $response["response"]['transaction_id']);
150
+ if (!$result["success"]) {
151
+ Mage::getSingleton("checkout/session")->addError($result["error_message"]);
152
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
153
+ } else {
154
+ // additional subscription profile setting for success transaction
155
+ $newTransactionDate = new Zend_Date(time());
156
+ $profile->setXpSuccessTransactionDate($newTransactionDate->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
157
+ $profile->setXpCountSuccessTransaction(1);
158
+
159
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE);
160
+ }
161
+
162
+ } else {
163
+ Mage::getSingleton("checkout/session")->addError($response["error_message"]);
164
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
165
+ }
166
+ }
167
+ }
168
+
169
+
170
+ }
171
+
172
+ /**
173
+ * Fetch details
174
+ *
175
+ * @param string $referenceId
176
+ * @param Varien_Object $result
177
+ */
178
+ public function getRecurringProfileDetails($referenceId, Varien_Object $result){
179
+ // TODO
180
+ }
181
+
182
+ /**
183
+ * Check whether can get recurring profile details
184
+ *
185
+ * @return bool
186
+ */
187
+ public function canGetRecurringProfileDetails(){
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Update data
193
+ *
194
+ * @param Mage_Payment_Model_Recurring_Profile $profile
195
+ */
196
+ public function updateRecurringProfile(Mage_Payment_Model_Recurring_Profile $profile){
197
+ // TODO
198
+ }
199
+
200
+ /**
201
+ * Manage status
202
+ *
203
+ * @param Mage_Payment_Model_Recurring_Profile $profile
204
+ */
205
+ public function updateRecurringProfileStatus(Mage_Payment_Model_Recurring_Profile $profile){
206
+ // TODO
207
+ }
208
+
209
+ }
210
+
app/code/community/Cdev/XPaymentsConnector/Model/Paymentconfiguration.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+
30
+ class Cdev_XPaymentsConnector_Model_Paymentconfiguration extends Mage_Core_Model_Abstract
31
+ {
32
+ /**
33
+ * Internal constructor
34
+ *
35
+ * @return void
36
+ * @access protected
37
+ * @see ____func_see____
38
+ * @since 1.0.0
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_init('xpaymentsconnector/paymentconfiguration');
43
+ }
44
+ }
45
+
app/code/community/Cdev/XPaymentsConnector/Model/Quote.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ if ($reservedOrderId) {
29
+ return $reservedOrderId;
30
+ }
31
+ else{
32
+ return parent::getReservedOrderId();
33
+ }
34
+ }
35
+ }
36
+
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal.php ADDED
@@ -0,0 +1,87 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Rewrite nominal items total
24
+ * Collects only items segregated by isNominal property
25
+ * Aggregates row totals per item
26
+ */
27
+ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal extends Mage_Sales_Model_Quote_Address_Total_Nominal
28
+ {
29
+ /**
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
+ $collector = Mage::getSingleton('sales/quote_address_total_nominal_collector',
38
+ array('store' => $address->getQuote()->getStore())
39
+ );
40
+
41
+ // invoke nominal totals
42
+ foreach ($collector->getCollectors() as $model) {
43
+ $model->collect($address);
44
+ }
45
+
46
+ // aggregate collected amounts into one to have sort of grand total per item
47
+ $totals = array();
48
+ foreach ($address->getAllNominalItems() as $item) {
49
+ $rowTotal = 0;
50
+ $baseRowTotal = 0;
51
+ $totalDetails = array();
52
+ foreach ($collector->getCollectors() as $model) {
53
+ $itemRowTotal = $model->getItemRowTotal($item);
54
+ if ($model->getIsItemRowTotalCompoundable($item)) {
55
+ $totals[] = $itemRowTotal;
56
+ if ($model->getCode() == "recurring_discount") {
57
+ $rowTotal -= $itemRowTotal;
58
+ $baseRowTotal -= $model->getItemBaseRowTotal($item);
59
+ } else {
60
+ $rowTotal += $itemRowTotal;
61
+ $baseRowTotal += $model->getItemBaseRowTotal($item);
62
+ }
63
+ $isCompounded = true;
64
+ } else {
65
+ $isCompounded = false;
66
+ }
67
+ if ((float)$itemRowTotal > 0 && $label = $model->getLabel()) {
68
+ if ($model->getCode() == "recurring_discount") {
69
+ $itemRowTotal = -$itemRowTotal;
70
+ }
71
+ $totalDetails[] = new Varien_Object(array(
72
+ 'label' => $label,
73
+ 'amount' => $itemRowTotal,
74
+ 'is_compounded' => $isCompounded,
75
+ ));
76
+ }
77
+ }
78
+
79
+ $item->setNominalRowTotal($rowTotal);
80
+ $item->setBaseNominalRowTotal($baseRowTotal);
81
+ $item->setNominalTotalDetails($totalDetails);
82
+ }
83
+
84
+ return $this;
85
+ }
86
+
87
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Quote/Address/Total/Nominal/Recurring/Discount.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Total model for recurring profile discount
24
+ */
25
+ class Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal_Recurring_Discount
26
+ extends Mage_Sales_Model_Quote_Address_Total_Nominal_RecurringAbstract
27
+ {
28
+ /**
29
+ * Custom row total/profile keys
30
+ *
31
+ * @var string
32
+ */
33
+ protected $_itemRowTotalKey = 'recurring_discount';
34
+ protected $_profileDataKey = 'discount_amount';
35
+
36
+ /**
37
+ * Get initial fee label
38
+ *
39
+ * @return string
40
+ */
41
+ public function getLabel()
42
+ {
43
+ return Mage::helper('sales')->__('Discount');
44
+ }
45
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Sales/Recurring/Profile.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ class Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile extends Mage_Sales_Model_Recurring_Profile {
23
+
24
+ /**
25
+ * Determine nearest possible profile start date
26
+ *
27
+ * @param Zend_Date $minAllowed
28
+ * @return Mage_Payment_Model_Recurring_Profile
29
+ */
30
+ public function setNearestStartDatetime(Zend_Date $minAllowed = null)
31
+ {
32
+ $paymentMethodCode = $this->getMethodCode();
33
+
34
+ $isXpaymentMethod = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentMethodCode);
35
+ if($isXpaymentMethod){
36
+ $date = $minAllowed;
37
+ if (!$date) {
38
+ $date = new Zend_Date(time());
39
+ }
40
+ $this->setStartDatetime($date->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
41
+ return $this;
42
+
43
+ }
44
+ return parent::setNearestStartDatetime($minAllowed);
45
+ }
46
+
47
+
48
+ public function createOrder()
49
+ {
50
+ $items = array();
51
+ $itemInfoObjects = func_get_args();
52
+
53
+ $billingAmount = 0;
54
+ $shippingAmount = 0;
55
+ $taxAmount = 0;
56
+ $isVirtual = 1;
57
+ $weight = 0;
58
+ $discountAmount = 0;
59
+ foreach ($itemInfoObjects as $itemInfo) {
60
+ $item = $this->_getItem($itemInfo);
61
+ $billingAmount += $item->getPrice();
62
+ $shippingAmount += $item->getShippingAmount();
63
+ $taxAmount += $item->getTaxAmount();
64
+ $discountAmount -= $itemInfo->getDiscountAmount();
65
+ $weight += $item->getWeight();
66
+ if (!$item->getIsVirtual()) {
67
+ $isVirtual = 0;
68
+ }
69
+ $items[] = $item;
70
+ }
71
+
72
+ $grandTotal = $billingAmount + $shippingAmount + $taxAmount + $discountAmount;
73
+
74
+ $order = Mage::getModel('sales/order');
75
+
76
+ $billingAddressInfo = $this->getBillingAddressInfo();
77
+ // add check for recurring profile order
78
+ if(!is_array($billingAddressInfo)){
79
+ $billingAddressInfo = unserialize($billingAddressInfo);
80
+ }
81
+ $billingAddress = Mage::getModel('sales/order_address')
82
+ ->setData($billingAddressInfo)
83
+ ->setId(null);
84
+
85
+ $shippingInfo = $this->getShippingAddressInfo();
86
+ // add check for recurring profile order
87
+ if(!is_array($shippingInfo)){
88
+ $shippingInfo = unserialize($shippingInfo);
89
+ }
90
+
91
+ $shippingAddress = Mage::getModel('sales/order_address')
92
+ ->setData($shippingInfo)
93
+ ->setId(null);
94
+
95
+ $payment = Mage::getModel('sales/order_payment')
96
+ ->setMethod($this->getMethodCode());
97
+
98
+ $transferDataKays = array(
99
+ 'store_id', 'store_name', 'customer_id', 'customer_email',
100
+ 'customer_firstname', 'customer_lastname', 'customer_middlename', 'customer_prefix',
101
+ 'customer_suffix', 'customer_taxvat', 'customer_gender', 'customer_is_guest',
102
+ 'customer_note_notify', 'customer_group_id', 'customer_note', 'shipping_method',
103
+ 'shipping_description', 'base_currency_code', 'global_currency_code', 'order_currency_code',
104
+ 'store_currency_code', 'base_to_global_rate', 'base_to_order_rate', 'store_to_base_rate',
105
+ 'store_to_order_rate'
106
+ );
107
+
108
+ $orderInfo = $this->getOrderInfo();
109
+
110
+ // add check for recurring profile order
111
+ if(!is_array($orderInfo)){
112
+ $orderInfo = unserialize($orderInfo);
113
+ }
114
+
115
+ foreach ($transferDataKays as $key) {
116
+ if (isset($orderInfo[$key])) {
117
+ $order->setData($key, $orderInfo[$key]);
118
+ } elseif (isset($shippingInfo[$key])) {
119
+ $order->setData($key, $shippingInfo[$key]);
120
+ }
121
+ }
122
+
123
+ $order->setStoreId($this->getStoreId())
124
+ ->setState(Mage_Sales_Model_Order::STATE_NEW)
125
+ ->setBaseToOrderRate($orderInfo['base_to_quote_rate'])
126
+ ->setStoreToOrderRate($orderInfo['store_to_quote_rate'])
127
+ ->setOrderCurrencyCode($orderInfo['quote_currency_code'])
128
+ ->setBaseSubtotal($billingAmount)
129
+ ->setSubtotal($billingAmount)
130
+ ->setBaseShippingAmount($shippingAmount)
131
+ ->setShippingAmount($shippingAmount)
132
+ ->setBaseTaxAmount($taxAmount)
133
+ ->setTaxAmount($taxAmount)
134
+ ->setDiscountAmount($discountAmount)
135
+ ->setBaseDiscountAmount($discountAmount)
136
+ ->setBaseGrandTotal($grandTotal)
137
+ ->setGrandTotal($grandTotal)
138
+ ->setIsVirtual($isVirtual)
139
+ ->setWeight($weight)
140
+ ->setTotalQtyOrdered($orderInfo['items_qty'])
141
+ ->setBillingAddress($billingAddress)
142
+ ->setShippingAddress($shippingAddress)
143
+ ->setPayment($payment);
144
+
145
+ foreach ($items as $item) {
146
+ $order->addItem($item);
147
+ }
148
+
149
+ return $order;
150
+ }
151
+
152
+
153
+ /**
154
+ * Check whether the workflow allows to suspend the profile
155
+ *
156
+ * @return bool
157
+ */
158
+ public function canSuspend()
159
+ {
160
+ $paymentMethodCode = $this->getMethodCode();
161
+ $isXpaymentMethod = Mage::helper("xpaymentsconnector")->isXpaymentsMethod($paymentMethodCode);
162
+ if($isXpaymentMethod){
163
+ return false;
164
+ }else{
165
+ return parent::canSuspend();
166
+ }
167
+
168
+ }
169
+
170
+ /**
171
+ * Create and return new order item based on profile item data and $itemInfo
172
+ * for regular payment
173
+ *
174
+ * @param Varien_Object $itemInfo
175
+ * @return Mage_Sales_Model_Order_Item
176
+ */
177
+ protected function _getRegularItem($itemInfo)
178
+ {
179
+ $price = $itemInfo->getPrice() ? $itemInfo->getPrice() : $this->getBillingAmount();
180
+ $shippingAmount = $itemInfo->getShippingAmount() ? $itemInfo->getShippingAmount() : $this->getShippingAmount();
181
+ $taxAmount = $itemInfo->getTaxAmount() ? $itemInfo->getTaxAmount() : $this->getTaxAmount();
182
+ $orderItemInfo = $this->getOrderItemInfo();
183
+ if(!is_array($orderItemInfo)){
184
+ $orderItemInfo = unserialize($orderItemInfo);
185
+ }
186
+
187
+ $item = Mage::getModel('sales/order_item')
188
+ ->setData($orderItemInfo)
189
+ ->setQtyOrdered($orderItemInfo['qty'])
190
+ ->setBaseOriginalPrice($orderItemInfo['price'])
191
+ ->setPrice($price)
192
+ ->setBasePrice($price)
193
+ ->setRowTotal($price)
194
+ ->setBaseRowTotal($price)
195
+ ->setTaxAmount($taxAmount)
196
+ ->setShippingAmount($shippingAmount)
197
+ ->setId(null);
198
+ return $item;
199
+ }
200
+
201
+
202
+
203
+
204
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Source/Paymentconfiguration.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Payment configuration data source
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_Model_Source_Paymentconfiguration
30
+ {
31
+ /**
32
+ * Options (cache)
33
+ *
34
+ * @var array
35
+ * @access protected
36
+ * @see ____var_see____
37
+ * @since 1.0.0
38
+ */
39
+ protected $_options = null;
40
+
41
+ /**
42
+ * Get data as option array
43
+ *
44
+ * @return array
45
+ * @access public
46
+ * @see ____func_see____
47
+ * @since 1.0.0
48
+ */
49
+ public function toOptionArray()
50
+ {
51
+ if (!$this->_options) {
52
+ $this->_options = Mage::getModel('xpaymentsconnector/paymentconfiguration')
53
+ ->getCollection()
54
+ ->toOptionArray();
55
+ }
56
+
57
+ return $this->_options;
58
+ }
59
+
60
+ }
app/code/community/Cdev/XPaymentsConnector/Model/Usercards.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
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
+ *
35
+ * @return void
36
+ * @access protected
37
+ * @see ____func_see____
38
+ * @since 1.0.0
39
+ */
40
+ protected function _construct()
41
+ {
42
+ $this->_init('xpaymentsconnector/usercards');
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
+
app/code/community/Cdev/XPaymentsConnector/controllers/Adminhtml/CustomerController.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
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
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/ControlController.php ADDED
@@ -0,0 +1,194 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * X-Payment connector management page controller
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_ControlController extends Mage_Adminhtml_Controller_Action
30
+ {
31
+ /**
32
+ * General action
33
+ *
34
+ * @return void
35
+ * @access public
36
+ * @see ____func_see____
37
+ * @since 1.0.0
38
+ */
39
+ public function indexAction()
40
+ {
41
+ $this->_title($this->__('System'))->_title($this->__('X-Payments connector control'));
42
+
43
+ $this->loadLayout();
44
+
45
+ $this->_setActiveMenu('system');
46
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('System'), Mage::helper('adminhtml')->__('System'));
47
+ $this->_addBreadcrumb(Mage::helper('adminhtml')->__('X-Payments connector control'), Mage::helper('adminhtml')->__('X-Payments connector control'));
48
+
49
+ $block = $this->getLayout()->createBlock('xpaymentsconnector/control');
50
+ $this->_addContent($block);
51
+
52
+ $this->renderLayout();
53
+ }
54
+
55
+ /**
56
+ * Test connection to X-Payments
57
+ *
58
+ * @return void
59
+ * @access public
60
+ * @see ____func_see____
61
+ * @since 1.0.0
62
+ */
63
+ public function testAction()
64
+ {
65
+ $session = Mage::getSingleton('adminhtml/session');
66
+
67
+ $model = Mage::getModel('xpaymentsconnector/payment_cc');
68
+
69
+ try {
70
+ if ($model->sendTestRequest()) {
71
+ $session->addSuccess(Mage::helper('adminhtml')->__('The test transaction has been completed successfully.'));
72
+
73
+ } else {
74
+ $session->addError(Mage::helper('adminhtml')->__('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.'));
75
+ }
76
+
77
+ } catch (Exception $e) {
78
+ $session->addException($e, '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.');
79
+ }
80
+
81
+ $this->_redirect('*/*/index');
82
+ }
83
+
84
+ /**
85
+ * Request and import payment configurations from X-Payments
86
+ *
87
+ * @return void
88
+ * @access public
89
+ * @see ____func_see____
90
+ * @since 1.0.0
91
+ */
92
+ public function requestAction()
93
+ {
94
+ $session = Mage::getSingleton('adminhtml/session');
95
+
96
+ $model = Mage::getModel('xpaymentsconnector/payment_cc');
97
+
98
+ $this->deleteAllPaymentConfigurations();
99
+ $store = Mage::app()->getStore(null)->getCode();
100
+ Mage::getConfig()->saveConfig('stores/' . $store . '/payment/xpayments/active', 0);
101
+
102
+ try {
103
+ $list = $model->requestPaymentMethods();
104
+ if ($list) {
105
+ foreach ($list as $data) {
106
+ $pc = Mage::getModel('xpaymentsconnector/paymentconfiguration')->setData(
107
+ array(
108
+ 'confid' => $data['id'],
109
+ 'name' => $data['name'],
110
+ 'module' => $data['moduleName'],
111
+ 'auth_exp' => $data['authCaptureInfo']['authExp'],
112
+ 'capture_min' => $data['authCaptureInfo']['captMinLimit'],
113
+ 'capture_max' => $data['authCaptureInfo']['captMaxLimit'],
114
+ 'hash' => $data['settingsHash'],
115
+ 'is_auth' => $data['transactionTypes']['auth'],
116
+ 'is_capture' => $data['transactionTypes']['capture'],
117
+ 'is_void' => $data['transactionTypes']['void'],
118
+ 'is_refund' => $data['transactionTypes']['refund'],
119
+ 'is_part_refund' => $data['transactionTypes']['refundPart'],
120
+ 'is_accept' => $data['transactionTypes']['accept'],
121
+ 'is_decline' => $data['transactionTypes']['decline'],
122
+ 'is_get_info' => $data['transactionTypes']['getInfo'],
123
+
124
+ )
125
+ );
126
+
127
+ $pc->save();
128
+
129
+ }
130
+
131
+ $session->addSuccess(Mage::helper('adminhtml')->__('Payment methods have been successfully imported.'));
132
+
133
+ } elseif (is_array($list)) {
134
+ $session->addError(Mage::helper('adminhtml')->__('There are no payment configurations for this store.'));
135
+ } else {
136
+ $session->addError(Mage::helper('adminhtml')->__('An error has occured during requesting payment methods from X-Payments. See log files for details.'));
137
+ }
138
+
139
+ } catch (Exception $e) {
140
+ $session->addException($e, 'An error has occured during requesting payment methods from X-Payments. See log files for details.');
141
+ }
142
+
143
+ $this->_redirect('*/*/index');
144
+ }
145
+
146
+ /**
147
+ * Clear imported payment configurations
148
+ *
149
+ * @return void
150
+ * @access public
151
+ * @see ____func_see____
152
+ * @since 1.0.0
153
+ */
154
+ public function clearAction()
155
+ {
156
+ $this->deleteAllPaymentConfigurations();
157
+ $store = Mage::app()->getStore(null)->getCode();
158
+ Mage::getConfig()->saveConfig('stores/' . $store . '/payment/xpayments/active', 0);
159
+
160
+ Mage::getSingleton('adminhtml/session')->addSuccess(
161
+ Mage::helper('adminhtml')->__('The list of imported payment configurations has been cleared. X-Payments connector payment method has been disabled.')
162
+ );
163
+
164
+ $this->_redirect('*/*/index');
165
+ }
166
+
167
+
168
+ /**
169
+ * Delete all payment configurations
170
+ *
171
+ * @return void
172
+ * @access protected
173
+ * @see ____func_see____
174
+ * @since 1.0.0
175
+ */
176
+
177
+ protected function deleteAllPaymentConfigurations()
178
+ {
179
+ try {
180
+ $list = Mage::getModel('xpaymentsconnector/paymentconfiguration')->getCollection();
181
+ if ($list) {
182
+ foreach ($list as $item) {
183
+ $item->delete();
184
+ }
185
+ }
186
+
187
+ } catch (Exception $e) {
188
+ Mage::log(
189
+ sprintf('Couldn\'t delete payment configuration. [%s]', var_export($item, true)),
190
+ Zend_Log::ERR
191
+ );
192
+ }
193
+ }
194
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/CustomerController.php ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Customer account controller
24
+ */
25
+
26
+ class Cdev_XPaymentsConnector_CustomerController extends Mage_Core_Controller_Front_Action
27
+ {
28
+
29
+ /**
30
+ * Check customer authentication
31
+ */
32
+ public function preDispatch()
33
+ {
34
+ parent::preDispatch();
35
+ $action = $this->getRequest()->getActionName();
36
+ $loginUrl = Mage::helper('customer')->getLoginUrl();
37
+
38
+ if (!Mage::getSingleton('customer/session')->authenticate($this, $loginUrl)) {
39
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Display downloadable links bought by customer
45
+ *
46
+ */
47
+ public function usercardsAction()
48
+ {
49
+ $request = $this->getRequest()->getPost();
50
+ if (!empty($request)) {
51
+ if ($request["action"] == "remove") {
52
+ if (count($request["card"]) > 0) {
53
+
54
+ $itemCollection = Mage::getModel("xpaymentsconnector/usercards")
55
+ ->getCollection()
56
+ ->addFieldToFilter('xp_card_id', array('in' => $request["card"]));
57
+ foreach ($itemCollection as $item) {
58
+ if ($item->getUsageType() == Cdev_XPaymentsConnector_Model_Usercards::RECURRING_CARD) {
59
+ $txnId = $item->getData("txnId");
60
+ $recurringProfile = Mage::getModel('sales/recurring_profile')->load($txnId,"reference_id");
61
+ if($recurringProfile->getState() == Mage_Sales_Model_Recurring_Profile::STATE_ACTIVE){
62
+ $errorMessage = Mage::helper("xpaymentsconnector")->__("You can't delete %s card. Because this is recurring card and this recurring is still active.",$item->getXpCardId());
63
+ Mage::getSingleton("customer/session")->addError($errorMessage);
64
+ continue;
65
+ }
66
+ }
67
+ $item->delete();
68
+ }
69
+ $message = $this->__('Credit cards have been removed successfully.');
70
+ Mage::getSingleton("customer/session")->addSuccess($message);
71
+ } else {
72
+ $message = $this->__('You have not selected any credit card.');
73
+ Mage::getSingleton("customer/session")->addError($message);
74
+ }
75
+ }
76
+ }
77
+
78
+
79
+ $this->loadLayout();
80
+ $this->_initLayoutMessages('customer/session');
81
+ if ($block = $this->getLayout()->getBlock('xpaymentsconnector_customer_usercards')) {
82
+ $block->setRefererUrl($this->_getRefererUrl());
83
+ }
84
+ $headBlock = $this->getLayout()->getBlock('head');
85
+ if ($headBlock) {
86
+ $headBlock->setTitle(Mage::helper('xpaymentsconnector')->__('My Payment Cards'));
87
+ }
88
+ $this->renderLayout();
89
+ }
90
+
91
+
92
+ public function cardaddAction(){
93
+
94
+ $isPostResponse = $this->getRequest()->isPost();
95
+ if($isPostResponse){
96
+ // Check request data
97
+ $request = $this->getRequest()->getPost();
98
+
99
+ if (empty($request)) {
100
+ Mage::throwException('Request doesn\'t contain POST elements.');
101
+ }
102
+
103
+ // check txn id
104
+ if (empty($request['txnId'])) {
105
+ Mage::throwException('Missing or invalid transaction ID');
106
+ }
107
+
108
+ $CCPaymentModel = Mage::getModel("xpaymentsconnector/payment_cc");
109
+ $transactionStatusLabel = $CCPaymentModel->getTransactionStatusLabels();
110
+ $resultMessage = "";
111
+
112
+ list($status, $response) = $CCPaymentModel->requestPaymentInfo($request['txnId']);
113
+
114
+ if (
115
+ !$status
116
+ || !in_array($response['status'], array($CCPaymentModel::AUTH_STATUS, $CCPaymentModel::CHARGED_STATUS))
117
+ ) {
118
+ $errorMessage = $this->__("Transaction status is '%s'. Card authorization has been cancelled.",$transactionStatusLabel[$response['status']]);
119
+ Mage::getSingleton("customer/session")->addError($errorMessage);
120
+ $resultMessage = "Card authorization has been cancelled.";
121
+ }else{
122
+ // save user card
123
+ Mage::getSingleton("checkout/session")->setData("user_card_save",true);
124
+ $newCardData = $CCPaymentModel->saveUserCard($request);
125
+ Mage::getSingleton("checkout/session")->unsetData("user_card_save");
126
+ $resultMessage = $this->__("Payment card has been added successfully!");
127
+
128
+ Mage::getSingleton("customer/session")->addSuccess( $this->__("You created card number '%s'. Transaction status is '%s'.",$newCardData->getData("xp_card_id"),$transactionStatusLabel[$response['status']]));
129
+ }
130
+
131
+ $this->getResponse()->setBody(
132
+ $this->getLayout()
133
+ ->createBlock('xpaymentsconnector/customer_success')->setData("result_message",$resultMessage)
134
+ ->toHtml()
135
+ );
136
+ return;
137
+ }
138
+
139
+ $this->loadLayout();
140
+ $this->_initLayoutMessages('customer/session');
141
+ if ($block = $this->getLayout()->getBlock('xpaymentsconnector_customer_cardadd')) {
142
+ $block->setRefererUrl($this->_getRefererUrl());
143
+ }
144
+ $headBlock = $this->getLayout()->getBlock('head');
145
+ if ($headBlock) {
146
+ $headBlock->setTitle(Mage::helper('xpaymentsconnector')->__('Add new credit card to list (X-Payments)'));
147
+ }
148
+ $this->renderLayout();
149
+ }
150
+
151
+ }
app/code/community/Cdev/XPaymentsConnector/controllers/ProcessingController.php ADDED
@@ -0,0 +1,577 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Process payment controller
24
+ *
25
+ * @package Cdev_XPaymentsConnector
26
+ * @see ____class_see____
27
+ * @since 1.0.0
28
+ */
29
+ class Cdev_XPaymentsConnector_ProcessingController extends Mage_Core_Controller_Front_Action
30
+ {
31
+ /**
32
+ * Get checkout session
33
+ *
34
+ * @return object
35
+ * @access protected
36
+ * @see ____func_see____
37
+ * @since 1.0.0
38
+ */
39
+ protected function _getCheckout()
40
+ {
41
+ return Mage::getSingleton('checkout/session');
42
+ }
43
+
44
+ /**
45
+ * Start payment (handshake + redirect to X-Payments)
46
+ *
47
+ * @return void
48
+ * @access public
49
+ * @see ____func_see____
50
+ * @since 1.0.0
51
+ */
52
+ public function redirectAction()
53
+ {
54
+ try {
55
+ $session = $this->_getCheckout();
56
+
57
+ // Get order id
58
+ $order = Mage::getModel('sales/order');
59
+ $orderId = $session->getLastRealOrderId();
60
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
61
+
62
+ if($orderId){
63
+
64
+ $order->loadByIncrementId($session->getLastRealOrderId());
65
+
66
+ $result = $api->sendHandshakeRequest($order);
67
+
68
+ if (!$result) {
69
+ $this->_getCheckout()->addError('Failed to complete the payment transaction. Please use another payment method or contact the store administrator.');
70
+
71
+ } else {
72
+
73
+ // Update order
74
+ if ($order->getState() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
75
+ $order->setState(
76
+ Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
77
+ (bool)Mage_Sales_Model_Order::STATE_PENDING_PAYMENT,
78
+ Mage::helper('xpaymentsconnector')->__('Customer has been redirected to X-Payments.')
79
+ )->save();
80
+ }
81
+
82
+ $this->loadLayout();
83
+
84
+ $this->renderLayout();
85
+
86
+ return;
87
+ }
88
+
89
+
90
+ }
91
+ $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
92
+ if(!empty($profileIds)){
93
+ $this->loadLayout();
94
+ $this->renderLayout();
95
+ return;
96
+ }
97
+
98
+ if (!$orderId || $profileIds) {
99
+ Mage::throwException('No order or profile for processing found');
100
+ }
101
+
102
+
103
+
104
+ } catch (Mage_Core_Exception $e) {
105
+ $this->_getCheckout()->addError($e->getMessage());
106
+
107
+ } catch(Exception $e) {
108
+ Mage::logException($e);
109
+ }
110
+
111
+ $this->_redirect('checkout/cart');
112
+ }
113
+
114
+ public function getOnepage()
115
+ {
116
+ return Mage::getSingleton('checkout/type_onepage');
117
+ }
118
+
119
+ /**
120
+ * Return customer from X-Payments
121
+ *
122
+ * @return void
123
+ * @access public
124
+ * @see ____func_see____
125
+ * @since 1.0.0
126
+ */
127
+
128
+ public function returnAction()
129
+ {
130
+ if ($this->processCancel()) {
131
+ return;
132
+ }
133
+
134
+ // Check request type
135
+ if (!$this->getRequest()->isPost()) {
136
+ Mage::throwException('Wrong request type.');
137
+ }
138
+
139
+ // Check request data
140
+ $request = $this->getRequest()->getPost();
141
+ if (empty($request)) {
142
+ Mage::throwException('Request doesn\'t contain POST elements.');
143
+ }
144
+
145
+ // Check order id
146
+ if (empty($request['refId'])) {
147
+ Mage::throwException('Missing or invalid order ID');
148
+ }
149
+
150
+ // Check order
151
+ $order = Mage::getModel('sales/order')->loadByIncrementId(intval($request['refId']));
152
+
153
+ if (!$order->getId()) {
154
+ Mage::throwException('Order not found');
155
+ }
156
+
157
+ $refId = $request['refId'];
158
+
159
+ /*make a temporary entry for cardholder data*/
160
+ Mage::helper("xpaymentsconnector")->savePaymentResponse($request);
161
+
162
+ if($order->getId()){
163
+ /*update order table*/
164
+ $customOrderId = Mage::helper("xpaymentsconnector")->getOrderKey();
165
+ $order->setData('xpc_txnid', $request['txnId']);
166
+ $order->setData("xp_card_data", serialize($request));
167
+ $order->save();
168
+ /*end (update order table)*/
169
+
170
+ $result = Mage::getModel("xpaymentsconnector/payment_cc")->updateOrderByXpaymentResponse($order->getId(),$request['txnId'],$refId);
171
+
172
+ if ($result["success"]) {
173
+ /* save credit card to user profile */
174
+ Mage::getModel("xpaymentsconnector/payment_cc")->saveUserCard($request);
175
+ /* end (save payment card) */
176
+ $this->getResponse()->setBody(
177
+ $this->getLayout()
178
+ ->createBlock('xpaymentsconnector/success')
179
+ ->setOrder($order)
180
+ ->toHtml()
181
+ );
182
+ return;
183
+
184
+ } else {
185
+
186
+ if ($order->canCancel()) {
187
+
188
+ $this->restoreCart($order);
189
+
190
+ $order->cancel();
191
+ $order->addStatusToHistory(
192
+ Mage_Sales_Model_Order::STATE_CANCELED,
193
+ Mage::helper('xpaymentsconnector')->__('The payment has been canceled')
194
+ );
195
+ $order->save();
196
+ }
197
+
198
+ $this->getResponse()->setBody(
199
+ $this->getLayout()
200
+ ->createBlock('xpaymentsconnector/cancel')
201
+ ->setOrder($order)
202
+ ->toHtml()
203
+ );
204
+ return;
205
+
206
+ }
207
+
208
+ $this->restoreCart($order);
209
+
210
+ $this->getResponse()->setBody(
211
+ $this->getLayout()
212
+ ->createBlock('xpaymentsconnector/failure')
213
+ ->setOrder($order)
214
+ ->toHtml()
215
+ );
216
+ }
217
+ }
218
+
219
+ /**
220
+ * Callback request
221
+ *
222
+ * @return void
223
+ * @access public
224
+ * @see ____func_see____
225
+ * @since 1.0.0
226
+ */
227
+ public function callbackAction(){
228
+
229
+ // Check request type
230
+
231
+ if (!$this->getRequest()->isPost()) {
232
+ Mage::throwException('Wrong request type.');
233
+ }
234
+
235
+ // Check IP addresses
236
+ $ips = preg_grep(
237
+ '/^.+$/Ss',
238
+ explode(',', Mage::getStoreConfig('xpaymentsconnector/settings/xpay_allowed_ip_addresses'))
239
+ );
240
+ if ($ips) {
241
+ $helper = Mage::helper('core/http');
242
+ if (method_exists($helper, 'getRemoteAddr')) {
243
+ $remoteAddr = $helper->getRemoteAddr();
244
+
245
+ } else {
246
+ $request = $this->getRequest()->getServer();
247
+ $remoteAddr = $request['REMOTE_ADDR'];
248
+ }
249
+
250
+ if (!in_array($remoteAddr, $ips)) {
251
+ Mage::throwException('IP can\'t be validated as X-Payments server IP.');
252
+ }
253
+ }
254
+
255
+ $xpaymentsHelper = Mage::helper('xpaymentsconnector');
256
+
257
+ // Check request data
258
+ $request = $this->getRequest()->getPost();
259
+
260
+ if (empty($request)) {
261
+ Mage::throwException('Request doesn\'t contain POST elements.');
262
+ }
263
+
264
+ // check txn id
265
+ if (empty($request['txnId'])) {
266
+ Mage::throwException('Missing or invalid transaction ID');
267
+ }
268
+
269
+ // add request to log
270
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
271
+ if ($request['updateData']){
272
+ $request['updateData'] = $api->decryptXML($request['updateData']);
273
+ }
274
+
275
+ Mage::log(serialize($request), null, $xpaymentsHelper::XPAYMENTS_LOG_FILE,true);
276
+
277
+ // Check order
278
+ $order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request['txnId']);
279
+ if ($order->getId()) {
280
+
281
+ if (
282
+ $request['updateData']
283
+ && isset($request['updateData']['status'])
284
+ ) {
285
+
286
+ switch (intval($request['updateData']['status'])) {
287
+ case $api::DECLINED_STATUS:
288
+ $order->cancel();
289
+ $order->addStatusToHistory(
290
+ $order::STATE_CANCELED,
291
+ $xpaymentsHelper->__('charge: Callback request')
292
+ );
293
+ break;
294
+
295
+ case $api::CHARGED_STATUS:
296
+ $order->addStatusToHistory(
297
+ $order::STATE_COMPLETE,
298
+ $xpaymentsHelper->__('charge: Callback request')
299
+ );
300
+ break;
301
+ }
302
+ $order->save();
303
+ }
304
+
305
+ } elseif (isset($request["updateData"]["parentId"])) {
306
+
307
+ $userCardModel = Mage::getModel("xpaymentsconnector/usercards");
308
+ $userCardCollection = $userCardModel
309
+ ->getCollection()
310
+ ->addFieldToSelect('user_id')
311
+ ->addFieldToSelect('last_4_cc_num')
312
+ ->addFieldToSelect('card_type')
313
+ ->addFilter("txnId", $request["updateData"]["parentId"]);
314
+ if ($userCardCollection->getSize()) {
315
+ $newPrepaidCard = $userCardCollection->getFirstItem()->getData();
316
+ $newPrepaidCard["txnId"] = $request['txnId'];
317
+ $newPrepaidCard["usage_type"] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
318
+ $newPrepaidCard["amount"] = $request["updateData"]["amount"];
319
+ $userCardModel->setData($newPrepaidCard);
320
+ $userCardModel->save();
321
+ } else {
322
+ $order = Mage::getModel('sales/order')->loadByAttribute('xpc_txnid', $request["updateData"]["parentId"]);
323
+ if ($order->getId()) {
324
+ $newPrepaidCard = array();
325
+ $newPrepaidCard["user_id"] = $order->getData("customer_id");
326
+ $newPrepaidCard["txnId"] = $request['txnId'];
327
+ $newPrepaidCard["usage_type"] = Cdev_XPaymentsConnector_Model_Usercards::BALANCE_CARD;
328
+ $newPrepaidCard["amount"] = $request["updateData"]["amount"];
329
+
330
+ $parentXpaymentResponseData = unserialize($order->getData("xp_card_data"));
331
+ $newPrepaidCard["last_4_cc_num"] = $parentXpaymentResponseData["last_4_cc_num"];
332
+ $newPrepaidCard["card_type"] = $parentXpaymentResponseData["card_type"];
333
+
334
+ $userCardModel->setData($newPrepaidCard);
335
+ $userCardModel->save();
336
+ } else {
337
+
338
+ Mage::log("Unable to create 'prepaid cart' because there is no corresponding order with the number of tokens -".$request['txnId'],
339
+ null,
340
+ $xpaymentsHelper::XPAYMENTS_LOG_FILE,true);
341
+
342
+ }
343
+ }
344
+ }
345
+ exit(0);
346
+ }
347
+
348
+ /**
349
+ * Payment is success
350
+ *
351
+ * @return void
352
+ * @access public
353
+ * @see ____func_see____
354
+ * @since 1.0.0
355
+ */
356
+ public function successAction()
357
+ {
358
+ Mage::getSingleton('checkout/session')->setData('xpayments_token', null);
359
+ $this->_redirect('checkout/onepage/success');
360
+ }
361
+
362
+ /**
363
+ * Payment is cancelled
364
+ *
365
+ * @return void
366
+ * @access public
367
+ * @see ____func_see____
368
+ * @since 1.0.0
369
+ */
370
+ public function cancelAction()
371
+ {
372
+ Mage::helper("xpaymentsconnector")->unsetXpaymentPrepareOrder();
373
+ $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
374
+ if(empty($profileIds)){
375
+ $this->_getCheckout()->addError(Mage::helper('xpaymentsconnector')->__('The order has been canceled.'));
376
+ }
377
+ $this->_redirect('checkout/cart');
378
+ }
379
+
380
+ /**
381
+ * Process cancel by customer (from X-Payments interface)
382
+ *
383
+ * @return void
384
+ * @access protected
385
+ * @see ____func_see____
386
+ * @since 1.0.0
387
+ */
388
+ protected function processCancel()
389
+ {
390
+ $query = $this->getRequest()->getQuery();
391
+ if ($query && isset($query['action']) && $query['action'] == 'cancel') {
392
+
393
+ // Check order id
394
+ if (empty($query['refId'])) {
395
+ Mage::throwException('Missing or invalid order ID');
396
+ }
397
+
398
+ // Check order
399
+ $order = Mage::getModel('sales/order')->loadByIncrementId(intval($query['refId']));
400
+ $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
401
+
402
+ if (!$order->getId() && empty($profileIds)) {
403
+ Mage::throwException('Order not found');
404
+ }
405
+
406
+ /*update recurring*/
407
+ if (!empty($profileIds)) {
408
+ foreach ($profileIds as $profileId) {
409
+ Mage::helper("xpaymentsconnector")->addRecurringTransactionError();
410
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
411
+ $profile->setState(Mage_Sales_Model_Recurring_Profile::STATE_CANCELED);
412
+ $profile->save();
413
+ }
414
+
415
+ $this->getResponse()->setBody(
416
+ $this->getLayout()
417
+ ->createBlock('xpaymentsconnector/cancel')
418
+ ->setOrder($order)
419
+ ->toHtml()
420
+ );
421
+ return true;
422
+ }
423
+
424
+ if ($order->getId()) {
425
+ if ($order->canCancel()) {
426
+ $this->restoreCart($order);
427
+
428
+ $order->cancel();
429
+ $order->addStatusToHistory(
430
+ Mage_Sales_Model_Order::STATE_CANCELED,
431
+ Mage::helper('xpaymentsconnector')->__('The payment has been canceled')
432
+ );
433
+ $order->save();
434
+ }
435
+
436
+ $this->getResponse()->setBody(
437
+ $this->getLayout()
438
+ ->createBlock('xpaymentsconnector/cancel')
439
+ ->setOrder($order)
440
+ ->toHtml()
441
+ );
442
+
443
+ return true;
444
+ }
445
+
446
+ }
447
+
448
+ return false;
449
+ }
450
+
451
+ /**
452
+ * Restore cart content on payment failure
453
+ *
454
+ * @return void
455
+ * @access puplic
456
+ * @see ____func_see____
457
+ * @since 1.0.6
458
+ */
459
+ public function restoreCart($order)
460
+ {
461
+
462
+ $session = Mage::getSingleton('checkout/session');
463
+
464
+ $quote = Mage::getModel('sales/quote')->load($order->getQuoteId());
465
+
466
+ //Return quote
467
+ if ($quote->getId()) {
468
+
469
+ $quote->setIsActive(1)->setReservedOrderId(NULL)->save();
470
+ $session->replaceQuote($quote);
471
+
472
+ }
473
+
474
+ }
475
+
476
+ public function getPaymentIframeAction(){
477
+
478
+ $api = Mage::getModel('xpaymentsconnector/payment_cc');
479
+ $result = $api->sendIframeHandshakeRequest();
480
+
481
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
482
+ return;
483
+ }
484
+
485
+
486
+ /**
487
+ * Iframe return customer from X-Payments
488
+ *
489
+ * @return void
490
+ * @access public
491
+ * @see ____func_see____
492
+ * @since 1.0.0
493
+ */
494
+ public function iframereturnAction()
495
+ {
496
+ if ($this->processCancel()) {
497
+ return;
498
+ }
499
+
500
+ // Check request type
501
+ if (!$this->getRequest()->isPost()) {
502
+ Mage::throwException('Wrong request type.');
503
+ }
504
+
505
+ // Check request data
506
+ $request = $this->getRequest()->getPost();
507
+
508
+ if (empty($request)) {
509
+ Mage::throwException('Request doesn\'t contain POST elements.');
510
+ }
511
+
512
+ // Check order id
513
+ if (empty($request['refId'])) {
514
+ Mage::throwException('Missing or invalid order ID');
515
+ }
516
+
517
+ if(!empty($request)){
518
+ Mage::helper("xpaymentsconnector")->savePaymentResponse($request);
519
+ }
520
+ $profileIds = Mage::getSingleton('checkout/session')->getLastRecurringProfileIds();
521
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
522
+ if($profileIds && !$useIframe){
523
+ foreach($profileIds as $profileId){
524
+ $profile = Mage::getModel('sales/recurring_profile')->load($profileId);
525
+ $payDeferredSubscription = Mage::helper("xpaymentsconnector")->payDeferredSubscription($profile);
526
+ if(!$payDeferredSubscription){
527
+ $updateProfile = Mage::getModel("xpaymentsconnector/payment_cc")->createFirstRecurringOrder($profile);
528
+ $updateProfile->save();
529
+ }
530
+ }
531
+ $this->_redirect('checkout/onepage/success');
532
+
533
+ return;
534
+ }
535
+
536
+
537
+ $this->getResponse()->setBody(
538
+ $this->getLayout()
539
+ ->createBlock('xpaymentsconnector/beforesuccess')
540
+ ->toHtml()
541
+ );
542
+
543
+ return;
544
+ }
545
+
546
+
547
+ public function saveusercardAction(){
548
+ $request = $this->getRequest()->getPost();
549
+ if(!empty($request)){
550
+ if($request["user_card_save"]){
551
+ Mage::getSingleton("checkout/session")->setData("user_card_save",$request["user_card_save"]);
552
+ }
553
+ }
554
+ }
555
+
556
+ public function istokenactualAction(){
557
+ $currentToken = $this->getRequest()->getParam("token");
558
+ $result = array();
559
+ if($currentToken){
560
+ $savedToken = Mage::helper("xpaymentsconnector")->getIframeToken();
561
+ $result["is_actual"] = ($currentToken == $savedToken) ? true: false;
562
+ }else{
563
+ $result["is_actual"] = false;
564
+ }
565
+
566
+ if(!$result["is_actual"]){
567
+ $result["error_message"] =
568
+ Mage::helper("xpaymentsconnector")->__("Your order state has been changed during checkout. You will be redirected to the cart contents page.");
569
+ $result["redirect"] = Mage::getUrl("checkout/cart",array("unset_xp_prepare_order"=>1));
570
+ }
571
+
572
+ $this->getResponse()->setBody(Mage::helper('core')->jsonEncode($result));
573
+
574
+ }
575
+
576
+
577
+ }
app/code/community/Cdev/XPaymentsConnector/etc/config.xml ADDED
@@ -0,0 +1,414 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 Valerii Demidov
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.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
+ <modules>
25
+ <Cdev_XPaymentsConnector>
26
+ <version>1.0.9</version>
27
+ </Cdev_XPaymentsConnector>
28
+ </modules>
29
+ <global>
30
+ <models>
31
+ <sales>
32
+ <rewrite>
33
+ <recurring_profile>Cdev_XPaymentsConnector_Model_Sales_Recurring_Profile</recurring_profile>
34
+ <quote_address_total_nominal>Cdev_XPaymentsConnector_Model_Quote_Address_Total_Nominal</quote_address_total_nominal>
35
+ <quote>Cdev_XPaymentsConnector_Model_Quote</quote>
36
+ </rewrite>
37
+ </sales>
38
+ <payment>
39
+ <rewrite>
40
+ <recurring_profile>Cdev_XPaymentsConnector_Model_Payment_Recurring_Profile</recurring_profile>
41
+ </rewrite>
42
+ </payment>
43
+ <xpaymentsconnector>
44
+ <class>Cdev_XPaymentsConnector_Model</class>
45
+ <resourceModel>xpaymentsconnector_mysql4</resourceModel>
46
+ </xpaymentsconnector>
47
+ <xpaymentsconnector_mysql4>
48
+ <class>Cdev_XPaymentsConnector_Model_Mysql4</class>
49
+ <entities>
50
+ <paymentconfiguration>
51
+ <table>xpayment_configurations</table>
52
+ </paymentconfiguration>
53
+ <usercards>
54
+ <table>xpayment_user_cards</table>
55
+ </usercards>
56
+ </entities>
57
+ </xpaymentsconnector_mysql4>
58
+ </models>
59
+ <helpers>
60
+ <xpaymentsconnector>
61
+ <class>Cdev_XPaymentsConnector_Helper</class>
62
+ </xpaymentsconnector>
63
+ </helpers>
64
+ <resources>
65
+ <xpaymentsconnector_setup>
66
+ <setup>
67
+ <module>Cdev_XPaymentsConnector</module>
68
+ </setup>
69
+ <connection>
70
+ <use>core_setup</use>
71
+ </connection>
72
+ </xpaymentsconnector_setup>
73
+ <xpaymentsconnector_write>
74
+ <connection>
75
+ <use>core_write</use>
76
+ </connection>
77
+ </xpaymentsconnector_write>
78
+ <xpaymentsconnector_read>
79
+ <connection>
80
+ <use>core_read</use>
81
+ </connection>
82
+ </xpaymentsconnector_read>
83
+ </resources>
84
+ <blocks>
85
+ <customer>
86
+ <rewrite>
87
+ <account_navigation>Cdev_XPaymentsConnector_Block__Customer_Account_Navigation</account_navigation>
88
+ </rewrite>
89
+ </customer>
90
+ <xpaymentsconnector>
91
+ <class>Cdev_XPaymentsConnector_Block</class>
92
+ </xpaymentsconnector>
93
+ </blocks>
94
+ <events>
95
+ <sales_order_save_before>
96
+ <observers>
97
+ <xpaymentsconnector>
98
+ <type>singleton</type>
99
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
100
+ <method>salesOrderSaveBefore</method>
101
+ </xpaymentsconnector>
102
+ </observers>
103
+ </sales_order_save_before>
104
+ <sales_order_payment_cancel_invoice>
105
+ <observers>
106
+ <xpaymentsconnector>
107
+ <type>singleton</type>
108
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
109
+ <method>invoiceVoid</method>
110
+ </xpaymentsconnector>
111
+ </observers>
112
+ </sales_order_payment_cancel_invoice>
113
+ <sales_order_invoice_save_before>
114
+ <observers>
115
+ <xpaymentsconnector>
116
+ <type>singleton</type>
117
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
118
+ <method>orderInvoiceSaveBefore</method>
119
+ </xpaymentsconnector>
120
+ </observers>
121
+ </sales_order_invoice_save_before>
122
+ <controller_action_predispatch_checkout_onepage_index>
123
+ <observers>
124
+ <xpaymentsconnector>
125
+ <type>singleton</type>
126
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
127
+ <method>preDispatchCheckout</method>
128
+ </xpaymentsconnector>
129
+ </observers>
130
+ </controller_action_predispatch_checkout_onepage_index>
131
+ <controller_action_postdispatch_checkout_onepage_savePayment>
132
+ <observers>
133
+ <xpaymentsconnector>
134
+ <type>singleton</type>
135
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
136
+ <method>postDispatchSavePayment</method>
137
+ </xpaymentsconnector>
138
+ </observers>
139
+ </controller_action_postdispatch_checkout_onepage_savePayment>
140
+ <!--<checkout_type_onepage_save_order_after>-->
141
+ <checkout_type_onepage_save_order_after>
142
+ <observers>
143
+ <xpaymentsconnector>
144
+ <type>singleton</type>
145
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
146
+ <method>updateOrder</method>
147
+ </xpaymentsconnector>
148
+ </observers>
149
+ </checkout_type_onepage_save_order_after>
150
+ <checkout_onepage_controller_success_action>
151
+ <observers>
152
+ <xpaymentsconnector>
153
+ <type>singleton</type>
154
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
155
+ <method>orderSuccessAction</method>
156
+ </xpaymentsconnector>
157
+ </observers>
158
+ </checkout_onepage_controller_success_action>
159
+ <payment_method_is_active>
160
+ <observers>
161
+ <paymentfilter_payment_method_is_active>
162
+ <type>singleton</type>
163
+ <class>xpaymentsconnector/observer</class>
164
+ <method>paymentMethodIsActive</method>
165
+ </paymentfilter_payment_method_is_active>
166
+ </observers>
167
+ </payment_method_is_active>
168
+ <controller_action_postdispatch_adminhtml_sales_order_create_save>
169
+ <observers>
170
+ <xpaymentsconnector>
171
+ <type>singleton</type>
172
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
173
+ <method>postdispatchAdminhtmlSalesOrderCreateSave</method>
174
+ </xpaymentsconnector>
175
+ </observers>
176
+ </controller_action_postdispatch_adminhtml_sales_order_create_save>
177
+ <controller_action_predispatch_adminhtml_sales_order_create_save>
178
+ <observers>
179
+ <xpaymentsconnector>
180
+ <type>singleton</type>
181
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
182
+ <method>predispatchAdminhtmlSalesOrderCreateSave</method>
183
+ </xpaymentsconnector>
184
+ </observers>
185
+ </controller_action_predispatch_adminhtml_sales_order_create_save>
186
+ <controller_action_predispatch_adminhtml_sales_order_create_index>
187
+ <observers>
188
+ <xpaymentsconnector>
189
+ <type>singleton</type>
190
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
191
+ <method>unsetXpaymentSelectedCard</method>
192
+ </xpaymentsconnector>
193
+ </observers>
194
+ </controller_action_predispatch_adminhtml_sales_order_create_index>
195
+ <controller_action_postdispatch_adminhtml_sales_order_create_loadBlock>
196
+ <observers>
197
+ <xpaymentsconnector>
198
+ <type>singleton</type>
199
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
200
+ <method>adminhtmlSavePaymentCard</method>
201
+ </xpaymentsconnector>
202
+ </observers>
203
+ </controller_action_postdispatch_adminhtml_sales_order_create_loadBlock>
204
+ <!--add redirect for buying recurring product by xpayments method(without iframe) -->
205
+ <checkout_submit_all_after>
206
+ <observers>
207
+ <xpaymentsconnector>
208
+ <type>singleton</type>
209
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
210
+ <method>addRedirectForXpaymentMethod</method>
211
+ </xpaymentsconnector>
212
+ </observers>
213
+ </checkout_submit_all_after>
214
+ <!--set discount for recurring product(for ajax cart item quantity update). Remove X-Payments token -->
215
+ <checkout_cart_update_items_after>
216
+ <observers>
217
+ <web4proall_upd>
218
+ <type>singleton</type>
219
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
220
+ <method>updateCartItem</method>
221
+ </web4proall_upd>
222
+ </observers>
223
+ </checkout_cart_update_items_after>
224
+ <!--Remove X-Payments token -->
225
+ <checkout_cart_add_product_complete>
226
+ <observers>
227
+ <web4proall_upd>
228
+ <type>singleton</type>
229
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
230
+ <method>checkoutCartAdd</method>
231
+ </web4proall_upd>
232
+ </observers>
233
+ </checkout_cart_add_product_complete>
234
+ <!--set discount for recurring product-->
235
+ <controller_action_predispatch_checkout_cart_index>
236
+ <observers>
237
+ <web4procheckout>
238
+ <type>singleton</type>
239
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
240
+ <method>preDispatchCartIndex</method>
241
+ </web4procheckout>
242
+ </observers>
243
+ </controller_action_predispatch_checkout_cart_index>
244
+ <!--Remove X-Payments token and prepare order number -->
245
+ <controller_action_postdispatch_checkout_cart_delete>
246
+ <observers>
247
+ <web4procheckout>
248
+ <type>singleton</type>
249
+ <class>Cdev_XPaymentsConnector_Model_Observer</class>
250
+ <method>postdispatchCartDelete</method>
251
+ </web4procheckout>
252
+ </observers>
253
+ </controller_action_postdispatch_checkout_cart_delete>
254
+
255
+
256
+ </events>
257
+ <sales>
258
+ <quote>
259
+ <nominal_totals>
260
+ <recurring_discount>
261
+ <class>xpaymentsconnector/quote_address_total_nominal_recurring_discount</class>
262
+ <sort_order>10</sort_order>
263
+ </recurring_discount>
264
+ </nominal_totals>
265
+ </quote>
266
+
267
+ </sales>
268
+
269
+ </global>
270
+ <frontend>
271
+ <routers>
272
+ <xpaymentsconnector>
273
+ <use>standard</use>
274
+ <args>
275
+ <module>Cdev_XPaymentsConnector</module>
276
+ <frontName>xpaymentsconnector</frontName>
277
+ </args>
278
+ </xpaymentsconnector>
279
+ </routers>
280
+ <events>
281
+ </events>
282
+ <translate>
283
+ <modules>
284
+ <Cdev_XPaymentsConnector>
285
+ <files>
286
+ <default>Cdev_XPaymentsConnector.csv</default>
287
+ </files>
288
+ </Cdev_XPaymentsConnector>
289
+ </modules>
290
+ </translate>
291
+ <layout>
292
+ <updates>
293
+ <xpaymentsconnector>
294
+ <file>xpaymentsconnector.xml</file>
295
+ </xpaymentsconnector>
296
+ </updates>
297
+ </layout>
298
+ </frontend>
299
+ <admin>
300
+ <routers>
301
+ <xpaymentsconnector>
302
+ <use>admin</use>
303
+ <args>
304
+ <module>Cdev_XPaymentsConnector</module>
305
+ <frontName>xpaymentsconnector</frontName>
306
+ </args>
307
+ </xpaymentsconnector>
308
+ </routers>
309
+ </admin>
310
+ <adminhtml>
311
+ <layout>
312
+ <updates>
313
+ <xpaymentsconnector>
314
+ <file>xpaymentsconnector.xml</file>
315
+ </xpaymentsconnector>
316
+ </updates>
317
+ </layout>
318
+ <translate>
319
+ <modules>
320
+ <Cdev_XPaymentsConnector>
321
+ <files>
322
+ <default>Cdev_XPaymentsConnector.csv</default>
323
+ </files>
324
+ </Cdev_XPaymentsConnector>
325
+ </modules>
326
+ </translate>
327
+ <acl>
328
+ <resources>
329
+ <admin>
330
+ <children>
331
+ <system>
332
+ <children>
333
+ <config>
334
+ <children>
335
+ <xpaymentsconnector>
336
+ <title>X-Payments connector Settings</title>
337
+ </xpaymentsconnector>
338
+ </children>
339
+ </config>
340
+ </children>
341
+ </system>
342
+ </children>
343
+ </admin>
344
+ </resources>
345
+ </acl>
346
+ <menu>
347
+ <system>
348
+ <children>
349
+ <control translate="title" module="xpaymentsconnector">
350
+ <title>X-Payments connector</title>
351
+ <sort_order>300</sort_order>
352
+ <action>xpaymentsconnector/control</action>
353
+ </control>
354
+ </children>
355
+ </system>
356
+ </menu>
357
+ </adminhtml>
358
+ <default>
359
+ <payment>
360
+ <xpayments>
361
+ <active>0</active>
362
+ <model>xpaymentsconnector/payment_cc</model>
363
+ <order_status>1</order_status>
364
+ <allowspecific>0</allowspecific>
365
+ <title>Credit Card (X-Payments)</title>
366
+ </xpayments>
367
+ <savedcards>
368
+ <active>0</active>
369
+ <model>xpaymentsconnector/payment_savedcards</model>
370
+ <order_status>1</order_status>
371
+ <allowspecific>0</allowspecific>
372
+ <title>Use saved payment cards (X-Payments)</title>
373
+ </savedcards>
374
+ <prepaidpayments>
375
+ <active>0</active>
376
+ <model>xpaymentsconnector/payment_prepaidpayments</model>
377
+ <order_status>1</order_status>
378
+ <allowspecific>0</allowspecific>
379
+ <title>Prepaid Payments (X-Payments)</title>
380
+ </prepaidpayments>
381
+ </payment>
382
+ <xpaymentsconnector>
383
+ <settings>
384
+ <activationstatus>0</activationstatus>
385
+ <xpay_minimum_payment_recurring_amount>0.5</xpay_minimum_payment_recurring_amount>
386
+ </settings>
387
+ </xpaymentsconnector>
388
+ </default>
389
+ <admin>
390
+ <routers>
391
+ <adminhtml>
392
+ <args>
393
+ <modules>
394
+ <xpaymentsconnector before="Mage_Adminhtml">Cdev_XPaymentsConnector_Adminhtml</xpaymentsconnector>
395
+ </modules>
396
+ </args>
397
+ </adminhtml>
398
+ </routers>
399
+ </admin>
400
+
401
+ <crontab>
402
+ <jobs>
403
+ <create_order_by_subscription>
404
+ <schedule>
405
+ <cron_expr>*/30 * * * *</cron_expr>
406
+ </schedule>
407
+ <run>
408
+ <model>xpaymentsconnector/observer::createOrdersByCustomerSubscriptions</model>
409
+ </run>
410
+ </create_order_by_subscription>
411
+ </jobs>
412
+ </crontab>
413
+
414
+ </config>
app/code/community/Cdev/XPaymentsConnector/etc/system.xml ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 Valerii Demidov
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.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
+ <order_status translate="label">
79
+ <label>New order status</label>
80
+ <frontend_type>select</frontend_type>
81
+ <source_model>adminhtml/system_config_source_order_status</source_model>
82
+ <sort_order>6</sort_order>
83
+ <show_in_default>1</show_in_default>
84
+ <show_in_website>1</show_in_website>
85
+ <show_in_store>0</show_in_store>
86
+ </order_status>
87
+ <confid translate="label">
88
+ <label>Payment configuration</label>
89
+ <frontend_type>select</frontend_type>
90
+ <sort_order>7</sort_order>
91
+ <source_model>xpaymentsconnector/source_paymentconfiguration</source_model>
92
+ <show_in_default>1</show_in_default>
93
+ <show_in_website>1</show_in_website>
94
+ <show_in_store>0</show_in_store>
95
+ </confid>
96
+ <use_iframe translate="label">
97
+ <label>Use iFrame</label>
98
+ <frontend_type>select</frontend_type>
99
+ <source_model>adminhtml/system_config_source_yesno</source_model>
100
+ <sort_order>8</sort_order>
101
+ <show_in_default>1</show_in_default>
102
+ <show_in_website>1</show_in_website>
103
+ <show_in_store>0</show_in_store>
104
+ </use_iframe>
105
+ <use_authorize translate="label">
106
+ <label>Use forced Authorize operation</label>
107
+ <frontend_type>select</frontend_type>
108
+ <source_model>adminhtml/system_config_source_yesno</source_model>
109
+ <sort_order>8</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>0</show_in_store>
113
+ </use_authorize>
114
+ <use_initialfee_authorize translate="label">
115
+ <label>Use forced Authorize operation for initial fee</label>
116
+ <frontend_type>select</frontend_type>
117
+ <source_model>adminhtml/system_config_source_yesno</source_model>
118
+ <sort_order>8</sort_order>
119
+ <show_in_default>1</show_in_default>
120
+ <show_in_website>1</show_in_website>
121
+ <show_in_store>0</show_in_store>
122
+ </use_initialfee_authorize>
123
+
124
+ </fields>
125
+ </xpayments>
126
+ <savedcards translate="label" module="xpaymentsconnector">
127
+ <label>Use saved credit cards (X-Payments)</label>
128
+ <frontend_type>text</frontend_type>
129
+ <sort_order>201</sort_order>
130
+ <show_in_default>1</show_in_default>
131
+ <show_in_website>1</show_in_website>
132
+ <show_in_store>0</show_in_store>
133
+ <fields>
134
+ <active translate="label">
135
+ <label>Enabled</label>
136
+ <frontend_type>select</frontend_type>
137
+ <source_model>adminhtml/system_config_source_yesno</source_model>
138
+ <sort_order>1</sort_order>
139
+ <show_in_default>1</show_in_default>
140
+ <show_in_website>1</show_in_website>
141
+ <show_in_store>0</show_in_store>
142
+ </active>
143
+ <sort_order translate="label">
144
+ <label>Sort order</label>
145
+ <frontend_type>text</frontend_type>
146
+ <sort_order>2</sort_order>
147
+ <show_in_default>1</show_in_default>
148
+ <show_in_website>1</show_in_website>
149
+ <show_in_store>0</show_in_store>
150
+ </sort_order>
151
+ <title translate="label">
152
+ <label>Title</label>
153
+ <frontend_type>text</frontend_type>
154
+ <sort_order>3</sort_order>
155
+ <show_in_default>1</show_in_default>
156
+ <show_in_website>1</show_in_website>
157
+ <show_in_store>0</show_in_store>
158
+ </title>
159
+ </fields>
160
+ </savedcards>
161
+ <prepaidpayments>
162
+ <label>Prepaid Payments (X-Payments)</label>
163
+ <frontend_type>text</frontend_type>
164
+ <sort_order>201</sort_order>
165
+ <show_in_default>1</show_in_default>
166
+ <show_in_website>1</show_in_website>
167
+ <show_in_store>0</show_in_store>
168
+ <fields>
169
+ <active translate="label">
170
+ <label>Enabled</label>
171
+ <frontend_type>select</frontend_type>
172
+ <source_model>adminhtml/system_config_source_yesno</source_model>
173
+ <sort_order>1</sort_order>
174
+ <show_in_default>1</show_in_default>
175
+ <show_in_website>1</show_in_website>
176
+ <show_in_store>0</show_in_store>
177
+ </active>
178
+ <sort_order translate="label">
179
+ <label>Sort order</label>
180
+ <frontend_type>text</frontend_type>
181
+ <sort_order>2</sort_order>
182
+ <show_in_default>1</show_in_default>
183
+ <show_in_website>1</show_in_website>
184
+ <show_in_store>0</show_in_store>
185
+ </sort_order>
186
+ <title translate="label">
187
+ <label>Title</label>
188
+ <frontend_type>text</frontend_type>
189
+ <sort_order>3</sort_order>
190
+ <show_in_default>1</show_in_default>
191
+ <show_in_website>1</show_in_website>
192
+ <show_in_store>0</show_in_store>
193
+ </title>
194
+ </fields>
195
+ </prepaidpayments>
196
+ </groups>
197
+ </payment>
198
+ <xpaymentsconnector translate="label" module="xpaymentsconnector">
199
+ <label>X-Payments connector</label>
200
+ <tab>sales</tab>
201
+ <frontend_type>text</frontend_type>
202
+ <sort_order>995</sort_order>
203
+ <show_in_default>1</show_in_default>
204
+ <show_in_website>0</show_in_website>
205
+ <show_in_store>0</show_in_store>
206
+ <groups>
207
+ <settings translate="label">
208
+ <label>X-Payments Connector Settings</label>
209
+ <frontend_type>text</frontend_type>
210
+ <sort_order>1</sort_order>
211
+ <show_in_default>1</show_in_default>
212
+ <show_in_website>0</show_in_website>
213
+ <show_in_store>0</show_in_store>
214
+ <fields>
215
+ <xpay_conf_bundle translate="label,comment">
216
+ <label>X-Payments configuration bundle</label>
217
+ <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>
218
+ <frontend_type>text</frontend_type>
219
+ <sort_order>10</sort_order>
220
+ <show_in_default>1</show_in_default>
221
+ <show_in_website>0</show_in_website>
222
+ <show_in_store>0</show_in_store>
223
+ </xpay_conf_bundle>
224
+ <xpay_allowed_ip_addresses translate="label,comment">
225
+ <label>IP addresses for X-Payments callbacks</label>
226
+ <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>
227
+ <frontend_type>text</frontend_type>
228
+ <sort_order>60</sort_order>
229
+ <show_in_default>1</show_in_default>
230
+ <show_in_website>0</show_in_website>
231
+ <show_in_store>0</show_in_store>
232
+ </xpay_allowed_ip_addresses>
233
+ <xpay_currency translate="label,comment">
234
+ <label>Payment currency</label>
235
+ <comment><![CDATA[All payments will be made using the currency specified here.]]></comment>
236
+ <frontend_type>select</frontend_type>
237
+ <source_model>adminhtml/system_config_source_currency</source_model>
238
+ <sort_order>70</sort_order>
239
+ <show_in_default>1</show_in_default>
240
+ <show_in_website>0</show_in_website>
241
+ <show_in_store>0</show_in_store>
242
+ </xpay_currency>
243
+ <xpay_minimum_payment_recurring_amount translate="label,comment">
244
+ <label>Setup minimum payment amount for recurring orders and customer card authorization actions</label>
245
+ <comment><![CDATA[This is minimal authorisation amount for recurring subscriptions ordered with start date in the future and customer card authorization actions.]]></comment>
246
+ <sort_order>80</sort_order>
247
+ <show_in_default>1</show_in_default>
248
+ <show_in_website>0</show_in_website>
249
+ <show_in_store>0</show_in_store>
250
+ </xpay_minimum_payment_recurring_amount>
251
+
252
+ </fields>
253
+ </settings>
254
+ </groups>
255
+ </xpaymentsconnector>
256
+ </sections>
257
+ </config>
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Used to store all payment methods derived from the account of "X-Payments" server
24
+ */
25
+
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+
29
+ $installer->run("
30
+ CREATE TABLE {$this->getTable('xpayment_configurations')} (
31
+ `confid` int(6) NOT NULL default 0,
32
+ `name` varchar(255) NOT NULL default '',
33
+ `module` varchar(255) NOT NULL default '',
34
+ `auth_exp` int(11) NOT NULL default 0,
35
+ `capture_min` decimal(12,2) NOT NULL default '0.00',
36
+ `capture_max` decimal(12,2) NOT NULL default '0.00',
37
+ `hash` char(32) NOT NULL default '',
38
+ `is_auth` char(1) NOT NULL default '',
39
+ `is_capture` char(1) NOT NULL default '',
40
+ `is_void` char(1) NOT NULL default '',
41
+ `is_refund` char(1) NOT NULL default '',
42
+ `is_part_refund` char(1) NOT NULL default '',
43
+ `is_accept` char(1) NOT NULL default '',
44
+ `is_decline` char(1) NOT NULL default '',
45
+ `is_get_info` char(1) NOT NULL default '',
46
+ `is_enabled` char(1) NOT NULL default '',
47
+ PRIMARY KEY (confid)
48
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
49
+
50
+ ALTER TABLE {$this->getTable('sales_flat_order')} ADD xpc_txnid varchar(32) NOT NULL default '';
51
+
52
+ ");
53
+
54
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.0-1.0.1.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
22
+ /**
23
+ * Used to store saved customer payment cards
24
+ */
25
+
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+
29
+ $installer->run("
30
+ CREATE TABLE {$this->getTable('xpayment_user_cards')} (
31
+ `xp_card_id` int(11) unsigned NOT NULL auto_increment,
32
+ `user_id` int(11) NOT NULL default 0,
33
+ `txnId` varchar(255) NOT NULL default '',
34
+ `last_4_cc_num` varchar(4) NOT NULL default '',
35
+ `card_type` varchar(255) NOT NULL default '',
36
+ PRIMARY KEY (xp_card_id)
37
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
38
+
39
+ ");
40
+
41
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.1-1.0.2.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Used for generate unique order keys for "X-Payments" server
24
+ * Also used for temporary storage of data received from the "X-Payments"
25
+ */
26
+
27
+ $installer = $this;
28
+ $installer->startSetup();
29
+
30
+ $installer->run("
31
+ CREATE TABLE {$this->getTable('xpayment_prepare_order')} (
32
+ `prepare_order_id` int(11) unsigned NOT NULL auto_increment,
33
+ `quote_id` int(10) unsigned not null,
34
+ `payment_response` text NOT NULL,
35
+ PRIMARY KEY (prepare_order_id)
36
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
37
+
38
+ ");
39
+
40
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Add additional column for storage unique order keys for "X-Payments" server
24
+ */
25
+
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+ $setup = new Mage_Sales_Model_Resource_Setup('core_setup');
29
+
30
+ $installer->getConnection()->addColumn($this->getTable('sales/order'),
31
+ 'xp_order_key',
32
+ "int(11) DEFAULT 0"
33
+ );
34
+
35
+
36
+
37
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.3-1.0.4.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Add additional order status for all "X-Payments" without invoices
24
+ */
25
+
26
+ $installer = $this;
27
+ $connection = $installer->getConnection();
28
+ $installer->startSetup();
29
+
30
+ $status = Mage::getModel('sales/order_status');
31
+ $status->setStatus('xp_pending_payment');
32
+ $status->setLabel('X-Payments Pending Payment');
33
+ $status->assignState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT);
34
+ $status->save();
35
+
36
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
22
+ /**
23
+ * Adding an additional column for "X-Payments Prepaid Payments" cards
24
+ */
25
+
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+ $setup = new Mage_Sales_Model_Resource_Setup('core_setup');
29
+
30
+ $installer->getConnection()
31
+ ->addColumn($this->getTable('xpayment_user_cards'),
32
+ 'is_balance_card',
33
+ "int(1) DEFAULT 0"
34
+ );
35
+ $installer->getConnection()
36
+ ->addColumn($this->getTable('xpayment_user_cards'),
37
+ 'amount',
38
+ "decimal(12,4) NULL"
39
+ );
40
+
41
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.5-1.0.6.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
22
+ /**
23
+ * Adding an additional column for customer card data
24
+ */
25
+
26
+ $installer = $this;
27
+ $installer->startSetup();
28
+ $setup = new Mage_Sales_Model_Resource_Setup('core_setup');
29
+
30
+ $installer->getConnection()->addColumn($this->getTable('sales/order'),
31
+ 'xp_card_data',
32
+ "text NOT NULL"
33
+ );
34
+
35
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.6-1.0.7.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+
22
+ /**
23
+ * Update usage column "is_balance_card"
24
+ */
25
+
26
+ $installer = $this;
27
+
28
+ $installer->startSetup();
29
+
30
+ $table = $installer->getTable('xpayment_user_cards');
31
+
32
+ $installer->run("ALTER TABLE `".$table."` CHANGE `is_balance_card` `usage_type` int(1) NULL DEFAULT '0' AFTER `card_type`,
33
+ COMMENT=''; ");
34
+
35
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.7-1.0.8.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Adding columns for 'count of failed transactions during one cycle' and
24
+ * 'Date of success transaction'
25
+ */
26
+
27
+ $installer = $this;
28
+
29
+ $installer->startSetup();
30
+
31
+ $table = $installer->getTable('sales/recurring_profile');
32
+
33
+ $installer->getConnection()->addColumn($table,
34
+ "xp_cycle_failure_count", "smallint(5) NULL DEFAULT '0' COMMENT 'Count of failure transaction in cycle'");
35
+
36
+ $installer->getConnection()->addColumn($table,
37
+ "xp_success_transaction_date", "timestamp NOT NULL DEFAULT '0000-00-00 00:00:00' COMMENT 'Date of success transaction'");
38
+
39
+ $installer->getConnection()->addColumn($table,
40
+ "xp_count_success_transaction", "int(11) NULL DEFAULT '0' COMMENT 'Count of success transaction'");
41
+
42
+
43
+ $installer->endSetup();
app/code/community/Cdev/XPaymentsConnector/sql/xpaymentsconnector_setup/mysql4-upgrade-1.0.8-1.0.9.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+
22
+ /**
23
+ * Remove additional column for storage unique order keys for "X-Payments" server
24
+ */
25
+
26
+
27
+ $installer = $this;
28
+ $installer->startSetup();
29
+ $setup = new Mage_Sales_Model_Resource_Setup('core_setup');
30
+
31
+ $installer->getConnection()->dropColumn($this->getTable('sales/order'),
32
+ 'xp_order_key'
33
+ );
34
+
35
+ $installer->getConnection()->dropTable($this->getTable('xpayment_prepare_order'));
36
+
37
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/xpaymentsconnector.xml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 Valerii Demidov
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <layout>
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>
38
+ </reference>
39
+ <reference name="js">
40
+ <block type="adminhtml/template" template="xpaymentsconnector/usercards/tab/js.phtml" name="usercards.tab.js" as="usercards_tab_js"></block>
41
+ </reference>
42
+ </adminhtml_customer_edit>
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/>
50
+ </action>
51
+ </reference>
52
+ </adminhtml_sales_order_create_index>
53
+
54
+ <adminhtml_sales_order_view>
55
+ <reference name="sales_order_tabs">
56
+ <action method="addTab">
57
+ <name>xp_order_state</name>
58
+ <block>xpaymentsconnector/adminhtml_sales_order_view_tab_xporderstate</block>
59
+ </action>
60
+ </reference>
61
+ </adminhtml_sales_order_view>
62
+
63
+ <adminhtml_sales_recurring_profile_view>
64
+ <reference name="sales.recurring.profile.tab.info">
65
+ <remove name="sales.recurring.profile.view.fees" />
66
+ <block type="xpaymentsconnector/recurring_profile_view" name="xpaymentsconnector.recurring.profile.view.fees" as="fees" template="sales/recurring/profile/view/info.phtml">
67
+ <action method="prepareFeesInfo"/>
68
+ <action method="addToParentGroup"><value>info_blocks_row_2</value></action>
69
+ <action method="setViewColumn"><value>2</value></action>
70
+ <action method="setViewLabel" translate="value"><value>Profile Payments</value></action>
71
+ </block>
72
+ </reference>
73
+ </adminhtml_sales_recurring_profile_view>
74
+
75
+ </layout>
app/design/adminhtml/default/default/template/xpaymentsconnector/control.phtml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Control
25
+ */
26
+ ?>
27
+ <?php if ($this->getRequiremenetsErrors()) { ?>
28
+
29
+ <h4><?php echo $this->helper('adminhtml')->__('Failed to meet environment requirements'); ?></h4>
30
+ <ul>
31
+ <?php foreach ($this->getRequiremenetsErrors() as $err) { ?>
32
+ <li class="error"><?php echo $this->helper('adminhtml')->__($err); ?></li>
33
+ <?php } ?>
34
+ </ul>
35
+ <br />
36
+ <hr />
37
+ <br />
38
+
39
+ <?php } ?>
40
+
41
+ <?php if ($this->getConfigurationErrors()) { ?>
42
+
43
+ <h4><?php echo Mage::helper('xpaymentsconnector')->__('Configuration problems'); ?></h4>
44
+ <ul>
45
+ <?php foreach ($this->getConfigurationErrors() as $err) { ?>
46
+ <li class="error"><?php echo Mage::helper('xpaymentsconnector')->__($err); ?></li>
47
+ <?php } ?>
48
+ </ul>
49
+ <br />
50
+ <hr />
51
+ <br />
52
+ <?php } ?>
53
+
54
+ <h4><?php echo Mage::helper('xpaymentsconnector')->__('Test module'); ?></h4>
55
+
56
+ <p><?php echo Mage::helper('xpaymentsconnector')->__("To test the module settings and connection with X-Payments click the button below. If the module is configured properly, a 'Test transaction completed successfully' message will be displayed at the top of the page."); ?></p>
57
+
58
+ <form action="<?php echo $this->getUrl('xpaymentsconnector/control/test'); ?>" method="post" name="testmodule_form">
59
+ <?php echo $this->getBlockHtml('formkey'); ?>
60
+ <?php echo $this->getChildHtml('testButton'); ?>
61
+ </form>
62
+
63
+ <br />
64
+ <br />
65
+
66
+ <h4><?php echo Mage::helper('xpaymentsconnector')->__('Import payment methods'); ?></h4>
67
+
68
+ <p><?php echo Mage::helper('xpaymentsconnector')->__('To be able to use X-Payments payment methods you need to import them from X-Payments first.'); ?></p>
69
+
70
+ <?php if ($this->isMethodsRequested()) { ?>
71
+
72
+ <?php echo Mage::helper('xpaymentsconnector')->__('The list of payment configurations imported from X-Payments'); ?>:<br />
73
+
74
+ <div class="grid">
75
+ <table cellpadding="5" cellspacing="1">
76
+ <tr class="headings">
77
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Payment method'); ?></th>
78
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Payment method ID'); ?></th>
79
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Auth'); ?></th>
80
+ <!--th><?php echo Mage::helper('xpaymentsconnector')->__('Capture'); ?></th>
81
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Void'); ?></th>
82
+ <th class="last"><?php echo Mage::helper('xpaymentsconnector')->__('Refund'); ?></th-->
83
+ </tr>
84
+
85
+ <?php foreach($this->getPaymentMethods() as $pm) { ?>
86
+
87
+ <tr>
88
+ <td><?php echo $pm['name']; ?></td>
89
+ <td><?php echo $pm['confid']; ?></td>
90
+ <td><?php if ($pm['is_auth']) { ?><?php echo $this->__('Yes'); ?><?php } else { ?><?php echo $this->__('No'); ?><?php } ?></td>
91
+ <!--td><?php if ($pm['is_capture']) { ?><?php echo $this->helper('adminhtml')->__('Yes'); ?><?php } else { ?><?php echo $this->helper('adminhtml')->__('No'); ?><?php } ?></td>
92
+ <td><?php if ($pm['is_void']) { ?><?php echo $this->__('Yes'); ?><?php } else { ?><?php echo $this->__('No'); ?><?php } ?></td>
93
+ <td class="last"><?php if ($pm['is_refund']) { ?><?php echo $this->__('Yes'); ?><?php } else { ?><?php echo $this->__('No'); ?><?php } ?></td-->
94
+ </tr>
95
+
96
+ <?php } ?>
97
+
98
+ </table>
99
+ </div>
100
+
101
+ <form action="<?php echo $this->getUrl('xpaymentsconnector/control/clear'); ?>" method="post" name="clear_form">
102
+ <?php echo $this->getBlockHtml('formkey'); ?>
103
+ <?php echo $this->getChildHtml('clearButton'); ?>
104
+ </form>
105
+
106
+ <?php if ($this->isMethodsAlreadyImported()) { ?>
107
+ <br />
108
+ <br />
109
+ <p><?php echo $this->__('Warning! Importing payment configurations from X-Payments will disable the X-Payments connector payment method!'); ?></p>
110
+ <?php } ?>
111
+
112
+ <?php } ?>
113
+
114
+ <form action="<?php echo $this->getUrl('xpaymentsconnector/control/request'); ?>" method="post" name="request_form">
115
+ <?php echo $this->getBlockHtml('formkey'); ?>
116
+ <?php echo $this->getChildHtml('requestButton'); ?>
117
+ </form>
118
+
119
+
app/design/adminhtml/default/default/template/xpaymentsconnector/form/prepaidpayments.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * X-Payments Prepaid Payments method form.
25
+ *
26
+ * @see CCdev_XPaymentsConnector_Block_Form_Prepaidpayments
27
+ */
28
+ ?>
29
+ <?php $_code = $this->getMethodCode() ?>
30
+ <?php $userAdminhtmlPrepaidCardsList = $this->getAdminhtmlUserPrepaidCardsList(); ?>
31
+ <?php
32
+ $admSession = Mage::getSingleton('adminhtml/session');
33
+ $cardSelected = $admSession->getData("xp_prepaid_payments");
34
+ ?>
35
+
36
+ <?php if( $userAdminhtmlPrepaidCardsList && ($userAdminhtmlPrepaidCardsList->getSize()>0)):?>
37
+ <ul id="payment_form_<?php echo $_code ?>" class="adminhtml-payment-form" style="display:none;">
38
+ <?php foreach($userAdminhtmlPrepaidCardsList as $key => $prepaidCard):?>
39
+ <?php $checked = ($prepaidCard->getData("xp_card_id") == $cardSelected)?"checked":"";
40
+ ?>
41
+ <li>
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()); ?>
49
+ </span>
50
+ </span>
51
+
52
+ </li>
53
+ <?php endforeach;?>
54
+ </ul>
55
+ <?php endif;?>
56
+
app/design/adminhtml/default/default/template/xpaymentsconnector/form/savedcards.phtml ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Savedcards
25
+ */
26
+ ?>
27
+ <?php $_code = $this->getMethodCode() ?>
28
+ <?php $userAdminhtmlCreditCardsList = $this->getAdminhtmlUserCreditCardsList(); ?>
29
+ <?php
30
+ $admSession = Mage::getSingleton('adminhtml/session');
31
+ $cardSelected = $admSession->getData("xp_payment_card");
32
+ ?>
33
+
34
+ <?php if( $userAdminhtmlCreditCardsList && ($userAdminhtmlCreditCardsList->getSize()>0)):?>
35
+ <ul id="payment_form_<?php echo $_code ?>" class="adminhtml-payment-form" style="display:none;">
36
+ <?php foreach($userAdminhtmlCreditCardsList as $key => $creditCard):?>
37
+ <?php $checked = ($creditCard->getData("xp_card_id") == $cardSelected)?"checked":"";
38
+ ?>
39
+
40
+ <li>
41
+ <span class="input-box">
42
+ <input disabled="" type="radio" <?php echo $checked;?> title="<?php echo "'".$creditCard->getData("card_type")."'"; ?> - credit card" class="input-radio x-payment-card validate-one-required-by-name" id="<?php echo $_code."_".$creditCard->getData("xp_card_id"); ?>" name="payment[xp_payment_card]" value="<?php echo $creditCard->getData("xp_card_id");?>" />
43
+ <label for="<?php echo $_code."_".$creditCard->getData("xp_card_id") ?>">Use card ( **<?php echo $creditCard->getData("last_4_cc_num");?> )</label>
44
+ <span class="x-payment-card-logo <?php echo strtolower($creditCard->getData("card_type")) ?>" title="<?php echo $creditCard->getData("card_type");?>"></span>
45
+ </span>
46
+
47
+ </li>
48
+ <?php endforeach;?>
49
+ </ul>
50
+ <?php endif;?>
51
+
app/design/adminhtml/default/default/template/xpaymentsconnector/info.phtml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @category Cdev
16
+ * @package Cdev_XPaymentsConnector
17
+ * @copyright Copyright (c) 2010 Creative Development LLC <info@cdev.ru>. 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 } ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/info/cc.phtml ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Cc
25
+ */
26
+ ?>
27
+ <?php
28
+ $orderCardData = unserialize($this->getInfo()->getMethodInstance()->getOrder()->getData("xp_card_data"));
29
+ ?>
30
+ <?php echo $this->getMethod()->getTitle(); ?>
31
+ <br />
32
+ <?php if ($this->getInfo()->getLastTransId() == '') { ?>
33
+ <!--em><?php echo Mage::helper('xpaymentsconnector')->__('You will be redirected to X-Payments website when you place an order.'); ?></em-->
34
+ <?php } else { ?>
35
+ <?php echo Mage::helper('xpaymentsconnector')->__('X-Payments Transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())); ?><br />
36
+ <?php } ?>
37
+ <?php if(!empty($orderCardData)): ?>
38
+ <span id="x-payment-prepaid-card-info">
39
+ <?php echo $this->__("For current order we used your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
40
+ </span>
41
+ <?php endif;?>
app/design/adminhtml/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Prepaidpayments
25
+ */
26
+ ?>
27
+ <?
28
+ $admSession = Mage::getSingleton('adminhtml/session');
29
+ $xpPrepaidPaymentsCard = $admSession->getData("xp_prepaid_payments");
30
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($xpPrepaidPaymentsCard)->getData();
31
+ ?>
32
+ <?php echo $this->getMethod()->getTitle(); ?>
33
+ <br />
34
+ <?php if (!empty($cardData)): ?>
35
+ <span id="x-payment-prepaid-card-info">
36
+ <?php echo $this->__("For current order we charged funds from your payment card (**%s)",$cardData['last_4_cc_num']); ?>
37
+ </span>
38
+ <?php elseif ($orderId = $this->getRequest()->getParam("order_id")): ?>
39
+ <?php $orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData("xp_card_data")); ?>
40
+ <span id="x-payment-prepaid-card-info">
41
+ <?php echo $this->__("For current order we charged funds from your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
42
+ </span>
43
+ <?php endif; ?>
44
+
45
+
app/design/adminhtml/default/default/template/xpaymentsconnector/info/savedcards.phtml ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Savedcards
25
+ */
26
+ ?>
27
+ <?
28
+ $admSession = Mage::getSingleton('adminhtml/session');
29
+ $adminhtmlPaymentCardNumber = $admSession->getData("xp_payment_card");
30
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
31
+ $paymentCardNumber = $quote->getPayment()->getData("xp_payment_card");
32
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber)->getData();
33
+ ?>
34
+ <?php echo $this->getMethod()->getTitle(); ?>
35
+ <br />
36
+ <?php if (!empty($cardData)): ?>
37
+ <span id="x-payment-card-info">
38
+ <?php echo $this->__("For current order we used your payment card (**%s)",$cardData['last_4_cc_num']); ?>
39
+ </span>
40
+ <?php elseif ($orderId = $this->getRequest()->getParam("order_id")): ?>
41
+ <?php $orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData("xp_card_data")); ?>
42
+ <span id="x-payment-card-info">
43
+ <?php echo $this->__("For current order we used your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
44
+ </span>
45
+ <?php elseif ($adminhtmlPaymentCardNumber): ?>
46
+ <?php $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($adminhtmlPaymentCardNumber)->getData(); ?>
47
+ <?php if(!empty($cardData)): ?>
48
+ <span id="x-payment-card-info">
49
+ <?php echo $this->__("For current order we used your payment card (**%s)",$cardData['last_4_cc_num']); ?>
50
+ </span>
51
+ <?php endif; ?>
52
+ <?php endif; ?>
53
+
54
+
app/design/adminhtml/default/default/template/xpaymentsconnector/order/view/tab/xporderstate.phtml ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * X-Payments order state template
25
+ *
26
+ * @see Cdev_XPaymentsConnector_Block_Adminhtml_Sales_Order_View_Tab_Xporderstate
27
+ */
28
+ ?>
29
+
30
+ <?php $xpaymentsOrderInfo = $this->getXpaymentsOrderInfo(); ?>
31
+ <?php if($xpaymentsOrderInfo["success"]): ?>
32
+ <?php $xpaymentOrderState = $xpaymentsOrderInfo["info"]["payment"];?>
33
+ <?php $xpaymentOrdertransactionsList = $xpaymentsOrderInfo["info"]["transactions"]; ?>
34
+ <div class="entry-edit">
35
+ <div class="entry-edit-head">
36
+ <h4><?php echo $this->__('Transaction list'); ?></h4>
37
+ </div>
38
+
39
+ <div class="grid np">
40
+ <div class="hor-scroll">
41
+ <table cellspacing="0" id="xpayment-transaction-list" class="data order-tables">
42
+ <colgroup>
43
+ <col />
44
+ <col />
45
+ <col width="1">
46
+ <col width="1">
47
+ <col width="1">
48
+ <col width="1">
49
+ <col width="1">
50
+ </colgroup><thead>
51
+ <tr class="headings">
52
+ <th><span class="nobr"><?php echo $this->__('Additional info'); ?></span></th>
53
+ <th><span class="nobr"><?php echo $this->__('Date, time'); ?></span></th>
54
+ <th><span class="nobr"><?php echo $this->__('Type'); ?></span></th>
55
+ <th><span class="nobr"><?php echo $this->__('Result payment status'); ?></span></th>
56
+ <th class="last"><span class="nobr"><?php echo $this->__('Transaction result'); ?></span></th>
57
+ <th class="last"><span class="nobr"><?php echo $this->__('Total'); ?></span></th>
58
+ </tr>
59
+ </thead>
60
+ <tbody>
61
+ <?php $rowClass = "odd";?>
62
+ <?php foreach($xpaymentOrdertransactionsList as $key => $transaction):?>
63
+ <?php $rowClass = ($key%2==0)?"even":"odd"; ?>
64
+ <tr class="border pointer <?php echo $rowClass?>">
65
+ <td>
66
+ <div class="item-container" >
67
+ <table cellspacing="0" class="form-list">
68
+ <tbody>
69
+ <?php foreach($transaction["fields"] as $field): ?>
70
+ <tr>
71
+ <td class="label"><label><?php echo $field["name"]?></label></td>
72
+ <td class="value"><strong><?php echo $field["value"]?></strong></td>
73
+ </tr>
74
+ <?php endforeach; ?>
75
+ </tbody>
76
+ </table>
77
+ </div>
78
+ </td>
79
+ <td>
80
+ <div class="item-container">
81
+ <div class="item-text">
82
+ <strong>
83
+ <?php echo date("M d,Y H:i:s",$transaction["date"]);?>
84
+ </strong>
85
+ </div>
86
+ </div>
87
+ </td>
88
+ <td class="a-center">
89
+ <span class="price">
90
+ <strong>
91
+ <?php echo $transaction["action"];?>
92
+ </strong>
93
+ </span></td>
94
+ <td class="a-center">
95
+ <span class="price">
96
+ <?php echo $transaction["payment_status"];?>
97
+ </span>
98
+ </td>
99
+ <td class="a-center">
100
+ <span class="price">
101
+ <?php echo $transaction["status"];?>
102
+ </span>
103
+ </td>
104
+ <td class="a-center">
105
+ <span class="price">
106
+ <strong>
107
+ <?php echo $transaction["total"];?>
108
+ </strong>
109
+ </span>
110
+ </td>
111
+ </tr>
112
+ <?php endforeach;?>
113
+ </tbody>
114
+ </table>
115
+ </div>
116
+ </div>
117
+ </div>
118
+
119
+ <p>
120
+ <br />
121
+ <br />
122
+ <div class="entry-edit">
123
+ <div class="entry-edit-head">
124
+ <h4><?php echo $this->__('Order state'); ?></h4>
125
+ </div>
126
+
127
+ <div class="grid">
128
+ <div class="hor-scroll">
129
+ <table cellspacing="0" class="data order-tables">
130
+ <colgroup><col>
131
+ <col width="1">
132
+ <col width="1">
133
+ <col width="1">
134
+ <col width="1">
135
+ </colgroup><thead>
136
+ <tr class="headings">
137
+ <th><span class="nobr"><?php echo $this->__('Amount'); ?></span></th>
138
+ <th><span class="nobr"><?php echo $this->__('Authorized'); ?></span></th>
139
+ <th><span class="nobr"><?php echo $this->__('Captured'); ?></span></th>
140
+ <th class="last"><span class="nobr"><?php echo $this->__('Refunds'); ?></span></th>
141
+ </tr>
142
+ </thead>
143
+ <tbody class="even">
144
+ <tr class="border">
145
+ <td>
146
+ <div class="item-container" id="order_item_446">
147
+ <div class="item-text">
148
+ <?php if(!empty($xpaymentOrderState["message"])): ?>
149
+ <h5 class="title">
150
+ <span id="order_title">
151
+ <?php echo $this->__($xpaymentOrderState["message"]);?>
152
+ </span></h5>
153
+ <?php endif;?>
154
+ <span class="price">
155
+ <?php echo Mage::helper('core')->currency($xpaymentOrderState["amount"], true, false);?>
156
+ </span>
157
+ </div>
158
+ </div>
159
+ </td>
160
+ <td class="a-center">
161
+ <span class="price">
162
+ <?php echo Mage::helper('core')->currency($xpaymentOrderState["authorized"], true, false);?>
163
+ </span></td>
164
+ <td class="a-center">
165
+ <span class="price">
166
+ <?php echo Mage::helper('core')->currency($xpaymentOrderState["capturedAmount"], true, false);?>
167
+ </span>
168
+ </td>
169
+ <td class="a-center">
170
+ <span class="price">
171
+ <?php echo Mage::helper('core')->currency($xpaymentOrderState["refundedAmount"], true, false);?>
172
+ </span>
173
+ </td>
174
+ </tr>
175
+
176
+ </tbody>
177
+ </table>
178
+ </div>
179
+ </div>
180
+ </div>
181
+ </p>
182
+
183
+ <?php else: ?>
184
+ <?php echo $xpaymentsOrderInfo["error_message"];?>
185
+ <?php endif;?>
app/design/adminhtml/default/default/template/xpaymentsconnector/pdf/info.phtml ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php echo $this->getMethod()->getTitle() ?>
app/design/adminhtml/default/default/template/xpaymentsconnector/usercards/tab/js.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+
23
+ <script type="text/javascript">
24
+ function refreshUsercardsGrid(grid, gridMassAction, transport) {
25
+ grid.reload();
26
+ gridMassAction.unselectAll();
27
+ }
28
+ </script>
app/design/frontend/default/default/layout/xpaymentsconnector.xml ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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 Valerii Demidov
17
+ * @category Cdev
18
+ * @package Cdev_XPaymentsConnector
19
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
20
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
21
+ */
22
+ -->
23
+ <layout version="1.0.0">
24
+
25
+ <checkout_onepage_index translate="label">
26
+ <reference name="head">
27
+ <block type="core/text" name="google.jquery">
28
+ <action method="setText">
29
+ <text>
30
+ <![CDATA[<script type="text/javascript" src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script>]]></text>
31
+ </action>
32
+ </block>
33
+ <block type="core/text" name="google.jquery.noconflict" after="google.jquery">
34
+ <action method="setText">
35
+ <text><![CDATA[<script type="text/javascript">jQuery.noConflict(); </script>]]></text>
36
+ </action>
37
+ </block>
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
+ </reference>
49
+ </checkout_onepage_index>
50
+
51
+ <checkout_onepage_review translate="label">
52
+ <reference name="checkout.onepage.review.info.items.after">
53
+ <block type="xpaymentsconnector/checkout_onepage_settings" name="xpayment_settings" output="toHtml"
54
+ template="xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml"/>
55
+ </reference>
56
+ <reference name="checkout.onepage.review.button">
57
+ <action method="setTemplate">
58
+ <template helper="xpaymentsconnector/data/getReviewButtonTemplate">
59
+ <name>xpaymentsconnector/checkout/onepage/review/button.phtml</name>
60
+ <block>checkout.onepage.review.button</block>
61
+ </template>
62
+ </action>
63
+ </reference>
64
+ </checkout_onepage_review>
65
+
66
+
67
+ <xpaymentsconnector_processing_redirect>
68
+ <reference name="root">
69
+ <action method="setTemplate">
70
+ <template>xpaymentsconnector/blank.phtml</template>
71
+ </action>
72
+ </reference>
73
+ <reference name="content">
74
+ <block type="xpaymentsconnector/redirect" name="xpaymentsconnector_redirect"
75
+ template="xpaymentsconnector/redirect.phtml"/>
76
+ </reference>
77
+ </xpaymentsconnector_processing_redirect>
78
+
79
+
80
+ <customer_account>
81
+ <reference name="head">
82
+ <action method="addItem">
83
+ <type>js_css</type>
84
+ <name>xpayment/settings.css</name>
85
+ <params/>
86
+ </action>
87
+ </reference>
88
+ <reference name="customer_account_navigation">
89
+ <action method="addLink" translate="label" module="xpaymentsconnector">
90
+ <name>customer_usercards</name>
91
+ <path>xpaymentsconnector/customer/usercards</path>
92
+ <label>My Payment Cards</label>
93
+ </action>
94
+ </reference>
95
+ </customer_account>
96
+
97
+ <xpaymentsconnector_customer_usercards translate="label">
98
+ <label>Customer My Account credit cards list</label>
99
+ <update handle="customer_account"/>
100
+ <reference name="my.account.wrapper">
101
+ <block type="xpaymentsconnector/customer_usercards" name="xpaymentsconnector_customer_usercards" template="xpaymentsconnector/customer/usercards/list.phtml" />
102
+ </reference>
103
+ <reference name="root">
104
+ <action method="setHeaderTitle" translate="title" module="xpaymentsconnector"><title>My credit cards list</title></action>
105
+ </reference>
106
+ </xpaymentsconnector_customer_usercards>
107
+
108
+ <xpaymentsconnector_customer_cardadd translate="label">
109
+ <label>Add new credit card to list (X-Payments)</label>
110
+ <update handle="customer_account"/>
111
+ <reference name="my.account.wrapper">
112
+ <block type="xpaymentsconnector/customer_cardadd" name="xpaymentsconnector_customer_cardadd" template="xpaymentsconnector/customer/usercards/cardadd.phtml" />
113
+ </reference>
114
+ </xpaymentsconnector_customer_cardadd>
115
+
116
+
117
+ <!--add discount item on user profile page-->
118
+ <sales_recurring_profile_view>
119
+ <reference name="sales.recurring.profile.view">
120
+ <remove name="sales.recurring.profile.view.fees" />
121
+ <block type="xpaymentsconnector/recurring_profile_view" name="xpaymentsconnector.sales.recurring.profile.view.fees" as="fees" template="sales/recurring/profile/view/info.phtml">
122
+ <action method="prepareFeesInfo"/>
123
+ <action method="addToParentGroup"><value>info_blocks_row_2</value></action>
124
+ <action method="setViewColumn"><value>2</value></action>
125
+ <action method="setViewLabel" translate="value"><value>Profile Payments</value></action>
126
+ </block>
127
+ </reference>
128
+ </sales_recurring_profile_view>
129
+
130
+ </layout>
app/design/frontend/default/default/template/xpaymentsconnector/blank.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
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') ?>
29
+ </body>
30
+ </html>
app/design/frontend/default/default/template/xpaymentsconnector/cancel.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @author Valerii Demidov
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
+ ?>
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/default/default/template/xpaymentsconnector/checkout/onepage/beforesuccess.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ /**
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
+ jQuery.ajax({
51
+ url: "<?php echo $this->getSaveOrderUrl();?>",
52
+ type: "post",
53
+ data: {"payment[method]": "<?php echo $this->getXpaymentsCode();?>","form_key":"<?php echo $formKey;?>"},
54
+ datatype: 'json',
55
+ success: function(data){
56
+ var response = jQuery.parseJSON(data);
57
+ if(response.success == true){
58
+ window.parent.location = "<?php echo $this->getCheckoutSuccessUrl();?>";
59
+ }else if(response.success == false){
60
+ if(response['error_messages']){
61
+ alert(response['error_messages']);
62
+ }
63
+ if(response['redirect'] != undefined){
64
+ window.parent.location = response['redirect'];
65
+ }else{
66
+ window.parent.location = "<?php echo Mage::getUrl();?>";
67
+ }
68
+ }
69
+ },
70
+ error:function(){
71
+ }
72
+ });
73
+ });
74
+ </script>
75
+ </body>
76
+
77
+ </html>
app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/review/button.phtml ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ $xpayUrlMas = parse_url(Mage::getModel('xpaymentsconnector/payment_cc')->getConfig('xpay_url'));
24
+ $xpayUrl = $xpayUrlMas["scheme"]."://".$xpayUrlMas["host"];
25
+ $updateCartUrl = Mage::getUrl("checkout/cart",array("unset_xp_prepare_order"=>1));
26
+ $checkIframeUrl = Mage::getUrl('xpaymentsconnector/processing/istokenactual', array('_nosid' => true,'_secure'=>true));
27
+ ?>
28
+
29
+ <button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="submitXpaymentIframe('<?php echo $checkIframeUrl;?>');"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
30
+
31
+ <script type="text/javascript">
32
+ /*process iframe session expired*/
33
+ var redirectUrl = '<?php echo $updateCartUrl;?>';
34
+ var eventUrlPath = '<?php echo $xpayUrl; ?>';
35
+ Event.observe(window, 'message', function (event) {
36
+ var eventUrl = event.origin;
37
+ if (eventUrl == eventUrlPath) {
38
+ var jsonEventData = JSON.parse(event.data)
39
+ if (jsonEventData.message = "paymentFormSubmitError") {
40
+ if (jsonEventData.params.type != undefined && jsonEventData.params.type == "2") {
41
+ Foobar = function () {
42
+ this.callBack = function () {
43
+ window.location.replace(redirectUrl);
44
+ };
45
+ }
46
+ Foobar.prototype = {
47
+ Init: function () {
48
+ var self = this;
49
+ var errorMessage = jsonEventData.params.error+ " (X-Payments)";
50
+ alert(errorMessage);
51
+ self.callBack.call();
52
+
53
+ }
54
+ };
55
+ var foobar = new Foobar();
56
+ foobar.Init();
57
+ }
58
+ }
59
+ }
60
+ });
61
+ </script>
62
+
63
+
64
+
65
+
app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/settings.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ * @category Cdev
16
+ * @package Cdev_XPaymentsConnector
17
+ * @copyright Copyright (c) 2010 Creative Development LLC <info@cdev.ru>. All rights reserved
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ * @version SVN: $Id: blank.phtml 3624 2010-07-28 05:45:05Z max $
20
+ */
21
+ ?>
22
+ <?php
23
+
24
+
25
+ ?>
26
+
27
+ <script>
28
+ /* function xpaymentSave(){
29
+ if (checkout.loadWaiting!=false) return;
30
+
31
+ var validator = new Validation(this.form);
32
+ if (validator.validate()) {
33
+ checkout.setLoadWaiting('billing');
34
+
35
+ // if ($('billing:use_for_shipping') && $('billing:use_for_shipping').checked) {
36
+ // $('billing:use_for_shipping').value=1;
37
+ // }
38
+ console.log(this.saveUrl);
39
+ /*var request = new Ajax.Request(
40
+ this.saveUrl,
41
+ {
42
+ method: 'post',
43
+ onComplete: this.onComplete,
44
+ onSuccess: this.onSave,
45
+ onFailure: checkout.ajaxFailure.bind(checkout),
46
+ parameters: Form.serialize(this.form)
47
+ }
48
+ );*//*
49
+ }
50
+ },
51
+
52
+ alert("ura");*/
53
+
54
+ </script>
55
+
56
+
app/design/frontend/default/default/template/xpaymentsconnector/checkout/onepage/xpayment-iframe.phtml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * Additional settings for "IFrame" variant of payment method (frontend)
25
+ *
26
+ * @see Cdev_XPaymentsConnector_Block_Checkout_Onepage_Settings
27
+ */
28
+ ?>
29
+
30
+ <?php
31
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
32
+ $isRecuringProduct = Mage::helper("xpaymentsconnector")->checkIsRecurringOrder();
33
+ $IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
34
+ ?>
35
+
36
+ <?php if($this->isXpaymentMethod() && $useIframe):?>
37
+ <?php
38
+ $iFrameUrl = $this->getIframeUrl();
39
+ $isNeedToSaveUserCard = Mage::helper("xpaymentsconnector")->isNeedToSaveUserCard();
40
+ $customerRegistered = Mage::helper("xpaymentsconnector")->isRegisteredUser();
41
+ ?>
42
+ <div id="xpayment-iframe-block">
43
+ <iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
44
+ </iframe>
45
+ <?php if($customerRegistered):?>
46
+ <?php if(!$isRecuringProduct): ?>
47
+ <?php if ($IsSaveCardsPaymentActive): ?>
48
+ <span id="iframe-save-card-switcher" >
49
+ <input type="checkbox" <?php echo ($isNeedToSaveUserCard)?"checked":"";?> title="<?php echo $this->__("Use this credit card"); ?>" class="checkbox x-payment-card " id="iframe_savecard" name="iframe_savecard" value="1" />
50
+ <label for="iframe_savecard"><?php echo $this->__("I want to use this credit card for my future orders in this shop."); ?></label>
51
+ </span>
52
+ <script type="text/javascript">
53
+ var url = "<?php echo Mage::getUrl("xpaymentsconnector/processing/saveusercard");?>";
54
+ $('iframe_savecard').observe('change',
55
+ function() {
56
+ if($('iframe_savecard').checked === true) {
57
+ new Ajax.Request(url, {
58
+ parameters: "user_card_save=1"
59
+ });
60
+ }else{
61
+ new Ajax.Request(url, {
62
+ parameters: "user_card_save=0"
63
+ });
64
+ }
65
+ });
66
+ </script>
67
+ <?php endif; ?>
68
+ <?php else: ?>
69
+ <span id="iframe-save-card-switcher" >
70
+ <?php echo $this->__("Your credit card will be saved for this subscription."); ?>
71
+ </span>
72
+ <?php endif;?>
73
+ <?php endif;?>
74
+ </div>
75
+ <?php endif;?>
76
+
77
+
app/design/frontend/default/default/template/xpaymentsconnector/customer/cardaddsuccess.phtml ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ /**
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/default/default/template/xpaymentsconnector/customer/usercards/cardadd.phtml ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Customer_Cardadd
25
+ */
26
+ ?>
27
+ <?php
28
+ $xpayUrlMas = parse_url(Mage::getModel('xpaymentsconnector/payment_cc')->getConfig('xpay_url'));
29
+ $xpayUrl = $xpayUrlMas["scheme"]."://".$xpayUrlMas["host"];
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
+ $iFrameUrl = $this->getIframeUrl();
38
+ ?>
39
+ <div id="new-card-block">
40
+ <div id="xpayment-iframe-block">
41
+ <iframe id="xp-iframe" class="xp-iframe" data-src="<?php echo $iFrameUrl;?>" src="<?php echo $iFrameUrl;?>" name="xp-iframe">
42
+ </iframe>
43
+ <button onclick="cardAuthorizeSubmit();" id="create-card-button" class="button" title="Add new card" type="button"><span><span>Create card</span></span></button>
44
+ <span style="display:none;" id="card-add-please-wait" class="please-wait">
45
+ <img class="v-middle" title="<?php echo $this->__("Submit card information...");?>" alt="<?php echo $this->__("Submit card information...");?>"
46
+ src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>">&nbsp;<?php echo $this->__("Submit card information...");?>
47
+ </span>
48
+ </div>
49
+ </div>
50
+
51
+
52
+
53
+ <div class="buttons-set">
54
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
55
+ </div>
56
+
57
+ <script type="text/javascript">
58
+ /*process iframe session expired*/
59
+ var redirectUrl = '<?php echo $this->getUrl('xpaymentsconnector/customer/usercards');?>';
60
+ var eventUrlPath = '<?php echo $xpayUrl; ?>';
61
+ Event.observe(window, 'message', function (event) {
62
+ var eventUrl = event.origin;
63
+ if (eventUrl == eventUrlPath) {
64
+ var jsonEventData = JSON.parse(event.data)
65
+ if (jsonEventData.message = "paymentFormSubmitError") {
66
+ if (jsonEventData.params.type != undefined && jsonEventData.params.type == "2") {
67
+ Foobar = function () {
68
+ this.callBack = function () {
69
+ window.location.replace(redirectUrl);
70
+ };
71
+ }
72
+ Foobar.prototype = {
73
+ Init: function () {
74
+ var self = this;
75
+ var errorMessage = jsonEventData.params.error + " (X-Payments)";
76
+ console.log(jsonEventData);
77
+ alert(errorMessage);
78
+ self.callBack.call();
79
+
80
+ }
81
+ };
82
+ var foobar = new Foobar();
83
+ foobar.Init();
84
+ }
85
+ }
86
+ }
87
+ });
88
+
89
+
90
+ function cardAuthorizeSubmit() {
91
+
92
+ var message = {
93
+ message: 'submitPaymentForm',
94
+ params: {}
95
+ };
96
+ $("create-card-button").hide();
97
+ $("card-add-please-wait").show()
98
+ var messageJson = JSON.stringify(message);
99
+ var xpcShown = $('xp-iframe');
100
+ xpcShown.contentWindow.postMessage(messageJson, '*');
101
+ window.addEventListener("message", receiveMessage, false);
102
+
103
+
104
+ }
105
+
106
+ function receiveMessage(event)
107
+ {
108
+ $("create-card-button").show();
109
+ $("card-add-please-wait").hide()
110
+ }
111
+ </script>
app/design/frontend/default/default/template/xpaymentsconnector/customer/usercards/list.phtml ADDED
@@ -0,0 +1,103 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Customer_Usercards
25
+ */
26
+ ?>
27
+ <?php $_items = $this->getItems(); ?>
28
+ <?php $cardUsageOptions = Mage::getModel("xpaymentsconnector/usercards")->getCardsUsageOptions();?>
29
+ <div class="page-title">
30
+ <h1><?php echo Mage::helper('xpaymentsconnector')->__('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 Mage::helper('xpaymentsconnector')->__('Card id #') ?></th>
48
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Card number') ?></th>
49
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Card type') ?></th>
50
+ <th><?php echo Mage::helper('xpaymentsconnector')->__('Usage 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" value="<?php echo $_item->getData("xp_card_id");?>" name="card[]"></td>
58
+ <td><?php echo $_item->getData("xp_card_id");?></td>
59
+ <td>**<?php echo $_item->getData("last_4_cc_num");?></td>
60
+ <td><span class="x-payment-card-logo-list <?php echo strtolower($_item->getData("card_type")) ?>" title="<?php echo $_item->getData("card_type");?>"></span></td>
61
+ <td><?php echo $cardUsageOptions[$_item->getData("usage_type")];?></td>
62
+ </tr>
63
+ <?php endforeach; ?>
64
+ </tbody>
65
+ </table>
66
+ <input type="hidden" name="action" value="remove">
67
+
68
+ <script type="text/javascript">decorateTable('my-credit-cards-table')</script>
69
+ <?php else: ?>
70
+ <p><?php echo Mage::helper('xpaymentsconnector')->__('You have no saved credit cards yet.'); ?></p>
71
+ <?php endif; ?>
72
+ <?php echo $this->getChildHtml('pager'); ?>
73
+ <div class="buttons-set">
74
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
75
+ <?php if(count($_items)): ?>
76
+ <button class="button" title="Save" type="submit"><span><span>Remove</span></span></button>
77
+ <?php endif; ?>
78
+ <button onclick="window.location='<?php echo $this->getAddCardUrl();?>'" class="button" title="Add new card" type="button"><span><span>Add new card</span></span></button>
79
+ </div>
80
+ </form>
81
+
82
+ <script type="text/javascript">
83
+ //<![CDATA[
84
+
85
+ function addRelatedCard(event){
86
+ Event.stop(event)
87
+ var checkboxes = $$('.related-checkbox');
88
+ var values = [];
89
+ for(var i=0;i<checkboxes.length;i++){
90
+ checkboxes[i].checked = true;
91
+ }
92
+ }
93
+ function removeRelatedCard(event){
94
+ Event.stop(event)
95
+ var checkboxes = $$('.related-checkbox');
96
+ var values = [];
97
+ for(var i=0;i<checkboxes.length;i++){
98
+ checkboxes[i].checked = false;
99
+ }
100
+ }
101
+ //]]>
102
+ </script>
103
+
app/design/frontend/default/default/template/xpaymentsconnector/failure.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
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/default/default/template/xpaymentsconnector/form/cc.phtml ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Form_Cc
25
+ */
26
+ ?>
27
+ <?php
28
+ $_code=$this->getMethodCode();
29
+ $useIframe = Mage::getStoreConfig('payment/xpayments/use_iframe');
30
+ $isRecuringProduct = Mage::helper("xpaymentsconnector")->checkIsRecurringOrder();
31
+ $IsSaveCardsPaymentActive = (bool)Mage::getStoreConfig('payment/savedcards/active');
32
+ ?>
33
+ <?php if (!$useIframe): ?>
34
+ <?php if (!$isRecuringProduct): ?>
35
+ <?php if ($IsSaveCardsPaymentActive): ?>
36
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
37
+ <li>
38
+ <span class="input-box">
39
+ <input type="checkbox"
40
+ title="<?php echo $this->__("I want to save a credit card for my future orders in this shop"); ?>"
41
+ class="checkbox x-payment-card " id="<?php echo $_code . "_" . "save_card" ?>"
42
+ name="savecard" value="1"/>
43
+ <label
44
+ for="<?php echo $_code . "_" . "save_card" ?>"><?php echo $this->__("I want to save a credit card for my future orders in this shop"); ?></label>
45
+ </span>
46
+ </li>
47
+ </ul>
48
+ <?php endif; ?>
49
+ <?php else: ?>
50
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
51
+ <li>
52
+ <span class="input-box">
53
+ <?php echo $this->__("Your credit card will be saved for this subscription."); ?>
54
+ </span>
55
+ </li>
56
+ </ul>
57
+ <?php endif; ?>
58
+ <?php endif; ?>
59
+
60
+
app/design/frontend/default/default/template/xpaymentsconnector/form/savedcards.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Form_Savedcards
25
+ */
26
+ ?>
27
+
28
+ <?php $_code=$this->getMethodCode() ?>
29
+ <?php $userCreditCardsList = $this->getUserCreditCardsList();?>
30
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none;">
31
+ <?php if($userCreditCardsList):?>
32
+ <?php foreach($userCreditCardsList as $key => $creditCard):?>
33
+ <li>
34
+ <span class="input-box">
35
+ <input type="radio" title="<?php echo "'".$creditCard->getData("card_type")."'"; ?> - credit card" class="input-radio x-payment-card validate-one-required-by-name" id="<?php echo $_code."_".$creditCard->getData("xp_card_id"); ?>" name="payment[xp_payment_card]" value="<?php echo $creditCard->getData("xp_card_id");?>" />
36
+ <label for="<?php echo $_code."_".$creditCard->getData("xp_card_id") ?>">Use card ( **<?php echo $creditCard->getData("last_4_cc_num");?> )</label>
37
+ <span class="x-payment-card-logo <?php echo strtolower($creditCard->getData("card_type")) ?>" title="<?php echo $creditCard->getData("card_type");?>"></span>
38
+ </span>
39
+
40
+ </li>
41
+ <?php endforeach;?>
42
+ <?php endif;?>
43
+ </ul>
44
+
app/design/frontend/default/default/template/xpaymentsconnector/info/cc.phtml ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Cc
25
+ */
26
+ ?>
27
+ <?php
28
+
29
+ $order = $this->getInfo()->getMethodInstance()->getOrder();
30
+ $orderCardData = array();
31
+ if($order){
32
+ $orderCardData = unserialize($this->getInfo()->getMethodInstance()->getOrder()->getData("xp_card_data"));
33
+ }
34
+
35
+ ?>
36
+ <?php echo $this->getMethod()->getTitle(); ?>
37
+ <br />
38
+ <?php if ($this->getInfo()->getLastTransId() == '') { ?>
39
+ <!--em><?php echo Mage::helper('xpaymentsconnector')->__('You will be redirected to X-Payments website when you place an order.'); ?></em-->
40
+ <?php } else { ?>
41
+ <?php echo Mage::helper('xpaymentsconnector')->__('X-Payments Transaction ID: %s', $this->htmlEscape($this->getInfo()->getLastTransId())); ?><br />
42
+ <?php } ?>
43
+ <?php if(!empty($orderCardData)): ?>
44
+ <span id="x-payment-prepaid-card-info">
45
+ <?php echo $this->__("For current order we used your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
46
+ </span>
47
+ <?php endif;?>
app/design/frontend/default/default/template/xpaymentsconnector/info/prepaidpayments.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Prepaidpayments
25
+ */
26
+ ?>
27
+ <?
28
+ $admSession = Mage::getSingleton('adminhtml/session');
29
+ $xpPrepaidPaymentsCard = $admSession->getData("xp_prepaid_payments");
30
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($xpPrepaidPaymentsCard)->getData();
31
+ ?>
32
+ <?php echo $this->getMethod()->getTitle(); ?>
33
+ <br />
34
+ <?php if (!empty($cardData)): ?>
35
+ <span id="x-payment-prepaid-card-info">
36
+ <?php echo $this->__("For current order we charged funds from your payment card (**%s)",$cardData['last_4_cc_num']); ?>
37
+ </span>
38
+ <?php elseif ($orderId = $this->getRequest()->getParam("order_id")): ?>
39
+ <?php $orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData("xp_card_data")); ?>
40
+ <span id="x-payment-prepaid-card-info">
41
+ <?php echo $this->__("For current order we charged funds from your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
42
+ </span>
43
+ <?php endif; ?>
44
+
45
+
app/design/frontend/default/default/template/xpaymentsconnector/info/savedcards.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
22
+ <?php
23
+ /**
24
+ * @see Cdev_XPaymentsConnector_Block_Info_Savedcards
25
+ */
26
+ ?>
27
+ <?
28
+ $admSession = Mage::getSingleton('adminhtml/session');
29
+ $adminhtmlPaymentCardNumber = $admSession->getData("xp_payment_card");
30
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
31
+ $paymentCardNumber = $quote->getPayment()->getData("xp_payment_card");
32
+ $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($paymentCardNumber)->getData();
33
+ ?>
34
+ <?php echo $this->getMethod()->getTitle(); ?>
35
+ <br />
36
+ <?php if (!empty($cardData)): ?>
37
+ <span id="x-payment-card-info">
38
+ <?php echo $this->__("For current order we used your payment card (**%s)",$cardData['last_4_cc_num']); ?>
39
+ </span>
40
+ <?php elseif ($orderId = $this->getRequest()->getParam("order_id")): ?>
41
+ <?php $orderCardData = unserialize(Mage::getModel('sales/order')->load($orderId)->getData("xp_card_data")); ?>
42
+ <span id="x-payment-card-info">
43
+ <?php echo $this->__("For current order we used your payment card (**%s)",$orderCardData['last_4_cc_num']); ?>
44
+ </span>
45
+ <?php elseif ($adminhtmlPaymentCardNumber): ?>
46
+ <?php $cardData = Mage::getModel("xpaymentsconnector/usercards")->load($adminhtmlPaymentCardNumber)->getData(); ?>
47
+ <?php if(!empty($cardData)): ?>
48
+ <span id="x-payment-card-info">
49
+ <?php echo $this->__("For current order we used your payment card (**%s)",$cardData['last_4_cc_num']); ?>
50
+ </span>
51
+ <?php endif; ?>
52
+ <?php endif; ?>
53
+
54
+
55
+
app/design/frontend/default/default/template/xpaymentsconnector/redirect.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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 Valerii Demidov
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
+ ?>
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 ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
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
+ * @category Cdev
17
+ * @package Cdev_XPaymentsConnector
18
+ * @copyright Copyright (c) 2014 Internet Solutions for Business WEB4PRO <info@web4pro.com.ua>. 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
+ */
22
+ -->
23
+ <config>
24
+ <modules>
25
+ <Cdev_XPaymentsConnector>
26
+ <active>true</active>
27
+ <codePool>community</codePool>
28
+ </Cdev_XPaymentsConnector>
29
+ </modules>
30
+ </config>
app/locale/en_US/Cdev_XPaymentsConnector.csv ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "The payment has been canceled","The payment has been canceled"
2
+ "Please","Please"
3
+ "continue shopping.","continue shopping."
4
+ "Error occured","Error occured"
5
+ "You are being redirected to the payment form. Please wait a few seconds.","You are being redirected to the payment form. Please wait a few seconds."
6
+ "Your payment has been successfully processed by our shop system.","Your payment has been successfully processed by our shop system."
7
+ "here","here"
8
+ "Please click %s if you are not redirected automatically.","Please click %s if you are not redirected automatically."
9
+ "Please wait, your order is being created ...","Please wait, your order is being created ..."
10
+ "Your credit card will be saved for this subscription.","Your credit card will be saved for this subscription."
11
+ "I want to use this credit card for my future orders in this shop.","I want to use this credit card for my future orders in this shop."
12
+ "Edit payment cards list (X-Payments)","Edit payment cards list (X-Payments)"
13
+ "Card id #","Card id #"
14
+ "Card number","Card number"
15
+ "Card type","Card type"
16
+ "Usage card type","Usage card type"
17
+ "You have no saved credit cards yet.","You have no saved credit cards yet."
18
+ "Back","Back"
19
+ "I want to save a credit card for my future orders in this shop","I want to save a credit card for my future orders in this shop"
20
+ "Your credit card will be saved for this subscription.","Your credit card will be saved for this subscription."
21
+ "You will be redirected to X-Payments website when you place an order.","You will be redirected to X-Payments website when you place an order."
22
+ "X-Payments Transaction ID: %s","X-Payments Transaction ID: %s"
23
+ "For current order we used your payment card (**%s)","For current order we used your payment card (**%s)"
24
+ "For current order we charged funds from your payment card (**%s)","For current order we charged funds from your payment card (**%s)"
25
+ "Balance:","Balance:"
26
+ "Transaction list","Transaction list"
27
+ "Additional info","Additional info"
28
+ "Date, time","Date, time"
29
+ "Type","Type"
30
+ "Result payment status","Result payment status"
31
+ "Transaction result","Transaction result"
32
+ "Total","Total"
33
+ "Order state","Order state"
34
+ "Amount","Amount"
35
+ "Authorized","Authorized"
36
+ "Captured","Captured"
37
+ "Refunds","Refunds"
38
+ "Failed to meet environment requirements","Failed to meet environment requirements"
39
+ "Configuration problems","Configuration problems"
40
+ "Test module","Test module"
41
+ "To test the module settings and connection with X-Payments click the button below. If the module is configured properly, a 'Test transaction completed successfully' message will be displayed at the top of the page.","To test the module settings and connection with X-Payments click the button below. If the module is configured properly, a 'Test transaction completed successfully' message will be displayed at the top of the page."
42
+ "Import payment methods","Import payment methods"
43
+ "To be able to use X-Payments payment methods you need to import them from X-Payments first.","To be able to use X-Payments payment methods you need to import them from X-Payments first."
44
+ "The list of payment configurations imported from X-Payments","The list of payment configurations imported from X-Payments"
45
+ "Payment method","Payment method"
46
+ "Payment method ID","Payment method ID"
47
+ "Auth","Auth"
48
+ "Yes","Yes"
49
+ "Warning! Importing payment configurations from X-Payments will disable the X-Payments connector payment method!","Warning! Importing payment configurations from X-Payments will disable the X-Payments connector payment method!"
50
+ "Import payment methods from X-Payments","Import payment methods from X-Payments"
51
+ "Clear","Clear"
52
+ "Payment cards","Payment cards"
53
+ "X-Payment Order State","X-Payment Order State"
54
+ "This order has been broken. Parameter 'xpayments transaction id' is not available.","This order has been broken. Parameter 'xpayments transaction id' is not available."
55
+ "Can't get information about the order from X-Payments server. More information is available in log files.","Can't get information about the order from X-Payments server. More information is available in log files."
56
+ "Delete","Delete"
57
+ "Are you sure you want to delete the selected card(s)?","Are you sure you want to delete the selected card(s)?"
58
+ "Card id","Card id"
59
+ "X-Payments order url","X-Payments order url"
60
+ "Card number (last 4 digits)","Card number (last 4 digits)"
61
+ "X-Payments connector control","X-Payments connector control"
62
+ "System","System"
63
+ "The test transaction has been completed successfully.","The test transaction has been completed successfully."
64
+ "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."
65
+ "Payment methods have been successfully imported.","Payment methods have been successfully imported."
66
+ "There are no payment configurations for this store.","There are no payment configurations for this store."
67
+ "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."
68
+ "The list of imported payment configurations has been cleared. X-Payments connector payment method has been disabled.","The list of imported payment configurations has been cleared. X-Payments connector payment method has been disabled."
69
+ "Credit cards have been removed successfully.","Credit cards have been removed successfully."
70
+ "You have not selected any credit card.","You have not selected any credit card."
71
+ "My Payment Cards","My Payment Cards"
72
+ "Customer has been redirected to X-Payments.","Customer has been redirected to X-Payments."
73
+ "charge: Callback request","charge: Callback request"
74
+ "The order has been canceled.","The order has been canceled."
75
+ "This profile has run out of maximal limit of unsuccessful payment attempts.","This profile has run out of maximal limit of unsuccessful payment attempts."
76
+ "%s. The subscription has been canceled","%s. The subscription has been canceled"
77
+ "Transaction status is '%s'. The subscription has been canceled.","Transaction status is '%s'. The subscription has been canceled."
78
+ "The subscription has been canceled.","The subscription has been canceled."
79
+ "To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s","To create a subscription that uses an X-Payments method, your card will be charged a minimal payment - %s%s"
80
+ "You can't make an order using card (**%s) worth over %s","You can't make an order using card (**%s) worth over %s"
81
+ "Transaction token can not be found or has wrong type","Transaction token can not be found or has wrong type"
82
+ "Transaction token can not be found or has wrong type. The order has been canceled.","Transaction token can not be found or has wrong type. The order has been canceled."
83
+ "preauthorize: Customer returned successfully","preauthorize: Customer returned successfully"
84
+ "charge: Callback request","charge: Callback request"
85
+ "%s. The order has been canceled","%s. The order has been canceled"
86
+ "Transaction status is "%s". The order has been canceled.","Transaction status is "%s". The order has been canceled."
87
+ "Capture action is not available.","Capture action is not available."
88
+ "Refund action is not available.","Refund action is not available."
89
+ "Initial Fee %s.","Initial Fee %s."
90
+ "X-Payments connector","X-Payments connector"
91
+ "X-Payments configuration bundle","X-Payments configuration bundle"
92
+ "Configuration bundle is generated by X-Payments for this shop. It should be obtained from this shop details page in X-Payments back-end.","Configuration bundle is generated by X-Payments for this shop. It should be obtained from this shop details page in X-Payments back-end."
93
+ "IP addresses for X-Payments callbacks","IP addresses for X-Payments callbacks"
94
+ "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.","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."
95
+ "Payment currency","Payment currency"
96
+ "All payments will be made using the currency specified here.","All payments will be made using the currency specified here."
97
+ "Setup minimum payment amount for recurring orders and customer card authorization actions","Setup minimum payment amount for recurring orders and customer card authorization actions"
98
+ "This is minimal authorisation amount for recurring subscriptions ordered with start date in the future and customer card authorization actions.","This is minimal authorisation amount for recurring subscriptions ordered with start date in the future and customer card authorization actions."
99
+ "Payment configuration","Payment configuration"
100
+ "Use forced Authorize operation for initial fee","Use forced Authorize operation for initial fee"
101
+ "Use iFrame","Use iFrame"
102
+ "Use forced Authorize operation","Use forced Authorize operation"
103
+ "Use saved credit cards (X-Payments)","Use saved credit cards (X-Payments)"
104
+ "Prepaid Payments (X-Payments)","Prepaid Payments (X-Payments)"
105
+ "Add new credit card to list (X-Payments)","Add new credit card to list (X-Payments)"
106
+ "Submit card information...","Submit card information..."
107
+ "Payment card has been added successfully!","Payment card has been added successfully!"
108
+ "Transaction status is '%s'. Card authorization has been cancelled.","Transaction status is '%s'. Card authorization has been cancelled."
109
+ "Card authorization has been cancelled.","Card authorization has been cancelled."
110
+ "Transaction status is '%s'","Transaction status is '%s'"
111
+ "You created card number '%s'. Transaction status is '%s'.","You created card number '%s'. Transaction status is '%s'."
112
+ "Your order state has been changed during checkout. You will be redirected to the cart contents page.","Your order state has been changed during checkout. You will be redirected to the cart contents page."
113
+
114
+
115
+
116
+
117
+
118
+
119
+
120
+
121
+
js/xpayment/checkout-submit.js ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
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 Valerii Demidov
15
+ * @category Cdev
16
+ * @package Cdev_XPaymentsConnector
17
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ function submitXpaymentIframe(iframeCheckUrl) {
22
+
23
+ var currentIframeUrl = jQuery("#xp-iframe").attr("src");
24
+ var currentToken = getUrlParameterByName("token",currentIframeUrl);
25
+ var postData = {"token": currentToken};
26
+ jQuery("#review-buttons-container .btn-checkout").hide();
27
+ jQuery("#review-please-wait").show();
28
+
29
+ jQuery.ajax({
30
+ url: iframeCheckUrl,
31
+ type: 'post',
32
+ data: postData,
33
+ success: function(data){
34
+
35
+ var respnse = jQuery.parseJSON(data);
36
+ if(respnse.is_actual == false){
37
+ alert(respnse.error_message)
38
+ window.location.replace(respnse.redirect);
39
+ return false;
40
+ }
41
+
42
+ if (typeof Checkout != "undefined") {
43
+ if (typeof checkout != "undefined") {
44
+ var message = {
45
+ message: 'submitPaymentForm',
46
+ params: postData
47
+ };
48
+ var messageJson = JSON.stringify(message);
49
+ var xpcShown = jQuery('.xp-iframe').get(0);
50
+ xpcShown.contentWindow.postMessage(messageJson, '*');
51
+ window.addEventListener("message", receiveMessage, false);
52
+
53
+ }
54
+ }
55
+ },
56
+ error: function(){
57
+ alert('error!');
58
+ }
59
+ });
60
+ }
61
+
62
+
63
+ function receiveMessage(event)
64
+ {
65
+ jQuery("#review-buttons-container .btn-checkout").show();
66
+ jQuery("#review-please-wait").hide();
67
+ }
68
+
69
+
70
+ function getUrlParameterByName(name,url) {
71
+ name = name.replace(/[\[]/, "\\[").replace(/[\]]/, "\\]");
72
+ var regex = new RegExp("[\\?&]" + name + "=([^&#]*)"),
73
+ results = regex.exec(url);
74
+ return results == null ? "" : decodeURIComponent(results[1].replace(/\+/g, " "));
75
+ }
76
+
77
+
js/xpayment/images/card_types.png ADDED
Binary file
js/xpayment/images/loader.gif ADDED
Binary file
js/xpayment/settings.css ADDED
@@ -0,0 +1,426 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
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 Valerii Demidov
15
+ * @category Cdev
16
+ * @package Cdev_XPaymentsConnector
17
+ * @copyright (c) Qualiteam Software Ltd. <info@qtmsoft.com>. All rights reserved.
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ #xpayment-iframe-block iframe {
22
+ text-align: center;
23
+ height: 300px;
24
+ overflow-x: hidden;
25
+ overflow-y: hidden;
26
+ border: 0px;
27
+ width: 87%;
28
+ margin: 0 auto;
29
+ clear: both;
30
+ margin-left: 13%;
31
+ }
32
+
33
+ #xpayment-iframe-block {
34
+ padding-bottom: 10px;
35
+ border-left: 1px solid #d9dde3;
36
+ border-right: 1px solid #d9dde3;
37
+ }
38
+
39
+ iframe .buttonRow {
40
+ display: none;
41
+ }
42
+
43
+ * {
44
+ margin: 0;
45
+ padding: 0;
46
+ }
47
+
48
+ .b-loader-wrap {
49
+ position: fixed;
50
+ width: 100%;
51
+ height: 100%;
52
+ }
53
+
54
+ #ajax-loader {
55
+ background: url("images/loader.gif") 50% 50% no-repeat;
56
+ height: 213px;
57
+ left: 50%;
58
+ margin-bottom: 0;
59
+ margin-left: -245px;
60
+ margin-right: 0;
61
+ margin-top: -106px;
62
+ position: fixed;
63
+ text-align: center;
64
+ top: 50%;
65
+ width: 400px;
66
+ z-index: 100000;
67
+ }
68
+
69
+ #payment_form_xpayments > li {
70
+ padding-left: 20px;
71
+ }
72
+
73
+ .input-radio.x-payment-card {
74
+ margin-right: 3px;
75
+ }
76
+ #select-all-cards{
77
+ color: darkblue;
78
+ }
79
+
80
+ #unselect-all-cards{
81
+ color: darkblue;
82
+ }
83
+ #iframe-save-card-switcher {
84
+ padding-left: 15%;
85
+ }
86
+
87
+ /* payment cards styles */
88
+
89
+ #payment_form_savedcards .input-box {
90
+ display: block;
91
+ width: 170px;
92
+ position: relative;
93
+ }
94
+
95
+ #payment_form_savedcards > li {
96
+ padding-left: 20px;
97
+ }
98
+
99
+ #payment_form_savedcards.adminhtml-payment-form > li {
100
+ padding-left: 0px;
101
+ margin-left: -2px;
102
+ }
103
+
104
+ /* prepaid payments styles*/
105
+
106
+ #payment_form_prepaidpayments .input-box {
107
+ display: block;
108
+ width: 170px;
109
+ position: relative;
110
+ }
111
+
112
+ #payment_form_prepaidpayments > li {
113
+ padding-left: 20px;
114
+ }
115
+
116
+ #payment_form_prepaidpayments.adminhtml-payment-form > li {
117
+ padding-left: 0px;
118
+ margin-left: -2px;
119
+ }
120
+
121
+ #payment_form_prepaidpayments .balance {
122
+ margin-left: 20px;
123
+ }
124
+
125
+
126
+
127
+ .x-payment-card-logo.mc {
128
+ background-attachment: scroll;
129
+ background-clip: border-box;
130
+ background-color: rgba(0, 0, 0, 0);
131
+ background-image: url("images/card_types.png");
132
+ background-origin: padding-box;
133
+ background-repeat: no-repeat;
134
+
135
+ background-position: 2px -1px;
136
+ background-size:40px auto;
137
+ width: 40px;
138
+ height: 20px;
139
+ position: absolute;
140
+ top: 0;
141
+ right: 0;
142
+ }
143
+ .x-payment-card-logo.visa {
144
+ background-attachment: scroll;
145
+ background-clip: border-box;
146
+ background-color: rgba(0, 0, 0, 0);
147
+ background-image: url("images/card_types.png");
148
+ background-origin: padding-box;
149
+ background-repeat: no-repeat;
150
+
151
+ background-position: 2px -21px;
152
+ background-size:40px auto;
153
+ width: 40px;
154
+ height: 20px;
155
+ position: absolute;
156
+ top: 0;
157
+ right: 0;
158
+ }
159
+ .x-payment-card-logo.jcb {
160
+ background-attachment: scroll;
161
+ background-clip: border-box;
162
+ background-color: rgba(0, 0, 0, 0);
163
+ background-image: url("images/card_types.png");
164
+ background-origin: padding-box;
165
+ background-repeat: no-repeat;
166
+
167
+ background-position: 6px -41px;
168
+ background-size:40px auto;
169
+ width: 40px;
170
+ height: 20px;
171
+ position: absolute;
172
+ top: 0;
173
+ right: 0;
174
+ }
175
+ .x-payment-card-logo.amex {
176
+ background-attachment: scroll;
177
+ background-clip: border-box;
178
+ background-color: rgba(0, 0, 0, 0);
179
+ background-image: url("images/card_types.png");
180
+ background-origin: padding-box;
181
+ background-repeat: no-repeat;
182
+
183
+ background-position: 6px -61px;
184
+ background-size: 40px auto;
185
+ width: 40px;
186
+ height: 20px;
187
+ position: absolute;
188
+ top: 0;
189
+ right: 0;
190
+ }
191
+ .x-payment-card-logo.dc {
192
+ background-attachment: scroll;
193
+ background-clip: border-box;
194
+ background-color: rgba(0, 0, 0, 0);
195
+ background-image: url("images/card_types.png");
196
+ background-origin: padding-box;
197
+ background-repeat: no-repeat;
198
+
199
+ background-position: 2px -81px;
200
+ background-size: 40px auto;
201
+ width: 40px;
202
+ height: 20px;
203
+ position: absolute;
204
+ top: 0;
205
+ right: 0;
206
+ }
207
+ .x-payment-card-logo.dicl {
208
+ background-attachment: scroll;
209
+ background-clip: border-box;
210
+ background-color: rgba(0, 0, 0, 0);
211
+ background-image: url("images/card_types.png");
212
+ background-origin: padding-box;
213
+ background-repeat: no-repeat;
214
+
215
+ background-position: 2px -101px;
216
+ background-size:40px auto;
217
+ width: 40px;
218
+ height: 20px;
219
+ position: absolute;
220
+ top: 0;
221
+ right: 0;
222
+ }
223
+ .x-payment-card-logo.sw {
224
+ background-attachment: scroll;
225
+ background-clip: border-box;
226
+ background-color: rgba(0, 0, 0, 0);
227
+ background-image: url("images/card_types.png");
228
+ background-origin: padding-box;
229
+ background-repeat: no-repeat;
230
+
231
+ background-position: 2px -121px;
232
+ background-size:40px auto;
233
+ width: 40px;
234
+ height: 20px;
235
+ position: absolute;
236
+ top: 0;
237
+ right: 0;
238
+ }
239
+ .x-payment-card-logo.cup {
240
+ background-attachment: scroll;
241
+ background-clip: border-box;
242
+ background-color: rgba(0, 0, 0, 0);
243
+ background-image: url("images/card_types.png");
244
+ background-origin: padding-box;
245
+ background-repeat: no-repeat;
246
+
247
+ background-position: 4px -141px;
248
+ background-size:40px auto;
249
+ width: 40px;
250
+ height: 20px;
251
+ position: absolute;
252
+ top: 0;
253
+ right: 0;
254
+ }
255
+ .x-payment-card-logo.bc {
256
+ background-attachment: scroll;
257
+ background-clip: border-box;
258
+ background-color: rgba(0, 0, 0, 0);
259
+ background-image: url("images/card_types.png");
260
+ background-origin: padding-box;
261
+ background-repeat: no-repeat;
262
+
263
+ background-position: 2px -161px;
264
+ background-size:40px auto;
265
+ width: 40px;
266
+ height: 20px;
267
+ position: absolute;
268
+ top: 0;
269
+ right: 0;
270
+ }
271
+
272
+ /* list*/
273
+
274
+ .x-payment-card-logo-list.mc{
275
+ margin-left:5px;
276
+ background-image: url("images/card_types.png");
277
+ background-color: rgba(0, 0, 0, 0);
278
+ background-origin: padding-box;
279
+ background-repeat: no-repeat;
280
+ background-size:45px auto;
281
+ background-position: 2px 1px;
282
+ display: inline-block;
283
+ width: 40px;
284
+ height: 22px;
285
+
286
+ }
287
+
288
+ .x-payment-card-logo-list.visa{
289
+ margin-left:5px;
290
+ background-image: url("images/card_types.png");
291
+ background-color: rgba(0, 0, 0, 0);
292
+ background-origin: padding-box;
293
+ background-repeat: no-repeat;
294
+ background-size:45px auto;
295
+ background-position: 2px -21px;
296
+ display: inline-block;
297
+ width: 40px;
298
+ height: 22px;
299
+
300
+ }
301
+
302
+ .x-payment-card-logo-list.jcb {
303
+ margin-left:5px;
304
+ background-image: url("images/card_types.png");
305
+ background-color: rgba(0, 0, 0, 0);
306
+ background-origin: padding-box;
307
+ background-repeat: no-repeat;
308
+ background-size:45px auto;
309
+ background-position: 6px -42px;
310
+ display: inline-block;
311
+ width: 40px;
312
+ height: 22px;
313
+
314
+ }
315
+
316
+ .x-payment-card-logo-list.amex {
317
+ margin-left:5px;
318
+ background-image: url("images/card_types.png");
319
+ background-color: rgba(0, 0, 0, 0);
320
+ background-origin: padding-box;
321
+ background-repeat: no-repeat;
322
+ background-size:45px auto;
323
+ background-position: 8px -66px;
324
+ display: inline-block;
325
+ width: 40px;
326
+ height: 22px;
327
+
328
+ }
329
+ .x-payment-card-logo-list.dc {
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: 2px -90px;
337
+ display: inline-block;
338
+ width: 40px;
339
+ height: 22px;
340
+
341
+ }
342
+ .x-payment-card-logo-list.dicl {
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 -112px;
350
+ display: inline-block;
351
+ width: 40px;
352
+ height: 22px;
353
+
354
+ }
355
+ .x-payment-card-logo-list.sw {
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 -134px;
363
+ display: inline-block;
364
+ width: 40px;
365
+ height: 22px;
366
+
367
+ }
368
+ .x-payment-card-logo-list.cup {
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: 4px -157px;
376
+ display: inline-block;
377
+ width: 40px;
378
+ height: 22px;
379
+
380
+ }
381
+ .x-payment-card-logo-list.bc {
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: 2px -179px;
389
+ display: inline-block;
390
+ width: 40px;
391
+ height: 22px;
392
+
393
+ }
394
+
395
+
396
+
397
+ /*admin cards list*/
398
+
399
+ #customer_edit_tab_usercards_table td{
400
+ text-align: center;
401
+ }
402
+
403
+ /* end(payment cards styles) */
404
+
405
+ #wait-message{
406
+ margin:1%;
407
+ }
408
+
409
+ /*add new credit card block style*/
410
+ #new-card-block #xpayment-iframe-block {
411
+ background-color: rgb(251, 250, 246);
412
+ border: 1px solid rgb(196, 193, 188);
413
+ padding-bottom: 40px;
414
+ padding-top: 10px;
415
+ }
416
+
417
+ #new-card-block #xpayment-iframe-block #create-card-button{
418
+ float: right;
419
+ padding-right: 25px;
420
+ }
421
+
422
+ #new-card-block #xpayment-iframe-block #xp-iframe{
423
+ height: 260px;
424
+ }
425
+ xp-iframe
426
+ /*end (add new credit card block style)*/
package.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>CDev_XPaymentsConnector</name>
4
+ <version>1.2.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>
8
+ <extends/>
9
+ <summary>Connector to integrate Magento CE with X-Payments PA-DSS certified solution for PCI compliant CC processing</summary>
10
+ <description>X-Payments connector&#xD;
11
+ This extension integrates Magento with X-Payments - a PA-DSS certified payment module.&#xD;
12
+ </description>
13
+ <notes>Version number: 1.2.0</notes>
14
+ <authors><author><name>Valerii Demidov</name><user>Valerii</user><email>vdemidov@corp.web4pro.com.ua</email></author></authors>
15
+ <date>2014-07-16</date>
16
+ <time>13:18:27</time>
17
+ <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="Cardtype.php" hash="62499b375fa9c7ba091ff7763d54a95d"/><file name="Txnid.php" hash="13d4ed0d24df35cc9956dc155b3ce8b5"/></dir><dir name="Tab"><file name="Usercards.php" hash="248e454bc1c43d41013fd5d077b39961"/></dir></dir></dir><dir name="Sales"><dir name="Order"><dir name="View"><dir name="Tab"><file name="Xporderstate.php" hash="c18f9945cc3a67e8687bc14b4a989fa1"/></dir></dir></dir></dir><dir name="Usercards"><file name="Grid.php" hash="ba4e515d5e9342b11d63dc796aa96e8a"/></dir></dir><file name="Beforesuccess.php" hash="60a7d25651a98f71ca67ed70380e1659"/><file name="Cancel.php" hash="3283657e21047278d81ac4478ac81de6"/><dir name="Checkout"><dir name="Onepage"><file name="Settings.php" hash="8d975592555c5f7dd52299f026ee5fb7"/></dir></dir><file name="Control.php" hash="e0ef77a236030598882937acb2a9c4e0"/><dir name="Customer"><dir name="Account"><file name="Navigation.php" hash="aad9aa09d20706f042f1deac00d04473"/></dir><file name="Cardadd.php" hash="6d065170bb39961c921bdb84eac6e209"/><file name="Success.php" hash="54f243e60b735cdd5cd879be65838fee"/><file name="Usercards.php" hash="ce4b7f73fb735a55d914ba0dad38d68a"/></dir><file name="Failure.php" hash="537aec3d3ee63ff1ac2d2300c2ca259e"/><dir name="Form"><file name="Cc.php" hash="ce7a6fe2a208cb736ccd3ccddf39d003"/><file name="Prepaidpayments.php" hash="66959c7b8e7714f80f44da9afde93936"/><file name="Savedcards.php" hash="552579e7918fc666dc6de8983fc185b3"/></dir><dir name="Info"><file name="Cc.php" hash="80ec2f2dd7691519d481977ab7bdcec4"/><file name="Prepaidpayments.php" hash="5046201a95c114c6020696b7d2855b7f"/><file name="Savedcards.php" hash="5e8b71515b6d516621aea6abfda332fe"/></dir><dir name="Recurring"><dir name="Profile"><file name="View.php" hash="ee800cc7d48e437d3e993e5bd6d42a96"/></dir></dir><file name="Redirect.php" hash="e4745b70dbe2d33b327a70eb195c9345"/><file name="Success.php" hash="d2f023bc2206cbb33997b791a57b1b4e"/></dir><dir name="Helper"><file name="Data.php" hash="c2f7dd0c2c7b06b623e06c2a7d8e74be"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Paymentconfiguration"><file name="Collection.php" hash="98760f276af5182d42801865cb116db4"/></dir><file name="Paymentconfiguration.php" hash="ca045f953ec018c583279340c137ff71"/><dir name="Usercards"><file name="Collection.php" hash="6df6d26bef085e86c6db625487006086"/></dir><file name="Usercards.php" hash="ffb98ad5a0c252bbbf14adb086cf0d3c"/></dir><file name="Observer.php" hash="1d076222d9fd78a7c49ecb01d9decae6"/><dir name="Payment"><file name="Cc.php" hash="7d32e75b3995813ec5a71947eede6a9e"/><file name="Prepaidpayments.php" hash="9bbab2a26748c59609d6c81d8fc37c41"/><dir name="Recurring"><file name="Profile.php" hash="7c0e5c707531e5d258b8c493243c00a1"/></dir><file name="Savedcards.php" hash="e97d591bcdf4b66231aa62cb72b32770"/></dir><file name="Paymentconfiguration.php" hash="c0a6c5b610e42037f9904247e657a0e6"/><dir name="Quote"><dir name="Address"><dir name="Total"><dir name="Nominal"><dir name="Recurring"><file name="Discount.php" hash="9c2ee0abac22865bb349dc11cebd66b2"/></dir></dir><file name="Nominal.php" hash="a835e5ed1692a8712571db963c22bd60"/></dir></dir></dir><file name="Quote.php" hash="6d9e11998cda75b478b0b03297db303a"/><dir name="Sales"><dir name="Recurring"><file name="Profile.php" hash="5f5486cb753946720ad932b6eb5d6831"/></dir></dir><dir name="Source"><file name="Paymentconfiguration.php" hash="eb9b8e1187a4a4f4614582d5f7932c37"/></dir><file name="Usercards.php" hash="049b38f03920a17d5dbd0ba5e3a834cc"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="CustomerController.php" hash="8f2bc887259b9d5ae6f3a731e7a2eb6a"/></dir><file name="ControlController.php" hash="92e1380179483d97cd27be1d147833ba"/><file name="CustomerController.php" hash="38cb8af6cf9cf609fd31da5ec79ef263"/><file name="ProcessingController.php" hash="7ab567f40d731ed85bb38172ebcbebf5"/></dir><dir name="etc"><file name="config.xml" hash="cff33030e70acdd9b53b1970cf6bead0"/><file name="system.xml" hash="d9fd273ac8f7ea361a923696af286a8f"/></dir><dir name="sql"><dir name="xpaymentsconnector_setup"><file name="mysql4-install-1.0.0.php" hash="5b6ed901a54700d986dd81029104ed72"/><file name="mysql4-upgrade-1.0.0-1.0.1.php" hash="5e2da32a0f87b747a5e9f3d9095e962a"/><file name="mysql4-upgrade-1.0.1-1.0.2.php" hash="566cd8aa894ff488f60bd718ad8b2772"/><file name="mysql4-upgrade-1.0.2-1.0.3.php" hash="0f44cf02457c2b6a887b399e94b89e57"/><file name="mysql4-upgrade-1.0.3-1.0.4.php" hash="f353d20a6d6ac827be5cd581cc988660"/><file name="mysql4-upgrade-1.0.4-1.0.5.php" hash="9b71385496b9b42e5a79b0cbbc557dff"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="fa79555b4802a96579f314a670ab8ed3"/><file name="mysql4-upgrade-1.0.6-1.0.7.php" hash="b9708303f3160fc0c9347f4600e27aba"/><file name="mysql4-upgrade-1.0.7-1.0.8.php" hash="2d07945a0438bf29f1386e47b2b5498b"/><file name="mysql4-upgrade-1.0.8-1.0.9.php" hash="83a4aace7f0e389c5caaaf97675f6c24"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="bfe38bbacc0cc7d3a2bc4c51fc0c2a53"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="control.phtml" hash="66bb941b66f57585b2035f29afcea22d"/><dir name="form"><file name="prepaidpayments.phtml" hash="bfe70a3c62187bcd9915fb621eda58b9"/><file name="savedcards.phtml" hash="27ef4734f19ded0eb98214276a58e550"/></dir><dir name="info"><file name="cc.phtml" hash="67282ccf6f932de083bc477cc4238d22"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="299a1719dd63755b9d31f25c4d9738ac"/></dir><file name="info.phtml" hash="ab312e6f206c51ff3134b9a3ce5b5440"/><dir name="order"><dir name="view"><dir name="tab"><file name="xporderstate.phtml" hash="9a91a75622f7b2309e1fc16d61552952"/></dir></dir></dir><dir name="pdf"><file name="info.phtml" hash="9603c212b8efd1247ce36239d7365a73"/></dir><dir name="usercards"><dir name="tab"><file name="js.phtml" hash="ae8189ee0b9f0bd09d61692403527331"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="xpaymentsconnector.xml" hash="3c61c475430307e89459a92b44b140e6"/></dir><dir name="template"><dir name="xpaymentsconnector"><file name="blank.phtml" hash="a22778db8681a9aaee22eb2d8f8c6533"/><file name="cancel.phtml" hash="3ba9764fcbf85a3504664b342450ec2b"/><dir name="checkout"><dir name="onepage"><file name="beforesuccess.phtml" hash="8e05eff3705ac40d758c21523640f969"/><dir name="review"><file name="button.phtml" hash="ed96034bc129f74af1020384499840a9"/></dir><file name="settings.phtml" hash="3770940ac85ef9037160f4d1278069be"/><file name="xpayment-iframe.phtml" hash="26e89590e2390602a7c836a6c73d6d01"/></dir></dir><dir name="customer"><file name="cardaddsuccess.phtml" hash="6771721173b99c0cf70391c22d878276"/><dir name="usercards"><file name="cardadd.phtml" hash="6cee3d1ac74fcab72d9eb5284ce01139"/><file name="list.phtml" hash="5bf980a24c788af17cd80a8bf511807f"/></dir></dir><file name="failure.phtml" hash="3d0691440fda2d1f3a314cd151d6ea90"/><dir name="form"><file name="cc.phtml" hash="7c8766bc36d2f9a60e242ae551002437"/><file name="savedcards.phtml" hash="acbfcc5771443fcee06d715c3c049546"/></dir><dir name="info"><file name="cc.phtml" hash="9f96547c119d966eb26c67fb557cf1b8"/><file name="prepaidpayments.phtml" hash="f4bd2aa628257cb1f3450a1632a0b771"/><file name="savedcards.phtml" hash="b44b31ecdf8c653ea8299c9664061b27"/></dir><file name="redirect.phtml" hash="4c9c74e94c9a3015dee181a0ef978550"/></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Cdev_XPaymentsConnector.xml" hash="3b87bc5a9c17519d38e7de93b5ad13b9"/></dir></target><target name="mage"><dir name="js"><dir name="xpayment"><file name="checkout-submit.js" hash="2473c659fddf7c62d85f05ab4874745c"/><dir name="images"><file name="card_types.png" hash="d35ba97c55e2cc1273a0dd1d7862d84c"/><file name="loader.gif" hash="e67d85a8d2d4021514815d0ff4d65173"/></dir><file name="settings.css" hash="653c4d64a546ef82b63664bd569bafa8"/></dir></dir></target><target name="magelocale"><dir><dir name="en_US"><file name="Cdev_XPaymentsConnector.csv" hash="b920adfca23deb393fc0a5a85f5c7527"/></dir></dir></target></contents>
18
+ <compatible/>
19
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
20
+ </package>