Planet_Payment_Checkout - Version 1.0.0

Version Notes

Planet Payment Gateway Integration

Download this release

Release Info

Developer Mayank
Extension Planet_Payment_Checkout
Version 1.0.0
Comparing to
See all releases


Version 1.0.0

Files changed (181) hide show
  1. app/code/community/PlanetPayment/Core/Block/Checkout/Cart/Totals.php +123 -0
  2. app/code/community/PlanetPayment/Core/Block/Sales/Order/Totals.php +144 -0
  3. app/code/community/PlanetPayment/Core/Helper/Data.php +31 -0
  4. app/code/community/PlanetPayment/Core/Helper/Error.php +178 -0
  5. app/code/community/PlanetPayment/Core/Model/Currency/Import.php +118 -0
  6. app/code/community/PlanetPayment/Core/Model/System/Config/General/Encryption.php +45 -0
  7. app/code/community/PlanetPayment/Core/Model/System/Config/General/Mode.php +49 -0
  8. app/code/community/PlanetPayment/Core/Model/System/Config/Payment/Currency.php +61 -0
  9. app/code/community/PlanetPayment/Core/Model/System/Config/Source/Enabledisable.php +27 -0
  10. app/code/community/PlanetPayment/Core/Model/Xml/Abstract.php +161 -0
  11. app/code/community/PlanetPayment/Core/Model/Xml/Request.php +195 -0
  12. app/code/community/PlanetPayment/Core/Model/Xml/Response.php +116 -0
  13. app/code/community/PlanetPayment/Core/etc/adminhtml.xml +50 -0
  14. app/code/community/PlanetPayment/Core/etc/config.xml +76 -0
  15. app/code/community/PlanetPayment/Core/etc/system.xml +131 -0
  16. app/code/community/PlanetPayment/CurrencyManager/Block/Adminhtml/Countrywise.php +82 -0
  17. app/code/community/PlanetPayment/CurrencyManager/Block/Adminhtml/Price.php +46 -0
  18. app/code/community/PlanetPayment/CurrencyManager/Helper/Data.php +214 -0
  19. app/code/community/PlanetPayment/CurrencyManager/Helper/Tax.php +63 -0
  20. app/code/community/PlanetPayment/CurrencyManager/Model/Currency.php +120 -0
  21. app/code/community/PlanetPayment/CurrencyManager/Model/Ipay.php +596 -0
  22. app/code/community/PlanetPayment/CurrencyManager/Model/Locale.php +59 -0
  23. app/code/community/PlanetPayment/CurrencyManager/Model/Observer.php +44 -0
  24. app/code/community/PlanetPayment/CurrencyManager/Model/Store.php +43 -0
  25. app/code/community/PlanetPayment/CurrencyManager/etc/config.xml +127 -0
  26. app/code/community/PlanetPayment/CurrencyManager/etc/system.xml +125 -0
  27. app/code/community/PlanetPayment/CurrencyManager/sql/currency_setup/install-1.0.0.php +22 -0
  28. app/code/local/Planet/Pay/Block/Adminhtml/Order.php +20 -0
  29. app/code/local/Planet/Pay/Block/Adminhtml/Order/Info.php +25 -0
  30. app/code/local/Planet/Pay/Block/Adminhtml/Order/View.php +144 -0
  31. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Credit.php +63 -0
  32. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Delivery.php +66 -0
  33. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Request.php +61 -0
  34. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Items/Renderer/Default.php +64 -0
  35. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Request.php +111 -0
  36. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Credit.php +120 -0
  37. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Delivery.php +86 -0
  38. app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Request.php +86 -0
  39. app/code/local/Planet/Pay/Block/Adminhtml/Pay.php +37 -0
  40. app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit.php +67 -0
  41. app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Form.php +37 -0
  42. app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Tab/Form.php +63 -0
  43. app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Tabs.php +43 -0
  44. app/code/local/Planet/Pay/Block/Adminhtml/Pay/Grid.php +102 -0
  45. app/code/local/Planet/Pay/Block/Checkout/Onepage.php +70 -0
  46. app/code/local/Planet/Pay/Block/Checkout/Onepage/Payment/Methods.php +99 -0
  47. app/code/local/Planet/Pay/Block/Checkout/Onepage/Review.php +33 -0
  48. app/code/local/Planet/Pay/Block/Form/Form.php +69 -0
  49. app/code/local/Planet/Pay/Block/Form/Pay.php +133 -0
  50. app/code/local/Planet/Pay/Block/Info/Pay.php +36 -0
  51. app/code/local/Planet/Pay/Block/Method/List.php +34 -0
  52. app/code/local/Planet/Pay/Block/Planet/Order/Grid.php +163 -0
  53. app/code/local/Planet/Pay/Block/Profile/Edit.php +211 -0
  54. app/code/local/Planet/Pay/Block/Profile/List.php +68 -0
  55. app/code/local/Planet/Pay/Helper/Data.php +217 -0
  56. app/code/local/Planet/Pay/Model/Authorizenet.php +51 -0
  57. app/code/local/Planet/Pay/Model/Autoloader.php +19 -0
  58. app/code/local/Planet/Pay/Model/Carddetail.php +49 -0
  59. app/code/local/Planet/Pay/Model/Checkout/Observer.php +19 -0
  60. app/code/local/Planet/Pay/Model/Checkout/Type/Onepage.php +134 -0
  61. app/code/local/Planet/Pay/Model/Currency/Import/Planet.php +205 -0
  62. app/code/local/Planet/Pay/Model/Method.php +47 -0
  63. app/code/local/Planet/Pay/Model/Order.php +26 -0
  64. app/code/local/Planet/Pay/Model/Orderlog.php +15 -0
  65. app/code/local/Planet/Pay/Model/Payment.php +513 -0
  66. app/code/local/Planet/Pay/Model/Resource/Carddetail.php +16 -0
  67. app/code/local/Planet/Pay/Model/Resource/Carddetail/Collection.php +26 -0
  68. app/code/local/Planet/Pay/Model/Resource/Method.php +16 -0
  69. app/code/local/Planet/Pay/Model/Resource/Method/Collection.php +49 -0
  70. app/code/local/Planet/Pay/Model/Resource/Order.php +16 -0
  71. app/code/local/Planet/Pay/Model/Resource/Order/Collection.php +15 -0
  72. app/code/local/Planet/Pay/Model/Resource/Orderlog.php +16 -0
  73. app/code/local/Planet/Pay/Model/Resource/Orderlog/Collection.php +59 -0
  74. app/code/local/Planet/Pay/Model/Sales/Order/Payment.php +600 -0
  75. app/code/local/Planet/Pay/Model/Select.php +511 -0
  76. app/code/local/Planet/Pay/Model/System/Config/Payment/PaymentAction.php +49 -0
  77. app/code/local/Planet/Pay/Model/System/Config/Source/Yesno.php +58 -0
  78. app/code/local/Planet/Pay/controllers/Adminhtml/BrandController.php +138 -0
  79. app/code/local/Planet/Pay/controllers/PaymentController.php +117 -0
  80. app/code/local/Planet/Pay/controllers/Planet/OrderController.php +215 -0
  81. app/code/local/Planet/Pay/controllers/ProfileController.php +79 -0
  82. app/code/local/Planet/Pay/data/planet_pay_setup/data-install-1.0.1.php +25 -0
  83. app/code/local/Planet/Pay/data/planet_pay_setup/data-upgrade-1.0.3-1.0.4.php +29 -0
  84. app/code/local/Planet/Pay/data/planet_pay_setup/data-upgrade-1.0.4-1.0.5.php +20 -0
  85. app/code/local/Planet/Pay/etc/adminhtml.xml +30 -0
  86. app/code/local/Planet/Pay/etc/config.xml +228 -0
  87. app/code/local/Planet/Pay/etc/system.xml +158 -0
  88. app/code/local/Planet/Pay/sql/planet_pay_setup/install-1.0.1.php +30 -0
  89. app/code/local/Planet/Pay/sql/planet_pay_setup/mysql4-upgrade-1.0.5-1.0.6.php +48 -0
  90. app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.1-1.0.2.php +42 -0
  91. app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.2-1.0.3.php +52 -0
  92. app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.3-1.0.4.php +18 -0
  93. app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.4-1.0.5.php +45 -0
  94. app/design/adminhtml/default/default/layout/planet_pay.xml +16 -0
  95. app/design/adminhtml/default/default/template/planet_pay/order/view/handling/credit.phtml +32 -0
  96. app/design/adminhtml/default/default/template/planet_pay/order/view/handling/delivery.phtml +39 -0
  97. app/design/adminhtml/default/default/template/planet_pay/order/view/handling/request.phtml +45 -0
  98. app/design/adminhtml/default/default/template/planet_pay/order/view/info.phtml +76 -0
  99. app/design/adminhtml/default/default/template/planet_pay/order/view/items.phtml +37 -0
  100. app/design/adminhtml/default/default/template/planet_pay/order/view/items/renderer/default.phtml +212 -0
  101. app/design/adminhtml/default/default/template/planet_pay/order/view/loviitinfo.phtml +30 -0
  102. app/design/adminhtml/default/default/template/planet_pay/order/view/planetinfo.phtml +30 -0
  103. app/design/adminhtml/default/default/template/planet_pay/order/view/request/criterions.phtml +24 -0
  104. app/design/adminhtml/default/default/template/planet_pay/order/view/request/customer.phtml +11 -0
  105. app/design/adminhtml/default/default/template/planet_pay/order/view/request/options.phtml +13 -0
  106. app/design/adminhtml/default/default/template/planet_pay/order/view/tab/credit.phtml +27 -0
  107. app/design/adminhtml/default/default/template/planet_pay/order/view/tab/delivery.phtml +14 -0
  108. app/design/adminhtml/default/default/template/planet_pay/order/view/tab/info.phtml +56 -0
  109. app/design/adminhtml/default/default/template/planet_pay/order/view/tab/request.phtml +14 -0
  110. app/design/adminhtml/default/default/template/planet_pay/sales/order/totals.phtml +86 -0
  111. app/design/frontend/default/default/template/checkout/onepage/review/totals.phtml +37 -0
  112. app/design/frontend/default/default/template/planet_pay/checkoutform.phtml +35 -0
  113. app/design/frontend/default/default/template/planet_pay/email/items.phtml +4 -0
  114. app/design/frontend/default/default/template/planet_pay/form/form.phtml +3 -0
  115. app/design/frontend/default/default/template/planet_pay/form/pay.phtml +152 -0
  116. app/design/frontend/default/default/template/planet_pay/form/pay_backup_1oct.phtml +151 -0
  117. app/design/frontend/default/default/template/planet_pay/onepage/payment.phtml +90 -0
  118. app/design/frontend/default/default/template/planet_pay/onepage/payment/methods.phtml +75 -0
  119. app/design/frontend/default/default/template/planet_pay/onepage/review.phtml +44 -0
  120. app/design/frontend/default/default/template/planet_pay/onepage/review/button.phtml +19 -0
  121. app/design/frontend/default/default/template/planet_pay/onepage/review/info.phtml +91 -0
  122. app/design/frontend/default/default/template/planet_pay/onepage/review/items_after.phtml +2 -0
  123. app/design/frontend/default/default/template/planet_pay/profile/edit.phtml +195 -0
  124. app/design/frontend/default/default/template/planet_pay/profile/list.phtml +79 -0
  125. app/etc/modules/PlanetPayment_Core.xml +9 -0
  126. app/etc/modules/PlanetPayment_CurrencyManager.xml +26 -0
  127. app/etc/modules/Planet_Pay.xml +9 -0
  128. lib/PlanetLib/Filter/FilterRound.php +32 -0
  129. lib/PlanetLib/Filter/FilterString.php +26 -0
  130. lib/PlanetLib/Payment.php +386 -0
  131. lib/PlanetLib/Payment/PaymentCriterion.php +215 -0
  132. lib/PlanetLib/Payment/PaymentCustomer.php +260 -0
  133. lib/PlanetLib/Payment/PaymentOrderposition.php +428 -0
  134. lib/PlanetLib/Payon.php +134 -0
  135. lib/PlanetLib/Planet.php +128 -0
  136. lib/PlanetLib/PlanetException.php +15 -0
  137. lib/PlanetLib/Request/Curl.php +34 -0
  138. lib/PlanetLib/Request/Stream.php +30 -0
  139. lib/PlanetLib/Resources/Content/Brands.php +61 -0
  140. lib/PlanetLib/Resources/Translation/BrandNames.php +74 -0
  141. lib/PlanetLib/Resources/Translation/ErrorCodes.php +74 -0
  142. lib/PlanetLib/Resources/Translation/de/BrandNames.php +159 -0
  143. lib/PlanetLib/Resources/Translation/de/ErrorCodes.php +90 -0
  144. lib/PlanetLib/Resources/Translation/de/ServiceMessages.php +25 -0
  145. lib/PlanetLib/Response.php +120 -0
  146. lib/PlanetLib/Validator/ValidatorDate.php +49 -0
  147. lib/PlanetLib/Validator/ValidatorEmail.php +37 -0
  148. lib/PlanetLib/Validator/ValidatorFloat.php +67 -0
  149. lib/PlanetLib/Validator/ValidatorInt.php +61 -0
  150. lib/PlanetLib/Validator/ValidatorInterface.php +22 -0
  151. lib/PlanetLib/Validator/ValidatorIp.php +37 -0
  152. lib/PlanetLib/Validator/ValidatorPhone.php +54 -0
  153. lib/PlanetLib/Validator/ValidatorString.php +70 -0
  154. lib/PlanetLib/View.php +136 -0
  155. lib/PlanetLib/Writer/WriterSession.php +40 -0
  156. lib/PlanetLib/WriterInterface.php +22 -0
  157. lib/PlanetLib/config.ini +20 -0
  158. media/Planet/img/AMEX.jpg +0 -0
  159. media/Planet/img/CARTE.jpg +0 -0
  160. media/Planet/img/DINERS.jpg +0 -0
  161. media/Planet/img/DINERS.png +0 -0
  162. media/Planet/img/DISCOVER.jpg +0 -0
  163. media/Planet/img/HIPERCARD.jpg +0 -0
  164. media/Planet/img/IDEAL.jpg +0 -0
  165. media/Planet/img/JCB.jpg +0 -0
  166. media/Planet/img/JCB.png +0 -0
  167. media/Planet/img/KLARNA_INSTALLMENTS.jpg +0 -0
  168. media/Planet/img/KLARNA_INVOICE.jpg +0 -0
  169. media/Planet/img/MASTER.jpg +0 -0
  170. media/Planet/img/MASTER.png +0 -0
  171. media/Planet/img/PAYPAL.png +0 -0
  172. media/Planet/img/SOFORTUEBERWEISUNG.jpg +0 -0
  173. media/Planet/img/VISA.jpg +0 -0
  174. media/Planet/img/VISAELECTRON.jpg +0 -0
  175. media/Planet/img/maestro.jpg +0 -0
  176. media/Planet/img/place_order.jpg +0 -0
  177. media/Planet/img/ukash.jpg +0 -0
  178. package.xml +18 -0
  179. server.php +22 -0
  180. skin/frontend/base/default/css/planet_pay/payon.css +53 -0
  181. skin/frontend/base/default/js/planet_pay/add-summary-script.js +10 -0
app/code/community/PlanetPayment/Core/Block/Checkout/Cart/Totals.php ADDED
@@ -0,0 +1,123 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_Core
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Cart Totals
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_Core
24
+ * @author mohd shamim<mohds@chetu.com>
25
+ */
26
+ class PlanetPayment_Core_Block_Checkout_Cart_Totals extends Mage_Checkout_Block_Cart_Totals {
27
+
28
+ /**
29
+ * Check if we have display grand total in base currency
30
+ *
31
+ * @return bool
32
+ */
33
+ public function needDisplayBaseGrandtotal() {
34
+ $quote = $this->getQuote();
35
+ $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
36
+ if ($payment_method_code == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
37
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode() ||
38
+ ($this->_isPyc() && $quote->getQuoteCurrencyCode() != $quote->getPayment()->getIpayCurrencyCode())) {
39
+ return true;
40
+ }
41
+ } elseif ($payment_method_code == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
42
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode() ||
43
+ ($this->_isPyc() && $quote->getQuoteCurrencyCode() != $quote->getPayment()->getUpopCurrencyCode())) {
44
+ return true;
45
+ }
46
+ } else {
47
+ if ($quote->getBaseCurrencyCode() != $quote->getQuoteCurrencyCode()) {
48
+ return true;
49
+ }
50
+ }
51
+
52
+ return false;
53
+ }
54
+
55
+ /**
56
+ * Get formated in base currency base grand total value
57
+ *
58
+ * @return string
59
+ */
60
+ public function displayBaseGrandtotal() {
61
+ $firstTotal = reset($this->_totals);
62
+ if ($firstTotal) {
63
+ $quote = $this->getQuote();
64
+ $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
65
+ if ($payment_method_code == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
66
+ $exchangeRate = $quote->getIpayExchangeRate();
67
+ } elseif ($payment_method_code == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
68
+ $exchangeRate = $quote->getUpopExchangeRate();
69
+ } else {
70
+ $exchangeRate = '';
71
+ }
72
+
73
+ if ($this->_isPyc() && $exchangeRate) {
74
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
75
+ if ($payment_method_code == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
76
+ $currency_code = $quote->getPayment()->getIpayCurrencyCode();
77
+ } elseif ($payment_method_code == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
78
+ $currency_code = $quote->getPayment()->getUpopCurrencyCode();
79
+ }
80
+ $currency = Mage::app()->getLocale()->currency($currency_code)->getSymbol() . " " . number_format($total * $exchangeRate, 2);
81
+ } elseif ($this->_isMcp()) {
82
+ $total = $firstTotal->getAddress()->getGrandTotal();
83
+ $currency = Mage::app()->getStore()->getCurrentCurrency()->format($total, array(), true);
84
+ } else {
85
+ $total = $firstTotal->getAddress()->getBaseGrandTotal();
86
+ $currency = Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
87
+ }
88
+ return $currency;
89
+ }
90
+ return '-';
91
+ }
92
+
93
+ /**
94
+ * Check the payment service configure in backend
95
+ *
96
+ * @return int
97
+ */
98
+ protected function _isPyc() {
99
+ $quote = $this->getQuote();
100
+ $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
101
+ if ($payment_method_code == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
102
+ return Mage::getmodel('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_PYC;
103
+ } elseif ($payment_method_code == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
104
+ return Mage::getmodel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_PYC;
105
+ }
106
+ }
107
+
108
+ /**
109
+ * Check the payment service configure in backend
110
+ *
111
+ * @return int
112
+ */
113
+ protected function _isMcp() {
114
+ $quote = $this->getQuote();
115
+ $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
116
+ if ($payment_method_code == PlanetPayment_IpayGateway_Model_Ipay::METHOD_CODE) {
117
+ return Mage::getmodel('ipay/ipay')->getConfigData("service") == PlanetPayment_IpayGateway_Model_Ipay::PAYMENT_SERVICE_MCP;
118
+ } elseif ($payment_method_code == PlanetPayment_Upop_Model_Upop::METHOD_CODE) {
119
+ return Mage::getmodel('upop/upop')->getConfigData("service") == PlanetPayment_Upop_Model_Upop::PAYMENT_SERVICE_MCP;
120
+ }
121
+ }
122
+
123
+ }
app/code/community/PlanetPayment/Core/Block/Sales/Order/Totals.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_Core
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Order Totals
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_Core
24
+ * @author mohd shamim<mohds@chetu.com>
25
+ */
26
+ class PlanetPayment_Core_Block_Sales_Order_Totals extends Mage_Sales_Block_Order_Totals {
27
+
28
+ /**
29
+ * Initialize order totals array
30
+ *
31
+ * @return Mage_Sales_Block_Order_Totals
32
+ */
33
+ protected function _initTotals() {
34
+ $source = $this->getSource();
35
+
36
+ $this->_totals = array();
37
+ $this->_totals['subtotal'] = new Varien_Object(array(
38
+ 'code' => 'subtotal',
39
+ 'value' => $source->getSubtotal(),
40
+ 'label' => $this->__('Subtotal')
41
+ ));
42
+
43
+
44
+ /**
45
+ * Add shipping
46
+ */
47
+ if (!$source->getIsVirtual() && ((float) $source->getShippingAmount() || $source->getShippingDescription())) {
48
+ $this->_totals['shipping'] = new Varien_Object(array(
49
+ 'code' => 'shipping',
50
+ 'field' => 'shipping_amount',
51
+ 'value' => $this->getSource()->getShippingAmount(),
52
+ 'label' => $this->__('Shipping & Handling')
53
+ ));
54
+ }
55
+
56
+ /**
57
+ * Add discount
58
+ */
59
+ if (((float) $this->getSource()->getDiscountAmount()) != 0) {
60
+ if ($this->getSource()->getDiscountDescription()) {
61
+ $discountLabel = $this->__('Discount (%s)', $source->getDiscountDescription());
62
+ } else {
63
+ $discountLabel = $this->__('Discount');
64
+ }
65
+ $this->_totals['discount'] = new Varien_Object(array(
66
+ 'code' => 'discount',
67
+ 'field' => 'discount_amount',
68
+ 'value' => $source->getDiscountAmount(),
69
+ 'label' => $discountLabel
70
+ ));
71
+ }
72
+
73
+ $this->_totals['grand_total'] = new Varien_Object(array(
74
+ 'code' => 'grand_total',
75
+ 'field' => 'grand_total',
76
+ 'strong' => true,
77
+ 'value' => $source->getGrandTotal(),
78
+ 'label' => $this->__('Grand Total')
79
+ ));
80
+
81
+ /**
82
+ * Base grandtotal
83
+ */
84
+ if ($this->needDisplayBaseGrandtotal()) {
85
+ $quoteId = $this->getOrder()->getQuoteId();
86
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
87
+ if ($quote->getId()) {
88
+ $payment_method_code = $quote->getPayment()->getMethodInstance()->getCode();
89
+ $exchangeRate = '';
90
+ if ($this->_isPyc() && $exchangeRate) {
91
+ $total = $source->getBaseGrandTotal();
92
+ } else {
93
+ $total = $source->getBaseGrandTotal();
94
+ $currency = Mage::app()->getStore()->getBaseCurrency()->format($total, array(), true);
95
+ }
96
+ if ($this->getOrder()->isCurrencyDifferent()) {
97
+ $this->_totals['base_grandtotal'] = new Varien_Object(array(
98
+ 'code' => 'base_grandtotal',
99
+ 'value' => $this->getOrder()->formatBasePrice($source->getBaseGrandTotal()),
100
+ 'label' => $this->__('Grand Total to be Charged'),
101
+ 'is_formated' => true,
102
+ ));
103
+ }
104
+ }
105
+ }
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * Check if we have display grand total in base currency
111
+ *
112
+ * @return bool
113
+ */
114
+ public function needDisplayBaseGrandtotal() {
115
+ $order = $this->getOrder();
116
+ $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
117
+ if ($order->getBaseCurrencyCode() != $order->getQuoteCurrencyCode()) {
118
+ return true;
119
+ }
120
+
121
+ return false;
122
+ }
123
+
124
+ /**
125
+ * Check if payment service set as pyc
126
+ *
127
+ * @return bool
128
+ */
129
+ protected function _isPyc() {
130
+ $order = $this->getOrder();
131
+ $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
132
+ }
133
+
134
+ /**
135
+ * Check if payment service set as mcp
136
+ *
137
+ * @return bool
138
+ */
139
+ protected function _isMcp() {
140
+ $order = $this->getOrder();
141
+ $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
142
+ }
143
+
144
+ }
app/code/community/PlanetPayment/Core/Helper/Data.php ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_C
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Helper Data
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author mohd shamim <mohds@chetu.com>
28
+ */
29
+ class PlanetPayment_Core_Helper_Data extends Mage_Core_Helper_Abstract {
30
+
31
+ }
app/code/community/PlanetPayment/Core/Helper/Error.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_C
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Helper Error
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author mohd shamim <mohds@chetu.com>
28
+ */
29
+ class PlanetPayment_Core_Helper_Error extends Mage_Core_Helper_Abstract {
30
+
31
+ /**
32
+ * Hold the code value and their description for arc
33
+ *
34
+ * @var array
35
+ */
36
+ private $__arcs = array(
37
+ 'code' => 'Definition',
38
+ '00' => 'Approval',
39
+ '1' => 'See RESPONSE_TEXT for issuer phone number',
40
+ '2' => 'See RESPONSE_TEXT for issuer phone number',
41
+ '3' => 'Invalid merchant ID',
42
+ '4' => 'Pick up card',
43
+ '05' => 'Do not honor',
44
+ '6' => 'General error',
45
+ '7' => 'Do not honor',
46
+ '8' => 'Honor with customer ID',
47
+ '10' => 'Partial approval for the authorized amount returned',
48
+ '11' => 'VIP approval',
49
+ '12' => 'Invalid transaction',
50
+ '13' => 'Invalid transaction amount',
51
+ '14' => 'Invalid card number',
52
+ '15' => 'No such issuer',
53
+ '17' => 'Customer cancellation',
54
+ '19' => 'Re-enter transaction',
55
+ '21' => 'Unable to back out transaction',
56
+ '25' => 'Unable to locate record in file, or account number is missing from inquiry',
57
+ '27' => 'Issuer File Update field edit error',
58
+ '28' => 'Temporarily unavailable',
59
+ '30' => 'Format error',
60
+ '32' => 'Partial reversal',
61
+ '40' => 'Requested function not supported',
62
+ '41' => 'Pickup card—lost',
63
+ '43' => 'Pickup card—stolen',
64
+ '51' => 'Insufficient funds',
65
+ '52' => 'No checking account',
66
+ '53' => 'No savings account',
67
+ '54' => 'Expired card',
68
+ '55' => 'Incorrect PIN',
69
+ '57' => 'Transaction not permitted—card',
70
+ '58' => 'Transaction not permitted—terminal',
71
+ '59' => 'Suspected fraud',
72
+ '61' => 'Exceeds withdrawal limit',
73
+ '62' => 'Invalid service code, restricted',
74
+ '63' => 'Security violation',
75
+ '65' => 'Activity limit exceeded',
76
+ '68' => 'Response received late',
77
+ '75' => 'PIN tries exceeded',
78
+ '76' => 'Unable to locate',
79
+ '77' => 'Inconsistent data, rev. or repeat',
80
+ '78' => 'No account',
81
+ '79' => 'Already reversed',
82
+ '80' => 'Invalid date',
83
+ '81' => 'Cryptographic error',
84
+ '82' => 'CVV data incorrect',
85
+ '83' => 'Cannot verify PIN',
86
+ '84' => 'Invalid authorization life cycle',
87
+ '85' => 'No reason to decline',
88
+ '86' => 'Cannot verify PIN',
89
+ '87' => 'Network unavailable',
90
+ '91' => 'Issuer unavailable',
91
+ '92' => 'Destination not found',
92
+ '93' => 'Violation, cannot complete',
93
+ '94' => 'Duplicate transmission detected',
94
+ '96' => 'Re-send, system error',
95
+ 'AX' => 'Amount exceeds either the minimum or maximum allowed amount',
96
+ 'B1' => 'Surcharge amount not permitted on Visa cards or EBT food stamps',
97
+ 'ER' => 'Error—see MRC response',
98
+ 'N0' => 'Force STIP',
99
+ 'N3' => 'Cash back service not available',
100
+ 'N4' => 'Exceeds issuer withdrawal limit',
101
+ 'N7' => 'CVV2 value supplied is invalid',
102
+ 'P2' => 'Invalid biller information',
103
+ 'P5' => 'PIN charge/unblock declined',
104
+ 'P6' => 'Unsafe PIN',
105
+ 'Q1' => 'Card authentication failed',
106
+ 'R0' => 'Customer requested stop of specific recurring payment.',
107
+ 'R1' => 'Customer requested stop of all recurring payments from specific merchant.',
108
+ 'R3' => 'Revocation of All Authorizations Order',
109
+ 'SD' => 'Transaction is declined by the Gateway based on merchant’s settings for ACCOUNT_VALIDATION and CONSUMER_VALIDATION',
110
+ 'TO' => 'Re-submit',
111
+ 'XA' => 'Forward to issuer',
112
+ 'XD' => 'Forward to issuer',
113
+ 'Z3' => 'Unable to go online, declined.',);
114
+
115
+ /**
116
+ * Hold the code value and their description for arc
117
+ *
118
+ * @var array
119
+ */
120
+ private $__mrcs = array(
121
+ 'Code' => 'Definition',
122
+ '0' => 'Payment server validation approved',
123
+ 'AE' => 'AUTH_EXPIRED authorizations are held for 10 days and then released',
124
+ 'AR' => 'ACCOUNT_NUMBER BIN is not setup to process',
125
+ 'AX' => 'Transaction amount value requirements exceeded, see response text for details',
126
+ 'CD' => 'Commercial data already associated',
127
+ 'CF' => 'Credit refused, must have a relevant sale in order to process credit',
128
+ 'DC' => 'Data conflict',
129
+ 'DF' => 'Data-Frequency mismatch. The combination of fields has violated the Gateway frequency logic.',
130
+ 'DR' => 'Delete refused—data integrity enforcement',
131
+ 'IB' => 'Invalid base64 encoding',
132
+ 'IC' => 'Missing/invalid company key',
133
+ 'ID' => 'Missing/invalid transaction data',
134
+ 'IE' => 'Invalid encryption',
135
+ 'IK' => 'Invalid key (See RESPONSE_TEXT for the invalid key)',
136
+ 'IS' => 'Inactive service',
137
+ 'IT' => 'Invalid XML transmission format',
138
+ 'IX' => 'Invalid XML transaction format',
139
+ 'IY' => 'Invalid type attribute',
140
+ 'IZ' => 'Invalid compression (future use)',
141
+ 'LM' => 'Field LAST_FOUR did not match last four digits of cardholder’s acct. no. contained in TRACK_DATA',
142
+ 'MK' => 'Missing key (See RESPONSE_TEXT for the missing key)',
143
+ 'MY' => 'Missing type attribute',
144
+ 'NF' => 'Transaction not found',
145
+ 'NM' => 'No data mapping; please call Planet Payment',
146
+ 'NS' => 'Transaction not settled',
147
+ 'NX' => 'No XML "FIELDS" node present',
148
+ 'SE' => 'System error; please call Planet Payment',
149
+ 'SU' => 'System unavailable, retry',
150
+ 'TC' => 'Transaction already captured',
151
+ 'TD' => 'Transaction already deleted',
152
+ 'TR' => 'Transaction already reversed',
153
+ 'TS' => 'Transaction already settled',
154
+ 'TV' => 'Transaction already voided',
155
+ 'UP' => 'Unable to process at this time, retry',
156
+ 'VR' => 'VOID_REFUSED Merchants receiving a decline for a sale transaction will not be able to void it.',
157
+ 'XE' => 'Currency conversion error; please call Planet Payment',);
158
+
159
+ /**
160
+ * To get the error message corresponding to arc or mrc code
161
+ *
162
+ * @param type $code
163
+ * @param type $type
164
+ * @return string
165
+ */
166
+ public function getErrorMessage($code, $type = 'arc') {
167
+ if ($type == 'arc') {
168
+ if (isset($this->__arcs[$code])) {
169
+ return $this->__arcs[$code];
170
+ }
171
+ } else if (isset($this->__mrcs[$code])) {
172
+ return $this->__mrcs[$code];
173
+ } else {
174
+ return '';
175
+ }
176
+ }
177
+
178
+ }
app/code/community/PlanetPayment/Core/Model/Currency/Import.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_Currency_Import extends Mage_Directory_Model_Currency_Import_Abstract {
30
+
31
+ /**
32
+ * Hold the messages
33
+ *
34
+ * @var array
35
+ */
36
+ protected $_messages = array();
37
+
38
+ /**
39
+ * Hold the currency rates
40
+ *
41
+ * @var array
42
+ */
43
+ protected $_rates = array();
44
+
45
+ /**
46
+ * call the currency rate look up request or throw exception
47
+ */
48
+ public function __construct() {
49
+ $request = $this->_getRequestModel()
50
+ ->generateCurrencyRateLookUpRequest()
51
+ ->send();
52
+ if ($request->getResponse()->isSuccess()) {
53
+ $this->_rates = $this->_formatConvertionXml($request->getResponse());
54
+ } else {
55
+ Mage::throwException("Communication Error! Please try later");
56
+ }
57
+ }
58
+
59
+ /**
60
+ * To Get the currency rate message
61
+ *
62
+ * @param type $currencyFrom
63
+ * @param type $currencyTo
64
+ * @param type $retry
65
+ * @return array
66
+ */
67
+ protected function _convert($currencyFrom, $currencyTo, $retry = 0) {
68
+ if (count($this->_rates)) {
69
+ try {
70
+ $nativeCurrency = Mage::getStoreConfig('planet_payment_ppcore/ppcore_general/native_currency');
71
+ if ($currencyFrom != $nativeCurrency) {
72
+ $this->_messages[] = Mage::helper('planet_payment_core')->__('Planet Payment Native currency is different from store base currency');
73
+ } else if (isset($this->_rates[$currencyTo])) {
74
+ return $this->_rates[$currencyTo];
75
+ } else {
76
+ $this->_messages[] = Mage::helper('planet_payment_core')->__("Unable to retrieve the conversion rate from %s to %s", $currencyFrom, $currencyTo);
77
+ }
78
+ } catch (Exception $e) {
79
+ if ($retry == 0) {
80
+ $this->_convert($currencyFrom, $currencyTo, 1);
81
+ } else {
82
+ $this->_messages[] = Mage::helper('planet_payment_core')->__('Cannot retrieve rate from Planet Payment');
83
+ }
84
+ }
85
+ } else {
86
+ $this->_messages[] = Mage::helper('planet_payment_core')->__("Unable to retrieve the conversion rate from %s to %s", $currencyFrom, $currencyTo);
87
+ }
88
+ }
89
+
90
+ /**
91
+ * To format the conversion rate xml with attribute
92
+ *
93
+ * @param type $response
94
+ * @return array
95
+ */
96
+ protected function _formatConvertionXml($response) {
97
+ $responsexml = $response->getXmlContent();
98
+ $currencyRates = array();
99
+ if ($responsexml) {
100
+ $rates = $responsexml->FIELDS->RATES;
101
+ foreach ($rates->RATE as $rate) {
102
+ $attributes = $rate->CURRENCY_CODE->Attributes();
103
+ $currencyRates[(string) $attributes['ALPHA']] = 1 / (float) $rate->EXCHANGE_RATE;
104
+ }
105
+ }
106
+ return $currencyRates;
107
+ }
108
+
109
+ /**
110
+ * To get the request xml model
111
+ *
112
+ * @return object
113
+ */
114
+ protected function _getRequestModel() {
115
+ return Mage::getSingleton('planet_payment_core/xml_request');
116
+ }
117
+
118
+ }
app/code/community/PlanetPayment/Core/Model/System/Config/General/Encryption.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_System_Config_General_Encryption {
30
+
31
+ /**
32
+ * To provide the option to dropdown
33
+ *
34
+ * @return string
35
+ */
36
+ public function toOptionArray() {
37
+ $options = array();
38
+ $options[] = array(
39
+ 'value' => "triple-des",
40
+ 'label' => "Triple-DES"
41
+ );
42
+ return $options;
43
+ }
44
+
45
+ }
app/code/community/PlanetPayment/Core/Model/System/Config/General/Mode.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_System_Config_General_Mode {
30
+
31
+ /**
32
+ * to provide the option for dropdown
33
+ *
34
+ * @return string
35
+ */
36
+ public function toOptionArray() {
37
+ $options = array();
38
+ $options[] = array(
39
+ 'value' => 'testing',
40
+ 'label' => "Testing"
41
+ );
42
+ $options[] = array(
43
+ 'value' => 'production',
44
+ 'label' => "Production"
45
+ );
46
+ return $options;
47
+ }
48
+
49
+ }
app/code/community/PlanetPayment/Core/Model/System/Config/Payment/Currency.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_System_Config_Payment_Currency extends Mage_Adminhtml_Model_System_Config_Source_Currency {
30
+
31
+ /**
32
+ * Allowed Currencies and Add New currecny code to the array inorder to show that in the select box
33
+ *
34
+ * @var array
35
+ */
36
+ private $__allowedCurrencies = array(
37
+ 'USD',
38
+ 'CAD',
39
+ 'HKD'
40
+ );
41
+
42
+ /**
43
+ * To allow multiple currency to be set
44
+ *
45
+ * @param type $isMultiSelect
46
+ * @return array
47
+ */
48
+ public function toOptionArray($isMultiSelect) {
49
+ $options = parent::toOptionArray($isMultiSelect);
50
+ $allowedOptions = array();
51
+ foreach ($options as $option) {
52
+ if (isset($option['value'])) {
53
+ if (in_array($option['value'], $this->__allowedCurrencies)) {
54
+ array_push($allowedOptions, $option);
55
+ }
56
+ }
57
+ }
58
+ return $allowedOptions;
59
+ }
60
+
61
+ }
app/code/community/PlanetPayment/Core/Model/System/Config/Source/Enabledisable.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * To change this license header, choose License Headers in Project Properties.
5
+ * To change this template file, choose Tools | Templates
6
+ * and open the template in the editor.
7
+ */
8
+
9
+ /**
10
+ * Description of Enabledisable
11
+ *
12
+ * @author mohds
13
+ */
14
+ class PlanetPayment_Core_Model_System_Config_Source_Enabledisable {
15
+
16
+ /**
17
+ * To provide an option of enable for dropdown
18
+ *
19
+ * @return array
20
+ */
21
+ public function toOptionArray() {
22
+ return array(
23
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Enable')),
24
+ );
25
+ }
26
+
27
+ }
app/code/community/PlanetPayment/Core/Model/Xml/Abstract.php ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_Xml_Abstract extends Mage_Core_Model_Abstract {
30
+
31
+ /**
32
+ *
33
+ * @var string
34
+ */
35
+ protected $_generalConfigPath = "planet_payment_ppcore/ppcore_general/";
36
+
37
+ /**
38
+ *
39
+ * @var string
40
+ */
41
+ protected $_paymentConfigPath = "payment/ppcore/";
42
+
43
+ /**
44
+ *
45
+ * @var int
46
+ */
47
+ protected $_testKey = "123451234512345115432154321543214512345112345123";
48
+
49
+ const CONFIG_KEY = 'Magento';
50
+ const APP_NAME = 'PP_Core';
51
+
52
+ /**
53
+ * returns planet payment general configurations based on the parameters
54
+ *
55
+ * @param string $path
56
+ */
57
+ protected function _getConfig($path, $type = 'payment') {
58
+ if ($type == 'payment') {
59
+ $configPath = $this->_paymentConfigPath . $path;
60
+ } else {
61
+ $configPath = $this->_generalConfigPath . $path;
62
+ }
63
+
64
+ return Mage::getStoreConfig($configPath, Mage::app()->getStore()->getId());
65
+ }
66
+
67
+ /**
68
+ * return encryption key for general configuration
69
+ *
70
+ * @return type int
71
+ */
72
+ protected function _generateKey() {
73
+ if ($this->_isProductionMode()) {
74
+ $hex = $this->_getConfig('encryption_key', 'ppcore_general');
75
+ } else {
76
+ $hex = $this->_testKey;
77
+ }
78
+
79
+ $rv = '';
80
+ foreach (str_split($hex, 2) as $b) {
81
+ $rv .= chr(hexdec($b));
82
+ }
83
+ return $rv;
84
+ }
85
+
86
+ /**
87
+ * To check for the production mode
88
+ *
89
+ * @return bool
90
+ */
91
+ protected function _isProductionMode() {
92
+ return $this->_getConfig('url', 'ppcore_general') == 'production';
93
+ }
94
+
95
+ /**
96
+ * To check for the encryption set or not
97
+ *
98
+ * @return bool
99
+ */
100
+ protected function _hasEncryption() {
101
+ return (bool) $this->_getConfig('encryption', 'ppcore_general');
102
+ }
103
+
104
+ /**
105
+ * Accespts the request xml and encrypt TRANSACTION NODE
106
+ *
107
+ * @param Varien_Simplexml_Element $request
108
+ */
109
+ protected function _encryptRequest(Varien_Simplexml_Element &$request) {
110
+ if ($this->_getConfig('encryption_type', 'ppcore_general') == 'triple-des') {
111
+ $transactionToEncrypt = $request->TRANSACTION;
112
+ $transactionToEncryptAsXml = $transactionToEncrypt->asXML();
113
+ $key = $this->_generateKey();
114
+ $encryptedTransactionXml = base64_encode(mcrypt_encrypt(MCRYPT_3DES, $key, $transactionToEncryptAsXml, MCRYPT_MODE_ECB));
115
+ $request = $this->_getRootNode(true, $encryptedTransactionXml);
116
+ }
117
+ }
118
+
119
+ /**
120
+ * Accespts the response xml and decrypt TRANSACTION NODE
121
+ *
122
+ * @param string $response
123
+ * @return string
124
+ */
125
+ protected function _decryptResponse($response) {
126
+ if ($this->_getConfig('encryption_type', 'ppcore_general') == 'triple-des') {
127
+ $transactionToDecrypt = $response[0];
128
+ $key = $this->_generateKey();
129
+ $response = mcrypt_decrypt(MCRYPT_3DES, $key, base64_decode($transactionToDecrypt), MCRYPT_MODE_ECB);
130
+ }
131
+
132
+ return $response;
133
+ }
134
+
135
+ /**
136
+ * Generates client name to pass with communications
137
+ *
138
+ * Parts:
139
+ * - MyERP: the ERP that this connector is for (not always applicable)
140
+ * - Majver: version info for the ERP (not always applicable)
141
+ * - MinVer: version info for the ERP (not always applicable)
142
+ * - MyConnector: Name of the OEM's connector AND the name of the OEM (company) *required*
143
+ * - Majver: OEM's connector version *required*
144
+ * - MinVer: OEM's connector version *required*
145
+ *
146
+ * @example Magento,1.4,.0.1,Core by Planet Payment,2,0.1
147
+ * @return string
148
+ */
149
+ protected function _getClientName() {
150
+ $mageVersion = Mage::getVersion();
151
+ $mageVerParts = explode('.', $mageVersion, 2);
152
+
153
+ $part = array();
154
+ $part[] = self::CONFIG_KEY;
155
+ $part[] = $mageVerParts[0];
156
+ $part[] = $mageVerParts[1];
157
+ $part[] = self::APP_NAME;
158
+ return implode(',', $part);
159
+ }
160
+
161
+ }
app/code/community/PlanetPayment/Core/Model/Xml/Request.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPaymentCoreRequest
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_Xml_Request extends PlanetPayment_Core_Model_Xml_Abstract {
30
+
31
+ const LOG_FILE = 'pp_rate.log';
32
+ const GATEWAY_URL_PRODUCTION = 'https://prd.txngw.com';
33
+ const GATEWAY_URL_TESTING = 'http://uap.txngw.com';
34
+ const port = '86';
35
+ const ports = '443';
36
+
37
+ /**
38
+ * Returns the response model object
39
+ *
40
+ * @return object PlanetPayment_Core_Model_Xml_Response
41
+ */
42
+ protected function _getResponseModel() {
43
+ return Mage::getModel('planet_payment_core/xml_response');
44
+ }
45
+
46
+ /**
47
+ * Returns the root node. Two options here, either get a simple xml root node
48
+ * as a varien_simplexml object or get the complete encrypted request wrapped in
49
+ * root node.
50
+ *
51
+ * @param bool $afterEncrypt
52
+ * @param string $encryptedXml
53
+ * @return Varien_Simplexml_Element
54
+ */
55
+ protected function _getRootNode($afterEncrypt = false, $encryptedXml = false) {
56
+ $hasEncryption = $this->_hasEncryption();
57
+
58
+ $key = $this->_getConfig('key', 'ppcore_general');
59
+ $encryption = $hasEncryption ? '1' : '0';
60
+ if ($afterEncrypt) {
61
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1">' . $encryptedXml . '</REQUEST>';
62
+ } else {
63
+ $rootNodeString = '<REQUEST KEY="' . $key . '" PROTOCOL="1" ENCODING="' . $encryption . '" FMT="1"/>';
64
+ }
65
+
66
+ return new Varien_Simplexml_Element($rootNodeString);
67
+ }
68
+
69
+ /**
70
+ * Transaction request for currency rate look up for mcp
71
+ *
72
+ * @return PlanetPayment_Core_Model_Xml_Request
73
+ */
74
+ public function generateCurrencyRateLookUpRequest() {
75
+ try {
76
+ $hasEncryption = $this->_hasEncryption();
77
+
78
+ $key = $this->_getConfig('key', 'ppcore_general');
79
+ $encryption = $hasEncryption ? '1' : '0';
80
+ $request = $this->_getRootNode();
81
+ $transaction = $request->addChild('TRANSACTION');
82
+ $fields = $transaction->addChild('FIELDS');
83
+ $fields->addChild('TERMINAL_ID', $this->_getConfig('terminal_id', 'ppcore_general'));
84
+ //$fields->addChild('PIN', $this->_getConfig('pin', 'ppcore_general'));
85
+ $fields->addChild('SERVICE_FORMAT', '0000');
86
+ $fields->addChild('CURRENCY_INDICATOR', '1');
87
+ $fields->addChild('SERVICE', 'CURRENCY');
88
+ $fields->addChild('SERVICE_TYPE', 'RATE');
89
+ $fields->addChild('SERVICE_SUBTYPE', 'QUERY');
90
+ $fields->addChild('QUERY_TYPE', '1');
91
+ // $fields->addChild('FESP_IND', '9'); //added
92
+ //Sending Few Additional data to Gateway
93
+ $this->addAdditionalData($fields, true);
94
+ $this->setTransactionForLog($request);
95
+ $this->setCurrencyRate(true);
96
+
97
+ if ($hasEncryption) {
98
+ $this->_encryptRequest($request);
99
+ }
100
+
101
+ $this->setTransaction($request);
102
+ } catch (Exception $e) {
103
+ Mage::log($e->getmessage(), null, self::LOG_FILE);
104
+ Mage::throwException($e->getmessage());
105
+ }
106
+
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Adding Order Id and Incremented Order id and Customer Ip to Request XML
112
+ *
113
+ * @param obj $fields
114
+ * @param boolean $frontrequest
115
+ */
116
+ public function addAdditionalData($fields, $frontrequest = false) {
117
+ $payment = $this->getPayment();
118
+ if ($payment) {
119
+ $order = $payment->getOrder(); //to create a order object
120
+ //Set User data
121
+ if ($order) {
122
+ $fields->addChild('TICKET', $order->getIncrementId());
123
+ $fields->addChild('USER_DATA_1', $order->getId());
124
+ $fields->addChild('CLIENT_IP', $order->getData('remote_ip'));
125
+ $fields->addChild('FESP_IND', '9');
126
+ //Get Store Details from where order placed...
127
+ $store = $order->getData('store_name');
128
+ $store = str_replace(array("<br>", "\n", "\r"), '-', $store);
129
+ $stores = explode('-', $store);
130
+ $fields->addChild('USER_DATA_3', $stores[0]);
131
+ $fields->addChild('USER_DATA_4', $stores[1]);
132
+ $fields->addChild('USER_DATA_5', $stores[2]);
133
+
134
+ $frontrequest = false;
135
+ }
136
+ }
137
+
138
+ if ($frontrequest) {
139
+ $fields->addChild('CLIENT_IP', $_SERVER['REMOTE_ADDR']);
140
+ $fields->addChild('FESP_IND', '9');
141
+ $fields->addChild('USER_DATA_3', Mage::app()->getWebsite()->getName());
142
+ $fields->addChild('USER_DATA_4', Mage::app()->getGroup()->getName());
143
+ $fields->addChild('USER_DATA_5', Mage::app()->getStore()->getName());
144
+ }
145
+
146
+ $fields->addChild('USER_DATA_6', (string) Mage::getConfig()->getNode()->modules->PlanetPayment_Ppcore->version);
147
+ $fields->addChild('USER_DATA_7', Mage::getVersion());
148
+ }
149
+
150
+ /**
151
+ * Sending the request to Planet Payment
152
+ *
153
+ * @return PlanetPayment_Core_Model_Xml_Request
154
+ */
155
+ public function send() {
156
+ $transaction = $this->getTransaction();
157
+
158
+ if ($transaction) {
159
+ try {
160
+ $isProduction = $this->_isProductionMode();
161
+ if ($isProduction) {
162
+ $url = self::GATEWAY_URL_PRODUCTION;
163
+ } else {
164
+ $url = self::GATEWAY_URL_TESTING;
165
+ }
166
+ //Selecting port based on the url
167
+ $port = self::port;
168
+ if (strstr($url, 'https://')) {
169
+ $port = self::ports;
170
+ }
171
+ //print $transaction->asXML();exit;
172
+ $client = new Zend_Http_Client($url, array('keepalive' => true, 'timeout' => 360));
173
+ $client->getUri()->setPort($port);
174
+ $client->setRawData($transaction->asXML(), 'text/xml');
175
+ $client->setMethod(Zend_Http_Client::POST);
176
+ $response = $client->request()->getBody();
177
+
178
+ //Setting response to response model object
179
+ $responseModel = $this->_getResponseModel();
180
+ $responseModel->setCoreRequest($this);
181
+ $responseModel->setCoreResponse($response);
182
+ $this->setResponse($responseModel);
183
+ } catch (Exception $e) {
184
+ Mage::log($e->getmessage(), null, self::LOG_FILE);
185
+ Mage::throwException($e->getmessage());
186
+ }
187
+
188
+ return $this;
189
+ } else {
190
+ Mage::log("invalid Transaction", null, self::LOG_FILE);
191
+ Mage::throwException('invalid Transaction');
192
+ }
193
+ }
194
+
195
+ }
app/code/community/PlanetPayment/Core/Model/Xml/Response.php ADDED
@@ -0,0 +1,116 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_Core_Model_Xml_Response extends PlanetPayment_Core_Model_Xml_Abstract {
30
+
31
+ /**
32
+ * Hold the response xml string
33
+ *
34
+ * @var object SImpleXML
35
+ */
36
+ protected $_responseXml = null;
37
+
38
+ /**
39
+ * returns the response after decryption
40
+ *
41
+ * @return object SImpleXML
42
+ */
43
+ protected function _getResponse() {
44
+ $response = $this->getCoreResponse();
45
+ if ($response) {
46
+ $xmlResponse = simplexml_load_string($response);
47
+ if ($xmlResponse instanceof SimpleXMLElement) {
48
+
49
+ if ($this->_hasEncryption()) {
50
+ $this->_responseXml = simplexml_load_string($this->_decryptResponse($xmlResponse[0]));
51
+ } else {
52
+ $this->_responseXml = $xmlResponse->RESPONSE;
53
+ }
54
+
55
+ //Logging
56
+ //echo print_r($this->_getRequestObject()->getTransactionForLog()->asXML());die;
57
+ $requestXml = $this->_getRequestObject()->getTransactionForLog()->asXML();
58
+ $requestXml = preg_replace("/<ACCOUNT_NUMBER>[0-9]+([0-9]{4})/", '<ACCOUNT_NUMBER>************$1', $requestXml);
59
+ $requestXml = preg_replace("/<CVV>([0-9]+)<\/CVV>/", '<CVV>***</CVV>', $requestXml);
60
+
61
+ Mage::log("Print Request : " . $requestXml, null, PlanetPayment_Core_Model_Xml_Request::LOG_FILE, true);
62
+ Mage::log("Print Response : " . $this->_responseXml->asXML(), null, PlanetPayment_Core_Model_Xml_Request::LOG_FILE, true);
63
+ } else {
64
+ Mage::throwException('Invalid response');
65
+ }
66
+ } else {
67
+ Mage::throwException('Invalid response');
68
+ }
69
+
70
+ return $this->_responseXml;
71
+ }
72
+
73
+ /**
74
+ * Checking whether the request was successful
75
+ *
76
+ * @return bool
77
+ */
78
+ public function isSuccess() {
79
+ $responseXml = $this->_getResponse();
80
+ if ($responseXml->FIELDS->ARC) {
81
+ if ($responseXml->FIELDS->ARC == '00' && $responseXml->FIELDS->MRC == '00') {
82
+ return true;
83
+ } else {
84
+ $errorHelper = Mage::helper('planet_payment_core/error');
85
+ $arcMsg = $errorHelper->getErrorMessage((string) $responseXml->FIELDS->ARC, 'arc');
86
+ $mrcMsg = $errorHelper->getErrorMessage((string) $responseXml->FIELDS->MRC, 'mrc');
87
+ $this->setMessage("<i> (" . $arcMsg . ", " . $mrcMsg . ")</i><br/>RESPONSE TEXT:" . $responseXml->FIELDS->RESPONSE_TEXT);
88
+ }
89
+ }
90
+
91
+ return false;
92
+ }
93
+
94
+ /**
95
+ * Returns the Xml content of response
96
+ *
97
+ * @return object SImpleXML
98
+ */
99
+ public function getXmlContent() {
100
+ if (!$this->_responseXml) {
101
+ $this->_getResponse();
102
+ }
103
+
104
+ return $this->_responseXml;
105
+ }
106
+
107
+ /**
108
+ * Returning the request object of this response
109
+ *
110
+ * @return object
111
+ */
112
+ protected function _getRequestObject() {
113
+ return $this->getCoreRequest();
114
+ }
115
+
116
+ }
app/code/community/PlanetPayment/Core/etc/adminhtml.xml ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <acl>
32
+ <resources>
33
+ <admin>
34
+ <children>
35
+ <system>
36
+ <children>
37
+ <config>
38
+ <children>
39
+ <planet_payment_ppcore translate="title" module="cms">
40
+ <title>Planet Payment Core</title>
41
+ </planet_payment_ppcore>
42
+ </children>
43
+ </config>
44
+ </children>
45
+ </system>
46
+ </children>
47
+ </admin>
48
+ </resources>
49
+ </acl>
50
+ </config>
app/code/community/PlanetPayment/Core/etc/config.xml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <modules>
32
+ <PlanetPayment_Core>
33
+ <version>0.1.0</version>
34
+ </PlanetPayment_Core>
35
+ </modules>
36
+ <global>
37
+ <currency>
38
+ <import>
39
+ <services>
40
+ <planet_payment_core>
41
+ <name>Planet Payment</name>
42
+ <model>PlanetPayment_Core_Model_Currency_Import</model>
43
+ </planet_payment_core>
44
+ </services>
45
+ </import>
46
+ </currency>
47
+ <models>
48
+ <planet_payment_core>
49
+ <class>PlanetPayment_Core_Model</class>
50
+ </planet_payment_core>
51
+ </models>
52
+ <blocks>
53
+ <planet_payment_core>
54
+ <class>PlanetPayment_Core_Block</class>
55
+ </planet_payment_core>
56
+
57
+
58
+ <checkout>
59
+ <rewrite>
60
+ <cart_totals>PlanetPayment_Core_Block_Checkout_cart_Totals</cart_totals>
61
+ </rewrite>
62
+ </checkout>
63
+
64
+ <sales>
65
+ <rewrite>
66
+ <order_totals>PlanetPayment_Core_Block_Sales_Order_Totals</order_totals>
67
+ </rewrite>
68
+ </sales>
69
+ </blocks>
70
+ <helpers>
71
+ <planet_payment_core>
72
+ <class>PlanetPayment_Core_Helper</class>
73
+ </planet_payment_core>
74
+ </helpers>
75
+ </global>
76
+ </config>
app/code/community/PlanetPayment/Core/etc/system.xml ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Core
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Core
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ -->
30
+ <config>
31
+ <tabs>
32
+ <planetpaymentall translate="label">
33
+ <label>PlanetPayment Extensions</label>
34
+ <sort_order>400</sort_order>
35
+ </planetpaymentall>
36
+ </tabs>
37
+ <sections>
38
+ <planet_payment_ppcore translate="label">
39
+ <label>Planet Payment Exchange Rate</label>
40
+ <tab>planetpaymentall</tab>
41
+ <frontend_type>text</frontend_type>
42
+ <sort_order>100</sort_order>
43
+ <show_in_default>1</show_in_default>
44
+ <show_in_website>1</show_in_website>
45
+ <show_in_store>1</show_in_store>
46
+ <groups>
47
+ <ppcore_general translate="label">
48
+ <label>General</label>
49
+ <frontend_type>text</frontend_type>
50
+ <sort_order>0</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ <fields>
55
+ <url translate="label">
56
+ <label>URL</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>planet_payment_core/system_config_general_mode</source_model>
59
+ <sort_order>0</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </url>
64
+ <key translate="label">
65
+ <label>Company Key</label>
66
+ <frontend_type>text</frontend_type>
67
+ <validate>required-entry</validate>
68
+ <sort_order>1</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ <comment>Required.</comment>
73
+ </key>
74
+ <terminal_id translate="label">
75
+ <label>Terminal Id</label>
76
+ <frontend_type>text</frontend_type>
77
+ <validate>required-entry</validate>
78
+ <sort_order>1</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <comment>Required.</comment>
83
+ </terminal_id>
84
+ <encryption translate="label">
85
+ <label>Encryption</label>
86
+ <frontend_type>select</frontend_type>
87
+ <source_model>planet_payment_core/system_config_source_enabledisable</source_model>
88
+ <sort_order>3</sort_order>
89
+ <show_in_default>1</show_in_default>
90
+ <show_in_website>1</show_in_website>
91
+ <show_in_store>1</show_in_store>
92
+ <comment>Recommended.</comment>
93
+ </encryption>
94
+ <encryption_type translate="label">
95
+ <label>Encryption Type</label>
96
+ <frontend_type>select</frontend_type>
97
+ <source_model>planet_payment_core/system_config_general_encryption</source_model>
98
+ <sort_order>4</sort_order>
99
+ <show_in_default>1</show_in_default>
100
+ <show_in_website>1</show_in_website>
101
+ <show_in_store>1</show_in_store>
102
+ <depends>
103
+ <encryption>1</encryption>
104
+ </depends>
105
+ </encryption_type>
106
+ <encryption_key translate="label">
107
+ <label>Encryption Key</label>
108
+ <frontend_type>text</frontend_type>
109
+ <sort_order>5</sort_order>
110
+ <show_in_default>1</show_in_default>
111
+ <show_in_website>1</show_in_website>
112
+ <show_in_store>1</show_in_store>
113
+ <depends>
114
+ <encryption>1</encryption>
115
+ </depends>
116
+ </encryption_key>
117
+ <native_currency translate="comment">
118
+ <label>Native Currency</label>
119
+ <frontend_type>select</frontend_type>
120
+ <source_model>planet_payment_core/system_config_payment_currency</source_model>
121
+ <sort_order>4</sort_order>
122
+ <show_in_default>1</show_in_default>
123
+ <show_in_website>1</show_in_website>
124
+ <show_in_store>1</show_in_store>
125
+ </native_currency>
126
+ </fields>
127
+ </ppcore_general>
128
+ </groups>
129
+ </planet_payment_ppcore>
130
+ </sections>
131
+ </config>
app/code/community/PlanetPayment/CurrencyManager/Block/Adminhtml/Countrywise.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Countrywise CurrencyManager
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar kumar Singh<diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Block_Adminhtml_Countrywise extends Mage_Adminhtml_Block_System_Config_Form_Field {
27
+
28
+ /**
29
+ * Get block's html output
30
+ *
31
+ * @param Varien_Data_Form_Element_Abstract $element
32
+ * @return string
33
+ */
34
+ protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
35
+ $this->setElement($element);
36
+ $this->setTemplate('currencymanager/countrywise.phtml');
37
+ return $this->toHtml();
38
+ }
39
+
40
+ /**
41
+ * Get Allowed Currencies
42
+ *
43
+ * @return mixed
44
+ */
45
+ protected function getAllowedCurrencies() {
46
+ if (!$this->hasData('allowed_currencies')) {
47
+ $currencies = Mage::app()->getLocale()->getOptionCurrencies();
48
+ $allowedCurrencyCodes = Mage::getSingleton('directory/currency')->getConfigAllowCurrencies();
49
+
50
+ $formattedCurrencies = array();
51
+ foreach ($currencies as $currency) {
52
+ $formattedCurrencies[$currency['value']]['label'] = $currency['label'];
53
+ }
54
+
55
+ $allowedCurrencies = array();
56
+ foreach ($allowedCurrencyCodes as $currencyCode) {
57
+ $allowedCurrencies[$currencyCode] = $formattedCurrencies[$currencyCode]['label'];
58
+ }
59
+
60
+ $this->setData('allowed_currencies', $allowedCurrencies);
61
+ }
62
+ return $this->getData('allowed_currencies');
63
+ }
64
+
65
+ /**
66
+ * Get Currency Manager Setting Value
67
+ *
68
+ * @param string $key
69
+ * @return string
70
+ */
71
+ protected function _getValue($key) {
72
+ $value = $this->getElement()->getData('value/' . $key);
73
+ if (is_null($value)) {
74
+ $key = explode("/", $key);
75
+ $key = array_shift($key);
76
+ $value = Mage::app()->getConfig()->getNode('default/currencymanager/general/' . $key);
77
+ return (string) $value;
78
+ }
79
+ return $value;
80
+ }
81
+
82
+ }
app/code/community/PlanetPayment/CurrencyManager/Block/Adminhtml/Price.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Product Price Format
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar kumar Singh<diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Block_Adminhtml_Price extends Mage_Adminhtml_Block_Catalog_Product_Helper_Form_Price {
27
+
28
+ /**
29
+ * Get Escaped Value
30
+ *
31
+ * @param mixed $index
32
+ * @return string
33
+ */
34
+ public function getEscapedValue($index = null) {
35
+ $options = Mage::helper('currencymanager')->getOptions(array());
36
+ $value = $this->getValue();
37
+ if (!is_numeric($value)) {
38
+ return null;
39
+ }
40
+ if (isset($options['precision'])) {
41
+ return number_format($value, $options['precision'], null, '');
42
+ }
43
+ return parent::getEscapedValue($index);
44
+ }
45
+
46
+ }
app/code/community/PlanetPayment/CurrencyManager/Helper/Data.php ADDED
@@ -0,0 +1,214 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * CurrencyManager helper data
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Helper_Data extends Mage_Core_Helper_Abstract {
27
+
28
+ /**
29
+ * Store all currency setting options.
30
+ *
31
+ * @var array
32
+ */
33
+ protected $_options = array();
34
+
35
+ /**
36
+ * Hold boolean value for in order
37
+ *
38
+ * @var bool
39
+ */
40
+ protected $_inOrder = false;
41
+
42
+ /**
43
+ * Get options
44
+ *
45
+ * @param array $options
46
+ * @param boolean $old
47
+ * @param string $currency
48
+ * @return decimal
49
+ */
50
+ public function getOptions($options = array(), $old = false, $currency = "default") {
51
+ $storeId = Mage::app()->getStore()->getStoreId();
52
+ if (!isset($this->_options[$storeId][$currency])) {
53
+ $this->setOptions($currency);
54
+ }
55
+ $newOptions = $this->_options[$storeId][$currency];
56
+ if (count($options) > 0) {
57
+ return $newOptions + $options;
58
+ } else {
59
+ return $newOptions;
60
+ }
61
+ }
62
+
63
+ /**
64
+ * Clear options
65
+ *
66
+ * @param array $options
67
+ * @return array
68
+ */
69
+ public function clearOptionValues($options) {
70
+ $oldOptions = array("position", "format", "display", "precision", "script", "name", "currency", "symbol");
71
+ foreach (array_keys($options) as $optionKey) {
72
+ if (!in_array($optionKey, $oldOptions)) {
73
+ unset($options[$optionKey]);
74
+ }
75
+ }
76
+ return $options;
77
+ }
78
+
79
+ /**
80
+ * Check if currency manager is enabled.
81
+ *
82
+ * @return boolean
83
+ */
84
+ public function isActive() {
85
+ $config = Mage::getStoreConfig('currencymanager/general');
86
+ $storeId = Mage::app()->getStore()->getStoreId();
87
+ return ($this->isInOrder() || (($config['enabled']) && ($storeId > 0)) || (($config['enabledadm']) && ($storeId == 0)) );
88
+ }
89
+
90
+ /**
91
+ * Set Currency Manager Options
92
+ *
93
+ * @param string $currency
94
+ * @return PlanetPayment_CurrencyManager_Helper_Data
95
+ */
96
+ public function setOptions($currency = "default") {
97
+ $config = Mage::getStoreConfig('currencymanager/general');
98
+ $options = array();
99
+ $storeId = Mage::app()->getStore()->getStoreId();
100
+ if ($this->isActive()) {
101
+ if ($this->_inOrder) {
102
+ //get precision from order
103
+ //set $options
104
+ $order_id = Mage::app()->getRequest()->getParam('order_id');
105
+ $invoiceid = Mage::app()->getRequest()->getParam('invoice_id');
106
+ $creditmemoid = Mage::app()->getRequest()->getParam('creditmemo_id');
107
+ if (isset($invoiceid)) {
108
+ $invoice = Mage::getModel("sales/order_invoice")->load($invoiceid);
109
+ $order = $invoice->getOrder();
110
+ $order_id = $order->getId();
111
+ } else if (isset($creditmemoid)) {
112
+ $creditmemo = Mage::getModel('sales/order_creditmemo')->load($creditmemoid);
113
+ $order = $creditmemo->getOrder();
114
+ $order_id = $order->getId();
115
+ }
116
+ if (isset($order_id)) {
117
+ $order = Mage::getModel('sales/order')->load($order_id);
118
+ if ($order->getId()) {
119
+ $currencyPrecision = $order->getData('currency_precision');
120
+ $options = array('precision' => $currencyPrecision);
121
+ }
122
+ }
123
+ } else {
124
+ $this->getGeneralSettings($config, $options);
125
+ if (isset($config['countrywise'])) {
126
+ $this->collectCurrencySettings($config, $currency, $options);
127
+ }
128
+ }
129
+ }
130
+ $this->_options[$storeId][$currency] = $options;
131
+ if (!isset($this->_options[$storeId]["default"])) {
132
+ $this->_options[$storeId]["default"] = $options;
133
+ }
134
+ return $this;
135
+ }
136
+
137
+ /**
138
+ * Get general settings
139
+ *
140
+ * @param array $config
141
+ * @param array $options
142
+ */
143
+ protected function getGeneralSettings($config, &$options) {
144
+ if (isset($config['precision'])) {
145
+ $options['precision'] = min(30, max(-1, (int) $config['precision']));
146
+ }
147
+ }
148
+
149
+ /**
150
+ * Collect currency settings
151
+ *
152
+ * @param array $config
153
+ * @param array $currency
154
+ * @param array $options
155
+ */
156
+ protected function collectCurrencySettings($config, $currency, &$options) {
157
+ $countrywise_data = unserialize($config['countrywise']);
158
+ if (count($countrywise_data['precision']) > 0) {
159
+ $countrywise = array();
160
+ foreach ($countrywise_data['precision'] as $key => $val) {
161
+ $countrywise['currency'][] = $key;
162
+ $countrywise['precision'][] = $val;
163
+ }
164
+ }
165
+ if (count($countrywise['currency']) > 0) {
166
+ $optionsData = array();
167
+ $precision = $this->getCurrencySettings($currency, $countrywise, 'precision', true);
168
+ if ($precision !== false) {
169
+ $optionsData['precision'] = min(30, max(-1, $precision));
170
+ $options['precision'] = $optionsData['precision'];
171
+ }
172
+ }
173
+ }
174
+
175
+ /**
176
+ * Check if is in order
177
+ *
178
+ * @return boolean
179
+ */
180
+ public function isInOrder() {
181
+ //check sales, invoice areas
182
+ $module = Mage::app()->getRequest()->getModuleName();
183
+ $controller = Mage::app()->getRequest()->getControllerName();
184
+ if (in_array($module, array('sales')) || (($module == 'admin') && (strpos($controller, 'sales_order') !== false))) {
185
+ $this->_inOrder = true;
186
+ return true;
187
+ } else {
188
+ $this->_inOrder = false;
189
+ return false;
190
+ }
191
+ }
192
+
193
+ /**
194
+ * Get Currency Settings
195
+ *
196
+ * @param string $currency
197
+ * @param array $countrywise
198
+ * @param array $option
199
+ * @param boolean $int
200
+ * @return boolean
201
+ */
202
+ protected function getCurrencySettings($currency, $countrywise, $option, $int = false) {
203
+ $data = array_combine($countrywise['currency'], $countrywise[$option]);
204
+ if (array_key_exists($currency, $data)) {
205
+ $value = $data[$currency];
206
+ if ($value === "") {
207
+ return false;
208
+ }
209
+ return ($int) ? (int) $value : $value;
210
+ }
211
+ return false;
212
+ }
213
+
214
+ }
app/code/community/PlanetPayment/CurrencyManager/Helper/Tax.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * CurrencyManager helper tax
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Helper_Tax extends Mage_Tax_Helper_Data {
27
+
28
+ /**
29
+ * Get product price with all tax settings processing
30
+ *
31
+ * @param Mage_Catalog_Model_Product $product
32
+ * @param decimal $price
33
+ * @param mixed $includingTax
34
+ * @param mixed $shippingAddress
35
+ * @param mixed $billingAddress
36
+ * @param mixed $ctc
37
+ * @param mixed $store
38
+ * @param mixed $priceIncludesTax
39
+ * @param boolean $roundPrice
40
+ * @return string
41
+ */
42
+ public function getPrice($product, $price, $includingTax = null, $shippingAddress = null, $billingAddress = null, $ctc = null, $store = null, $priceIncludesTax = null, $roundPrice = true) {
43
+ if (!$price) {
44
+ return '';
45
+ }
46
+
47
+ $store = Mage::app()->getStore($store);
48
+ if (!$this->needPriceConversion($store)) {
49
+ return $price;
50
+ }
51
+ Mage::app()->getStore($store)->setNeedToRound(true);
52
+ if (version_compare(Mage::getVersion(), '1.8.1', '>')) {
53
+ //Helper rewrite
54
+ $result = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $priceIncludesTax, $roundPrice);
55
+ } else {
56
+ //Helper rewrite
57
+ $result = parent::getPrice($product, $price, $includingTax, $shippingAddress, $billingAddress, $ctc, $store, $priceIncludesTax);
58
+ }
59
+ Mage::app()->getStore($store)->setNeedToRound(false);
60
+ return $result;
61
+ }
62
+
63
+ }
app/code/community/PlanetPayment/CurrencyManager/Model/Currency.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Currency model
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Model_Currency extends Mage_Directory_Model_Currency {
27
+
28
+ /**
29
+ * Apply currency format to number with specific rounding precision
30
+ *
31
+ * @param double $price
32
+ * @param array $options
33
+ * @param bool $includeContainer
34
+ * @param bool $addBrackets
35
+ * @return String
36
+ */
37
+ public function format($price, $options = array(), $includeContainer = true, $addBrackets = false) {
38
+ $helper = Mage::helper('currencymanager');
39
+ return $this->formatPrecision(
40
+ $price, isset($options["precision"]) ? $options["precision"] : 2, $helper->clearOptionValues($options), $includeContainer, $addBrackets
41
+ );
42
+ }
43
+
44
+ /**
45
+ * Returns the formatted price
46
+ *
47
+ * @param double $price
48
+ * @param array $options
49
+ * @return String
50
+ */
51
+ public function formatTxt($price, $options = array()) {
52
+ $helper = Mage::helper('currencymanager');
53
+ $answer = parent::formatTxt($price, $helper->clearOptionValues($options));
54
+
55
+ if ($helper->isActive()) {
56
+ $moduleName = Mage::app()->getRequest()->getModuleName();
57
+
58
+ $optionsAdvanced = $helper->getOptions($options, false, $this->getCurrencyCode());
59
+ $options = $helper->getOptions($options, true, $this->getCurrencyCode());
60
+ if (isset($options["precision"])) {
61
+ $price = round($price, $options["precision"]);
62
+ }
63
+ $answer = parent::formatTxt($price, $options);
64
+ if (count($options) > 0) {
65
+ if (($moduleName == 'admin')) {
66
+ $answer = parent::formatTxt($price, $helper->clearOptionValues($options));
67
+ }
68
+ $minDecimalCount = $optionsAdvanced['precision'];
69
+ if ($minDecimalCount <= $options['precision']) {
70
+ $options['precision'] = $minDecimalCount;
71
+ }
72
+ $answer = $this->formatWithPrecision($options, $optionsAdvanced, $price, $answer);
73
+ }
74
+ }
75
+ return $answer;
76
+ }
77
+
78
+ /**
79
+ * Returns the formatted price
80
+ *
81
+ * @param int $options
82
+ * @param array $optionsAdvanced
83
+ * @param double $price
84
+ * @param string $answer
85
+ * @return String
86
+ */
87
+ protected function formatWithPrecision($options, $optionsAdvanced, &$price, $answer) {
88
+ $helper = Mage::helper('currencymanager');
89
+ if (isset($optionsAdvanced['precision'])) {
90
+ $price = round($price, $optionsAdvanced['precision']);
91
+ if ($optionsAdvanced['precision'] < 0) {
92
+ $options['precision'] = 0;
93
+ }
94
+ if (!isset($price)) {
95
+ $price = 0;
96
+ }
97
+ return parent::formatTxt($price, $helper->clearOptionValues($options));
98
+ }
99
+ return $answer;
100
+ }
101
+
102
+ /**
103
+ * Convert price to currency format
104
+ *
105
+ * @param double $price
106
+ * @param int $toCurrency
107
+ * @return String
108
+ */
109
+ public function convert($price, $toCurrency = null) {
110
+ $result = parent::convert($price, $toCurrency);
111
+ $data = new Varien_Object(array(
112
+ "price" => $price,
113
+ "toCurrency" => $toCurrency,
114
+ "result" => $result
115
+ ));
116
+ Mage::dispatchEvent("currency_convert_after", array("conversion" => $data));
117
+ return $data->getData("result");
118
+ }
119
+
120
+ }
app/code/community/PlanetPayment/CurrencyManager/Model/Ipay.php ADDED
@@ -0,0 +1,596 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_IpayGateway
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment - Ipay main credit card processor class.
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class PlanetPayment_IpayGateway_Model_Ipay extends Mage_Payment_Model_Method_Cc {
30
+
31
+ const GATEWAY_URL_PRODUCTION = 'https://prd.txngw.com';
32
+ const GATEWAY_URL_TESTING = 'https://uap.txngw.com';
33
+ const PAYMENT_ACTION_AUTHORIZE = "authorize";
34
+ const PAYMENT_ACTION_AUTHORIZE_CAPTURE = "authorize_capture";
35
+ const PAYMENT_SERVICE_PYC = "pyc";
36
+ const PAYMENT_SERVICE_MCP = "mcp";
37
+ const PAYMENT_SERVICE_NORMAL = "normal";
38
+ const VALIDATE_EXISTING = 1;
39
+ const VALIDATE_NEW = 2;
40
+ const METHOD_CODE = 'ipay';
41
+ const KAPTCHA_URL_PRODUCTION = 'https://ssl.kaptcha.com/logo.htm';
42
+ const KAPTCHA_URL_TESTING = 'https://tst.kaptcha.com/logo.htm';
43
+ //Xmls wil be logged in this file if any error occures while authorising,
44
+ //ie the authorize process is wrapped inside a mysql transaction in magento,
45
+ //if anything goes wrong,
46
+ //The complete process will be rolled back. Since our database logging
47
+ //is inside this transaction, we will loose the log.
48
+ const LOG_FILE = 'ipay_log.txt';
49
+
50
+ /**
51
+ * Hold method code
52
+ *
53
+ * @var string
54
+ */
55
+ protected $_code = self::METHOD_CODE;
56
+
57
+ /**
58
+ * hold the form block type path
59
+ *
60
+ * @var string
61
+ */
62
+ protected $_formBlockType = 'ipay/payment_form';
63
+
64
+ /**
65
+ * Hold the form block for admin path
66
+ *
67
+ * @var string
68
+ */
69
+ protected $_formBlockTypeAdmin = 'ipay/adminhtml_payment_form';
70
+
71
+ /**
72
+ * Hold the info block path
73
+ *
74
+ * @var string
75
+ */
76
+ protected $_infoBlockType = 'ipay/payment_info';
77
+
78
+ /**
79
+ * Hold if gateway is there
80
+ *
81
+ * @var bool
82
+ */
83
+ protected $_isGateway = true;
84
+
85
+ /**
86
+ * Hold boolean value if authorize is enable
87
+ *
88
+ * @var bool
89
+ */
90
+ protected $_canAuthorize = true;
91
+
92
+ /**
93
+ * Hold boolean value if capture is enable
94
+ *
95
+ * @var bool
96
+ */
97
+ protected $_canCapture = true;
98
+
99
+ /**
100
+ * Hold boolean value if partial capture is enable
101
+ *
102
+ * @var bool
103
+ */
104
+ protected $_canCapturePartial = false;
105
+
106
+ /**
107
+ * Hold boolean value if refund is enable
108
+ *
109
+ * @var bool
110
+ */
111
+ protected $_canRefund = true;
112
+
113
+ /**
114
+ * Hold boolean value if partial refund is enable
115
+ *
116
+ * @var bool
117
+ */
118
+ protected $_canRefundInvoicePartial = true;
119
+
120
+ /**
121
+ * Hold boolean value if void is enable
122
+ *
123
+ * @var bool
124
+ */
125
+ protected $_canVoid = true;
126
+
127
+ /**
128
+ * Hold boolean value if can use internal is enable
129
+ *
130
+ * @var bool
131
+ */
132
+ protected $_canUseInternal = true;
133
+
134
+ /**
135
+ * Hold boolean value if guest checkout is enable
136
+ *
137
+ * @var bool
138
+ */
139
+ protected $_canUseCheckout = true;
140
+
141
+ /**
142
+ * Hold boolean value if multiple shipping is enable
143
+ *
144
+ * @var bool
145
+ */
146
+ protected $_canUseForMultishipping = true;
147
+
148
+ /**
149
+ * Hold boolean value if can save credit card is enable
150
+ *
151
+ * @var bool
152
+ */
153
+ protected $_canSaveCc = true;
154
+
155
+ /**
156
+ * to assign the data
157
+ *
158
+ * @param Object $data
159
+ * @return Object of class PlanetPayment_IpayGateway_Model_Ipay
160
+ */
161
+ public function assignData($data) {
162
+ if (!($data instanceof Varien_Object)) {
163
+ $data = new Varien_Object($data);
164
+ }
165
+ if ($data->getIpayProfileId()) { // use existing profile
166
+ $paymentProfile = Mage::getModel('ipay/profile')
167
+ ->load($data->getIpayProfileId())
168
+ ->exportPayment($this->getInfoInstance());
169
+ $this->setValidationMode(self::VALIDATE_EXISTING);
170
+ } else { // new profile
171
+ parent::assignData($data);
172
+ $this->getInfoInstance()
173
+ ->setIpayProfileId(null)
174
+ ->setIsVisible($data->getIsVisible());
175
+ $this->setValidationMode(self::VALIDATE_NEW);
176
+ }
177
+ return $this;
178
+ }
179
+
180
+ /**
181
+ * To cature the invoice
182
+ *
183
+ * @param Varien_Object $payment
184
+ * @param decimal $amount
185
+ * @return void
186
+ */
187
+ public function capture(Varien_Object $payment, $amount) {
188
+ try {
189
+ if (!$payment->getTransactionId() && $this->getConfigData('payment_action') == self::PAYMENT_ACTION_AUTHORIZE_CAPTURE) {
190
+ return $this->sale($payment, $amount);
191
+ }
192
+ $payment->setAmount($amount);
193
+ $request = $this->_getRequest();
194
+ //Overriding the setAmount method based on currency in which order is placed.
195
+ $order = $payment->getOrder();
196
+ $currencyPrecision = $order->getData('currency_precision');
197
+ if (isset($currencyPrecision)) {
198
+ $amount = round($amount, $currencyPrecision);
199
+ $amountInStoreCurrency = round($payment->getOrder()->getGrandTotal(), $currencyPrecision);
200
+ } else {
201
+ $amount = round($amount, 2);
202
+ $amountInStoreCurrency = round($payment->getOrder()->getGrandTotal(), 2);
203
+ }
204
+ $request->setPayment($payment)
205
+ ->setAmount($amount)
206
+ ->setAmountInStoreCurrency($amountInStoreCurrency);
207
+ $request->generateRequestForCapture();
208
+ $request->send();
209
+ $response = $request->getResponse();
210
+ if ($response->isSuccess()) {
211
+ $result = $response->getXmlContent();
212
+ Mage::getSingleton('core/session')->setData('fraud_rules', $result->asXML());
213
+ $payment->setStatus(self::STATUS_APPROVED);
214
+ //$payment->setCcTransId($result->getTransactionId());
215
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
216
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
217
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
218
+ }
219
+ } else {
220
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
221
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try again later or contact us"));
222
+ }
223
+ } catch (Exception $e) {
224
+ Mage::throwException(Mage::helper('ipay')->__($e->getMessage()));
225
+ }
226
+ }
227
+
228
+ /**
229
+ * Authorize and Capture
230
+ *
231
+ * @param Varien_Object $payment
232
+ * @param decimal $amount
233
+ */
234
+ public function sale(Varien_Object $payment, $amount) {
235
+ try {
236
+ $payment->setAmount($amount);
237
+ $request = $this->_getRequest();
238
+ //Overriding the setAmount method based on currency in which order is placed.
239
+ $order = $payment->getOrder();
240
+ if (is_object($order)) {
241
+ $currency = $order->getOrderCurrency(); //$order object
242
+ if (is_object($currency)) {
243
+ $quoteCurrency = $currency->getCurrencyCode();
244
+ }
245
+ } else {
246
+ $quote = Mage::helper('ipay')->getQuote();
247
+ $quoteCurrency = $quote->getQuoteCurrencyCode();
248
+ }
249
+ $helper = Mage::helper('currencymanager');
250
+ $options = $helper->getOptions(array(), true, $quoteCurrency);
251
+ if (isset($options["precision"])) {
252
+ $amount = round($amount, $options["precision"]);
253
+ $amountInStoreCurrency = round($payment->getOrder()->getGrandTotal(), $options["precision"]);
254
+ } else {
255
+ $amount = round($amount, 2);
256
+ $amountInStoreCurrency = round($payment->getOrder()->getGrandTotal(), 2);
257
+ }
258
+ $request->setPayment($payment)
259
+ ->setAmount($amount)
260
+ ->setAmountInStoreCurrency($amountInStoreCurrency);
261
+ $request->generateRequestForSale();
262
+ $request->send();
263
+ $response = $request->getResponse();
264
+ if ($response->isSuccess()) {
265
+ $result = $response->getXmlContent();
266
+ Mage::getSingleton('core/session')->setData('fraud_rules', $result->asXML());
267
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1 / $result->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('ipay')->getQuote()->getBaseToQuoteRate();
268
+ $payment->setStatus(self::STATUS_APPROVED);
269
+ $payment->setIpayExchangeRate($exchangeRate);
270
+ $payment->setIpayMarkup($result->FIELDS->PYC_MARKUP);
271
+ $payment->setIpayServiceUsed(Mage::getStoreConfig('payment/ipay/service'));
272
+ $payment->setLastTransId($result->FIELDS->TRANSACTION_ID);
273
+ $payment->setPycExhangeRate($result->FIELDS->PYC_EXCHANGE_RATE);
274
+ if (!$payment->getParentTransactionId() || $result->FIELDS->TRANSACTION_ID != $payment->getParentTransactionId()) {
275
+ $payment->setTransactionId($result->FIELDS->TRANSACTION_ID);
276
+ }
277
+ } else {
278
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
279
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try again later or contact us"));
280
+ }
281
+ } catch (Exception $e) {
282
+ Mage::throwException(Mage::helper('ipay')->__($e->getMessage()));
283
+ }
284
+ }
285
+
286
+ /**
287
+ * Authorizing payment
288
+ *
289
+ * @param Varien_Object $payment
290
+ * @param decimal $amount
291
+ * @return object of type PlanetPayment_IpayGateway_Model_Ipay
292
+ */
293
+ public function authorize(Varien_Object $payment, $amount) {
294
+ if ($amount <= 0) {
295
+ Mage::throwException(Mage::helper('ipay')->__('Invalid amount for authorization.'));
296
+ }
297
+
298
+ $payment->setAmount($amount);
299
+ $request = $this->_getRequest();
300
+ $request->setTransactionType(self::PAYMENT_ACTION_AUTHORIZE)
301
+ ->setPayment($payment);
302
+ $paymentType = $this->getPaymentType();
303
+ if ($paymentType == self::PAYMENT_SERVICE_PYC) {
304
+ $quote = Mage::helper('ipay')->getQuote();
305
+ $quoteCurrency = $quote->getQuoteCurrencyCode();
306
+ $helper = Mage::helper('currencymanager');
307
+ $options = $helper->getOptions(array(), true, $quoteCurrency);
308
+ if (isset($options["precision"])) {
309
+ $amount = round($amount, $options["precision"]);
310
+ } else {
311
+ $amount = round($amount, 2);
312
+ }
313
+ $request->setAmount($amount);
314
+ $request->generateRequestForPycAuth();
315
+ } else if ($paymentType == self::PAYMENT_SERVICE_MCP) {
316
+ $quote = Mage::helper('ipay')->getQuote();
317
+ $quoteCurrency = $quote->getQuoteCurrencyCode();
318
+ $helper = Mage::helper('currencymanager');
319
+ $options = $helper->getOptions(array(), true, $quoteCurrency);
320
+ if (isset($options["precision"])) {
321
+ $price = round($quote->getGrandTotal(), $options["precision"]);
322
+ } else {
323
+ $price = round($quote->getGrandTotal(), 2);
324
+ }
325
+ $request->setAmountInStoreCurrency($price);
326
+ //$request->setAmountInStoreCurrency(round(Mage::helper('ipay')->getQuote()->getGrandTotal(), 2));
327
+ $request->generateRequestForMcpAuth();
328
+ } else {
329
+ Mage::throwException(Mage::helper('ipay')->__("Couldn't process your request. Please try agin later."));
330
+ }
331
+ $request->send();
332
+ $response = $request->getResponse();
333
+ if ($response->isSuccess()) {
334
+ $result = $response->getXmlContent();
335
+ Mage::getSingleton('core/session')->setData('fraud_rules', $result->asXML());
336
+ $exchangeRate = $paymentType == self::PAYMENT_SERVICE_PYC ? (1 / $result->FIELDS->PYC_EXCHANGE_RATE) : Mage::helper('ipay')->getQuote()->getBaseToQuoteRate();
337
+ $payment->setCcApproval($result->FIELDS->APPROVAL_CODE)
338
+ ->setLastTransId($result->FIELDS->TRANSACTION_ID)
339
+ ->setTransactionId($result->FIELDS->TRANSACTION_ID)
340
+ ->setIpayExchangeRate($exchangeRate)
341
+ ->setIpayMarkup($result->FIELDS->PYC_MARKUP)
342
+ ->setIpayServiceUsed(Mage::getStoreConfig('payment/ipay/service'))
343
+ ->setIsTransactionClosed(0)
344
+ ->setCcTransId($result->FIELDS->P3DS_TRANSACTION_ID)
345
+ ->setPycExhangeRate($result->FIELDS->PYC_EXCHANGE_RATE)
346
+ ->setStatus(self::STATUS_APPROVED);
347
+ } else {
348
+ //The last added log will be rolled back if error occured. So if any
349
+ //exception occured, the xmls will be logged in var/log/ipay_log.txt
350
+ Mage::log($response->getLogInfo(), null, self::LOG_FILE, trues);
351
+ Mage::throwException(Mage::helper('ipay')->__('Payment authorization error.'));
352
+ }
353
+
354
+ return $this;
355
+ }
356
+
357
+ /**
358
+ * Void the payment through gateway
359
+ *
360
+ * @param Varien_Object $payment
361
+ * @return PlanetPayment_IpayGateway_Model_Ipay
362
+ */
363
+ public function void(Varien_Object $payment) {
364
+ /* @var $payment Mage_Sales_Model_Order_Payment */
365
+ if ($payment->getParentTransactionId()) {
366
+ $request = $this->_getRequest();
367
+ $request->setPayment($payment);
368
+
369
+ $request->generateRequestForVoid()
370
+ ->send();
371
+
372
+ $response = $request->getResponse();
373
+
374
+ if ($response->isSuccess()) {
375
+ $payment->setStatus(self::STATUS_SUCCESS);
376
+ return $this;
377
+ } else {
378
+ $payment->setStatus(self::STATUS_ERROR);
379
+ Mage::throwException($this->_wrapGatewayError($result->getResponseReasonText()));
380
+ }
381
+ } else {
382
+ $payment->setStatus(self::STATUS_ERROR);
383
+ Mage::throwException(Mage::helper('ipay')->__('Invalid transaction id'));
384
+ }
385
+ }
386
+
387
+ /**
388
+ * Refund the amount with transaction id
389
+ *
390
+ * @param Varien_Object $payment
391
+ * @param decimal $amount
392
+ * @return PlanetPayment_IpayGateway_Model_Ipay
393
+ */
394
+ public function refund(Varien_Object $payment, $amount) {
395
+ /* @var $payment Mage_Sales_Model_Order_Payment */
396
+ if ($payment->getRefundTransactionId() && $amount > 0) {
397
+ if ($amount == $payment->getBaseAmountPaid()) {
398
+ //avoid a rounding error
399
+ $amountConverted = $payment->getAmountPaid();
400
+ } else {
401
+ //calculate the amount based on the payment exchange rate
402
+ $amountConverted = $amount * $payment->getIpayExchangeRate();
403
+ }
404
+ $request = $this->_getRequest();
405
+ //Overriding the setAmount method based on currency in which order is placed.
406
+ $order = $payment->getOrder();
407
+ $currencyPrecision = $order->getData('currency_precision');
408
+ if (isset($currencyPrecision)) {
409
+ $amount = round($amount, $currencyPrecision);
410
+ $amountConverted = round($amountConverted, $currencyPrecision);
411
+ } else {
412
+ $amount = round($amount, 2);
413
+ $amountConverted = round($amountConverted, 2);
414
+ }
415
+ $request->setPayment($payment)
416
+ ->setAmount($amount)
417
+ ->setAmountInStoreCurrency($amountConverted);
418
+ $request->generateRequestForRefund()
419
+ ->send();
420
+ $response = $request->getResponse();
421
+ if ($response->isSuccess()) {
422
+ $payment->setStatus(self::STATUS_SUCCESS);
423
+ return $this;
424
+ } else {
425
+ $payment->setStatus(self::STATUS_ERROR);
426
+ Mage::throwException(Mage::helper('ipay')->__('Error in refunding the payment. Message:' . $response->getMessage()));
427
+ }
428
+ }
429
+ Mage::throwException(Mage::helper('ipay')->__('Error in refunding the payment'));
430
+ }
431
+
432
+ /**
433
+ * Identifying the payment type PYC or MCP
434
+ *
435
+ * @return string
436
+ */
437
+ public function getPaymentType() {
438
+ $typeConfig = $this->getConfigData("service");
439
+ $nativeCurrency = $this->getConfigData("currency");
440
+ $quoteCurrency = Mage::helper('ipay')->getQuote()->getQuoteCurrencyCode();
441
+ $acceptedCurrencies = explode(",", $this->getConfigData("accepted_currencies"));
442
+ if ($typeConfig == self::PAYMENT_SERVICE_PYC) {
443
+ if ($quoteCurrency == $nativeCurrency) {
444
+ return self::PAYMENT_SERVICE_PYC;
445
+ }
446
+ } else if (in_array($quoteCurrency, $acceptedCurrencies)) {
447
+ return self::PAYMENT_SERVICE_MCP;
448
+ }
449
+
450
+ return self::PAYMENT_SERVICE_NORMAL;
451
+ }
452
+
453
+ /**
454
+ * Retrieve block type for method form generation
455
+ *
456
+ * @return string
457
+ */
458
+ public function getFormBlockType() {
459
+ if (Mage::app()->getStore()->isAdmin()) {
460
+ return $this->_formBlockTypeAdmin;
461
+ } else {
462
+ return $this->_formBlockType;
463
+ }
464
+ }
465
+
466
+ /**
467
+ * returns the Xml request object
468
+ * @return object PlanetPayment_IpayGateway_Model_Xml_Request
469
+ */
470
+ protected function _getRequest() {
471
+ return Mage::getmodel('ipay/xml_request');
472
+ }
473
+
474
+ /**
475
+ * Returns checkout session
476
+ *
477
+ * @return Object
478
+ */
479
+ protected function _getSession() {
480
+ return Mage::getSingleton('checkout/session');
481
+ }
482
+
483
+ /**
484
+ * Validate payment method information object
485
+ *
486
+ * @param Mage_Payment_Model_Info $info
487
+ * @return Mage_Payment_Model_Abstract
488
+ */
489
+ public function validate() {
490
+ /*
491
+ * calling parent validate function
492
+ */
493
+ if ($this->getValidationMode() == self::VALIDATE_NEW) {
494
+
495
+ $info = $this->getInfoInstance();
496
+ $errorMsg = false;
497
+ $availableTypes = explode(',', $this->getConfigData('cctypes'));
498
+
499
+ $ccNumber = $info->getCcNumber();
500
+
501
+ // remove credit card number delimiters such as "-" and space
502
+ $ccNumber = preg_replace('/[\-\s]+/', '', $ccNumber);
503
+ $info->setCcNumber($ccNumber);
504
+
505
+ $ccType = '';
506
+
507
+ if (in_array($info->getCcType(), $availableTypes)) {
508
+ if ($this->validateCcNum($ccNumber)
509
+ // Other credit card type number validation
510
+ || ($this->OtherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber))) {
511
+
512
+ $ccType = 'OT';
513
+ $ccTypeRegExpList = array(
514
+ //Solo, Switch or Maestro. International safe
515
+ //'SS' => '/^((6759[0-9]{12})|(6334|6767[0-9]{12})|(6334|6767[0-9]{14,15})|(5018|5020|5038|6304|6759|6761|6763[0-9]{12,19})|(49[013][1356][0-9]{12})|(633[34][0-9]{12})|(633110[0-9]{10})|(564182[0-9]{10}))([0-9]{2,3})?$/', // Maestro / Solo
516
+ 'SO' => '/(^(6334)[5-9](\d{11}$|\d{13,14}$))|(^(6767)(\d{12}$|\d{14,15}$))/', // Solo only
517
+ 'SM' => '/(^(5[0678])\d{11,18}$)|(^(6[^05])\d{11,18}$)|(^(601)[^1]\d{9,16}$)|(^(6011)\d{9,11}$)|(^(6011)\d{13,16}$)|(^(65)\d{11,13}$)|(^(65)\d{15,18}$)|(^(49030)[2-9](\d{10}$|\d{12,13}$))|(^(49033)[5-9](\d{10}$|\d{12,13}$))|(^(49110)[1-2](\d{10}$|\d{12,13}$))|(^(49117)[4-9](\d{10}$|\d{12,13}$))|(^(49118)[0-2](\d{10}$|\d{12,13}$))|(^(4936)(\d{12}$|\d{14,15}$))/',
518
+ 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', // Visa
519
+ 'MC' => '/^5[1-5][0-9]{14}$/', // Master Card
520
+ 'AE' => '/^3[47][0-9]{13}$/', // American Express
521
+ 'DI' => '/^6011[0-9]{12}$/', // Discovery
522
+ 'JCB' => '/^(3[0-9]{15}|(2131|1800)[0-9]{11})$/', // JCB
523
+ 'DIN' => '/^(300[0-9]{11}|305[0-9]{11}|36[0-9]{12}|38[0-9]{12})$/', //DINERS
524
+ );
525
+
526
+ foreach ($ccTypeRegExpList as $ccTypeMatch => $ccTypeRegExp) {
527
+ if (preg_match($ccTypeRegExp, $ccNumber)) {
528
+ $ccType = $ccTypeMatch;
529
+ break;
530
+ }
531
+ }
532
+
533
+ if (!$this->OtherCcType($info->getCcType()) && $ccType != $info->getCcType()) {
534
+ $errorCode = 'ccsave_cc_type,ccsave_cc_number';
535
+ $errorMsg = $this->_getHelper()->__('Credit card number mismatch with credit card type.');
536
+ }
537
+ } else {
538
+ $errorCode = 'ccsave_cc_number';
539
+ $errorMsg = $this->_getHelper()->__('Invalid Credit Card Number');
540
+ }
541
+ } else {
542
+ $errorCode = 'ccsave_cc_type';
543
+ $errorMsg = $this->_getHelper()->__('Credit card type is not allowed for this payment method.');
544
+ }
545
+
546
+ //validate credit card verification number
547
+ if ($errorMsg === false && $this->hasVerification()) {
548
+ $verifcationRegEx = $this->getVerificationRegEx();
549
+ $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
550
+ if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) {
551
+ $errorMsg = $this->_getHelper()->__('Please enter a valid credit card verification number.');
552
+ }
553
+ }
554
+
555
+ if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
556
+ $errorCode = 'ccsave_expiration,ccsave_expiration_yr';
557
+ $errorMsg = $this->_getHelper()->__('Incorrect credit card expiration date.');
558
+ }
559
+
560
+ if ($errorMsg) {
561
+ Mage::throwException($errorMsg);
562
+ }
563
+
564
+ //This must be after all validation conditions
565
+ if ($this->getIsCentinelValidationEnabled()) {
566
+ $this->getCentinelValidator()->validate($this->getCentinelValidationData());
567
+ }
568
+ } else {
569
+ Mage_Payment_Model_Method_Abstract::validate();
570
+ }
571
+
572
+ return $this;
573
+ }
574
+
575
+ /**
576
+ * to return an array of credit cards to be verify
577
+ *
578
+ * @return array
579
+ */
580
+ public function getVerificationRegEx() {
581
+ $verificationExpList = array(
582
+ 'VI' => '/^[0-9]{3}$/', // Visa
583
+ 'MC' => '/^[0-9]{3}$/', // Master Card
584
+ 'AE' => '/^[0-9]{4}$/', // American Express
585
+ 'DI' => '/^[0-9]{3}$/', // Discovery
586
+ 'SS' => '/^[0-9]{3,4}$/',
587
+ 'SM' => '/^[0-9]{3,4}$/', // Switch or Maestro
588
+ 'SO' => '/^[0-9]{3,4}$/', // Solo
589
+ 'OT' => '/^[0-9]{3,4}$/',
590
+ 'JCB' => '/^[0-9]{4}$/', //JCB
591
+ 'DIN' => '/^[0-9]{3}$/', //DINERS
592
+ );
593
+ return $verificationExpList;
594
+ }
595
+
596
+ }
app/code/community/PlanetPayment/CurrencyManager/Model/Locale.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Locale model
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Model_Locale extends Mage_Core_Model_Locale {
27
+
28
+ /**
29
+ * Create Zend_Currency object for current locale
30
+ *
31
+ * @param string $ccode
32
+ * @return string
33
+ */
34
+ public function currency($ccode) {
35
+ $admcurrency = parent::currency($ccode);
36
+ $options = Mage::helper('currencymanager')->getOptions(array(), true, $ccode);
37
+ $admcurrency->setFormat($options, $ccode);
38
+
39
+ return $admcurrency;
40
+ }
41
+
42
+ /**
43
+ * returns array with price formatting info for js function formatCurrency in js/varien/js.js
44
+ *
45
+ * @return array
46
+ */
47
+ public function getJsPriceFormat() {
48
+ // For JavaScript prices
49
+ $parentFormat = parent::getJsPriceFormat();
50
+ $options = Mage::helper('currencymanager')->getOptions(array());
51
+ if (isset($options["precision"])) {
52
+ $parentFormat["requiredPrecision"] = $options["precision"];
53
+ $parentFormat["precision"] = $options["precision"];
54
+ }
55
+
56
+ return $parentFormat;
57
+ }
58
+
59
+ }
app/code/community/PlanetPayment/CurrencyManager/Model/Observer.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ * */
18
+
19
+ /**
20
+ * Observer model
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Model_Observer {
27
+
28
+ /**
29
+ * Add value to currency_precision field when an order is placed.
30
+ *
31
+ * @param Varien_Event_Observer $observer
32
+ * return void
33
+ */
34
+ public function salesOrderPlaceAfter(Varien_Event_Observer $observer) {
35
+ $orderwithipay = false;
36
+ $order = $observer->getEvent()->getOrder();
37
+ $order_currency_code = $order->getData('order_currency_code');
38
+ $payment_method_code = $order->getPayment()->getMethodInstance()->getCode();
39
+ $options = Mage::helper('currencymanager')->getOptions(array(), true, $order_currency_code);
40
+ $order->setData('currency_precision', ((($options["precision"] != '' || $options["precision"] == '0') /* && $orderwithipay */) ? $options["precision"] : 2));
41
+ $order->save();
42
+ }
43
+
44
+ }
app/code/community/PlanetPayment/CurrencyManager/Model/Store.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+
19
+ /**
20
+ * Store model
21
+ *
22
+ * @category PlanetPayment
23
+ * @package PlanetPayment_CurrencyManager
24
+ * @author Diwakar Kumar Singh <diwakars@chetu.com>
25
+ */
26
+ class PlanetPayment_CurrencyManager_Model_Store extends Mage_Core_Model_Store {
27
+
28
+ /**
29
+ * Round val up to precision
30
+ *
31
+ * @param decimal $price
32
+ * @return float
33
+ */
34
+ public function roundPrice($price) {
35
+ if (Mage::app()->getStore()->getNeedToRound()) {
36
+ return $price;
37
+ }
38
+
39
+ $options = Mage::helper('currencymanager')->getOptions();
40
+ return round($price, isset($options["precision"]) ? $options["precision"] : 2);
41
+ }
42
+
43
+ }
app/code/community/PlanetPayment/CurrencyManager/etc/config.xml ADDED
@@ -0,0 +1,127 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <PlanetPayment_CurrencyManager>
22
+ <name>PlanetPayment Currency Manager</name>
23
+ <version>1.0.0</version>
24
+ </PlanetPayment_CurrencyManager>
25
+ </modules>
26
+
27
+ <global>
28
+ <helpers>
29
+ <currencymanager>
30
+ <class>PlanetPayment_CurrencyManager_Helper</class>
31
+ </currencymanager>
32
+ <tax>
33
+ <rewrite>
34
+ <data>PlanetPayment_CurrencyManager_Helper_Tax</data>
35
+ </rewrite>
36
+ </tax>
37
+ </helpers>
38
+ <models>
39
+ <directory>
40
+ <rewrite>
41
+ <currency>PlanetPayment_CurrencyManager_Model_Currency</currency>
42
+ </rewrite>
43
+ </directory>
44
+
45
+ <core>
46
+ <rewrite>
47
+ <locale>PlanetPayment_CurrencyManager_Model_Locale</locale>
48
+ <store>PlanetPayment_CurrencyManager_Model_Store</store>
49
+ </rewrite>
50
+ </core>
51
+
52
+ <currencymanager>
53
+ <class>PlanetPayment_CurrencyManager_Model</class>
54
+ </currencymanager>
55
+ </models>
56
+
57
+ <blocks>
58
+ <currencymanager>
59
+ <class>PlanetPayment_CurrencyManager_Block</class>
60
+ </currencymanager>
61
+ <adminhtml>
62
+ <rewrite>
63
+ <catalog_product_helper_form_price>PlanetPayment_CurrencyManager_Block_Adminhtml_Price</catalog_product_helper_form_price>
64
+ </rewrite>
65
+ <rewrite>
66
+ <catalog_product_edit_tab_options_option>PlanetPayment_CurrencyManager_Block_Adminhtml_Catalog_Product_Edit_Tab_Options_Option</catalog_product_edit_tab_options_option>
67
+ </rewrite>
68
+ </adminhtml>
69
+ </blocks>
70
+
71
+ <resources>
72
+ <currency_setup>
73
+ <setup>
74
+ <module>PlanetPayment_CurrencyManager</module>
75
+ </setup>
76
+ <connection>
77
+ <use>core_setup</use>
78
+ </connection>
79
+ </currency_setup>
80
+ </resources>
81
+
82
+ <events>
83
+ <sales_order_place_after>
84
+ <observers>
85
+ <planetpayment_currencymanager_order_observer>
86
+ <class>PlanetPayment_CurrencyManager_Model_Observer</class>
87
+ <method>salesOrderPlaceAfter</method>
88
+ </planetpayment_currencymanager_order_observer>
89
+ </observers>
90
+ </sales_order_place_after>
91
+ </events>
92
+ </global>
93
+
94
+ <frontend>
95
+ <routers>
96
+ <currencymanager>
97
+ <use>standard</use>
98
+ <args>
99
+ <module>PlanetPayment_CurrencyManager</module>
100
+ <frontName>currencymanager</frontName>
101
+ </args>
102
+ </currencymanager>
103
+ </routers>
104
+ </frontend>
105
+ <adminhtml>
106
+ <acl>
107
+ <resources>
108
+ <admin>
109
+ <children>
110
+ <system>
111
+ <children>
112
+ <config>
113
+ <children>
114
+ <currencymanager translate="title" module="currencymanager">
115
+ <title>PlanetPayment Currency Manager</title>
116
+ <sort_order>500</sort_order>
117
+ </currencymanager>
118
+ </children>
119
+ </config>
120
+ </children>
121
+ </system>
122
+ </children>
123
+ </admin>
124
+ </resources>
125
+ </acl>
126
+ </adminhtml>
127
+ </config>
app/code/community/PlanetPayment/CurrencyManager/etc/system.xml ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <sections>
21
+ <currencymanager translate="label" module="currencymanager">
22
+ <label>Currency Manager</label>
23
+ <tab>planetpaymentall</tab>
24
+ <frontend_type>text</frontend_type>
25
+ <sort_order>400</sort_order>
26
+ <show_in_default>1</show_in_default>
27
+ <show_in_website>1</show_in_website>
28
+ <show_in_store>1</show_in_store>
29
+ <groups>
30
+ <general translate="label">
31
+ <label>Planet Payment - Currency Settings</label>
32
+ <frontend_type>text</frontend_type>
33
+ <sort_order>10</sort_order>
34
+ <show_in_default>1</show_in_default>
35
+ <show_in_website>1</show_in_website>
36
+ <show_in_store>1</show_in_store>
37
+ <fields>
38
+ <heading_frontend translate="label">
39
+ <label>Frontend Settings</label>
40
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
41
+ <sort_order>100</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </heading_frontend>
46
+ <enabled translate="label">
47
+ <label>Enabled for Frontend</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>110</sort_order>
51
+ <show_in_default>1</show_in_default>
52
+ <show_in_website>1</show_in_website>
53
+ <show_in_store>1</show_in_store>
54
+ </enabled>
55
+
56
+ <heading_admin translate="label">
57
+ <label>Admin Specific Settings</label>
58
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
59
+ <sort_order>200</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </heading_admin>
64
+ <enabledadm translate="label">
65
+ <label>Enabled for Admin</label>
66
+ <frontend_type>select</frontend_type>
67
+ <source_model>adminhtml/system_config_source_yesno</source_model>
68
+ <sort_order>210</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </enabledadm>
73
+ <heading_global translate="label">
74
+ <label>Currency Settings (Default)</label>
75
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
76
+ <sort_order>300</sort_order>
77
+ <show_in_default>1</show_in_default>
78
+ <show_in_website>1</show_in_website>
79
+ <show_in_store>1</show_in_store>
80
+ </heading_global>
81
+ <precision translate="label comment">
82
+ <label>Display precision</label>
83
+ <comment><![CDATA[Number of decimal (e.g. 0, 1, 2). Default: 0<br>Examples<br>4 => 20.2347<br>3 => 20.234<br>2 => 20.23<br>1 => 20.2<br>0 => 20]]></comment>
84
+ <frontend_type>text</frontend_type>
85
+ <sort_order>310</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ </precision>
90
+ <heading_specific translate="label">
91
+ <label>Currency Settings (for specific currency)</label>
92
+ <frontend_model>adminhtml/system_config_form_field_heading</frontend_model>
93
+ <sort_order>400</sort_order>
94
+ <show_in_default>1</show_in_default>
95
+ <show_in_website>1</show_in_website>
96
+ <show_in_store>1</show_in_store>
97
+ </heading_specific>
98
+ <countrywise translate="label"><!-- added -->
99
+ <label>Country Specific Settings</label>
100
+ <frontend_type>select</frontend_type>
101
+ <frontend_model>currencymanager/adminhtml_countrywise</frontend_model>
102
+ <backend_model>adminhtml/system_config_backend_serialized</backend_model>
103
+ <sort_order>420</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>1</show_in_store>
107
+ </countrywise>
108
+
109
+ </fields>
110
+ </general>
111
+ </groups>
112
+ </currencymanager>
113
+ </sections>
114
+
115
+ <default>
116
+ <currencymanager>
117
+ <general>
118
+ <enabled>0</enabled>
119
+ <enabledadm>0</enabledadm>
120
+ <precision>0</precision>
121
+ </general>
122
+ </currencymanager>
123
+ </default>
124
+
125
+ </config>
app/code/community/PlanetPayment/CurrencyManager/sql/currency_setup/install-1.0.0.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ /* @var $installer PlanetPayment_CurrencyManager_Model_Currency_Setup */
19
+ $installer = $this;
20
+ $installer->startSetup();
21
+ $installer->getConnection()->addColumn($installer->getTable('sales/order'), 'currency_precision', 'tinyint DEFAULT 2');
22
+ $installer->endSetup();
app/code/local/Planet/Pay/Block/Adminhtml/Order.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
6
+ {
7
+
8
+ /**
9
+ *
10
+ */
11
+ public function __construct()
12
+ {
13
+ $this->_controller = 'planet_order';
14
+ $this->_blockGroup = 'planet_pay';
15
+ $this->_headerText = Mage::helper('planet_pay')->__('Planet Order Manager');
16
+ parent::__construct();
17
+ $this->_removeButton('add');
18
+ }
19
+
20
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/Info.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_Info
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_Info extends Mage_Adminhtml_Block_Template
6
+ {
7
+ /**
8
+ * @return Mage_Sales_Model_Order
9
+ */
10
+ public function getOrder()
11
+ {
12
+ return Mage::registry('sales_order');
13
+ }
14
+
15
+ /**
16
+ * @return false|Mage_Core_Model_Abstract
17
+ */
18
+ public function getPlanetOrder()
19
+ {
20
+ $planetOrder = Mage::getModel('planet_pay/order');
21
+ $planetOrder->loadByMageOrder($this->getOrder());
22
+ return $planetOrder;
23
+ }
24
+
25
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View.php ADDED
@@ -0,0 +1,144 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View extends Mage_Adminhtml_Block_Widget_Form_Container
6
+ {
7
+
8
+ /**
9
+ *
10
+ */
11
+ public function __construct()
12
+ {
13
+ $this->_objectId = 'order_id';
14
+ $this->_controller = 'sales_order';
15
+ $this->_mode = 'view';
16
+
17
+ parent::__construct();
18
+
19
+ $this->_removeButton('delete');
20
+ $this->_removeButton('reset');
21
+ $this->_removeButton('save');
22
+ $this->setId('sales_order_view');
23
+ }
24
+
25
+ /**
26
+ * Retrieve order model object
27
+ *
28
+ * @return Mage_Sales_Model_Order
29
+ */
30
+ public function getOrder()
31
+ {
32
+ return Mage::registry('sales_order');
33
+ }
34
+
35
+ /**
36
+ * Retrieve Order Identifier
37
+ *
38
+ * @return int
39
+ */
40
+ public function getOrderId()
41
+ {
42
+ return $this->getOrder()->getId();
43
+ }
44
+
45
+ public function getHeaderText()
46
+ {
47
+ if ($_extOrderId = $this->getOrder()->getExtOrderId()) {
48
+ $_extOrderId = '[' . $_extOrderId . '] ';
49
+ } else {
50
+ $_extOrderId = '';
51
+ }
52
+ return Mage::helper('sales')->__('Order # %s %s | %s', $this->getOrder()->getRealOrderId(), $_extOrderId, $this->formatDate($this->getOrder()->getCreatedAtDate(), 'medium', true));
53
+ }
54
+
55
+ public function getUrl($params='', $params2=array())
56
+ {
57
+ $params2['order_id'] = $this->getOrderId();
58
+ return parent::getUrl($params, $params2);
59
+ }
60
+
61
+ public function getEditUrl()
62
+ {
63
+ return $this->getUrl('*/sales_order_edit/start');
64
+ }
65
+
66
+ public function getEmailUrl()
67
+ {
68
+ return $this->getUrl('*/*/email');
69
+ }
70
+
71
+ public function getCancelUrl()
72
+ {
73
+ return $this->getUrl('*/*/cancel');
74
+ }
75
+
76
+ public function getInvoiceUrl()
77
+ {
78
+ return $this->getUrl('*/sales_order_invoice/start');
79
+ }
80
+
81
+ public function getCreditmemoUrl()
82
+ {
83
+ return $this->getUrl('*/sales_order_creditmemo/start');
84
+ }
85
+
86
+ public function getHoldUrl()
87
+ {
88
+ return $this->getUrl('*/*/hold');
89
+ }
90
+
91
+ public function getUnholdUrl()
92
+ {
93
+ return $this->getUrl('*/*/unhold');
94
+ }
95
+
96
+ public function getShipUrl()
97
+ {
98
+ return $this->getUrl('*/sales_order_shipment/start');
99
+ }
100
+
101
+ public function getCommentUrl()
102
+ {
103
+ return $this->getUrl('*/*/comment');
104
+ }
105
+
106
+ public function getReorderUrl()
107
+ {
108
+ return $this->getUrl('*/sales_order_create/reorder');
109
+ }
110
+
111
+ /**
112
+ * Payment void URL getter
113
+ */
114
+ public function getVoidPaymentUrl()
115
+ {
116
+ return $this->getUrl('*/*/voidPayment');
117
+ }
118
+
119
+ protected function _isAllowedAction($action)
120
+ {
121
+ return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/' . $action);
122
+ }
123
+
124
+ /**
125
+ * Return back url for view grid
126
+ *
127
+ * @return string
128
+ */
129
+ public function getBackUrl()
130
+ {
131
+ if ($this->getOrder()->getBackUrl()) {
132
+ return $this->getOrder()->getBackUrl();
133
+ }
134
+
135
+ return $this->getUrl('*/*/');
136
+ }
137
+
138
+ public function getReviewPaymentUrl($action)
139
+ {
140
+ return $this->getUrl('*/*/reviewPayment', array('action' => $action));
141
+ }
142
+
143
+
144
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Credit.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Handling_Credit
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Handling_Credit extends Mage_Adminhtml_Block_Widget
6
+ {
7
+ /**
8
+ * @return Mage_Core_Block_Abstract
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ $onclick = "submitAndReloadArea($('order_credit_block').parentNode, '".$this->getSubmitUrl()."')";
13
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
14
+ ->setData(array(
15
+ 'label' => Mage::helper('sales')->__('Send Credit Note'),
16
+ 'class' => 'save',
17
+ 'onclick' => $onclick
18
+ ));
19
+ $this->setChild('submit_button', $button);
20
+ return parent::_prepareLayout();
21
+ }
22
+
23
+ /**
24
+ * @return Planet_Pay_Model_Resource_Orderlog_Collection
25
+ */
26
+ public function getOrderCreditLogs()
27
+ {
28
+ /** @var Planet_Pay_Model_Resource_Orderlog_Collection $orderRequestLogs */
29
+ $orderRequestLogs = Mage::getResourceModel('planet_pay/orderlog_collection');
30
+ $orderRequestLogs->setOrderFilter($this->getPlanetOrder());
31
+ $orderRequestLogs->setMethodFilter('credit_note');
32
+ return $orderRequestLogs;
33
+ }
34
+
35
+ /**
36
+ * Retrieve order model
37
+ *
38
+ * @return Mage_Sales_Model_Order
39
+ */
40
+ public function getOrder()
41
+ {
42
+ return Mage::registry('sales_order');
43
+ }
44
+
45
+ /**
46
+ * @return Planet_Pay_Model_Order
47
+ */
48
+ public function getPlanetOrder()
49
+ {
50
+ return Mage::registry('planet_order');
51
+ }
52
+
53
+ /**
54
+ * @return string
55
+ */
56
+ public function getSubmitUrl()
57
+ {
58
+ return $this->getUrl('*/*/sendCreditNote', array('order_id'=>$this->getOrder()->getId()));
59
+ }
60
+
61
+
62
+
63
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Delivery.php ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Handling_Delivery
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Handling_Delivery extends Mage_Adminhtml_Block_Template
6
+ {
7
+ /**
8
+ * @return Mage_Core_Block_Abstract
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ $onclick = "submitAndReloadArea($('order_delivery_block').parentNode, '".$this->getSubmitUrl()."')";
13
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
14
+ ->setData(array(
15
+ 'label' => Mage::helper('planet_pay')->__('Send Delivery Note'),
16
+ 'class' => 'save',
17
+ 'onclick' => $onclick
18
+ ));
19
+ $this->setChild('submit_button', $button);
20
+ return parent::_prepareLayout();
21
+ }
22
+
23
+ /**
24
+ * @return Planet_Pay_Model_Resource_Orderlog_Collection
25
+ */
26
+ public function getOrderDeliveryLogs()
27
+ {
28
+ /** @var Planet_Pay_Model_Resource_Orderlog_Collection $orderDeliveryLogs */
29
+ $orderDeliveryLogs = Mage::getResourceModel('planet_pay/orderlog_collection');
30
+ $orderDeliveryLogs->setOrderFilter($this->getPlanetOrder());
31
+ $orderDeliveryLogs->setMethodFilter('delivery_note');
32
+ foreach ($orderDeliveryLogs as $orderDeliveryLog) {
33
+ if ($orderDeliveryLog->getSuccess() == true) {
34
+ Mage::register('deliverySent', true);
35
+ }
36
+ }
37
+ return $orderDeliveryLogs;
38
+ }
39
+
40
+ /**
41
+ * Retrieve order model
42
+ *
43
+ * @return Mage_Sales_Model_Order
44
+ */
45
+ public function getOrder()
46
+ {
47
+ return Mage::registry('sales_order');
48
+ }
49
+
50
+ /**
51
+ * @return Planet_Pay_Model_Order
52
+ */
53
+ public function getPlanetOrder()
54
+ {
55
+ return Mage::registry('planet_order');
56
+ }
57
+
58
+ /**
59
+ * @return string
60
+ */
61
+ public function getSubmitUrl()
62
+ {
63
+ return $this->getUrl('*/*/sendDeliveryNote', array('order_id'=>$this->getOrder()->getId()));
64
+ }
65
+
66
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Handling/Request.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Handling_Request
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Handling_Request extends Mage_Adminhtml_Block_Template
6
+ {
7
+ /**
8
+ * @return Mage_Core_Block_Abstract
9
+ */
10
+ protected function _prepareLayout()
11
+ {
12
+ $onclick = "submitAndReloadArea($('order_request_block').parentNode, '".$this->getSubmitUrl()."')";
13
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
14
+ ->setData(array(
15
+ 'label' => Mage::helper('sales')->__('Send Order Request'),
16
+ 'class' => 'save',
17
+ 'onclick' => $onclick
18
+ ));
19
+ $this->setChild('submit_button', $button);
20
+ return parent::_prepareLayout();
21
+ }
22
+
23
+ /**
24
+ * @return Planet_Pay_Model_Resource_Orderlog_Collection
25
+ */
26
+ public function getOrderRequestLogs()
27
+ {
28
+ /** @var Planet_Pay_Model_Resource_Orderlog_Collection $orderRequestLogs */
29
+ $orderRequestLogs = Mage::getResourceModel('planet_pay/orderlog_collection');
30
+ $orderRequestLogs->setOrderFilter($this->getPlanetOrder());
31
+ $orderRequestLogs->setMethodFilter('order_request');
32
+ return $orderRequestLogs;
33
+ }
34
+
35
+ /**
36
+ * Retrieve order model
37
+ *
38
+ * @return Mage_Sales_Model_Order
39
+ */
40
+ public function getOrder()
41
+ {
42
+ return Mage::registry('sales_order');
43
+ }
44
+
45
+ /**
46
+ * @return Planet_Pay_Model_Order
47
+ */
48
+ public function getPlanetOrder()
49
+ {
50
+ return Mage::registry('planet_order');
51
+ }
52
+
53
+ /**
54
+ * @return string
55
+ */
56
+ public function getSubmitUrl()
57
+ {
58
+ return $this->getUrl('*/*/sendOrderRequest', array('order_id'=>$this->getOrder()->getId()));
59
+ }
60
+
61
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Items/Renderer/Default.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Items_Renderer_Default
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Items_Renderer_Default extends Mage_Adminhtml_Block_Sales_Order_View_Items_Renderer_Default
6
+ {
7
+
8
+ /**
9
+ * @return Varien_Object
10
+ */
11
+ public function getSubmitButton()
12
+ {
13
+ $onclick = "submitAndReloadArea($('order-credit').parentNode, '".$this->getSubmitUrl()."')";
14
+ $active = $this->isButtonActive();
15
+ $button = $this->getLayout()->createBlock('adminhtml/widget_button')
16
+ ->setData(array(
17
+ 'label' => Mage::helper('planet_pay')->__('Send Credit Note'),
18
+ 'class' => 'save',
19
+ 'onclick' => $onclick,
20
+ 'disabled'=> !$active
21
+ ));
22
+ return $button;
23
+ }
24
+
25
+ /**
26
+ * @return string
27
+ */
28
+ public function getSubmitUrl()
29
+ {
30
+ return $this->getUrl('*/*/sendProductCreditNote', array('order_id'=>$this->getOrder()->getId(),
31
+ 'item_id' =>$this->getItem()->getId()
32
+ ));
33
+ }
34
+
35
+ /**
36
+ * @return mixed
37
+ */
38
+ private function isButtonActive()
39
+ {
40
+ if (is_null(Mage::registry('deliverySent'))) {
41
+ /** @var Planet_Pay_Model_Resource_Orderlog_Collection $orderRequestLogs */
42
+ $orderRequestLogs = Mage::getResourceModel('planet_pay/orderlog_collection');
43
+ $orderRequestLogs->setOrderFilter($this->getPlanetOrder());
44
+ $orderRequestLogs->setMethodFilter('delivery_note');
45
+ $orderRequestLogs->setSuccessFilter();
46
+ if ($orderRequestLogs->count()) {
47
+ Mage::register('deliverySent', true);
48
+ }
49
+ }
50
+ if (Mage::registry('deliverySent') === true) {
51
+ return ((int)$this->getItem()->getQtyOrdered() - (int)$this->getItem()->getQtyRefunded() > 0);
52
+ }
53
+ return false;
54
+ }
55
+
56
+ /**
57
+ * @return Planet_Pay_Model_Order
58
+ */
59
+ public function getPlanetOrder()
60
+ {
61
+ return Mage::registry('planet_order');
62
+ }
63
+
64
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Request.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Request
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Request extends Mage_Adminhtml_Block_Template
6
+ {
7
+ protected $planetRequest;
8
+
9
+ /**
10
+ * @return array
11
+ */
12
+ public function getOrderRequestOptions()
13
+ {
14
+ $requestOptions = array();
15
+ $requestData = $this->getRequestData();
16
+ foreach ($requestData as $name => $value) {
17
+ if (!is_array($value)) {
18
+ $requestOptions[] = array(
19
+ 'name' => $name,
20
+ 'value'=> $value
21
+ );
22
+ }
23
+ }
24
+ return $requestOptions;
25
+ }
26
+
27
+ /**
28
+ * @return array
29
+ */
30
+ public function getOrderRequestCustomer()
31
+ {
32
+ $requestData = $this->getRequestData();
33
+ if (isset($requestData['customerData'])) {
34
+ return $requestData['customerData'];
35
+ }
36
+ else {
37
+ return array();
38
+ }
39
+ }
40
+
41
+ /**
42
+ * @return array
43
+ */
44
+ public function getOrderRequestCriterionData()
45
+ {
46
+ $criterionData = array();
47
+ $requestData = $this->getRequestData();
48
+ if (isset($requestData['criterionData'])) {
49
+ foreach ($requestData['criterionData'] as $name => $value) {
50
+ if (!is_array($value)) {
51
+ $criterionData[] = array(
52
+ 'name' => $name,
53
+ 'value'=> $value
54
+ );
55
+ }
56
+ }
57
+ }
58
+ return $criterionData;
59
+ }
60
+
61
+ /**
62
+ * @return array
63
+ */
64
+ public function getOrderRequestOrderItems()
65
+ {
66
+ $orderItems = array();
67
+ $requestData = $this->getRequestData();
68
+ if (isset($requestData['criterionData']['orderItems'])) {
69
+ foreach ($requestData['criterionData']['orderItems'] as $id => $orderItem) {
70
+ foreach ($orderItem as $name => $value) {
71
+ $orderItems[$id][] = array(
72
+ 'name' => $name,
73
+ 'value'=> $value
74
+ );
75
+ }
76
+ }
77
+ }
78
+ return $orderItems;
79
+ }
80
+
81
+ /**
82
+ * @return Mage_Sales_Model_Order
83
+ */
84
+ public function getOrder()
85
+ {
86
+ return Mage::registry('sales_order');
87
+ }
88
+
89
+ /**
90
+ * @return array|mixed
91
+ */
92
+ protected function getRequestData()
93
+ {
94
+ if (!is_null($this->planetRequest)){
95
+ return $this->planetRequest;
96
+ }
97
+ else {
98
+ /** @var Planet_Pay_Model_Order $planetOrder */
99
+ $planetOrder = Mage::getModel('planet_pay/order');
100
+ $planetOrder->loadByMageOrder($this->getOrder());
101
+ $request = $planetOrder->getPaymentRequest();
102
+ if (!is_null($request)) {
103
+ return json_decode($request, true);
104
+ }
105
+ else {
106
+ return array();
107
+ }
108
+ }
109
+ }
110
+
111
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Credit.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Tab_Credit
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Tab_Credit extends Mage_Adminhtml_Block_Sales_Order_Abstract
6
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
7
+ {
8
+ /**
9
+ * @return Mage_Sales_Model_Order
10
+ */
11
+ public function getOrder()
12
+ {
13
+ return Mage::registry('current_order');
14
+ }
15
+
16
+ /**
17
+ * @return Mage_Sales_Model_Order
18
+ */
19
+ public function getSource()
20
+ {
21
+ return $this->getOrder();
22
+ }
23
+
24
+ /**
25
+ * Retrieve order totals block settings
26
+ *
27
+ * @return array
28
+ */
29
+ public function getOrderTotalData()
30
+ {
31
+ return array(
32
+ 'can_display_total_due' => true,
33
+ 'can_display_total_paid' => true,
34
+ 'can_display_total_refunded' => true,
35
+ );
36
+ }
37
+
38
+ public function getOrderInfoData()
39
+ {
40
+ return array(
41
+ 'no_use_order_link' => true,
42
+ );
43
+ }
44
+
45
+
46
+ public function getViewUrl($orderId)
47
+ {
48
+ return $this->getUrl('*/*/*', array('order_id'=>$orderId));
49
+ }
50
+
51
+ /**
52
+ * ######################## TAB settings #################################
53
+ */
54
+
55
+ /**
56
+ * @return string
57
+ */
58
+ public function getTabLabel()
59
+ {
60
+ return Mage::helper('planet_pay')->__('Credit Note');
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function getTabTitle()
67
+ {
68
+ return Mage::helper('planet_pay')->__('Order Credit Note Info');
69
+ }
70
+
71
+ /**
72
+ * @return bool
73
+ */
74
+ public function canShowTab()
75
+ {
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * @return bool
81
+ */
82
+ public function isHidden()
83
+ {
84
+ return false;
85
+ }
86
+
87
+ /**
88
+ * @return string
89
+ */
90
+ public function getItemsHtml()
91
+ {
92
+ return $this->getChildHtml('order_credit_items');
93
+ }
94
+
95
+ /**
96
+ * @return mixed
97
+ */
98
+ public function isDeliveryNoteSent()
99
+ {
100
+ if (is_null(Mage::registry('deliverySent'))) {
101
+ /** @var Planet_Pay_Model_Resource_Orderlog_Collection $orderRequestLogs */
102
+ $orderRequestLogs = Mage::getResourceModel('planet_pay/orderlog_collection');
103
+ $orderRequestLogs->setOrderFilter($this->getPlanetOrder());
104
+ $orderRequestLogs->setMethodFilter('delivery_note');
105
+ $orderRequestLogs->setSuccessFilter();
106
+ if ($orderRequestLogs->count()) {
107
+ Mage::register('deliverySent', true);
108
+ }
109
+ }
110
+ return Mage::registry('deliverySent');
111
+ }
112
+
113
+ /**
114
+ * @return Planet_Pay_Model_Order
115
+ */
116
+ public function getPlanetOrder()
117
+ {
118
+ return Mage::registry('planet_order');
119
+ }
120
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Delivery.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Tab_Delivery
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Tab_Delivery extends Mage_Adminhtml_Block_Sales_Order_Abstract
6
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
7
+ {
8
+ /**
9
+ * @return Mage_Sales_Model_Order
10
+ */
11
+ public function getOrder()
12
+ {
13
+ return Mage::registry('current_order');
14
+ }
15
+
16
+ /**
17
+ * @return Mage_Sales_Model_Order
18
+ */
19
+ public function getSource()
20
+ {
21
+ return $this->getOrder();
22
+ }
23
+
24
+ /**
25
+ * Retrieve order totals block settings
26
+ *
27
+ * @return array
28
+ */
29
+ public function getOrderTotalData()
30
+ {
31
+ return array(
32
+ 'can_display_total_due' => true,
33
+ 'can_display_total_paid' => true,
34
+ 'can_display_total_refunded' => true,
35
+ );
36
+ }
37
+
38
+ public function getOrderInfoData()
39
+ {
40
+ return array(
41
+ 'no_use_order_link' => true,
42
+ );
43
+ }
44
+
45
+
46
+ public function getViewUrl($orderId)
47
+ {
48
+ return $this->getUrl('*/*/*', array('order_id'=>$orderId));
49
+ }
50
+
51
+ /**
52
+ * ######################## TAB settings #################################
53
+ */
54
+
55
+ /**
56
+ * @return string
57
+ */
58
+ public function getTabLabel()
59
+ {
60
+ return Mage::helper('planet_pay')->__('Delivery Request');
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function getTabTitle()
67
+ {
68
+ return Mage::helper('planet_pay')->__('Order Delivery Request Info');
69
+ }
70
+
71
+ /**
72
+ * @return bool
73
+ */
74
+ public function canShowTab()
75
+ {
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * @return bool
81
+ */
82
+ public function isHidden()
83
+ {
84
+ return false;
85
+ }
86
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Order/View/Tab/Request.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Adminhtml_Order_View_Tab_Request
4
+ */
5
+ class Planet_Pay_Block_Adminhtml_Order_View_Tab_Request extends Mage_Adminhtml_Block_Sales_Order_Abstract
6
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface
7
+ {
8
+ /**
9
+ * @return Mage_Sales_Model_Order
10
+ */
11
+ public function getOrder()
12
+ {
13
+ return Mage::registry('current_order');
14
+ }
15
+
16
+ /**
17
+ * @return Mage_Sales_Model_Order
18
+ */
19
+ public function getSource()
20
+ {
21
+ return $this->getOrder();
22
+ }
23
+
24
+ /**
25
+ * Retrieve order totals block settings
26
+ *
27
+ * @return array
28
+ */
29
+ public function getOrderTotalData()
30
+ {
31
+ return array(
32
+ 'can_display_total_due' => true,
33
+ 'can_display_total_paid' => true,
34
+ 'can_display_total_refunded' => true,
35
+ );
36
+ }
37
+
38
+ public function getOrderInfoData()
39
+ {
40
+ return array(
41
+ 'no_use_order_link' => true,
42
+ );
43
+ }
44
+
45
+
46
+ public function getViewUrl($orderId)
47
+ {
48
+ return $this->getUrl('*/*/*', array('order_id'=>$orderId));
49
+ }
50
+
51
+ /**
52
+ * ######################## TAB settings #################################
53
+ */
54
+
55
+ /**
56
+ * @return string
57
+ */
58
+ public function getTabLabel()
59
+ {
60
+ return Mage::helper('planet_pay')->__('Order Request');
61
+ }
62
+
63
+ /**
64
+ * @return string
65
+ */
66
+ public function getTabTitle()
67
+ {
68
+ return Mage::helper('planet_pay')->__('Order Request Info');
69
+ }
70
+
71
+ /**
72
+ * @return bool
73
+ */
74
+ public function canShowTab()
75
+ {
76
+ return true;
77
+ }
78
+
79
+ /**
80
+ * @return bool
81
+ */
82
+ public function isHidden()
83
+ {
84
+ return false;
85
+ }
86
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ **
4
+ ** Magento
5
+ *
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
16
+ * @module : Banner
17
+ * @Block :Adminhtml
18
+ *
19
+ * File to show the Add Banner button and Take Screenshot button for brand urls.
20
+ *
21
+ *
22
+ * @author: Chetu
23
+ */
24
+ class Planet_Pay_Block_Adminhtml_Pay extends Mage_Adminhtml_Block_Widget_Grid_Container {
25
+ /**
26
+ * Method to show the add banner, take screenshot button in the header section.
27
+ *return object
28
+ */
29
+ public function __construct() {
30
+ $this->_controller = 'adminhtml_pay';
31
+ $this->_blockGroup = 'planet_pay';
32
+ $this->_headerText = Mage::helper('planet_pay')->__('Brand Manager');
33
+ $this->_addButtonLabel = Mage::helper('planet_pay')->__('Add Brand');
34
+ parent::__construct();
35
+ }
36
+
37
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * *
5
+ * * Magento
6
+ *
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
17
+ * @module : Banner
18
+ * Banner module called when Edit the banner details.
19
+ *
20
+ * @author : Chetu
21
+ */
22
+
23
+ class Planet_Pay_Block_Adminhtml_Pay_Edit extends Mage_Adminhtml_Block_Widget_Form_Container {
24
+
25
+ /**
26
+ * Method to show the Save, Delete and Take Shot button.
27
+ * return array.
28
+ */
29
+ public function __construct() {
30
+ parent::__construct();
31
+ $id = $this->getRequest()->getParam('id');
32
+ $this->_objectId = 'id';
33
+ $this->_blockGroup = 'planet_pay';
34
+ $this->_controller = 'adminhtml_pay';
35
+ $this->_updateButton('save', 'label', Mage::helper('planet_pay')->__('Save Brand'));
36
+ $this->_updateButton('delete', 'label', Mage::helper('planet_pay')->__('Delete Brand'));
37
+ $this->_addButton('saveandcontinue', array(
38
+ 'label' => Mage::helper('adminhtml')->__('Save And Continue Edit'),
39
+ 'onclick' => 'saveAndContinueEdit()',
40
+ 'class' => 'save',
41
+ ), -100);
42
+
43
+ $this->_formScripts[] = "
44
+ function toggleEditor() {
45
+ if (tinyMCE.getInstanceById('brand_content') == null) {
46
+ tinyMCE.execCommand('mceAddControl', false, 'brand_content');
47
+ } else {
48
+ tinyMCE.execCommand('mceRemoveControl', false, 'brand_content');
49
+ }
50
+ }
51
+
52
+ function saveAndContinueEdit(){
53
+ editForm.submit($('edit_form').action+'back/edit/');
54
+ }
55
+ ";
56
+ }
57
+
58
+ public function getHeaderText() {
59
+ if (Mage::registry('brand_data')) {
60
+ $brandinreg = Mage::registry('brand_data');
61
+ return Mage::helper('planet_pay')->__("Edit Brand '%s'", $this->htmlEscape($brandinreg['brandname']));
62
+ } else {
63
+ return Mage::helper('planet_pay')->__('Add Brand');
64
+ }
65
+ }
66
+
67
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Form.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ **
4
+ ** Magento
5
+ *
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
16
+ * @module : Banner
17
+ * @Block :Banner edit form functionality to save the form detail.
18
+ *
19
+ * @author : Chetu
20
+ */
21
+ class Planet_Pay_Block_Adminhtml_Pay_Edit_Form extends Mage_Adminhtml_Block_Widget_Form {
22
+
23
+ protected function _prepareForm() {
24
+ $form = new Varien_Data_Form(array(
25
+ 'id' => 'edit_form',
26
+ 'action' => $this->getUrl('*/*/save', array('id' => $this->getRequest()->getParam('id'))),
27
+ 'method' => 'post',
28
+ 'enctype' => 'multipart/form-data'
29
+ )
30
+ );
31
+
32
+ $form->setUseContainer(true);
33
+ $this->setForm($form);
34
+ return parent::_prepareForm();
35
+ }
36
+
37
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Tab/Form.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ **
4
+ ** Magento
5
+ *
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
16
+ * @module : Banner
17
+ * Banner module display form with input fields and validation.
18
+ *
19
+ * @author : Chetu
20
+ */
21
+ class Planet_Pay_Block_Adminhtml_Pay_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
22
+ {
23
+ protected function _prepareForm()
24
+ {
25
+ $form = new Varien_Data_Form();
26
+ $this->setForm($form);
27
+ $Brandarrng = Mage::registry('brand_data');
28
+ $fieldset = $form->addFieldset('brand_form', array('legend'=>Mage::helper('planet_pay')->__('Brand information')));
29
+ $fieldset->addField('brandname', 'text', array(
30
+ 'label' => Mage::helper('planet_pay')->__('brandname'),
31
+ 'class' => 'required-entry',
32
+ 'required' => true,
33
+ 'name' => 'brandname',
34
+ 'value' => $Brandarrng['brandname']
35
+ ));
36
+
37
+ $fieldset->addField('brandcode', 'text', array(
38
+ 'label' => Mage::helper('planet_pay')->__('brandcode'),
39
+ 'class' => 'required-entry',
40
+ 'required' => true,
41
+ 'name' => 'brandcode',
42
+ 'value' => $Brandarrng['brandcode']
43
+ ));
44
+
45
+ $fieldset->addField('active', 'text', array(
46
+ 'label' => Mage::helper('planet_pay')->__('active'),
47
+ 'class' => 'required-entry',
48
+ 'required' => true,
49
+ 'name' => 'active',
50
+ 'value' => $Brandarrng['active']
51
+ ));
52
+
53
+ $fieldset->addField('brandid', 'text', array(
54
+ 'label' => Mage::helper('planet_pay')->__('brandid'),
55
+ 'class' => 'required-entry',
56
+ 'required' => true,
57
+ 'name' => 'brandid',
58
+ 'value' => $Brandarrng['brandid']
59
+ ));
60
+
61
+ return parent::_prepareForm();
62
+ }
63
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay/Edit/Tabs.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ **
4
+ ** Magento
5
+ *
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
16
+ * @module : Banner
17
+ * @Block : Adminhtml.
18
+ * File to show the Left side tab in the Banner module.
19
+ *
20
+ * @author : Chetu
21
+ */
22
+ class Planet_Pay_Block_Adminhtml_Pay_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
23
+ {
24
+
25
+ public function __construct()
26
+ {
27
+ parent::__construct();
28
+ $this->setId('brand_tabs');
29
+ $this->setDestElementId('edit_form');
30
+ $this->setTitle(Mage::helper('planet_pay')->__('Brand Information'));
31
+ }
32
+
33
+ protected function _beforeToHtml()
34
+ {
35
+ $this->getChildHtml('store_switcher');
36
+ $this->addTab('form_section', array(
37
+ 'label' => Mage::helper('planet_pay')->__('Brand Information'),
38
+ 'title' => Mage::helper('planet_pay')->__('Brand Information'),
39
+ 'content' => $this->getLayout()->createBlock('planet_pay/adminhtml_pay_edit_tab_form')->toHtml(),
40
+ ));
41
+ return parent::_beforeToHtml();
42
+ }
43
+ }
app/code/local/Planet/Pay/Block/Adminhtml/Pay/Grid.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /*
3
+ **
4
+ ** Magento
5
+ *
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
16
+ * @module : Banner
17
+ * @Block :Adminhtml
18
+ *
19
+ * File to show the brand module information in Grid layout.
20
+ *
21
+ *
22
+ * @author: Chetu
23
+ */
24
+ class Planet_Pay_Block_Adminhtml_Pay_Grid extends Mage_Adminhtml_Block_Widget_Grid {
25
+
26
+ public function __construct() {
27
+ parent::__construct();
28
+ $this->setId('brandGrid');
29
+ $this->setDefaultSort('id');
30
+ $this->setDefaultDir('ASC');
31
+ $this->setSaveParametersInSession(true);
32
+ }
33
+ /**
34
+ * Method to getbanner in collection.
35
+ *return array.
36
+ */
37
+ protected function _prepareCollection() {
38
+ $collection = Mage::getModel('planet_pay/method')->getCollection();
39
+ $this->setCollection($collection);
40
+ return parent::_prepareCollection();
41
+ }
42
+ /**
43
+ * Method to show the Brand detail in Grid Format.
44
+ *return object
45
+ */
46
+ protected function _prepareColumns() {
47
+ $this->addColumn('id', array(
48
+ 'header' => Mage::helper('planet_pay')->__('Id'),
49
+ 'align' => 'right',
50
+ 'width' => '50px',
51
+ 'index' => 'id',
52
+ ));
53
+ $this->addColumn('brandname', array(
54
+ 'header' => Mage::helper('planet_pay')->__('Brand Name'),
55
+ 'align' => 'left',
56
+ 'index' => 'brandname',
57
+ ));
58
+
59
+
60
+ $this->addColumn('brandcode', array(
61
+ 'header' => Mage::helper('planet_pay')->__('Brand Code'),
62
+ 'align' => 'left',
63
+ 'index' => 'brandcode',
64
+ ));
65
+
66
+ $this->addColumn('active', array(
67
+ 'header' => Mage::helper('planet_pay')->__('Active Brand'),
68
+ 'align' => 'left',
69
+ 'index' => 'active',
70
+ ));
71
+
72
+ $this->addColumn('brandid', array(
73
+ 'header' => Mage::helper('planet_pay')->__('Sort Brand'),
74
+ 'align' => 'left',
75
+ 'index' => 'brandid',
76
+ ));
77
+
78
+ $this->addColumn('action', array(
79
+ 'header' => Mage::helper('planet_pay')->__('Action'),
80
+ 'width' => '100',
81
+ 'type' => 'action',
82
+ 'getter' => 'getId',
83
+ 'actions' => array(
84
+ array(
85
+ 'caption' => Mage::helper('planet_pay')->__('Edit'),
86
+ 'url' => array('base' => '*/*/edit'),
87
+ 'field' => 'id'
88
+ )
89
+ ),
90
+ 'filter' => false,
91
+ 'sortable' => false,
92
+ 'index' => 'stores',
93
+ 'is_system' => true,
94
+ ));
95
+ return parent::_prepareColumns();
96
+ }
97
+
98
+ public function getRowUrl($row) {
99
+ return $this->getUrl('*/*/edit', array('id' => $row->getId()));
100
+ }
101
+
102
+ }
app/code/local/Planet/Pay/Block/Checkout/Onepage.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Checkout_Onepage
4
+ */
5
+ class Planet_Pay_Block_Checkout_Onepage extends Mage_Checkout_Block_Onepage
6
+ {
7
+ protected $activeStep;
8
+ protected $checkoutFilled;
9
+
10
+ /**
11
+ *
12
+ */
13
+ public function __construct()
14
+ {
15
+ parent::_construct();
16
+ if (is_null($this->activeStep)) {
17
+ $sessionActiveStep = $this->getCheckout()->getActiveStep();
18
+ if (is_string($sessionActiveStep)) {
19
+ $this->getCheckout()->setActiveStep(null);
20
+ $this->activeStep = $sessionActiveStep;
21
+ if ($sessionActiveStep == 'review') {
22
+ $this->getCheckout()->setReviewStep(true);
23
+ }
24
+ }
25
+ }
26
+ }
27
+
28
+ /**
29
+ * @return array
30
+ */
31
+ public function getSteps()
32
+ {
33
+ $steps = parent::getSteps();
34
+ if (!is_null($this->activeStep) && isset($steps[$this->activeStep])) {
35
+ $steps[$this->activeStep]['allow'] = true;
36
+ $steps[$this->activeStep]['complete'] = true;
37
+ }
38
+ return $steps;
39
+ }
40
+
41
+
42
+
43
+ /**
44
+ * @return string
45
+ */
46
+ public function getActiveStep()
47
+ {
48
+ if (!is_null($this->activeStep)) {
49
+ $this->fillCheckout();
50
+ return $this->activeStep;
51
+ }
52
+ else {
53
+ return parent::getActiveStep();
54
+ }
55
+ }
56
+
57
+ private function fillCheckout()
58
+ {
59
+ if (is_null($this->checkoutFilled)) {
60
+ $checkout = Mage::getSingleton('checkout/type_onepage');
61
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
62
+ $checkout->saveBilling($quote->getBillingAddress()->toArray(),false);
63
+ $checkout->saveShipping($quote->getShippingAddress()->toArray(),false);
64
+ $checkout->saveShippingMethod($quote->getShippingAddress()->getShippingMethod());
65
+ $brandCode = $quote->getPayment()->getAdditionalData();
66
+ $checkout->getCheckout()->setPlanetPaymentMethod($brandCode);
67
+ $this->checkoutFilled = true;
68
+ }
69
+ }
70
+ }
app/code/local/Planet/Pay/Block/Checkout/Onepage/Payment/Methods.php ADDED
@@ -0,0 +1,99 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Checkout
23
+ * @copyright Copyright (c) 2013 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
+ * One page checkout status
29
+ *
30
+ * @category Mage
31
+ * @category Mage
32
+ * @package Mage_Checkout
33
+ * @author Magento Core Team <core@magentocommerce.com>
34
+ */
35
+ class Planet_Pay_Block_Checkout_Onepage_payment_methods extends Mage_Payment_Block_Form_Container
36
+ {
37
+ public function getQuote()
38
+ {
39
+ return Mage::getSingleton('checkout/session')->getQuote();
40
+ }
41
+
42
+ /**
43
+ * Check payment method model
44
+ *
45
+ * @param Mage_Payment_Model_Method_Abstract|null
46
+ * @return bool
47
+ */
48
+ protected function _canUseMethod($method)
49
+ {
50
+ return $method && $method->canUseCheckout() && parent::_canUseMethod($method);
51
+ }
52
+
53
+ /**
54
+ * Retrieve code of current payment method
55
+ *
56
+ * @return mixed
57
+ */
58
+ public function getSelectedMethodCode()
59
+ {
60
+ if ($method = $this->getQuote()->getPayment()->getMethod()) {
61
+ return $method;
62
+ }
63
+ return parent::getSelectedMethodCode();
64
+ }
65
+
66
+ /**
67
+ * Payment method form html getter
68
+ * @param Mage_Payment_Model_Method_Abstract $method
69
+ */
70
+ public function getPaymentMethodFormHtml(Mage_Payment_Model_Method_Abstract $method)
71
+ {
72
+ return $this->getChildHtml('payment.method.' . $method->getCode());
73
+ }
74
+
75
+ /**
76
+ * Return method title for payment selection page
77
+ *
78
+ * @param Mage_Payment_Model_Method_Abstract $method
79
+ */
80
+ public function getMethodTitle(Mage_Payment_Model_Method_Abstract $method)
81
+ {
82
+ $form = $this->getChild('payment.method.' . $method->getCode());
83
+ if ($form && $form->hasMethodTitle()) {
84
+ return $form->getMethodTitle();
85
+ }
86
+ return $method->getTitle();
87
+ }
88
+
89
+ /**
90
+ * Payment method additional label part getter
91
+ * @param Mage_Payment_Model_Method_Abstract $method
92
+ */
93
+ public function getMethodLabelAfterHtml(Mage_Payment_Model_Method_Abstract $method)
94
+ {
95
+ if ($form = $this->getChild('payment.method.' . $method->getCode())) {
96
+ return $form->getMethodLabelAfterHtml();
97
+ }
98
+ }
99
+ }
app/code/local/Planet/Pay/Block/Checkout/Onepage/Review.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Checkout_Onepage_Review
4
+ */
5
+ class Planet_Pay_Block_Checkout_Onepage_Review extends Mage_Checkout_Block_Onepage_Review
6
+ {
7
+
8
+ private $errorMessage;
9
+
10
+ /**
11
+ * @return bool
12
+ */
13
+ public function loadReview()
14
+ {
15
+ if (Mage::getSingleton('checkout/session')->getReviewStep() === true) {
16
+ Mage::getSingleton('checkout/session')->setReviewStep(false);
17
+ return true;
18
+ }
19
+ return false;
20
+ }
21
+
22
+ /**
23
+ * @return null|string
24
+ */
25
+ public function getMessage()
26
+ {
27
+ if (is_null($this->errorMessage)) {
28
+ $this->errorMessage = Mage::getSingleton('checkout/session')->getErrorMessage();
29
+ Mage::getSingleton('checkout/session')->setErrorMessage(null);
30
+ }
31
+ return $this->errorMessage;
32
+ }
33
+ }
app/code/local/Planet/Pay/Block/Form/Form.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Form_Form
4
+ */
5
+ class Planet_Pay_Block_Form_Form extends Mage_Payment_Block_Form
6
+ {
7
+
8
+ /** @var bool */
9
+ protected $showIcons;
10
+
11
+ protected function _construct()
12
+ {
13
+ $paymentCode = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
14
+ if ($paymentCode == 'planet_pay') {
15
+ $this->setTemplate('planet_pay/form/form.phtml');
16
+ $this->showIcons = Mage::getStoreConfig('payment/planet_pay/show_icons_on_summary');
17
+ }
18
+ parent::_construct();
19
+ }
20
+
21
+ /**
22
+ * @return string
23
+ */
24
+ public function getForm()
25
+ {
26
+ /** @var Planet_Pay_Model_Payment $planetPaymentModel */
27
+ $planetPaymentModel = Mage::getModel('planet_pay/payment');
28
+ return $planetPaymentModel->getForm();
29
+ }
30
+
31
+ /**
32
+ * @return bool
33
+ */
34
+ public function isTokenization()
35
+ {
36
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
37
+ $custid = $customerData->getId();
38
+ $resource = Mage::getSingleton('core/resource');
39
+ $readConnection = $resource->getConnection('core_read');
40
+ $table = $resource->getTableName('planet_pay/carddetail');
41
+ $query = 'SELECT registeration_id,brand_name, cc_last_four,cc_exp_month,cc_exp_year FROM ' . $table . ' WHERE cust_id = '
42
+ . (int) $custid;
43
+ $resuid = $readConnection->fetchAll($query);
44
+ return $resuid;
45
+ }
46
+
47
+ /**
48
+ * @return bool
49
+ */
50
+ public function showIcons()
51
+ {
52
+ return $this->showIcons;
53
+ }
54
+
55
+ /**
56
+ * @return null|string
57
+ */
58
+ public function getImagePath()
59
+ {
60
+ $onePage = Mage::getSingleton('checkout/type_onepage');
61
+ $brandCode = $onePage->getCheckout()->getPlanetPaymentMethod();
62
+ $path = Mage::getBaseDir('media').'/planet/img/'.$brandCode.'.png';
63
+ if (file_exists($path)) {
64
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'/planet/img/'.$brandCode.'.png';
65
+ return $url;
66
+ }
67
+ return null;
68
+ }
69
+ }
app/code/local/Planet/Pay/Block/Form/Pay.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ use PlanetLib\Resources\Translation\BrandNames;
3
+
4
+ /**
5
+ * Class Planet_Pay_Block_Form_Pay
6
+ */
7
+ class Planet_Pay_Block_Form_Pay extends Mage_Payment_Block_Form
8
+ {
9
+ /**
10
+ * @var Planet_Pay_Model_Resource_Method_Collection
11
+ */
12
+ protected $_methodsCollection = null;
13
+
14
+ /** @var BrandNames */
15
+ protected $brandNames;
16
+
17
+ /** @var bool */
18
+ protected $showIcons;
19
+
20
+ protected function _construct()
21
+ {
22
+ $this->setTemplate('planet_pay/form/pay.phtml');
23
+
24
+ $autoloader = new Planet_Pay_Model_Autoloader();
25
+ $autoloader->init();
26
+
27
+ $language = Mage::app()->getLocale()->getLocale()->getLanguage();
28
+ $this->brandNames = new BrandNames($language);
29
+ $this->showbrandNamesIcons = Mage::getStoreConfig('payment/planet_pay/show_icons_in_selection');
30
+ $this->showIcons = Mage::getStoreConfig('payment/planet_pay/show_icons_in_selection');
31
+ parent::_construct();
32
+ }
33
+
34
+ /**
35
+ * adding function to show form on payment step
36
+ */
37
+ /**
38
+ * @return string
39
+ */
40
+ public function getForm()
41
+ {
42
+ /** @var Planet_Pay_Model_Payment $planetPaymentModel */
43
+ $planetPaymentModel = Mage::getModel('planet_pay/payment');
44
+ return $planetPaymentModel->getForm();
45
+ }
46
+
47
+ /**
48
+ * @return bool
49
+ */
50
+ public function isTokenization()
51
+ {
52
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
53
+ $custid = $customerData->getId();
54
+ $resource = Mage::getSingleton('core/resource');
55
+ $readConnection = $resource->getConnection('core_read');
56
+ $table = $resource->getTableName('planet_pay/carddetail');
57
+ $query = 'SELECT registeration_id,brand_name, cc_last_four,cc_exp_month,cc_exp_year FROM ' . $table . ' WHERE cust_id = '
58
+ . (int) $custid;
59
+ $resuid = $readConnection->fetchAll($query);
60
+ return $resuid;
61
+ }
62
+ /* finishing adding function in block */
63
+
64
+ /**
65
+ * @return Planet_Pay_Model_Resource_Method_Collection
66
+ */
67
+ protected function _getCollection()
68
+ {
69
+ return Mage::getResourceModel('planet_pay/method_collection');
70
+ }
71
+
72
+ /**
73
+ * @return Planet_Pay_Model_Resource_Method_Collection
74
+ */
75
+ public function getCollection()
76
+ {
77
+ if (is_null($this->_methodsCollection)) {
78
+ $config = Mage::getStoreConfig('payment/planet_pay/payment_methods');
79
+ $this->_methodsCollection = $this->_getCollection();
80
+ $this->_methodsCollection->onlySpecifiedBrands($config);
81
+ $this->_methodsCollection->setOrder('brandid', 'DESC');
82
+ $this->_methodsCollection->onlyActive();
83
+ }
84
+ return $this->_methodsCollection;
85
+ }
86
+
87
+ /**
88
+ * @param Planet_Pay_Model_Resource_Method $methodItem
89
+ * @return string
90
+ */
91
+ public function getName($methodItem)
92
+ {
93
+ if ($this->brandNames->localeExists()) {
94
+ $brandName = $this->brandNames->getBrandName($methodItem->getBrandcode());
95
+ if ($brandName) {
96
+ return $brandName;
97
+ }
98
+ }
99
+ return $methodItem->getBrandname();
100
+ }
101
+
102
+ /**
103
+ * @return bool
104
+ */
105
+ public function showIcons()
106
+ {
107
+ return $this->showIcons;
108
+ }
109
+
110
+ /**
111
+ * @param $methodItem
112
+ * @return null|string
113
+ */
114
+ public function getImagePath($methodItem)
115
+ {
116
+ $path = Mage::getBaseDir('media').'/planet/img/'.$methodItem->getBrandcode().'.jpg';
117
+ if (file_exists($path)) {
118
+ $url = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_MEDIA).'/planet/img/'.$methodItem->getBrandcode().'.jpg';
119
+ return $url;
120
+ }
121
+ return null;
122
+ }
123
+
124
+ /**
125
+ * @return mixed
126
+ */
127
+ public function getPaymentSelectionMessage()
128
+ {
129
+ $paymentSelectionMessage = Mage::getStoreConfig('payment/planet_pay/payment_selection_message');
130
+ return $paymentSelectionMessage;
131
+ }
132
+
133
+ }
app/code/local/Planet/Pay/Block/Info/Pay.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class planet_Pay_Block_Info_Pay extends Mage_Payment_Block_Info
3
+ {
4
+ /**
5
+ * Init ops payment information block
6
+ *
7
+ */
8
+ /*protected function _construct()
9
+ {
10
+ parent::_construct();
11
+ $this->setTemplate('pay/info/pay.phtml');
12
+ }*/
13
+ protected function _prepareSpecificInformation($transport = null)
14
+ {
15
+ if (null !== $this->_paymentSpecificInformation) {
16
+ return $this->_paymentSpecificInformation;
17
+ }
18
+ $info = $this->getInfo();
19
+ $profilearr = $info->getAdditionalInformation();
20
+ if(is_array($profilearr) && !empty($profilearr)){
21
+
22
+
23
+ }
24
+ $profileid = key($profilearr);
25
+ $transport = new Varien_Object();
26
+ $transport = parent::_prepareSpecificInformation($transport);
27
+ $transport->addData(array(
28
+ Mage::helper('payment')->__('Credit Card No Last 4') => $info->getCcLast4(),
29
+ //Mage::helper('payment')->__('Payon Profile Id') => $profileid,
30
+ Mage::helper('payment')->__('Card Type') => $info->getCcType(),
31
+ Mage::helper('payment')->__('Exp Date') => $info->getCcExpMonth() . ' / '.$info->getCcExpYear(),
32
+ Mage::helper('payment')->__('Card Owner') => $info->getCcOwner(),
33
+ ));
34
+ return $transport;
35
+ }
36
+ }
app/code/local/Planet/Pay/Block/Method/List.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Method_List
4
+ */
5
+ class Planet_Pay_Block_Method_List extends Mage_Core_Block_Template
6
+ {
7
+ /**
8
+ * @var Planet_Pay_Model_Resource_Method_Collection
9
+ */
10
+ protected $_methodsCollection = null;
11
+
12
+ /**
13
+ * @return Planet_Pay_Model_Resource_Method_Collection
14
+ */
15
+ protected function _getCollection()
16
+ {
17
+ return Mage::getResourceModel('planet_pay/method_collection');
18
+ }
19
+
20
+ /**
21
+ *
22
+ * @return Planet_Pay_Model_Resource_Method_Collection
23
+ */
24
+ public function getCollection()
25
+ {
26
+ if (is_null($this->_methodsCollection)) {
27
+ $this->_methodsCollection = $this->_getCollection();
28
+ $this->_methodsCollection->onlyActive();
29
+ }
30
+
31
+ return $this->_methodsCollection;
32
+ }
33
+
34
+ }
app/code/local/Planet/Pay/Block/Planet/Order/Grid.php ADDED
@@ -0,0 +1,163 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Block_Planet_Order_Grid
4
+ */
5
+ class Planet_Pay_Block_Planet_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
6
+ {
7
+
8
+ /**
9
+ *
10
+ */
11
+ public function __construct()
12
+ {
13
+ parent::__construct();
14
+ $this->setId('sales_order_grid');
15
+ $this->setUseAjax(true);
16
+ $this->setDefaultSort('created_at');
17
+ $this->setDefaultDir('DESC');
18
+ $this->setSaveParametersInSession(true);
19
+ }
20
+
21
+ /**
22
+ * @return string
23
+ */
24
+ protected function _getCollectionClass()
25
+ {
26
+ return 'sales/order_grid_collection';
27
+ }
28
+
29
+
30
+ /**
31
+ * @return Mage_Adminhtml_Block_Widget_Grid
32
+ */
33
+ protected function _prepareCollection()
34
+ {
35
+ /** @var Mage_Sales_Model_Resource_Order_Grid_Collection $collection */
36
+ $collection = Mage::getResourceModel($this->_getCollectionClass());
37
+ $collection->getSelect()->join(array('planet_order' => 'planet_pay_order'),
38
+ 'increment_id=order_id',
39
+ array(
40
+ 'planet_order_id' => 'id',
41
+ 'planet_payment_status' => 'payment_status',
42
+ 'planet_brand_name' => 'brand_name'
43
+ ));
44
+
45
+ $this->setCollection($collection);
46
+ return parent::_prepareCollection();
47
+ }
48
+
49
+ /**
50
+ * @return $this
51
+ */
52
+ protected function _prepareColumns()
53
+ {
54
+
55
+ $this->addColumn('real_order_id', array(
56
+ 'header'=> Mage::helper('sales')->__('Order #'),
57
+ 'width' => '80px',
58
+ 'type' => 'text',
59
+ 'index' => 'increment_id',
60
+ ));
61
+
62
+ $this->addColumn('planet_order_id', array(
63
+ 'header' => Mage::helper('planet_pay')->__('Planet Order #'),
64
+ 'width' => '80px',
65
+ 'index' => 'planet_order_id',
66
+ ));
67
+
68
+ if (!Mage::app()->isSingleStoreMode()) {
69
+ $this->addColumn('store_id', array(
70
+ 'header' => Mage::helper('sales')->__('Purchased From (Store)'),
71
+ 'index' => 'store_id',
72
+ 'type' => 'store',
73
+ 'store_view'=> true,
74
+ 'display_deleted' => true,
75
+ ));
76
+ }
77
+
78
+ $this->addColumn('created_at', array(
79
+ 'header' => Mage::helper('sales')->__('Purchased On'),
80
+ 'index' => 'created_at',
81
+ 'type' => 'datetime',
82
+ 'width' => '100px',
83
+ ));
84
+
85
+ $this->addColumn('billing_name', array(
86
+ 'header' => Mage::helper('sales')->__('Bill to Name'),
87
+ 'index' => 'billing_name',
88
+ ));
89
+
90
+ $this->addColumn('grand_total', array(
91
+ 'header' => Mage::helper('sales')->__('G.T. (Purchased)'),
92
+ 'index' => 'grand_total',
93
+ 'type' => 'currency',
94
+ 'currency' => 'order_currency_code',
95
+ ));
96
+
97
+ $this->addColumn('planet_brand_name', array(
98
+ 'header' => Mage::helper('planet_pay')->__('Payment Brand'),
99
+ 'width' => '100px',
100
+ 'index' => 'planet_brand_name'
101
+ ));
102
+
103
+ $this->addColumn('status', array(
104
+ 'header' => Mage::helper('planet_pay')->__('Order Status'),
105
+ 'index' => 'status',
106
+ 'type' => 'options',
107
+ 'width' => '70px',
108
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
109
+ ));
110
+
111
+ $this->addColumn('planet_payment_status', array(
112
+ 'header' => Mage::helper('planet_pay')->__('Payment Status'),
113
+ 'index' => 'planet_payment_status',
114
+ 'width' => '70px'
115
+ ));
116
+ /** TODO: add acl rule */
117
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
118
+ $this->addColumn('action',
119
+ array(
120
+ 'header' => Mage::helper('sales')->__('Action'),
121
+ 'width' => '50px',
122
+ 'type' => 'action',
123
+ 'getter' => 'getId',
124
+ 'actions' => array(
125
+ array(
126
+ 'caption' => Mage::helper('sales')->__('View'),
127
+ 'url' => array('base'=>'*/planet_order/view'),
128
+ 'field' => 'order_id'
129
+ )
130
+ ),
131
+ 'filter' => false,
132
+ 'sortable' => false,
133
+ 'index' => 'stores',
134
+ 'is_system' => true,
135
+ ));
136
+ }
137
+
138
+ return parent::_prepareColumns();
139
+ }
140
+
141
+ public function getRowClass($item)
142
+ {
143
+ return 'status_'.$item->getPlanetPaymentStatus();
144
+ }
145
+
146
+ /**
147
+ * @param $row
148
+ * @return bool|string
149
+ */
150
+ public function getRowUrl($row)
151
+ {
152
+ return $this->getUrl('*/planet_order/view', array('order_id' => $row->getId()));
153
+ }
154
+
155
+ /**
156
+ * @return string
157
+ */
158
+ public function getGridUrl()
159
+ {
160
+ return $this->getUrl('*/*/grid', array('_current'=>true));
161
+ }
162
+
163
+ }
app/code/local/Planet/Pay/Block/Profile/Edit.php ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_IpayGateway
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * IpayGateway Block Profile Edit
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class Planet_Pay_Block_Profile_Edit extends Mage_Directory_Block_Data {
30
+
31
+ const escpmsg = 'Edit Store Credit Card Profile';
32
+ const anscpmsg = 'Add New Store Credit Card Profile';
33
+
34
+ /**
35
+ * The payment profile being edited.
36
+ *
37
+ * @var Planet_Pay_Model_PaymentProfile
38
+ */
39
+ protected $_paymentProfile = null;
40
+
41
+ /**
42
+ * Returns the payment profile being edited.
43
+ *
44
+ * @return Planet_Pay_Model_PaymentProfile
45
+ */
46
+ public function getIpayPaymentProfile() {
47
+ return $this->_paymentProfile;
48
+ }
49
+
50
+ /**
51
+ * Retrieve customer session object
52
+ *
53
+ * @return Mage_Customer_Model_Session
54
+ */
55
+ public function getSession() {
56
+ return Mage::getSingleton('customer/session');
57
+ }
58
+
59
+ /**
60
+ * Retrieve customer model
61
+ *
62
+ * @return Mage_Customer_Model_Customer
63
+ */
64
+ public function getCustomer() {
65
+ return $this->getSession()->getCustomer();
66
+ }
67
+
68
+ /**
69
+ * Prepare the layout
70
+ *
71
+ * @return \PlanetPayment_IpayGateway_Block_Profile_Edit
72
+ */
73
+ protected function _prepareLayout() {
74
+ parent::_prepareLayout();
75
+
76
+ $this->_paymentProfile = Mage::getModel('planet_pay/profile');
77
+ $profileId = $this->getRequest()->getParam('profile_id');
78
+ if ($profileId) {
79
+ $this->_paymentProfile->load($profileId);
80
+ if ($this->_paymentProfile->getIpayProfileId() != $this->getCustomer()->getIpayProfileId()) {
81
+ $this->_paymentProfile->setData(array());
82
+ }
83
+ } else if ($this->getSession()->getProfileFormData()) {
84
+ $this->_paymentProfile->addData($this->getSession()->getProfileFormData(true));
85
+ }
86
+
87
+ $title = $this->_paymentProfile->getId() ? self::escpmsg : self::anscpmsg;
88
+ $this->setTitle($this->__($title));
89
+
90
+ return $this;
91
+ }
92
+
93
+ /**
94
+ * Returns a payment form block to access CC methods.
95
+ *
96
+ * @return PlanetPayment_IpayGateway_Block_Payment_Form
97
+ */
98
+ public function getPaymentBlock() {
99
+ if (!$this->hasPaymentBlock()) {
100
+ $method = Mage::getModel('ipay/ipay')->setIpayPaymentProfile($this->getIpayPaymentProfile());
101
+ $block = $this->getLayout()->createBlock('ipay/payment_form')
102
+ ->setIpayPaymentProfile($this->getIpayPaymentProfile())
103
+ ->setMethod($method);
104
+ $this->setPaymentBlock($block);
105
+ }
106
+ return $this->getData('payment_block');
107
+ }
108
+
109
+ /**
110
+ * return the avialable credit card types
111
+ *
112
+ * @return array
113
+ */
114
+ public function getCcAvailableTypes() {
115
+ return $this->getPaymentBlock()->getCcAvailableTypes();
116
+ }
117
+
118
+ /**
119
+ * return the credit cards year
120
+ *
121
+ * @return array
122
+ */
123
+ public function getCcYears() {
124
+ return $this->getPaymentBlock()->getCcYears();
125
+ }
126
+
127
+ /**
128
+ * return the credit card months
129
+ *
130
+ * @return array
131
+ */
132
+ public function getCcMonths() {
133
+ return $this->getPaymentBlock()->getCcMonths();
134
+ }
135
+
136
+ /**
137
+ * return the verification for payment
138
+ *
139
+ * @return bool
140
+ */
141
+ public function hasVerification() {
142
+ return $this->getPaymentBlock()->hasVerification();
143
+ }
144
+
145
+ /**
146
+ * return the back url
147
+ *
148
+ * @return string
149
+ */
150
+ public function getBackUrl() {
151
+ return $this->getUrl('*/*/index');
152
+ }
153
+
154
+ /**
155
+ * return the edit post url
156
+ *
157
+ * @return string
158
+ */
159
+ public function getPostUrl() {
160
+ return $this->getUrl('*/*/editPost');
161
+ }
162
+
163
+ /**
164
+ * return the success url
165
+ *
166
+ * @return string
167
+ */
168
+ public function getSuccessUrl() {
169
+ return $this->getUrl('*/*/index');
170
+ }
171
+
172
+ /**
173
+ * return the error url
174
+ *
175
+ * @return string
176
+ */
177
+ public function getErrorUrl() {
178
+ return $this->getUrl('*/*/*');
179
+ }
180
+
181
+ /**
182
+ * Use region codes instead of region IDs.
183
+ *
184
+ * @return string
185
+ */
186
+ public function getRegionsJs() {
187
+ $regionsJs = $this->getData('regions_js');
188
+ if (!$regionsJs) {
189
+ $countryIds = array();
190
+ foreach ($this->getCountryCollection() as $country) {
191
+ $countryIds[] = $country->getCountryId();
192
+ }
193
+ $collection = Mage::getModel('directory/region')->getResourceCollection()
194
+ ->addCountryFilter($countryIds)
195
+ ->load();
196
+ $regions = array();
197
+ foreach ($collection as $region) {
198
+ if (!$region->getRegionId()) {
199
+ continue;
200
+ }
201
+ $regions[$region->getCountryId()][$region->getCode()] = array(
202
+ 'code' => $region->getCode(),
203
+ 'name' => $region->getName()
204
+ );
205
+ }
206
+ $regionsJs = Mage::helper('core')->jsonEncode($regions);
207
+ }
208
+ return $regionsJs;
209
+ }
210
+
211
+ }
app/code/local/Planet/Pay/Block/Profile/List.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_IpayGateway
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * IpayGateway Block Profile List
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class Planet_Pay_Block_Profile_List extends Mage_Core_Block_Template {
30
+
31
+ /**
32
+ * Retrieve customer model
33
+ *
34
+ * @return Mage_Customer_Model_Customer
35
+ */
36
+ public function getCustomer() {
37
+ return Mage::getSingleton('customer/session')->getCustomer();
38
+ }
39
+
40
+ /**
41
+ * Returns an array of payment profiles.
42
+ *
43
+ * @return array
44
+ */
45
+ public function getPaymentProfiles() {
46
+ if (!$this->hasData('payment_profiles')) {
47
+ $profilesArray = array();
48
+ $profiles = Mage::getModel('planet_pay/carddetail')->getCollection()
49
+ ->addCustomerFilter($this->getCustomer());
50
+ foreach ($profiles as $profile) {
51
+ // don't display on frontend
52
+ $profilesArray[] = $profile;
53
+ }
54
+ }
55
+ $this->setPaymentProfiles($profilesArray);
56
+ return $this->getData('payment_profiles');
57
+ }
58
+
59
+ /**
60
+ * return the add url
61
+ *
62
+ * @return string
63
+ */
64
+ public function getAddUrl() {
65
+ return $this->getUrl('*/*/new');
66
+ }
67
+
68
+ }
app/code/local/Planet/Pay/Helper/Data.php ADDED
@@ -0,0 +1,217 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Helper_Data
4
+ */
5
+ class Planet_Pay_Helper_Data extends Mage_Checkout_Helper_Data
6
+ {
7
+
8
+
9
+
10
+ /**
11
+ * Returns data from the store config.
12
+ *
13
+ * @param string $key
14
+ * @return string
15
+ */
16
+ public function getConfigData($key) {
17
+ $path = 'payment/planet_pay/' . $key;
18
+ return Mage::getStoreConfig($path);
19
+ }
20
+ /**
21
+ * Send email for payment was failed
22
+ *
23
+ * @param Mage_Sales_Model_Quote $checkout
24
+ * @param string $message
25
+ * @param string $checkoutType
26
+ * @param int $orderId is unique id of the saved order for failed payment
27
+ * @return Planet_Pay_Helper_Checkout_Mailhelper
28
+ */
29
+ public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
30
+ {
31
+ $translate = Mage::getSingleton('core/translate');
32
+ $lastOrderId = Mage::getSingleton('checkout/session')->getLastOrderId();
33
+ $customerId = Mage::getSingleton('customer/session')->getCustomerId();
34
+ //die($lastOrderId);
35
+ /* @var $translate Mage_Core_Model_Translate */
36
+ $translate->setTranslateInline(false);
37
+
38
+ $mailTemplate = Mage::getModel('core/email_template');
39
+ /* @var $mailTemplate Mage_Core_Model_Email_Template */
40
+
41
+ //$template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());
42
+ $template = $mailTemplate->loadDefault('checkout_payment_failed_template');
43
+ //$template = $templateId = 2;
44
+
45
+ $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
46
+
47
+ $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId());
48
+ if ($copyTo && $copyMethod == 'bcc') {
49
+ $mailTemplate->addBcc($copyTo);
50
+ }
51
+
52
+ // to get receivers of the mail set by the admin in configuration
53
+ $_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId());
54
+ $sendTo = array(
55
+ array(
56
+ 'email' => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/email', $checkout->getStoreId()),
57
+ 'name' => Mage::getStoreConfig('trans_email/ident_'.$_reciever.'/name', $checkout->getStoreId())
58
+ )
59
+ );
60
+
61
+ if ($copyTo && $copyMethod == 'copy') {
62
+ foreach ($copyTo as $email) {
63
+ $sendTo[] = array(
64
+ 'email' => $email,
65
+ 'name' => null
66
+ );
67
+ }
68
+ }
69
+
70
+ // fetching and adding customer as recipient for failed email
71
+ $custdetail[]=array("email"=>$checkout->getCustomerEmail(),'name' => $checkout->getCustomerFirstname());
72
+ $sendTo = array_merge ( $sendTo, $custdetail );
73
+
74
+ // fetching shipping method
75
+ $shippingMethod = '';
76
+ if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
77
+ $data = explode('_', $shippingInfo);
78
+ $shippingMethod = $data[0];
79
+ }
80
+
81
+ //$shippingTotal = $shippingInfo->collectTotals();
82
+
83
+ // fetching payment method
84
+ $paymentMethod = '';
85
+ if ($paymentInfo = $checkout->getPayment()) {
86
+ $paymentMethod = $paymentInfo->getMethod();
87
+ }
88
+
89
+ // fetching currency code and symbol
90
+ $currency_code = $checkout->getStoreCurrencyCode();
91
+ $currency_symbol = Mage::app()->getLocale()->currency( $currency_code )->getSymbol();
92
+
93
+ // fetching subtotal of current quote
94
+ $sub_total = $checkout->getSubtotal();
95
+
96
+ // fetching shipping amount of current quote
97
+ $total_ship = $checkout->getShippingAddress()->getShippingAmount();
98
+
99
+ // fetching grand total for current quote
100
+ $total = $checkout->getGrandTotal();
101
+ //$totals = $checkout->getTotals();
102
+
103
+
104
+ // setting html for items to be set in template
105
+ $items = '';
106
+ $items = $checkout->getAllVisibleItems();
107
+
108
+ //$block = Mage::app()->getLayout()
109
+ // ->createBlock('core/template')
110
+ // ->setData('items',$items)
111
+ // ->setTemplate('planet_pay/email/items.phtml');
112
+ //echo "<pre>";print_r($block); die();
113
+ //$html = $block->getHtml();
114
+
115
+ //print_r($html); die();
116
+ //$items = 'items';
117
+
118
+ $itemsHtml = '<table cellspacing="0" cellpadding="0" border="0" width="650" style="border:1px solid #EAEAEA;">
119
+ <thead>
120
+ <tr>
121
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">Item</th>
122
+ <th align="left" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">Sku</th>
123
+ <th align="center" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">Qty</th>
124
+ <th align="right" bgcolor="#EAEAEA" style="font-size:13px; padding:3px 9px">Subtotal</th>
125
+ </tr>
126
+ </thead>
127
+ <tbody bgcolor="#F6F6F6">
128
+ ';
129
+ foreach ($checkout->getAllVisibleItems() as $_item) {
130
+ /* @var $_item Mage_Sales_Model_Quote_Item */
131
+ //$items .= $_item->getProduct()->getName() . ' x '. $_item->getQty() . ' '
132
+ // . $checkout->getStoreCurrencyCode() . ' '
133
+ // . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
134
+
135
+ $itemsHtml .= '<tr>
136
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
137
+ <strong style="font-size:11px;">'.$_item->getProduct()->getName().'</strong>
138
+ </td>
139
+ <td align="left" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">'.$_item->getSku().'</td>
140
+ <td align="center" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">'.$_item->getQty().'</td>
141
+ <td align="right" valign="top" style="font-size:11px; padding:3px 9px; border-bottom:1px dotted #CCCCCC;">
142
+ <span class="price">'.$currency_symbol . number_format(($_item->getProduct()->getFinalPrice() * $_item->getQty()),2).'</span>
143
+ </td>
144
+ </tr>';
145
+ }
146
+
147
+ $itemsHtml .= '</tbody>
148
+
149
+ <tbody>
150
+ <tr class="subtotal">
151
+ <td colspan="3" align="right" style="padding:3px 9px">
152
+ Subtotal </td>
153
+ <td align="right" style="padding:3px 9px">
154
+ <span class="price">'.$currency_symbol.number_format($sub_total,2).'</span> </td>
155
+ </tr>
156
+ <tr class="shipping">
157
+ <td colspan="3" align="right" style="padding:3px 9px">
158
+ Shipping &amp; Handling </td>
159
+ <td align="right" style="padding:3px 9px">
160
+ <span class="price">'.$currency_symbol.number_format($total_ship,2).'</span> </td>
161
+ </tr>
162
+ <tr class="grand_total">
163
+ <td colspan="3" align="right" style="padding:3px 9px">
164
+ <strong>Grand Total</strong>
165
+ </td>
166
+ <td align="right" style="padding:3px 9px">
167
+ <strong><span class="price">'.$currency_symbol.number_format($total,2).'</span></strong>
168
+ </td>
169
+ </tr>
170
+ </tbody>
171
+ </table>';
172
+ // items html formatting ends here
173
+
174
+
175
+ foreach ($sendTo as $recipient) {
176
+ $mailTemplate->setDesignConfig(array('area'=>'frontend', 'store'=>$checkout->getStoreId()))
177
+ ->sendTransactional(
178
+ $template,
179
+ Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()),
180
+ $recipient['email'],
181
+ $recipient['name'],
182
+ array(
183
+ 'reason' => $message,
184
+ 'checkoutType' => $checkoutType,
185
+ 'dateAndTime' => Mage::app()->getLocale()->date(),
186
+ 'customer_name' => $custdetail[0]['name'],//$recipient['name'],// . ' ' . $checkout->getCustomerLastname(),
187
+ 'customer_email'=> $custdetail[0]['email'],//$checkout->getCustomerEmail(),
188
+ 'recipient_email'=> $recipient['email'],
189
+ 'recipient_name'=> $recipient['name'],
190
+ 'is_customer' => ($custdetail[0]['email'] == $recipient['email']),
191
+ 'is_guest' => empty($customerId),
192
+ 'billingAddress'=> $checkout->getBillingAddress(),
193
+ 'shippingAddress'=> $checkout->getShippingAddress(),
194
+ 'shippingMethod'=> Mage::getStoreConfig('carriers/'.$shippingMethod.'/title'),
195
+ 'paymentMethod' => Mage::getStoreConfig('payment/'.$paymentMethod.'/title'),
196
+ 'items' => $itemsHtml,
197
+ 'total' => $total,
198
+ 'order_id' => $lastOrderId,
199
+ 'admin_order_link'=> Mage::getBaseUrl().'admin/sales_order/view/order_id/'.$lastOrderId.'/'
200
+ )
201
+ );
202
+ }
203
+
204
+ $translate->setTranslateInline(true);
205
+
206
+ return $this;
207
+ }
208
+
209
+ /**
210
+ * Is the payment method enabled?
211
+ *
212
+ * @return bool
213
+ */
214
+ public function isEnabled() {
215
+ return (bool) $this->getConfigData('active');
216
+ }
217
+ }
app/code/local/Planet/Pay/Model/Authorizenet.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Planet_Pay_Model_Select
5
+ */
6
+ class Planet_Pay_Model_Authorizenet extends Mage_Paygate_Model_Authorizenet {
7
+
8
+ /**
9
+ * @todo uncomment the following if you want to refund the payment, or make a patial payment
10
+ */
11
+ protected $_canCapturePartial = true;
12
+ protected $_canRefund = true;
13
+ protected $_canSaveCc = true;
14
+ protected $_canUseInternal = true;
15
+
16
+ /**
17
+ * It sets card`s data into additional information of payment model
18
+ * AuthorizeNet has added additional_information field in sale_flat_order_payment table
19
+ * where they savve credit card info, and disallow to save the card in other fields,
20
+ * This method is temprory and we need to fetch the card info from additional_information
21
+ * field.
22
+ * @param Mage_Paygate_Model_Authorizenet_Result $response
23
+ * @param Mage_Sales_Model_Order_Payment $payment
24
+ * @return Varien_Object
25
+ */
26
+ protected function _registerCard(Varien_Object $response, Mage_Sales_Model_Order_Payment $payment)
27
+ {
28
+ $cardsStorage = $this->getCardsStorage($payment);
29
+ $card = $cardsStorage->registerCard();
30
+ $card
31
+ ->setRequestedAmount($response->getRequestedAmount())
32
+ ->setBalanceOnCard($response->getBalanceOnCard())
33
+ ->setLastTransId($response->getTransactionId())
34
+ ->setProcessedAmount($response->getAmount())
35
+ ->setCcType($payment->getCcType())
36
+ ->setCcOwner($payment->getCcOwner())
37
+ ->setCcLast4($payment->getCcLast4())
38
+ ->setCcExpMonth($payment->getCcExpMonth())
39
+ ->setCcExpYear($payment->getCcExpYear())
40
+ ->setCcSsIssue($payment->getCcSsIssue())
41
+ ->setCcSsStartMonth($payment->getCcSsStartMonth())
42
+ ->setCcSsStartYear($payment->getCcSsStartYear());
43
+
44
+ $cardsStorage->updateCard($card);
45
+ //below is the only reason to override this method,
46
+ //$this->_clearAssignedData($payment);
47
+ return $card;
48
+ }
49
+ }
50
+ ?>
51
+
app/code/local/Planet/Pay/Model/Autoloader.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This is autoloader script
5
+ *
6
+ * Class Planet_Pay_Model_Autoloader
7
+ */
8
+ class Planet_Pay_Model_Autoloader
9
+ {
10
+ public function init()
11
+ {
12
+ spl_autoload_register(function ($class) {
13
+ if (strpos($class, 'PlanetLib\\') === 0) {
14
+ $libPath = Mage::getBaseDir('lib');
15
+ require_once $libPath.'/'.str_replace('\\', '/', $class). '.php';
16
+ }
17
+ }, false, true);
18
+ }
19
+ }
app/code/local/Planet/Pay/Model/Carddetail.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is card detail model for various card data
4
+ *
5
+ * Class Planet_Pay_Model_Order
6
+ */
7
+ class Planet_Pay_Model_Carddetail extends Mage_Core_Model_Abstract
8
+ {
9
+
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/carddetail');
13
+ }
14
+
15
+ /**
16
+ * To saved the card data
17
+ *
18
+ * @param Mage_Sales_Model_Order $order
19
+ */
20
+ public function saveCardDetail($result)
21
+ {
22
+ $getDetail = $result->toArray();
23
+ $saveCardDetail = Mage::getModel('planet_pay/carddetail');
24
+ $id = $getDetail['id'];
25
+ $paymentType = $getDetail['paymentType'];
26
+ $paymentBrand = $getDetail['paymentBrand'];
27
+ $last4Digits = $getDetail['card']['last4Digits'];
28
+ $holder = $getDetail['card']['holder'];
29
+ $expiryMonth = $getDetail['card']['expiryMonth'];
30
+ $expiryYear = $getDetail['card']['expiryYear'];
31
+ try{
32
+ $saveCardDetail->setResponseid($id);
33
+ $saveCardDetail->setPaymenttype($paymentType);
34
+ $saveCardDetail->setPaymentbrand($paymentBrand);
35
+ $saveCardDetail->setLastdigits($last4Digits);
36
+ $saveCardDetail->setExpirymonth($expiryMonth);
37
+ $saveCardDetail->setExpiryyear($expiryYear);
38
+ $saveCardDetail->setHolder($holder);
39
+ $insertId = $saveCardDetail->save();
40
+
41
+ } catch (Exception $ex) {
42
+
43
+ Mage::log($ex->getMessage(), null, Planet_Pay_Model_Select::LOG_FILE);
44
+ }
45
+
46
+ }
47
+
48
+
49
+ }
app/code/local/Planet/Pay/Model/Checkout/Observer.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Model_Checkout_Observer
4
+ */
5
+ class Planet_Pay_Model_Checkout_Observer
6
+ {
7
+ /**
8
+ * @param $orderId
9
+ */
10
+ public function checkoutSuccessAction($orderId)
11
+ {
12
+ $onePage = Mage::getSingleton('checkout/type_onepage');
13
+ /*$orderid = $orderId->order_ids[0];
14
+ $order = Mage::getModel('sales/order')->load($orderid);
15
+ $Incrementid = $order->getIncrementId();*/
16
+ $onePage->getCheckout()->setPlanetLastOrderId(null);
17
+ Mage::getSingleton('checkout/cart')->truncate()->save();
18
+ }
19
+ }
app/code/local/Planet/Pay/Model/Checkout/Type/Onepage.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Model_Checkout_Type_Onepage
4
+ */
5
+ class Planet_Pay_Model_Checkout_Type_Onepage extends Mage_Checkout_Model_Type_Onepage
6
+ {
7
+ /**
8
+ * @throws Mage_Core_Exception
9
+ * @return Mage_Checkout_Model_Type_Onepage
10
+ * @param $failed accepts true or false as parameter and if it is true then we should save failed order or order with failed payment
11
+ */
12
+ public function saveOrder( $failed = false)
13
+ {
14
+ $paycode = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
15
+ if($paycode == 'planet_pay'){
16
+
17
+ $data['checks'] = Mage_Payment_Model_Method_Abstract::CHECK_USE_CHECKOUT
18
+ | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_COUNTRY
19
+ | Mage_Payment_Model_Method_Abstract::CHECK_USE_FOR_CURRENCY
20
+ | Mage_Payment_Model_Method_Abstract::CHECK_ORDER_TOTAL_MIN_MAX
21
+ | Mage_Payment_Model_Method_Abstract::CHECK_ZERO_TOTAL;
22
+ $data['method'] = 'planet_pay';
23
+ $this->getQuote()->getPayment()->importData($data);
24
+ if(!empty($failed))
25
+ {
26
+ $this->saveFailedOrder();
27
+ }else{
28
+ parent::saveOrder();
29
+ }
30
+ return $this;
31
+ }
32
+ else{
33
+ if(!empty($failed))
34
+ {
35
+ $this->saveFailedOrder();
36
+ }else{
37
+ parent::saveOrder();
38
+ }
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Create order based on checkout type. Create customer if necessary.
44
+ *
45
+ * @return Mage_Checkout_Model_Type_Onepage
46
+ */
47
+ public function saveFailedOrder()
48
+ {
49
+
50
+ $this->validate();
51
+ $isNewCustomer = false;
52
+ switch ($this->getCheckoutMethod()) {
53
+ case self::METHOD_GUEST:
54
+ $this->_prepareGuestQuote();
55
+ break;
56
+ case self::METHOD_REGISTER:
57
+ $this->_prepareNewCustomerQuote();
58
+ $isNewCustomer = true;
59
+ break;
60
+ default:
61
+ $this->_prepareCustomerQuote();
62
+ break;
63
+ }
64
+ //die('order is available');
65
+ $service = Mage::getModel('sales/service_quote', $this->getQuote());
66
+ $service->submitAll();
67
+
68
+ if ($isNewCustomer) {
69
+ try {
70
+ $this->_involveNewCustomer();
71
+ } catch (Exception $e) {
72
+ Mage::logException($e);
73
+ }
74
+ }
75
+
76
+ $this->_checkoutSession->setLastQuoteId($this->getQuote()->getId())
77
+ ->setLastSuccessQuoteId($this->getQuote()->getId())
78
+ ->clearHelperData();
79
+
80
+ $order = $service->getOrder();
81
+ if ($order) {
82
+ Mage::dispatchEvent('checkout_type_onepage_save_order_after',
83
+ array('order'=>$order, 'quote'=>$this->getQuote()));
84
+
85
+ /**
86
+ * a flag to set that there will be redirect to third party after confirmation
87
+ * eg: paypal standard ipn
88
+ */
89
+ $redirectUrl = $this->getQuote()->getPayment()->getOrderPlaceRedirectUrl();
90
+ /**
91
+ * we only want to send to customer about new order when there is no redirect to third party
92
+ */
93
+ if (!$redirectUrl && $order->getCanSendNewEmailFlag()) {
94
+ try {
95
+ //$order->sendNewOrderEmail();
96
+ //return $this;
97
+
98
+ } catch (Exception $e) {
99
+ Mage::logException($e);
100
+ }
101
+ }
102
+
103
+ // add order information to the session
104
+ $this->_checkoutSession->setLastOrderId($order->getId())
105
+ ->setRedirectUrl($redirectUrl)
106
+ ->setLastRealOrderId($order->getIncrementId());
107
+
108
+ // as well a billing agreement can be created
109
+ $agreement = $order->getPayment()->getBillingAgreement();
110
+ if ($agreement) {
111
+ $this->_checkoutSession->setLastBillingAgreementId($agreement->getId());
112
+ }
113
+ }
114
+
115
+ // add recurring profiles information to the session
116
+ $profiles = $service->getRecurringPaymentProfiles();
117
+ if ($profiles) {
118
+ $ids = array();
119
+ foreach ($profiles as $profile) {
120
+ $ids[] = $profile->getId();
121
+ }
122
+ $this->_checkoutSession->setLastRecurringProfileIds($ids);
123
+ // TODO: send recurring profile emails
124
+ }
125
+
126
+ Mage::dispatchEvent(
127
+ 'checkout_submit_all_after',
128
+ array('order' => $order, 'quote' => $this->getQuote(), 'recurring_profiles' => $profiles)
129
+ );
130
+
131
+ return $this;
132
+ }
133
+
134
+ }
app/code/local/Planet/Pay/Model/Currency/Import/Planet.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_Upop
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_Upop
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class Planet_Pay_Model_Currency_Import_Planet extends Mage_Directory_Model_Currency_Import_Abstract {
30
+
31
+ protected $_messages = array();
32
+ protected $_rates = array();
33
+
34
+ public function __construct() {
35
+
36
+ $request = $this->_getRequestModel()
37
+ ->generateCurrencyRateLookUpRequest();
38
+ $responearr = json_decode($request, true);
39
+ Mage::log($responearr, null, 'pprate.log');
40
+ if (substr($responearr["result"]["code"], 0, 3) === "000") {
41
+ $this->_rates = $this->_formatConvertionXml($responearr['conversionRates']);
42
+ } else {
43
+ Mage::throwException("Communication Error! Please try later");
44
+ }
45
+ }
46
+
47
+ protected function _convert($currencyFrom, $currencyTo, $retry = 0) {
48
+ if (count($this->_rates)) {
49
+ try {
50
+ if (isset($this->_rates[$currencyTo])) {
51
+ return $this->_rates[$currencyTo];
52
+ } else {
53
+ $this->_messages[] = Mage::helper('planet_pay')->__("Unable to retrieve the conversion rate from %s to %s", $currencyFrom, $currencyTo);
54
+ }
55
+ } catch (Exception $e) {
56
+ if ($retry == 0) {
57
+ $this->_convert($currencyFrom, $currencyTo, 1);
58
+ } else {
59
+ $this->_messages[] = Mage::helper('planet_pay')->__('Cannot retrieve rate from planet');
60
+ }
61
+ }
62
+ } else {
63
+ $this->_messages[] = Mage::helper('planet_pay')->__("Unable to retrieve the conversion rate from %s to %s", $currencyFrom, $currencyTo);
64
+ }
65
+ }
66
+ public function runExchangeRateQuery() {
67
+ try {
68
+ $service = 'planet_payment_core';
69
+ $this->_getSession()->setCurrencyRateService($service);
70
+ if (!$service) {
71
+ throw new Exception(Mage::helper('adminhtml')->__('Invalid Import Service Specified'));
72
+ }
73
+ try {
74
+ $importModel = Mage::getModel(
75
+ Mage::getConfig()->getNode('global/currency/import/services/' . $service . '/model')->asArray()
76
+ );
77
+ } catch (Exception $e) {
78
+ Mage::throwException(Mage::helper('adminhtml')->__('Unable to initialize import model'));
79
+ }
80
+ $rates = $importModel->fetchRates();
81
+ $errors = $importModel->getMessages();
82
+ if (sizeof($errors) > 0) {
83
+ foreach ($errors as $error) {
84
+ Mage::log($error, null, 'exception.log');
85
+ }
86
+ Mage::log(Mage::helper('adminhtml')->__('All possible rates were fetched, please click on "Save" to apply'), null, 'exception.log');
87
+ } else {
88
+ Mage::log(Mage::helper('adminhtml')->__('All rates were fetched, please click on "Save" to apply'), null, 'exception.log');
89
+ }
90
+
91
+ Mage::getSingleton('adminhtml/session')->setRates($rates);
92
+
93
+
94
+ //Prepare Data Layout
95
+ $newRates = Mage::getSingleton('adminhtml/session')->getRates();
96
+ Mage::getSingleton('adminhtml/session')->unsetData('rates');
97
+
98
+ $currencyModel = Mage::getModel('directory/currency');
99
+ $currencies = $currencyModel->getConfigAllowCurrencies();
100
+ $defaultCurrencies = $currencyModel->getConfigBaseCurrencies();
101
+ $oldCurrencies = $this->_prepareRates($currencyModel->getCurrencyRates($defaultCurrencies, $currencies));
102
+
103
+ foreach ($currencies as $currency) {
104
+ foreach ($oldCurrencies as $key => $value) {
105
+ if (!array_key_exists($currency, $oldCurrencies[$key])) {
106
+ $oldCurrencies[$key][$currency] = '';
107
+ }
108
+ }
109
+ }
110
+
111
+ foreach ($oldCurrencies as $key => $value) {
112
+ ksort($oldCurrencies[$key]);
113
+ }
114
+
115
+ sort($currencies);
116
+
117
+ $_newRates = $this->_prepareRates($newRates);
118
+ $_oldRates = $oldCurrencies;
119
+ $_rates = ( $_newRates ) ? $_newRates : $_oldRates;
120
+ $data = array();
121
+ foreach ($defaultCurrencies as $_currencyCode) {
122
+ if (isset($_rates[$_currencyCode]) && is_array($_rates[$_currencyCode])) {
123
+ foreach ($_rates[$_currencyCode] as $_rate => $_value) {
124
+ $data[$_currencyCode][$_rate] = $_value;
125
+ }
126
+ }
127
+ }
128
+
129
+
130
+ if (is_array($data)) {
131
+ try {
132
+ foreach ($data as $currencyCode => $rate) {
133
+ foreach ($rate as $currencyTo => $value) {
134
+ $value = abs(Mage::getSingleton('core/locale')->getNumber($value));
135
+ $data[$currencyCode][$currencyTo] = $value;
136
+ if ($value == 0) {
137
+ Mage::log(Mage::helper('adminhtml')->__('Invalid input data for %s => %s rate', $currencyCode, $currencyTo), null, 'exception.log');
138
+ }
139
+ }
140
+ }
141
+
142
+
143
+ Mage::getModel('directory/currency')->saveRates($data);
144
+ //Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('All valid rates have been saved.'));
145
+ } catch (Exception $e) {
146
+ //Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
147
+ }
148
+ }
149
+ } catch (Exception $e) {
150
+ Mage::logException($e);
151
+ }
152
+ }
153
+ /**
154
+ * Prepare rate for currency
155
+ *
156
+ * @param type $array
157
+ * @return null
158
+ */
159
+ protected function _prepareRates($array) {
160
+ if (!is_array($array)) {
161
+ return $array;
162
+ }
163
+
164
+ foreach ($array as $key => $rate) {
165
+ foreach ($rate as $code => $value) {
166
+ $parts = explode('.', $value);
167
+ if (sizeof($parts) == 2) {
168
+ $parts[1] = str_pad(rtrim($parts[1], 0), 4, '0', STR_PAD_RIGHT);
169
+ $array[$key][$code] = join('.', $parts);
170
+ } elseif ($value > 0) {
171
+ $array[$key][$code] = number_format($value, 4);
172
+ } else {
173
+ $array[$key][$code] = null;
174
+ }
175
+ }
176
+ }
177
+ return $array;
178
+ }
179
+
180
+ protected function _formatConvertionXml($response) {
181
+ $currencyRates = array();
182
+ if ($response) {
183
+ $rates = $response['0']['rates'];
184
+ for ($i = 0; $i < count($rates); $i++) {
185
+ foreach ($rates[$i] as $key => $value) {
186
+
187
+ if ($key == 'currency') {
188
+
189
+ $ratecurr = $value;
190
+ } elseif ($key == 'value') {
191
+
192
+ $ratefetch = $value;
193
+ }
194
+ $currencyRates[$ratecurr] = 1 / (float) $ratefetch;
195
+ }
196
+ }
197
+ }
198
+ return $currencyRates;
199
+ }
200
+
201
+ protected function _getRequestModel() {
202
+ return Mage::getSingleton('planet_pay/payment');
203
+ }
204
+
205
+ }
app/code/local/Planet/Pay/Model/Method.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Planet method model for different brand
4
+ *
5
+ * Class Planet_Pay_Model_Method
6
+ */
7
+ class Planet_Pay_Model_Method extends Mage_Core_Model_Abstract
8
+ {
9
+ /**
10
+ * To hold various option
11
+ *
12
+ * @var string
13
+ */
14
+ protected $_options;
15
+
16
+ protected function _construct()
17
+ {
18
+ $this->_init('planet_pay/method');
19
+ }
20
+
21
+ /**
22
+ * This is brandcode
23
+ *
24
+ * @param $brandcode
25
+ */
26
+ public function loadByBrandcode($brandcode)
27
+ {
28
+ $this->load($brandcode, 'brandcode');
29
+ }
30
+
31
+ /**
32
+ * This return multi option as selected
33
+ *
34
+ * @param bool $isMultiselect
35
+ * @return mixed
36
+ */
37
+ public function toOptionArray($isMultiselect=true)
38
+ {
39
+ if (!$this->_options) {
40
+ $this->_options = Mage::getResourceModel('planet_pay/method_collection')->loadData()->toOptionArray(false);
41
+ }
42
+
43
+ $options = $this->_options;
44
+ return $options;
45
+ }
46
+
47
+ }
app/code/local/Planet/Pay/Model/Order.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * order resource model
4
+ *
5
+ * Class Planet_Pay_Model_Order
6
+ */
7
+ class Planet_Pay_Model_Order extends Mage_Core_Model_Abstract
8
+ {
9
+
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/order');
13
+ }
14
+
15
+ /**
16
+ * To load the magento order number
17
+ *
18
+ * @param Mage_Sales_Model_Order $order
19
+ */
20
+ public function loadByMageOrder($order)
21
+ {
22
+ $this->load($order->getIncrementId(), 'order_id');
23
+ }
24
+
25
+
26
+ }
app/code/local/Planet/Pay/Model/Orderlog.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * order log model for interacting order log table
4
+ *
5
+ * Class Planet_Pay_Model_Orderlog
6
+ */
7
+ class Planet_Pay_Model_Orderlog extends Mage_Core_Model_Abstract
8
+ {
9
+
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/orderlog');
13
+ }
14
+
15
+ }
app/code/local/Planet/Pay/Model/Payment.php ADDED
@@ -0,0 +1,513 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ use PlanetLib\Resources\Translation\ErrorCodes;
4
+
5
+ /**
6
+ * This is payment model for final processing of payment
7
+ *
8
+ * Class Planet_Pay_Model_Payment
9
+ */
10
+ class Planet_Pay_Model_Payment extends Mage_Core_Model_Abstract {
11
+
12
+ /**
13
+ * @var Mage_Checkout_Model_Session
14
+ */
15
+ protected $_checkoutSession;
16
+
17
+ /** @var array */
18
+ protected $_planetPayOptions;
19
+
20
+ /** @var bool */
21
+ protected $_planetTestMode;
22
+
23
+ /**
24
+ * @var Mage_Sales_Model_Quote
25
+ */
26
+ protected $_quote = null;
27
+
28
+ /**
29
+ *
30
+ * @var string
31
+ */
32
+ protected $paymentMethod;
33
+
34
+ /**
35
+ * @var \PlanetLib\Planet
36
+ */
37
+ protected $planet;
38
+
39
+ /**
40
+ * This is contructor to initialize variable
41
+ *
42
+ */
43
+ protected function _construct() {
44
+ $this->_checkoutSession = Mage::getSingleton('checkout/session');
45
+ $this->_planetPayOptions = Mage::getStoreConfig('payment/planet_pay');
46
+ $this->_planetTestMode = $this->_planetPayOptions['test_mode'];
47
+
48
+ $autoloader = new Planet_Pay_Model_Autoloader();
49
+ $autoloader->init();
50
+
51
+ $this->planet = new \PlanetLib\Planet();
52
+ if ($this->_planetTestMode) {
53
+ $this->planet->setUrl($this->_planetPayOptions['payment_request_url_test']);
54
+ } else {
55
+ $this->planet->setUrl($this->_planetPayOptions['payment_request_url_live']);
56
+ }
57
+
58
+ $onePage = Mage::getSingleton('checkout/type_onepage');
59
+ $this->paymentMethod = $onePage->getCheckout()->getPlanetPaymentMethod();
60
+ }
61
+
62
+ /**
63
+ * Quote object getter
64
+ *
65
+ * @return Mage_Sales_Model_Quote
66
+ */
67
+ public function getQuote() {
68
+ if ($this->_quote === null) {
69
+ return $this->_checkoutSession->getQuote();
70
+ }
71
+ return $this->_quote;
72
+ }
73
+
74
+ /**
75
+ * To get payment form and interact with library
76
+ *
77
+ * @return string
78
+ */
79
+ public function getForm() {
80
+ /** @var Planet_Pay_Model_Checkout_Type_Onepage $onePage */
81
+ $onePage = Mage::getSingleton('checkout/type_onepage');
82
+ $planetOrderId = $onePage->getCheckout()->getPlanetOrderId();
83
+ $magentoOrderId = Mage::getSingleton('checkout/type_onepage')->getLastOrderId();
84
+ $magentoOrderId = $magentoOrderId + 1;
85
+ /** @var Planet_Pay_Model_Order $planetOrder */
86
+ $planetOrder = Mage::getModel('planet_pay/order');
87
+ if (!is_null($planetOrderId)) {
88
+ $planetOrder->load($planetOrderId);
89
+ }
90
+ $planetOrder->setPaymentStatus('unfinished');
91
+ $planetOrder->save();
92
+
93
+ $onePage->getCheckout()->setPlanetOrderId($magentoOrderId);
94
+
95
+ $onePage = Mage::getSingleton('checkout/type_onepage');
96
+ $quote = $onePage->getCheckout()->getQuote();
97
+
98
+ $form = $this->generateForm($quote, $planetOrder);
99
+ return $form;
100
+ }
101
+
102
+ //Below function used in Old API and part of our testing
103
+
104
+ /**
105
+ * @return string
106
+ */
107
+ /* public function getpaymentForm()
108
+ {
109
+ $url = Mage::getUrl('planet/payment/check', array('form_key' => Mage::getSingleton('checkout/session')->getFormKey(),'payment' => 'planet_pay'));
110
+ $html .= '<form action="' . $url . '" class="'.paymentWidgets.'">';
111
+ $html .= '</form>';
112
+ return $html;
113
+ } */
114
+
115
+ /**
116
+ * Process tokenization resposne
117
+ *
118
+ * @param type $tokenize
119
+ * @throws Mage_Core_Exception
120
+ */
121
+ public function processPaymentTokenization($tokenize) {
122
+ //echo rand(); die('out');
123
+ $resultniz = $this->tokenizationpayment($tokenize);
124
+ $statusarr = json_decode($resultniz, true);
125
+ file_put_contents("var/log/paymentstatus.txt", print_r($statusarr, true), FILE_APPEND);
126
+ Mage::getSingleton('core/session')->setResult(json_decode($resultniz, true));
127
+ Mage::getSingleton('core/session')->setToken($tokenize);
128
+ $language = Mage::app()->getLocale()->getLocale()->getLanguage();
129
+ /** @var Planet_Pay_Model_Order $planetOrder */
130
+ $planetOrder = Mage::getModel('planet_pay/order');
131
+ $planetCarddetail = Mage::getModel('planet_pay/carddetail');
132
+ /** @var Planet_Pay_Model_Checkout_Type_Onepage $onePage */
133
+ $onePage = Mage::getSingleton('checkout/type_onepage');
134
+ /* $quote = Mage::getModel('sales/quote');
135
+ $payment = $quote->getPayment(); */
136
+ /* $payment = $order->getPayment();
137
+ $resource = Mage::getSingleton('core/resource');
138
+ $readConnection = $resource->getConnection('core_read');
139
+ $table = $resource->getTableName('planet_pay/carddetail');
140
+ // $query = 'SELECT payment_response FROM ' . $table . ' WHERE order_id = '
141
+ // . (int) $orderId . ' LIMIT 1';
142
+ // $results = $readConnection->fetchOne($query);
143
+ $query = $readConnection->select()
144
+ ->from($table, array('id', 'registeration_id', 'brand_name', 'cc_last_four', 'cc_exp_month', 'cc_exp_year', 'holder')) // select * from tablename or use array('id','title') selected values
145
+ ->where('registeration_id=?', $tokenize) // where id =1
146
+ ->limit('1');
147
+ $results = $readConnection->fetchAll($query); */
148
+
149
+ /* $payment->setCcLast4('1234');
150
+ $payment->setCcOwner('shamim');
151
+ $payment->setCcType('visa');
152
+ $payment->setCcExpMonth('02');
153
+ $payment->setCcExpYear('2014'); */
154
+
155
+ if (substr($statusarr["result"]["code"], 0, 3) === "000") {
156
+
157
+
158
+ $onePage->saveOrder();
159
+ $orderId = $onePage->getCheckout()->getLastOrderId();
160
+ $order = Mage::getModel('sales/order');
161
+ $order->load($orderId);
162
+
163
+ // for orders on hold for review
164
+ if ( $statusarr["result"]["code"] == "000.400.000" ) {
165
+ $order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, 'payment_review', '', false)->save();
166
+ }
167
+ ///
168
+ //$planetOrder->load($result->getOrderId());
169
+ //$planetOrder->setTransactionId($result->getTransactionId());
170
+ $planetOrder->setOrderId($order->getIncrementId());
171
+ $planetOrder->setPaymentStatus('paid');
172
+ $planetOrder->setPaymentResponse($resultniz);
173
+ $planetOrder->save();
174
+ } else {
175
+ $onePage->saveOrder();
176
+ $orderId = $onePage->getCheckout()->getLastOrderId();
177
+ $order = Mage::getModel('sales/order');
178
+ $order->load($orderId);
179
+ //$order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, 'decline', '', false)->save();
180
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED)->save();
181
+ $planetOrder->setTransactionId($result->getTransactionId());
182
+ $planetOrder->setOrderId($order->getIncrementId());
183
+ $planetOrder->setPaymentStatus('unfinished');
184
+ $planetOrder->setPaymentResponse(json_encode($result->toArray()));
185
+ $planetOrder->save();
186
+ throw new Mage_Core_Exception($result->getMessage());
187
+ }
188
+ }
189
+
190
+ public function generateCurrencyRateLookUpRequest() {
191
+
192
+ $testurl = '';
193
+ if ($this->_planetTestMode) {
194
+ $testurl = $this->_planetPayOptions['payment_request_url_test'];
195
+ } else {
196
+
197
+ $testurl = $this->_planetPayOptions['payment_request_url_live'];
198
+ }
199
+
200
+ if ($this->_planetTestMode) {
201
+
202
+ $data = array("authentication.userId" => $this->_planetPayOptions['authentication_userId_test'],
203
+ "authentication.password" => $this->_planetPayOptions['authentication_password_test'],
204
+ "authentication.entityId" => $this->_planetPayOptions['authentication_entityId_test']);
205
+ } else {
206
+ $data = array("authentication.userId" => $this->_planetPayOptions['authentication_userId'],
207
+ "authentication.password" => $this->_planetPayOptions['authentication_password'],
208
+ "authentication.entityId" => $this->_planetPayOptions['authentication_entityId']);
209
+ }
210
+ $url = $testurl . "/v1/currencies/conversionRates";
211
+ $fields_string = '';
212
+
213
+ foreach ($data as $key => $value) {
214
+ $fields_string[] = $key . '=' . urlencode($value) . '&';
215
+ }
216
+ $urlStringData = $url . '?' . implode('', $fields_string);
217
+ $modfurlStringData = substr_replace($urlStringData, "", -1);
218
+ $ch = curl_init();
219
+ curl_setopt($ch, CURLOPT_HEADER, 0);
220
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
221
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
222
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0); //Set curl to return the data instead of printing it to the browser.
223
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); # timeout after 10 seconds, you can increase it
224
+ curl_setopt($ch, CURLOPT_URL, $modfurlStringData); #set the url and get string together
225
+ $return = curl_exec($ch);
226
+ if ($errno = curl_errno($ch)) {
227
+ $error_message = curl_strerror($errno);
228
+ echo "cURL error ({$errno}):\n {$error_message}";
229
+ }
230
+ curl_close($ch);
231
+
232
+ return $return;
233
+ }
234
+
235
+ /**
236
+ * send payment request with tokenization
237
+ *
238
+ * @param type $tokenize
239
+ * @return type
240
+ */
241
+ public function tokenizationpayment($tokenize) {
242
+
243
+ //one way
244
+ $testurl = '';
245
+ if ($this->_planetTestMode) {
246
+ $testurl = $this->_planetPayOptions['payment_request_url_test'];
247
+ } else {
248
+
249
+ $testurl = $this->_planetPayOptions['payment_request_url_live'];
250
+ }
251
+ $quote = Mage::getModel('checkout/session')->getQuote();
252
+ $currency_code = Mage::app()->getStore()->getCurrentCurrencyCode();
253
+ $quoteData = $quote->getData();
254
+ $amount = $quoteData['grand_total'];
255
+ $grandTotal = number_format($amount, 2, '.', '');
256
+ $paymentype = $this->_planetPayOptions['payment_type_test'];
257
+
258
+ if ($this->_planetTestMode) {
259
+
260
+ $data = "authentication.userId=" . $this->_planetPayOptions['authentication_userId_test'] .
261
+ "&authentication.password=" . $this->_planetPayOptions['authentication_password_test'] .
262
+ "&authentication.entityId=" . $this->_planetPayOptions['authentication_entityId_test'] .
263
+ "&paymentType=$paymentype" .
264
+ "&currency=$currency_code" .
265
+ "&amount=$grandTotal";
266
+ } else {
267
+ $data = "authentication.userId=" . $this->_planetPayOptions['authentication_userId'] .
268
+ "&authentication.password=" . $this->_planetPayOptions['authentication_password'] .
269
+ "&authentication.entityId=" . $this->_planetPayOptions['authentication_entityId'] .
270
+ "&paymentType=$paymentype" .
271
+ "&currency=$currency_code" .
272
+ "&amount=$grandTotal";
273
+ }
274
+
275
+ $params = array('http' => array(
276
+ 'method' => 'POST',
277
+ 'content' => $data
278
+ ));
279
+ $url = $testurl . "/v1/registrations/" . $tokenize . "/payments";
280
+ $ch = curl_init($url);
281
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
282
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
283
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
284
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
285
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
286
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
287
+ 'Accept: application/json',
288
+ 'Content-Length: ' . strlen($data))
289
+ );
290
+
291
+ $result = curl_exec($ch);
292
+ curl_close($ch);
293
+ return $result;
294
+ }
295
+
296
+ /**
297
+ * To process regular Payment
298
+ *
299
+ * @param $token
300
+ * @throws Mage_Core_Exception
301
+ */
302
+ public function processPaymentResponse($token) {
303
+
304
+ $result = $this->planet->getResult($token);
305
+ $statusarr = $result->toArray();
306
+ file_put_contents("var/log/paymentstatus.txt", print_r($statusarr, true), FILE_APPEND);
307
+ Mage::getSingleton('core/session')->setResult($statusarr);
308
+ $language = Mage::app()->getLocale()->getLocale()->getLanguage();
309
+ /** @var Planet_Pay_Model_Order $planetOrder */
310
+ $planetOrder = Mage::getModel('planet_pay/order');
311
+ $planetCarddetail = Mage::getModel('planet_pay/carddetail');
312
+ /** @var Planet_Pay_Model_Checkout_Type_Onepage $onePage */
313
+ $onePage = Mage::getSingleton('checkout/type_onepage');
314
+
315
+ if ($result->isValid()) {
316
+ $onePage->saveOrder();
317
+ $orderId = $onePage->getCheckout()->getLastOrderId();
318
+ $order = Mage::getModel('sales/order');
319
+ $order->load($orderId);
320
+
321
+ // for orders on hold for review
322
+ if ( $statusarr["result"]["code"] == "000.400.000" ) {
323
+ $order->setState(Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW, 'payment_review', '', false)->save();
324
+ }
325
+
326
+ if ($statusarr['registrationId']) {
327
+
328
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
329
+ $custid = $customerData->getId();
330
+ $planetCarddetail->setCustId($custid);
331
+ $planetCarddetail->setRegisterationId($statusarr['registrationId']);
332
+ $planetCarddetail->setBrandName($statusarr['paymentBrand']);
333
+ $planetCarddetail->setPaymentType($statusarr['paymentType']);
334
+ $planetCarddetail->setccLastFour($statusarr['card']['last4Digits']);
335
+ $planetCarddetail->setccExpMonth($statusarr['card']['expiryMonth']);
336
+ $planetCarddetail->setCcExpYear($statusarr['card']['expiryYear']);
337
+ $planetCarddetail->setHolder($statusarr['card']['holder']);
338
+ }
339
+ //$planetOrder->load($result->getOrderId());
340
+ $planetOrder->setTransactionId($result->getTransactionId());
341
+ $planetOrder->setOrderId($order->getIncrementId());
342
+ $planetOrder->setPaymentStatus('paid');
343
+ $planetOrder->setPaymentResponse(json_encode($result->toArray()));
344
+ $planetOrder->save();
345
+ $planetCarddetail->save();
346
+ } else {
347
+ $onePage->saveOrder($paymentFailed = true);
348
+ // $onePage->saveOrder();
349
+ //$orderId = $onePage->getCheckout()->getLastOrderId();
350
+ $orderId = Mage::getSingleton('checkout/session')->getLastOrderId();
351
+ $order = Mage::getModel('sales/order');
352
+ $order->load($orderId);
353
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, 'decline', '', false)->save();
354
+ //$order->setState(Mage_Sales_Model_Order::STATE_CANCELED)->save();
355
+ $planetOrder->setTransactionId($result->getTransactionId());
356
+ $planetOrder->setOrderId($order->getIncrementId());
357
+ $planetOrder->setPaymentStatus('unfinished');
358
+ $planetOrder->setPaymentResponse(json_encode($result->toArray()));
359
+ $planetOrder->save();
360
+ Mage::helper('planet_pay')->sendPaymentFailedEmail($this->getQuote(), 'Payment failed!');
361
+ throw new Mage_Core_Exception($result->getMessage());
362
+ }
363
+ }
364
+
365
+ /**
366
+ * To generate payment form by getting token as needed
367
+ *
368
+ * @param Mage_Sales_Model_Quote $quote
369
+ * @param Planet_Pay_Model_Order $planetOrder
370
+ * @return string
371
+ */
372
+ private function generateForm($quote, $planetOrder) {
373
+ $token = $this->getToken($quote, $planetOrder, $this->paymentMethod);
374
+ Mage::getSingleton('core/session')->setGenerateToken($token);
375
+ //used as part of testing in old code
376
+ /* $url = Mage::getUrl('planet/payment/check', array('form_key' => Mage::getSingleton('checkout/session')->getFormKey(),
377
+ 'payment' => 'planet_pay')); */
378
+
379
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
380
+ if ($testMode) {
381
+ $javurl = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
382
+ } else {
383
+ $javurl = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
384
+ }
385
+ $srcurl = $javurl . "/v1/paymentWidgets.js";
386
+ $planetView = new \PlanetLib\View();
387
+
388
+ $url = Mage::getUrl('planet/payment/check', array('form_key' => Mage::getSingleton('checkout/session')->getFormKey(),
389
+ 'payment' => 'planet_pay'));
390
+ $planetView->setAction($url);
391
+ $planetView->setSrc($srcurl);
392
+ $planetView->setBrands(array($this->paymentMethod));
393
+ $planetView->setLanguage(Mage::app()->getLocale()->getLocale()->getLanguage());
394
+
395
+ //to get the customer info
396
+ //return $planetView->getForm($token);
397
+ return array('token' => $token, 'url' => $url);
398
+ }
399
+
400
+ /**
401
+ * To get the token by passing needed credentilas
402
+ *
403
+ * @param Mage_Sales_Model_Quote $quote
404
+ * @param Planet_Pay_Model_Order $planetOrder
405
+ * @param $paymentMethodCode
406
+ * @return string
407
+ */
408
+ private function getToken($quote, $planetOrder, $paymentMethodCode) {
409
+ $billingAddress = $quote->getBillingAddress();
410
+ $shippingAddress = $quote->getShippingAddress();
411
+ $items = $quote->getAllVisibleItems();
412
+ $customerip = Mage::helper('core/http')->getRemoteAddr();
413
+ $payment = $this->getPayment($quote);
414
+
415
+ /** @var Planet_Pay_Model_Method $paymentMethod */
416
+ $paymentMethod = Mage::getModel('planet_pay/method');
417
+ $paymentMethod->loadByBrandcode($paymentMethodCode);
418
+
419
+ $customer = array(
420
+ 'nameGiven' => $billingAddress->getData('firstname'),
421
+ 'nameSurname' => $billingAddress->getData('lastname'),
422
+ 'addressStreet' => $billingAddress->getData('street'),
423
+ 'addressZip' => $billingAddress->getData('postcode'),
424
+ 'addressState' => $billingAddress->getData('region'),
425
+ 'addressCity' => $billingAddress->getData('city'),
426
+ 'contactIp' => $customerip,
427
+ 'contactEmail' => $billingAddress->getData('email'));
428
+
429
+ $shippingAddress = $shippingAddress->collectTotals();
430
+
431
+
432
+ $criterion = array(
433
+ // 'customerDeliveryaddressStreet' => $shippingAddress->getData('street'),
434
+ 'customerDeliveryaddressCity' => $shippingAddress->getData('city'),
435
+ 'customerDeliveryaddressState' => $shippingAddress->getData('region'),
436
+ //'customerDeliveryaddressState2' => $shippingAddress->getData('region_id'),
437
+ 'customerDeliveryaddressCountry' => $shippingAddress->getData('country_id'),
438
+ 'customerDeliveryaddressZip' => $shippingAddress->getData('postcode'),
439
+ 'customerDeliveryAddressFirstName' => $shippingAddress->getData('firstname'),
440
+ 'customerDeliveryAddressLastName' => $shippingAddress->getData('lastname')
441
+ );
442
+
443
+ $payment->setCurrency($quote->getQuoteCurrencyCode());
444
+ $payment->setAmount($quote->grand_total);
445
+
446
+ $payment->setCustomerData($customer);
447
+ $payment->setCriterions($criterion);
448
+
449
+ $planetOrder->setPaymentStatus('unfinished');
450
+ $planetOrder->setTotalOrderSum($payment->getAmount());
451
+ $planetOrder->setPaymentRequest(json_encode($payment->toArray(true, true)));
452
+ $planetOrder->setCreateDate(date('Y-m-d H:i:s', time()));
453
+ $planetOrder->setBrandName($paymentMethod->getBrandcode());
454
+ $planetOrder->save();
455
+ $quotePayment = $this->getQuote()->getPayment();
456
+ $quotePayment->setAdditionalData($paymentMethod->getBrandcode());
457
+ $quotePayment->save();
458
+ $token = $this->planet->generateToken($payment);
459
+ return $token;
460
+ }
461
+
462
+ /**
463
+ * To set the payment data
464
+ *
465
+ * @return \PlanetLib\Payment
466
+ */
467
+ private function getPayment($quote) {
468
+ $payment = new \PlanetLib\Payment();
469
+ $onePage = Mage::getSingleton('checkout/type_onepage');
470
+ $planetOrderId = Mage::getModel("sales/order")->getCollection()->getLastItem()->getIncrementId();
471
+ //$planetOrderId = $onePage->getCheckout()->getPlanetOrderId();
472
+ $customerData = Mage::getSingleton('customer/session')->getCustomer();
473
+ $billingAddress = $quote->getBillingAddress();
474
+ $countryid = $billingAddress->getData('country_id');
475
+ $custid = $customerData->getId();
476
+ $payment_action = Mage::getStoreConfig('payment/planet_pay/payment_action');
477
+ if ($payment_action != "authorize_capture") {
478
+
479
+ $paymenttype = $this->_planetPayOptions['payment_type_test'];
480
+ } else {
481
+ $paymenttype = 'DB';
482
+ }
483
+ if ($this->_planetTestMode) {
484
+ $paymentCredentials = array(
485
+ 'authenticationUserId' => $this->_planetPayOptions['authentication_userId_test'],
486
+ 'authenticationEntityId' => $this->_planetPayOptions['authentication_entityId_test'],
487
+ //'transactionMode' => "CONNECTOR_TEST",
488
+ 'testMode' => "EXTERNAL",
489
+ 'merchantInvoiceId' => $planetOrderId + 1,
490
+ 'customermerchantCustomerId' => $custid,
491
+ 'billingcountry' => $countryid,
492
+ 'authenticationPassword' => $this->_planetPayOptions['authentication_password_test'],
493
+ 'paymentType' => $paymenttype
494
+ );
495
+ } else {
496
+ $paymentCredentials = array(
497
+ 'authenticationUserId' => $this->_planetPayOptions['authentication_userId'],
498
+ 'authenticationEntityId' => $this->_planetPayOptions['authentication_entityId'],
499
+ 'transactionMode' => "LIVE",
500
+ //'userLogin' => $this->_planetPayOptions['user_login'],
501
+ //'testMode' => "EXTERNAL",
502
+ 'merchantInvoiceId' => $planetOrderId + 1,
503
+ 'customermerchantCustomerId' => $custid,
504
+ 'billingcountry' => $countryid,
505
+ 'authenticationPassword' => $this->_planetPayOptions['authentication_password'],
506
+ 'paymentType' => $paymenttype
507
+ );
508
+ }
509
+ $payment->setCredentials($paymentCredentials);
510
+ return $payment;
511
+ }
512
+
513
+ }
app/code/local/Planet/Pay/Model/Resource/Carddetail.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Thos is pay model for cartdetail
4
+ *
5
+ * Class Planet_Pay_Model_Resource_Order
6
+ */
7
+ class Planet_Pay_Model_Resource_Carddetail extends Mage_Core_Model_Resource_Db_Abstract
8
+ {
9
+ /**
10
+ * Initialize connection and define main table and primary key
11
+ */
12
+ protected function _construct()
13
+ {
14
+ $this->_init('planet_pay/carddetail', 'id');
15
+ }
16
+ }
app/code/local/Planet/Pay/Model/Resource/Carddetail/Collection.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Model_Resource_Order_Collection
4
+ */
5
+ class Planet_Pay_Model_Resource_Carddetail_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
6
+ {
7
+ /**
8
+ * Define collection model
9
+ */
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/carddetail');
13
+ }
14
+
15
+ /**
16
+ * To add the customer id to filter the current customer
17
+ *
18
+ * @param Mage_Customer_Model_Customer $customer
19
+ * @return \Planet_Pay_Model_Resource_Carddetail_Collection
20
+ */
21
+ public function addCustomerFilter(Mage_Customer_Model_Customer $customer) {
22
+ $this->addFieldToFilter('cust_id', $customer->getId());
23
+ return $this;
24
+ }
25
+
26
+ }
app/code/local/Planet/Pay/Model/Resource/Method.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is planet pay model class
4
+ *
5
+ * Class Planet_Pay_Model_Resource_Method
6
+ */
7
+ class Planet_Pay_Model_Resource_Method extends Mage_Core_Model_Resource_Db_Abstract
8
+ {
9
+ /**
10
+ * Initialize connection and define main table and primary key
11
+ */
12
+ protected function _construct()
13
+ {
14
+ $this->_init('planet_pay/method', 'id');
15
+ }
16
+ }
app/code/local/Planet/Pay/Model/Resource/Method/Collection.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Model_Resource_Method_Collection
4
+ */
5
+ class Planet_Pay_Model_Resource_Method_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
6
+ {
7
+ /**
8
+ * Define collection model
9
+ */
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/method');
13
+ }
14
+
15
+ /**
16
+ * @return $this
17
+ */
18
+ public function onlyActive()
19
+ {
20
+ $this->addFilter('active', 1);
21
+ return $this;
22
+ }
23
+
24
+ /**
25
+ * @param $brands
26
+ * @return $this
27
+ */
28
+ public function onlySpecifiedBrands($brands)
29
+ {
30
+ $brands = explode(',', $brands);
31
+ $this->addFieldToFilter('brandcode', array("in"=>$brands));
32
+ return $this;
33
+ }
34
+
35
+ /**
36
+ * Convert collection items to select options array
37
+ *
38
+ * @return array
39
+ */
40
+ public function toOptionArray()
41
+ {
42
+ $options = $this->_toOptionArray('brandcode', 'brandname');
43
+ usort($options, function($a, $b) {
44
+ return strcasecmp($a['label'],$b['label']);
45
+ });
46
+ return $options;
47
+ }
48
+
49
+ }
app/code/local/Planet/Pay/Model/Resource/Order.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is order resource model
4
+ *
5
+ * Class Planet_Pay_Model_Resource_Order
6
+ */
7
+ class Planet_Pay_Model_Resource_Order extends Mage_Core_Model_Resource_Db_Abstract
8
+ {
9
+ /**
10
+ * Initialize connection and define main table and primary key
11
+ */
12
+ protected function _construct()
13
+ {
14
+ $this->_init('planet_pay/order', 'id');
15
+ }
16
+ }
app/code/local/Planet/Pay/Model/Resource/Order/Collection.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Class Planet_Pay_Model_Resource_Order_Collection
4
+ */
5
+ class Planet_Pay_Model_Resource_Order_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
6
+ {
7
+ /**
8
+ * Define collection model
9
+ */
10
+ protected function _construct()
11
+ {
12
+ $this->_init('planet_pay/order');
13
+ }
14
+
15
+ }
app/code/local/Planet/Pay/Model/Resource/Orderlog.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * This is order log model
4
+ *
5
+ * Class Planet_Pay_Model_Resource_Orderlog
6
+ */
7
+ class Planet_Pay_Model_Resource_Orderlog extends Mage_Core_Model_Resource_Db_Abstract
8
+ {
9
+ /**
10
+ * Initialize connection and define main table and primary key
11
+ */
12
+ protected function _construct()
13
+ {
14
+ $this->_init('planet_pay/orderlog', 'id');
15
+ }
16
+ }
app/code/local/Planet/Pay/Model/Resource/Orderlog/Collection.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ *
4
+ * Class Planet_Pay_Model_Resource_Orderlog_Collection
5
+ */
6
+ class Planet_Pay_Model_Resource_Orderlog_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
7
+ {
8
+ /**
9
+ * Define collection model
10
+ */
11
+ protected function _construct()
12
+ {
13
+ $this->_init('planet_pay/orderlog');
14
+ $this->setOrder('date', 'desc');
15
+ }
16
+
17
+ /**
18
+ * @param Planet_Pay_Model_Order $planetOrder
19
+ * @return $this
20
+ */
21
+ public function setOrderFilter($planetOrder)
22
+ {
23
+ $this->addFilter('planet_order_id', $planetOrder->getId());
24
+ return $this;
25
+ }
26
+
27
+ /**
28
+ * @param $method
29
+ * @return $this
30
+ */
31
+ public function setMethodFilter($method)
32
+ {
33
+ $methodMapper = $this->getMethodMapper();
34
+ $this->addFilter('method_name', $methodMapper[$method]);
35
+ return $this;
36
+ }
37
+
38
+ /**
39
+ * @return $this
40
+ */
41
+ public function setSuccessFilter()
42
+ {
43
+ $this->addFilter('success', true);
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * @return array
49
+ */
50
+ private function getMethodMapper()
51
+ {
52
+ return array(
53
+ 'order_request' => 'SubmitNewOrderResult',
54
+ 'delivery_note' => 'SubmitNewDeliveryResult',
55
+ 'credit_note' => 'SubmitNewCreditResult'
56
+ );
57
+ }
58
+
59
+ }
app/code/local/Planet/Pay/Model/Sales/Order/Payment.php ADDED
@@ -0,0 +1,600 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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_Sales
23
+ * @copyright Copyright (c) 2013 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
+ * Order payment information
29
+ *
30
+ * @method Mage_Sales_Model_Resource_Order_Payment _getResource()
31
+ * @method Mage_Sales_Model_Resource_Order_Payment getResource()
32
+ * @method int getParentId()
33
+ * @method Mage_Sales_Model_Order_Payment setParentId(int $value)
34
+ * @method float getBaseShippingCaptured()
35
+ * @method Mage_Sales_Model_Order_Payment setBaseShippingCaptured(float $value)
36
+ * @method float getShippingCaptured()
37
+ * @method Mage_Sales_Model_Order_Payment setShippingCaptured(float $value)
38
+ * @method float getAmountRefunded()
39
+ * @method Mage_Sales_Model_Order_Payment setAmountRefunded(float $value)
40
+ * @method float getBaseAmountPaid()
41
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountPaid(float $value)
42
+ * @method float getAmountCanceled()
43
+ * @method Mage_Sales_Model_Order_Payment setAmountCanceled(float $value)
44
+ * @method float getBaseAmountAuthorized()
45
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountAuthorized(float $value)
46
+ * @method float getBaseAmountPaidOnline()
47
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountPaidOnline(float $value)
48
+ * @method float getBaseAmountRefundedOnline()
49
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountRefundedOnline(float $value)
50
+ * @method float getBaseShippingAmount()
51
+ * @method Mage_Sales_Model_Order_Payment setBaseShippingAmount(float $value)
52
+ * @method float getShippingAmount()
53
+ * @method Mage_Sales_Model_Order_Payment setShippingAmount(float $value)
54
+ * @method float getAmountPaid()
55
+ * @method Mage_Sales_Model_Order_Payment setAmountPaid(float $value)
56
+ * @method float getAmountAuthorized()
57
+ * @method Mage_Sales_Model_Order_Payment setAmountAuthorized(float $value)
58
+ * @method float getBaseAmountOrdered()
59
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountOrdered(float $value)
60
+ * @method float getBaseShippingRefunded()
61
+ * @method Mage_Sales_Model_Order_Payment setBaseShippingRefunded(float $value)
62
+ * @method float getShippingRefunded()
63
+ * @method Mage_Sales_Model_Order_Payment setShippingRefunded(float $value)
64
+ * @method float getBaseAmountRefunded()
65
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountRefunded(float $value)
66
+ * @method float getAmountOrdered()
67
+ * @method Mage_Sales_Model_Order_Payment setAmountOrdered(float $value)
68
+ * @method float getBaseAmountCanceled()
69
+ * @method Mage_Sales_Model_Order_Payment setBaseAmountCanceled(float $value)
70
+ * @method int getIdealTransactionChecked()
71
+ * @method Mage_Sales_Model_Order_Payment setIdealTransactionChecked(int $value)
72
+ * @method int getQuotePaymentId()
73
+ * @method Mage_Sales_Model_Order_Payment setQuotePaymentId(int $value)
74
+ * @method string getAdditionalData()
75
+ * @method Mage_Sales_Model_Order_Payment setAdditionalData(string $value)
76
+ * @method string getCcExpMonth()
77
+ * @method Mage_Sales_Model_Order_Payment setCcExpMonth(string $value)
78
+ * @method string getCcSsStartYear()
79
+ * @method Mage_Sales_Model_Order_Payment setCcSsStartYear(string $value)
80
+ * @method string getEcheckBankName()
81
+ * @method Mage_Sales_Model_Order_Payment setEcheckBankName(string $value)
82
+ * @method string getMethod()
83
+ * @method Mage_Sales_Model_Order_Payment setMethod(string $value)
84
+ * @method string getCcDebugRequestBody()
85
+ * @method Mage_Sales_Model_Order_Payment setCcDebugRequestBody(string $value)
86
+ * @method string getCcSecureVerify()
87
+ * @method Mage_Sales_Model_Order_Payment setCcSecureVerify(string $value)
88
+ * @method string getCybersourceToken()
89
+ * @method Mage_Sales_Model_Order_Payment setCybersourceToken(string $value)
90
+ * @method string getIdealIssuerTitle()
91
+ * @method Mage_Sales_Model_Order_Payment setIdealIssuerTitle(string $value)
92
+ * @method string getProtectionEligibility()
93
+ * @method Mage_Sales_Model_Order_Payment setProtectionEligibility(string $value)
94
+ * @method string getCcApproval()
95
+ * @method Mage_Sales_Model_Order_Payment setCcApproval(string $value)
96
+ * @method string getCcLast4()
97
+ * @method Mage_Sales_Model_Order_Payment setCcLast4(string $value)
98
+ * @method string getCcStatusDescription()
99
+ * @method Mage_Sales_Model_Order_Payment setCcStatusDescription(string $value)
100
+ * @method string getEcheckType()
101
+ * @method Mage_Sales_Model_Order_Payment setEcheckType(string $value)
102
+ * @method string getPayboxQuestionNumber()
103
+ * @method Mage_Sales_Model_Order_Payment setPayboxQuestionNumber(string $value)
104
+ * @method string getCcDebugResponseSerialized()
105
+ * @method Mage_Sales_Model_Order_Payment setCcDebugResponseSerialized(string $value)
106
+ * @method string getCcSsStartMonth()
107
+ * @method Mage_Sales_Model_Order_Payment setCcSsStartMonth(string $value)
108
+ * @method string getEcheckAccountType()
109
+ * @method Mage_Sales_Model_Order_Payment setEcheckAccountType(string $value)
110
+ * @method string getLastTransId()
111
+ * @method Mage_Sales_Model_Order_Payment setLastTransId(string $value)
112
+ * @method string getCcCidStatus()
113
+ * @method Mage_Sales_Model_Order_Payment setCcCidStatus(string $value)
114
+ * @method string getCcOwner()
115
+ * @method Mage_Sales_Model_Order_Payment setCcOwner(string $value)
116
+ * @method string getCcType()
117
+ * @method Mage_Sales_Model_Order_Payment setCcType(string $value)
118
+ * @method string getIdealIssuerId()
119
+ * @method Mage_Sales_Model_Order_Payment setIdealIssuerId(string $value)
120
+ * @method string getPoNumber()
121
+ * @method Mage_Sales_Model_Order_Payment setPoNumber(string $value)
122
+ * @method string getCcExpYear()
123
+ * @method Mage_Sales_Model_Order_Payment setCcExpYear(string $value)
124
+ * @method string getCcStatus()
125
+ * @method Mage_Sales_Model_Order_Payment setCcStatus(string $value)
126
+ * @method string getEcheckRoutingNumber()
127
+ * @method Mage_Sales_Model_Order_Payment setEcheckRoutingNumber(string $value)
128
+ * @method string getAccountStatus()
129
+ * @method Mage_Sales_Model_Order_Payment setAccountStatus(string $value)
130
+ * @method string getAnetTransMethod()
131
+ * @method Mage_Sales_Model_Order_Payment setAnetTransMethod(string $value)
132
+ * @method string getCcDebugResponseBody()
133
+ * @method Mage_Sales_Model_Order_Payment setCcDebugResponseBody(string $value)
134
+ * @method string getCcSsIssue()
135
+ * @method Mage_Sales_Model_Order_Payment setCcSsIssue(string $value)
136
+ * @method string getEcheckAccountName()
137
+ * @method Mage_Sales_Model_Order_Payment setEcheckAccountName(string $value)
138
+ * @method string getCcAvsStatus()
139
+ * @method Mage_Sales_Model_Order_Payment setCcAvsStatus(string $value)
140
+ * @method string getCcNumberEnc()
141
+ * @method Mage_Sales_Model_Order_Payment setCcNumberEnc(string $value)
142
+ * @method string getCcTransId()
143
+ * @method Mage_Sales_Model_Order_Payment setCcTransId(string $value)
144
+ * @method string getFlo2cashAccountId()
145
+ * @method Mage_Sales_Model_Order_Payment setFlo2cashAccountId(string $value)
146
+ * @method string getPayboxRequestNumber()
147
+ * @method Mage_Sales_Model_Order_Payment setPayboxRequestNumber(string $value)
148
+ * @method string getAddressStatus()
149
+ * @method Mage_Sales_Model_Order_Payment setAddressStatus(string $value)
150
+ *
151
+ * @category Mage
152
+ * @package Mage_Sales
153
+ * @author Magento Core Team <core@magentocommerce.com>
154
+ */
155
+ class Planet_Pay_Model_Sales_Order_Payment extends Mage_Payment_Model_Info
156
+ {
157
+ /**
158
+ * Actions for payment when it triggered review state:
159
+ *
160
+ * Accept action
161
+ */
162
+ const REVIEW_ACTION_ACCEPT = 'accept';
163
+
164
+ /**
165
+ * Deny action
166
+ */
167
+ const REVIEW_ACTION_DENY = 'deny';
168
+
169
+ /**
170
+ * Update action
171
+ */
172
+ const REVIEW_ACTION_UPDATE = 'update';
173
+
174
+ /**
175
+ * Order model object
176
+ *
177
+ * @var Mage_Sales_Model_Order
178
+ */
179
+ protected $_order;
180
+
181
+ /**
182
+ * Billing agreement instance that may be created during payment processing
183
+ *
184
+ * @var Mage_Sales_Model_Billing_Agreement
185
+ */
186
+ protected $_billingAgreement = null;
187
+
188
+ /**
189
+ * Whether can void
190
+ * @var string
191
+ */
192
+ protected $_canVoidLookup = null;
193
+
194
+ /**
195
+ * Transactions registry to spare resource calls
196
+ * array(txn_id => sales/order_payment_transaction)
197
+ * @var array
198
+ */
199
+ protected $_transactionsLookup = array();
200
+
201
+ /**
202
+ * Event prefix
203
+ *
204
+ * @var string
205
+ */
206
+ protected $_eventPrefix = 'sales_order_payment';
207
+
208
+ /**
209
+ * Event object
210
+ *
211
+ * @var string
212
+ */
213
+ protected $_eventObject = 'payment';
214
+
215
+ /**
216
+ * Transaction addditional information container
217
+ *
218
+ * @var array
219
+ */
220
+ protected $_transactionAdditionalInfo = array();
221
+
222
+ /**
223
+ * Initialize resource model
224
+ */
225
+ protected function _construct()
226
+ {
227
+ $this->_init('sales/order_payment');
228
+ }
229
+ /**
230
+ * Decide whether authorization transaction may close (if the amount to capture will cover entire order)
231
+ * @param float $amountToCapture
232
+ * @return bool
233
+ */
234
+ protected function _isCaptureFinal($amountToCapture)
235
+ {
236
+ $amountToCapture = $this->_formatAmount($amountToCapture, true);
237
+ $orderGrandTotal = $this->_formatAmount($this->getOrder()->getBaseGrandTotal(), true);
238
+ if ($orderGrandTotal == $this->_formatAmount($this->getBaseAmountPaid(), true) + $amountToCapture) {
239
+ if (false !== $this->getShouldCloseParentTransaction()) {
240
+ $this->setShouldCloseParentTransaction(true);
241
+ }
242
+ return true;
243
+ }
244
+ return false;
245
+ }
246
+ /**
247
+ * Round up and cast specified amount to float or string
248
+ *
249
+ * @param string|float $amount
250
+ * @param bool $asFloat
251
+ * @return string|float
252
+ */
253
+ protected function _formatAmount($amount, $asFloat = false)
254
+ {
255
+ $amount = Mage::app()->getStore()->roundPrice($amount);
256
+ return !$asFloat ? (string)$amount : $amount;
257
+ }
258
+ // /**
259
+ // * TODO: implement this
260
+ // * @param Mage_Sales_Model_Order_Invoice $invoice
261
+ // * @return Mage_Sales_Model_Order_Payment
262
+ // */
263
+ // public function cancelCapture($invoice = null)
264
+ // {
265
+ // }
266
+
267
+ /**
268
+ * Create transaction,
269
+ * prepare its insertion into hierarchy and add its information to payment and comments
270
+ *
271
+ * To add transactions and related information,
272
+ * the following information should be set to payment before processing:
273
+ * - transaction_id
274
+ * - is_transaction_closed (optional) - whether transaction should be closed or open (closed by default)
275
+ * - parent_transaction_id (optional)
276
+ * - should_close_parent_transaction (optional) - whether to close parent transaction (closed by default)
277
+ *
278
+ * If the sales document is specified, it will be linked to the transaction as related for future usage.
279
+ * Currently transaction ID is set into the sales object
280
+ * This method writes the added transaction ID into last_trans_id field of the payment object
281
+ *
282
+ * To make sure transaction object won't cause trouble before saving, use $failsafe = true
283
+ *
284
+ * @param string $type
285
+ * @param Mage_Sales_Model_Abstract $salesDocument
286
+ * @param bool $failsafe
287
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
288
+ */
289
+ protected function _addTransaction($type, $salesDocument = null, $failsafe = false)
290
+ {
291
+ if ($this->getSkipTransactionCreation()) {
292
+ $this->unsTransactionId();
293
+ return null;
294
+ }
295
+
296
+ // look for set transaction ids
297
+ $transactionId = $this->getTransactionId();
298
+ if (null !== $transactionId) {
299
+ // set transaction parameters
300
+ $transaction = false;
301
+ if ($this->getOrder()->getId()) {
302
+ $transaction = $this->_lookupTransaction($transactionId);
303
+ }
304
+ if (!$transaction) {
305
+ $transaction = Mage::getModel('sales/order_payment_transaction')->setTxnId($transactionId);
306
+ }
307
+ $transaction
308
+ ->setOrderPaymentObject($this)
309
+ ->setTxnType($type)
310
+ ->isFailsafe($failsafe);
311
+
312
+ if ($this->hasIsTransactionClosed()) {
313
+ $transaction->setIsClosed((int)$this->getIsTransactionClosed());
314
+ }
315
+
316
+ //set transaction addition information
317
+ if ($this->_transactionAdditionalInfo) {
318
+ foreach ($this->_transactionAdditionalInfo as $key => $value) {
319
+ $transaction->setAdditionalInformation($key, $value);
320
+ }
321
+ }
322
+
323
+ // link with sales entities
324
+ $this->setLastTransId($transactionId);
325
+ $this->setCreatedTransaction($transaction);
326
+ $this->getOrder()->addRelatedObject($transaction);
327
+ if ($salesDocument && $salesDocument instanceof Mage_Sales_Model_Abstract) {
328
+ $salesDocument->setTransactionId($transactionId);
329
+ // TODO: linking transaction with the sales document
330
+ }
331
+
332
+ // link with parent transaction
333
+ $parentTransactionId = $this->getParentTransactionId();
334
+
335
+ if ($parentTransactionId) {
336
+ $transaction->setParentTxnId($parentTransactionId);
337
+ if ($this->getShouldCloseParentTransaction()) {
338
+ $parentTransaction = $this->_lookupTransaction($parentTransactionId);
339
+ if ($parentTransaction) {
340
+ if (!$parentTransaction->getIsClosed()) {
341
+ $parentTransaction->isFailsafe($failsafe)->close(false);
342
+ }
343
+ $this->getOrder()->addRelatedObject($parentTransaction);
344
+ }
345
+ }
346
+ }
347
+ return $transaction;
348
+ }
349
+ }
350
+ /**
351
+ * Public acces to _addTransaction method
352
+ *
353
+ * @param string $type
354
+ * @param Mage_Sales_Model_Abstract $salesDocument
355
+ * @param bool $failsafe
356
+ * @param string $message
357
+ * @return null|Mage_Sales_Model_Order_Payment_Transaction
358
+ */
359
+ public function addTransaction($type, $salesDocument = null, $failsafe = false, $message = false)
360
+ {
361
+ $transaction = $this->_addTransaction($type, $salesDocument, $failsafe);
362
+
363
+ if ($message) {
364
+ $order = $this->getOrder();
365
+ $message = $this->_appendTransactionToMessage($transaction, $message);
366
+ $order->addStatusHistoryComment($message);
367
+ }
368
+
369
+ return $transaction;
370
+ }
371
+ /**
372
+ * Prepend a "prepared_message" that may be set to the payment instance before, to the specified message
373
+ * Prepends value to the specified string or to the comment of specified order status history item instance
374
+ *
375
+ * @param string|Mage_Sales_Model_Order_Status_History $messagePrependTo
376
+ * @return string|Mage_Sales_Model_Order_Status_History
377
+ */
378
+ protected function _prependMessage($messagePrependTo)
379
+ {
380
+ $preparedMessage = $this->getPreparedMessage();
381
+ if ($preparedMessage) {
382
+ if (is_string($preparedMessage)) {
383
+ return $preparedMessage . ' ' . $messagePrependTo;
384
+ } elseif (is_object($preparedMessage)
385
+ && ($preparedMessage instanceof Mage_Sales_Model_Order_Status_History)
386
+ ) {
387
+ $comment = $preparedMessage->getComment() . ' ' . $messagePrependTo;
388
+ $preparedMessage->setComment($comment);
389
+ return $comment;
390
+ }
391
+ }
392
+ return $messagePrependTo;
393
+ }
394
+ /**
395
+ * Authorize payment either online or offline (process auth notification)
396
+ * Updates transactions hierarchy, if required
397
+ * Prevents transaction double processing
398
+ * Updates payment totals, updates order status and adds proper comments
399
+ *
400
+ * @param bool $isOnline
401
+ * @param float $amount
402
+ * @return Mage_Sales_Model_Order_Payment
403
+ */
404
+ protected function _authorize($isOnline, $amount)
405
+ {
406
+ // check for authorization amount to be equal to grand total
407
+ $this->setShouldCloseParentTransaction(false);
408
+ if (!$this->_isCaptureFinal($amount)) {
409
+ $this->setIsFraudDetected(true);
410
+ }
411
+
412
+ // update totals
413
+ $amount = $this->_formatAmount($amount, true);
414
+ $this->setBaseAmountAuthorized($amount);
415
+
416
+ // do authorization
417
+ $order = $this->getOrder();
418
+ $state = Mage_Sales_Model_Order::STATE_PROCESSING;
419
+ $status = true;
420
+ if ($isOnline) {
421
+ // invoke authorization on gateway
422
+ $this->getMethodInstance()->setStore($order->getStoreId())->authorize($this, $amount);
423
+ }
424
+
425
+ // similar logic of "payment review" order as in capturing
426
+ if ($this->getIsTransactionPending()) {
427
+ $message = Mage::helper('sales')->__('Authorizing amount of %s is pending approval on gateway.', $this->_formatPrice($amount));
428
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
429
+ if ($this->getIsFraudDetected()) {
430
+ $status = Mage_Sales_Model_Order::STATUS_FRAUD;
431
+ }
432
+ } else {
433
+ if ($this->getIsFraudDetected()) {
434
+ $state = Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW;
435
+ $message = Mage::helper('sales')->__('Order is suspended as its authorizing amount %s is suspected to be fraudulent.', $this->_formatPrice($amount));
436
+ $status = Mage_Sales_Model_Order::STATUS_FRAUD;
437
+ } else {
438
+ $message = Mage::helper('sales')->__('Authorized amount of %s.', $this->_formatPrice($amount));
439
+ }
440
+ }
441
+
442
+ // update transactions, order state and add comments
443
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
444
+ if ($order->isNominal()) {
445
+ $message = $this->_prependMessage(Mage::helper('sales')->__('Nominal order registered.'));
446
+ } else {
447
+ $message = $this->_prependMessage($message);
448
+ $message = $this->_appendTransactionToMessage($transaction, $message);
449
+ }
450
+ $order->setState($state, $status, $message);
451
+
452
+ return $this;
453
+ }
454
+ /**
455
+ * Authorize or authorize and capture payment on gateway, if applicable
456
+ * This method is supposed to be called only when order is placed
457
+ *
458
+ * @return Mage_Sales_Model_Order_Payment
459
+ */
460
+ public function place()
461
+ {
462
+ Mage::dispatchEvent('sales_order_payment_place_start', array('payment' => $this));
463
+ $order = $this->getOrder();
464
+
465
+ $this->setAmountOrdered($order->getTotalDue());
466
+ $this->setBaseAmountOrdered($order->getBaseTotalDue());
467
+ $this->setShippingAmount($order->getShippingAmount());
468
+ $this->setBaseShippingAmount($order->getBaseShippingAmount());
469
+
470
+ $methodInstance = $this->getMethodInstance();
471
+ $methodInstance->setStore($order->getStoreId());
472
+ $orderState = Mage_Sales_Model_Order::STATE_NEW;
473
+ $stateObject = new Varien_Object();
474
+
475
+ /**
476
+ * Do order payment validation on payment method level
477
+ */
478
+ //$methodInstance->validate();
479
+ $action = $methodInstance->getConfigPaymentAction();
480
+ if ($action) {
481
+ if ($methodInstance->isInitializeNeeded()) {
482
+ /**
483
+ * For method initialization we have to use original config value for payment action
484
+ */
485
+ $methodInstance->initialize($methodInstance->getConfigData('payment_action'), $stateObject);
486
+ } else {
487
+ $orderState = Mage_Sales_Model_Order::STATE_PROCESSING;
488
+ switch ($action) {
489
+ case Mage_Payment_Model_Method_Abstract::ACTION_ORDER:
490
+ $this->_order($order->getBaseTotalDue());
491
+ break;
492
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE:
493
+ $this->_authorize(true, $order->getBaseTotalDue()); // base amount will be set inside
494
+ $this->setAmountAuthorized($order->getTotalDue());
495
+ break;
496
+ case Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE:
497
+ $this->setAmountAuthorized($order->getTotalDue());
498
+ $this->setBaseAmountAuthorized($order->getBaseTotalDue());
499
+ $this->capture(null);
500
+ break;
501
+ default:
502
+ break;
503
+ }
504
+ }
505
+ }
506
+
507
+ $this->_createBillingAgreement();
508
+
509
+ $orderIsNotified = null;
510
+ if ($stateObject->getState() && $stateObject->getStatus()) {
511
+ $orderState = $stateObject->getState();
512
+ $orderStatus = $stateObject->getStatus();
513
+ $orderIsNotified = $stateObject->getIsNotified();
514
+ } else {
515
+ $orderStatus = $methodInstance->getConfigData('order_status');
516
+ if (!$orderStatus) {
517
+ $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
518
+ } else {
519
+ // check if $orderStatus has assigned a state
520
+ $states = $order->getConfig()->getStatusStates($orderStatus);
521
+ if (count($states) == 0) {
522
+ $orderStatus = $order->getConfig()->getStateDefaultStatus($orderState);
523
+ }
524
+ }
525
+ }
526
+ $isCustomerNotified = (null !== $orderIsNotified) ? $orderIsNotified : $order->getCustomerNoteNotify();
527
+ $message = $order->getCustomerNote();
528
+
529
+ // add message if order was put into review during authorization or capture
530
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
531
+ if ($message) {
532
+ $order->addStatusToHistory($order->getStatus(), $message, $isCustomerNotified);
533
+ }
534
+ } elseif ($order->getState() && ($orderStatus !== $order->getStatus() || $message)) {
535
+ // add message to history if order state already declared
536
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
537
+ } elseif (($order->getState() != $orderState) || ($order->getStatus() != $orderStatus) || $message) {
538
+ // set order state
539
+ $order->setState($orderState, $orderStatus, $message, $isCustomerNotified);
540
+ }
541
+
542
+ Mage::dispatchEvent('sales_order_payment_place_end', array('payment' => $this));
543
+
544
+ return $this;
545
+ }
546
+
547
+
548
+ /**
549
+ * Void payment either online or offline (process void notification)
550
+ * NOTE: that in some cases authorization can be voided after a capture. In such case it makes sense to use
551
+ * the amount void amount, for informational purposes.
552
+ * Updates payment totals, updates order status and adds proper comments
553
+ *
554
+ * @param bool $isOnline
555
+ * @param float $amount
556
+ * @param string $gatewayCallback
557
+ * @return Mage_Sales_Model_Order_Payment
558
+ */
559
+ protected function _void($isOnline, $amount = null, $gatewayCallback = 'void')
560
+ {
561
+ $order = $this->getOrder();
562
+ $authTransaction = $this->getAuthorizationTransaction();
563
+ $this->_generateTransactionId(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, $authTransaction);
564
+ $this->setShouldCloseParentTransaction(true);
565
+
566
+ // attempt to void
567
+ if ($isOnline) {
568
+ $this->getMethodInstance()->setStore($order->getStoreId())->$gatewayCallback($this);
569
+ }
570
+ if ($this->_isTransactionExists()) {
571
+ return $this;
572
+ }
573
+
574
+ // if the authorization was untouched, we may assume voided amount = order grand total
575
+ // but only if the payment auth amount equals to order grand total
576
+ if ($authTransaction && ($order->getBaseGrandTotal() == $this->getBaseAmountAuthorized())
577
+ && (0 == $this->getBaseAmountCanceled())) {
578
+ if ($authTransaction->canVoidAuthorizationCompletely()) {
579
+ $amount = (float)$order->getBaseGrandTotal();
580
+ }
581
+ }
582
+
583
+ if ($amount) {
584
+ $amount = $this->_formatAmount($amount);
585
+ }
586
+
587
+ // update transactions, order state and add comments
588
+ $transaction = $this->_addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_VOID, null, true);
589
+ $message = $this->hasMessage() ? $this->getMessage() : Mage::helper('sales')->__('Voided authorization.');
590
+ $message = $this->_prependMessage($message);
591
+ if ($amount) {
592
+ $message .= ' ' . Mage::helper('sales')->__('Amount: %s.', $this->_formatPrice($amount));
593
+ }
594
+ $message = $this->_appendTransactionToMessage($transaction, $message);
595
+ // $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
596
+ return $this;
597
+ }
598
+
599
+
600
+ }
app/code/local/Planet/Pay/Model/Select.php ADDED
@@ -0,0 +1,511 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * This Is payment model class to process the backend API process
5
+ *
6
+ * Class Planet_Pay_Model_Select
7
+ */
8
+ class Planet_Pay_Model_Select extends Mage_Payment_Model_Method_Abstract {
9
+ /*
10
+ * constant for action order
11
+ */
12
+
13
+ const ACTION_ORDER = 'order';
14
+
15
+ /**
16
+ * constant for action authorize
17
+ */
18
+ const ACTION_AUTHORIZE = 'authorize';
19
+
20
+ /**
21
+ * Contant for action authorize and capture
22
+ */
23
+ const ACTION_AUTHORIZE_CAPTURE = 'authorize_capture';
24
+
25
+ /**
26
+ * log file used for common issue
27
+ */
28
+ const LOG_FILE = 'planet_log.txt';
29
+
30
+ /**
31
+ * To hold the server credentils needed
32
+ *
33
+ * @var string
34
+ */
35
+ protected $_planetPaymentOptions;
36
+
37
+ /**
38
+ * Payment method code
39
+ *
40
+ * @var string
41
+ */
42
+ protected $_code = 'planet_pay';
43
+
44
+ /**
45
+ * To hold the form block class
46
+ *
47
+ * @var string
48
+ */
49
+ protected $_formBlockType = 'planet_pay/form_pay';
50
+ protected $_infoBlockType = 'planet_pay/info_pay';
51
+
52
+ /**
53
+ * To check wether gateway or not
54
+ *
55
+ * @var bool
56
+ */
57
+ protected $_isGateway = true;
58
+
59
+ /**
60
+ * To check for authorize support
61
+ *
62
+ * @var bool
63
+ */
64
+ protected $_canAuthorize = true;
65
+
66
+ /**
67
+ * To check for capture support
68
+ *
69
+ * @var bool
70
+ */
71
+ protected $_canCapture = true;
72
+
73
+ /**
74
+ * For partial capture
75
+ *
76
+ * @var bool
77
+ */
78
+ protected $_canCapturePartial = true;
79
+
80
+ /**
81
+ * To check for refund support
82
+ *
83
+ * @var bool
84
+ */
85
+ protected $_canRefund = true;
86
+
87
+ /**
88
+ * To Check for void support
89
+ *
90
+ * @var bool
91
+ */
92
+ protected $_canVoid = true;
93
+
94
+ /**
95
+ * To cehck for cancel invoice support
96
+ *
97
+ * @var bool
98
+ */
99
+ protected $_canCancelInvoice = false;
100
+
101
+ /**
102
+ * Magento assign data for info object
103
+ *
104
+ * @param mixed $data
105
+ * @return $this
106
+ */
107
+ public function assignData($data) {
108
+ if (!($data instanceof Varien_Object)) {
109
+ $data = new Varien_Object($data);
110
+ }
111
+ /* This is old code used in previous API */
112
+
113
+ //$result = Mage::getSingleton('core/session')->getResult();
114
+
115
+ $info = $this->getInfoInstance();
116
+
117
+ /* This is old code used in previous API */
118
+
119
+ /* if(!empty($result) && $result != null){
120
+ $cardarr = $result->toArray();
121
+ $carddetail = $cardarr['card'];
122
+ $info->cc_exp_month = $carddetail['expiryMonth'];
123
+ $info->cc_exp_year = $carddetail['expiryYear'];
124
+ } */
125
+
126
+ $info->setPlanetPaymentMethod($data->getPlanetPaymentMethod());
127
+ $onePage = Mage::getSingleton('checkout/type_onepage');
128
+ $onePage->getCheckout()->setPlanetPaymentMethod($data->getPlanetPaymentMethod());
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Authorize Method
134
+ *
135
+ * @param Varien_Object $payment
136
+ * @param type $amount
137
+ * @return \Planet_Pay_Model_Select
138
+ */
139
+ public function authorize(Varien_Object $payment, $amount) {
140
+
141
+ $order = $payment->getOrder();
142
+ $orderId = $order->getIncrementId();
143
+ $info = $this->getInfoInstance();
144
+ $status = Mage::getSingleton('core/session')->getResult();
145
+ $token = Mage::getSingleton('core/session')->getToken();
146
+ if (!is_array($status)) {
147
+ $status = $status->toArray();
148
+ }
149
+ // To store the payment card data
150
+ try {
151
+ if (!empty($status['card'])) {
152
+ $payment->setAdditionalInformation($status['threeDSecure']);
153
+ $payment->setCcLast4($status['card']['last4Digits']);
154
+ $payment->setCcOwner($status['card']['holder']);
155
+ $payment->setCcType($status['paymentBrand']);
156
+ $payment->setCcExpMonth($status['card']['expiryMonth']);
157
+ $payment->setCcExpYear($status['card']['expiryYear']);
158
+ $payment->setTransactionId($orderId);
159
+ $payment->setIsTransactionClosed(false);
160
+ } else {
161
+ $resource = Mage::getSingleton('core/resource');
162
+ $readConnection = $resource->getConnection('core_read');
163
+ $table = $resource->getTableName('planet_pay/carddetail');
164
+ $query = $readConnection->select()
165
+ ->from($table, array('id', 'registeration_id', 'brand_name', 'cc_last_four', 'cc_exp_month', 'cc_exp_year', 'holder')) // select * from tablename or use array('id','title') selected values
166
+ ->where('registeration_id=?', $token) // where id =1
167
+ ->limit('1');
168
+ $results = $readConnection->fetchAll($query);
169
+ $payment->setCcLast4($results[0]['cc_last_four']);
170
+ $payment->setAdditionalInformation($results[0]['id']);
171
+ $payment->setCcOwner($results[0]['holder']);
172
+ $payment->setCcType($results[0]['brand_name']);
173
+ $payment->setCcExpMonth($results[0]['cc_exp_month']);
174
+ $payment->setCcExpYear($results[0]['cc_exp_year']);
175
+ }
176
+ return $this;
177
+ } catch (Exception $ex) {
178
+ Mage::log($ex->getMessage(), null, Planet_Pay_Model_Select::LOG_FILE);
179
+ }
180
+ }
181
+
182
+ /**
183
+ * Capture Method
184
+ *
185
+ * @param Varien_Object $payment
186
+ * @param type $amount
187
+ * @return \Planet_Pay_Model_Select
188
+ */
189
+ public function capture(Varien_Object $payment, $amount) {
190
+
191
+ if (!$payment->getTransactionId() && $this->getConfigData('payment_action') == self::ACTION_AUTHORIZE_CAPTURE) {
192
+ $status = Mage::getSingleton('core/session')->getResult();
193
+ $code = $status['result']['code'];
194
+ $description = $status['result']['description'];
195
+ $amount = $payment->amount_ordered;
196
+ return $this->sale($payment, $amount, $code, $description);
197
+ }
198
+ $order = $payment->getOrder();
199
+ $amount = $payment->amount_ordered;
200
+ $result = $this->callApi($payment, $amount, 'CP');
201
+ if (substr($result["status"], 0, 3) !== "000") {
202
+ $errorMsg = $result["status"] . '/' . $result["description"];
203
+ } else {
204
+ Mage::log($result, null, $this->getCode() . 'capture.log');
205
+ //process result here to check status etc as per payment gateway.
206
+ // if invalid status throw exception
207
+ // $code = $result['result']['code'];
208
+ if (substr($result["status"], 0, 3) === "000") {
209
+ $payment->setTransactionId($result['merchantTransactionId']);
210
+ /* $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1' => 'value1', 'key2' => 'value2')); */
211
+ } else {
212
+ Mage::throwException($errorMsg);
213
+ }
214
+
215
+ // Add the comment and save the order
216
+ }
217
+ if ($errorMsg) {
218
+ Mage::throwException($errorMsg);
219
+ }
220
+
221
+ return $this;
222
+ }
223
+
224
+ public function sale(Varien_Object $payment, $amount, $code, $description) {
225
+ $order = $payment->getOrder();
226
+ $authresp = Mage::getSingleton('core/session')->getResult();
227
+ if (!is_array($authresp)) {
228
+ $authresp = $authresp->toArray();
229
+ }
230
+ // $result = $this->callApi($payment, $amount, 'DB');
231
+ if (substr($code, 0, 3) !== "000") {
232
+ $errorMsg = $code . '/' . $description;
233
+ } else {
234
+ Mage::log($result, null, $this->getCode() . 'debit.log');
235
+ //process result here to check status etc as per payment gateway.
236
+ // if invalid status throw exception
237
+ // $code = $result['result']['code'];
238
+ if (substr($code, 0, 3) === "000") {
239
+ $payment->setCcLast4($authresp['card']['last4Digits']);
240
+ $payment->setCcOwner($authresp['card']['holder']);
241
+ $payment->setCcType($authresp['paymentBrand']);
242
+ $payment->setCcExpMonth($authresp['card']['expiryMonth']);
243
+ $payment->setCcExpYear($authresp['card']['expiryYear']);
244
+ $payment->setTransactionId(rand(0, 1000));
245
+ /* $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1' => 'value1', 'key2' => 'value2')); */
246
+ } else {
247
+ Mage::throwException($errorMsg);
248
+ }
249
+
250
+ // Add the comment and save the order
251
+ }
252
+ if ($errorMsg) {
253
+ $payment->setCcLast4($authresp['card']['last4Digits']);
254
+ $payment->setCcOwner($authresp['card']['holder']);
255
+ $payment->setCcType($authresp['paymentBrand']);
256
+ $payment->setCcExpMonth($authresp['card']['expiryMonth']);
257
+ $payment->setCcExpYear($authresp['card']['expiryYear']);
258
+ $payment->setTransactionId(rand(0, 1000));
259
+ }
260
+
261
+ return $this;
262
+ }
263
+
264
+ /**
265
+ *
266
+ * @param Varien_Object $payment
267
+ * @param type $amount
268
+ * @return \Planet_Pay_Model_Select
269
+ */
270
+ public function refund(Varien_Object $payment, $amount) {
271
+
272
+ $order = $payment->getOrder();
273
+ $amount = $payment->amount_ordered;
274
+ $result = $this->callApi($payment, $amount, 'RF');
275
+ if (substr($result["status"], 0, 3) !== "000") {
276
+ $errorMsg = $result["status"] . '/' . $result["description"];
277
+ Mage::throwException($errorMsg);
278
+ } else {
279
+ Mage::log($result, null, $this->getCode() . 'refund.log');
280
+ //process result here to check status etc as per payment gateway.
281
+ // if invalid status throw exception
282
+ // $code = $result['result']['code'];
283
+ if (substr($result["status"], 0, 3) === "000") {
284
+ $payment->setTransactionId($result['merchantTransactionId']);
285
+ /* $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1' => 'value1', 'key2' => 'value2')); */
286
+ } else {
287
+ Mage::throwException($errorMsg);
288
+ }
289
+
290
+ // Add the comment and save the order
291
+ }
292
+ return $this;
293
+ }
294
+
295
+ /**
296
+ * Void Payment
297
+ *
298
+ * @param Varien_Object $payment
299
+ * @return \Planet_Pay_Model_Select
300
+ */
301
+ public function void(Varien_Object $payment) {
302
+ $order = $payment->getOrder();
303
+ $amount = $payment->amount_ordered;
304
+ $result = $this->callApi($payment, $amount, 'RV');
305
+ if (substr($result["status"], 0, 3) !== "000") {
306
+ $errorMsg = $result["status"] . '/' . $result["description"];
307
+ Mage::throwException($errorMsg);
308
+ } else {
309
+ Mage::log($result, null, $this->getCode() . 'void.log');
310
+ //process result here to check status etc as per payment gateway.
311
+ // if invalid status throw exception
312
+ // $code = $result['result']['code'];
313
+ if (substr($result["status"], 0, 3) === "000") {
314
+ $payment->setTransactionId($result['merchantTransactionId']);
315
+ $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, 'canceled', '', false)->save();
316
+ /* $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1' => 'value1', 'key2' => 'value2')); */
317
+ } else {
318
+ Mage::throwException($errorMsg);
319
+ }
320
+
321
+ // Add the comment and save the order
322
+ }
323
+ return $this;
324
+ }
325
+
326
+ /**
327
+ * Cancel payment
328
+ *
329
+ * @param Varien_Object $payment
330
+ * @return \Planet_Pay_Model_Select
331
+ */
332
+ public function cancel(Varien_Object $payment) {
333
+ $amount = $payment->amount_ordered;
334
+ $result = $this->callApi($payment, $amount, 'RV');
335
+ if (substr($result["status"], 0, 3) !== "000") {
336
+ $errorMsg = $result["status"] . '/' . $result["description"];
337
+ Mage::throwException($errorMsg);
338
+ } else {
339
+ Mage::log($result, null, $this->getCode() . 'cancel.log');
340
+ //process result here to check status etc as per payment gateway.
341
+ // if invalid status throw exception
342
+ // $code = $result['result']['code'];
343
+ if (substr($result["status"], 0, 3) === "000") {
344
+ $payment->setTransactionId($result['merchantTransactionId']);
345
+ /* $payment->setTransactionAdditionalInfo(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, array('key1' => 'value1', 'key2' => 'value2')); */
346
+ } else {
347
+ Mage::throwException($errorMsg);
348
+ }
349
+
350
+ // Add the comment and save the order
351
+ }
352
+ return $this;
353
+ }
354
+
355
+ /**
356
+ * This method call the gateway backend api
357
+ *
358
+ * @param Varien_Object $payment
359
+ * @param type $amount
360
+ * @param type $type
361
+ * @return type
362
+ */
363
+ private function callApi(Varien_Object $payment, $amount, $filename) {
364
+
365
+ $this->_planetPaymentOptions = Mage::getStoreConfig('payment/planet_pay');
366
+ $order = $payment->getOrder();
367
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
368
+ $cctypes = $payment->getCcType();
369
+ $billingaddress = $order->getBillingAddress();
370
+ $totals = number_format($amount, 2, '.', '');
371
+ $orderId = $order->getIncrementId();
372
+ if ($filename != 'DB') {
373
+ $resource = Mage::getSingleton('core/resource');
374
+ $readConnection = $resource->getConnection('core_read');
375
+ $table = $resource->getTableName('planet_pay/order');
376
+ // $query = 'SELECT payment_response FROM ' . $table . ' WHERE order_id = '
377
+ // . (int) $orderId . ' LIMIT 1';
378
+ // $results = $readConnection->fetchOne($query);
379
+ $query = $readConnection->select()
380
+ ->from($table, array('payment_response')) // select * from tablename or use array('id','title') selected values
381
+ ->where('order_id=?', $orderId) // where id =1
382
+ ->limit('1');
383
+ $results = $readConnection->fetchOne($query);
384
+ $result_arr = json_decode($results, true);
385
+ $token_payment = $result_arr['id'];
386
+ } else {
387
+ $authresp = Mage::getSingleton('core/session')->getResult($result);
388
+ $authresp = $authresp->toArray();
389
+ $token_payment = $authresp['id'];
390
+ }
391
+ //This code used in previous API
392
+
393
+ /* $Ordermodel = Mage::getModel('planet_pay/order')->load($orderId);
394
+ $paymentresposne = $orderdetail->getPaymentResponse();
395
+ $pay_res_arr = json_decode($paymentresposne->toArray()); */
396
+
397
+ $currencyDesc = $order->getOrderCurrencyCode();
398
+
399
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
400
+ if ($testMode) {
401
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
402
+ $url.="/v1/payments/" . $token_payment;
403
+ } else {
404
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
405
+ $url.="/v1/payments/" . $token_payment;
406
+ }
407
+ if ($filename != 'RV') {
408
+
409
+ if ($testMode) {
410
+ $fields = array(
411
+ 'referencedPaymentId' => $token_payment,
412
+ 'authentication.userId' => $this->_planetPaymentOptions['authentication_userId_test'],
413
+ 'authentication.password' => $this->_planetPaymentOptions['authentication_password_test'],
414
+ 'authentication.entityId' => $this->_planetPaymentOptions['authentication_entityId_test'],
415
+ 'merchantInvoiceId' => $orderId,
416
+ 'merchantTransactionId' => rand(0, 1000),
417
+ 'currency' => $currencyDesc,
418
+ 'amount' => $totals,
419
+ 'paymentType' => $filename,
420
+ 'testMode' => "EXTERNAL"
421
+ );
422
+ } else {
423
+ $fields = array(
424
+ 'referencedPaymentId' => $token_payment,
425
+ 'authentication.userId' => $this->_planetPaymentOptions['authentication_userId'],
426
+ 'authentication.password' => $this->_planetPaymentOptions['authentication_password'],
427
+ 'authentication.entityId' => $this->_planetPaymentOptions['authentication_entityId'],
428
+ 'merchantInvoiceId' => $orderId,
429
+ 'merchantTransactionId' => rand(0, 1000),
430
+ 'currency' => $currencyDesc,
431
+ 'amount' => $totals,
432
+ 'paymentType' => $filename
433
+ );
434
+ }
435
+ } else {
436
+
437
+ if ($testMode) {
438
+ $fields = array(
439
+ 'referencedPaymentId' => $token_payment,
440
+ 'authentication.userId' => $this->_planetPaymentOptions['authentication_userId_test'],
441
+ 'authentication.password' => $this->_planetPaymentOptions['authentication_password_test'],
442
+ 'authentication.entityId' => $this->_planetPaymentOptions['authentication_entityId_test'],
443
+ 'merchantInvoiceId' => $orderId,
444
+ 'merchantTransactionId' => rand(0, 1000),
445
+ 'paymentType' => $filename,
446
+ 'testMode' => "EXTERNAL"
447
+ );
448
+ } else {
449
+ $fields = array(
450
+ 'referencedPaymentId' => $token_payment,
451
+ 'authentication.userId' => $this->_planetPaymentOptions['authentication_userId'],
452
+ 'authentication.password' => $this->_planetPaymentOptions['authentication_password'],
453
+ 'authentication.entityId' => $this->_planetPaymentOptions['authentication_entityId'],
454
+ 'merchantInvoiceId' => $orderId,
455
+ 'merchantTransactionId' => rand(0, 1000),
456
+ 'paymentType' => $filename
457
+ );
458
+ }
459
+ }
460
+ $fields_string = "";
461
+ foreach ($fields as $key => $value) {
462
+ $fields_string .= $key . '=' . $value . '&';
463
+ }
464
+ file_put_contents("var/log/backofficerequestlog.txt", $fields_string, FILE_APPEND);
465
+ $fields_string = substr($fields_string, 0, -1);
466
+
467
+
468
+ //open connection
469
+
470
+ $ch = curl_init($url);
471
+
472
+ //set the url, number of POST vars, POST data
473
+
474
+ curl_setopt($ch, CURLOPT_URL, $url);
475
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
476
+ curl_setopt($ch, CURLOPT_POST, 1);
477
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string);
478
+ curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
479
+ curl_setopt($ch, CURLOPT_HEADER, 0); // DO NOT RETURN HTTP HEADERS
480
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); // RETURN THE CONTENTS OF THE CALL
481
+ curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 120); // Timeout on connect (2 minutes)
482
+ //execute post
483
+ $result = curl_exec($ch);
484
+ curl_close($ch);
485
+ $resultJson = json_decode($result, true);
486
+ //return $resultJson;
487
+ file_put_contents("var/log/backofficeresponse.txt", print_r($resultJson, true), FILE_APPEND);
488
+ $coderes = $resultJson['result']['code'];
489
+ $transid = $resultJson['merchantTransactionId'];
490
+ $description = $resultJson['result']['description'];
491
+ return array('status' => $coderes, 'merchantTransactionId' => $transid, 'description' => $description);
492
+ }
493
+
494
+ /**
495
+ * @return $this
496
+ */
497
+ public function validate() {
498
+ parent::validate();
499
+ return $this;
500
+ }
501
+
502
+ /**
503
+ * To get the order placed redirect url
504
+ *
505
+ * @return bool
506
+ */
507
+ public function getOrderPlaceRedirectUrl() {
508
+ return false;
509
+ }
510
+
511
+ }
app/code/local/Planet/Pay/Model/System/Config/Payment/PaymentAction.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package PlanetPayment_IpayGateway
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment - Provide Option for Payment Action
24
+ *
25
+ * @category PlanetPayment
26
+ * @package PlanetPayment_IpayGateway
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class Planet_Pay_Model_System_Config_Payment_PaymentAction {
30
+
31
+ /**
32
+ * To provide option for authorize and authorize_capture
33
+ *
34
+ * @return array
35
+ */
36
+ public function toOptionArray() {
37
+ return array(
38
+ array(
39
+ 'value' => Planet_Pay_Model_Select::ACTION_AUTHORIZE,
40
+ 'label' => Mage::helper('planet_pay')->__('Authorize Only')
41
+ ),
42
+ array(
43
+ 'value' => Planet_Pay_Model_Select::ACTION_AUTHORIZE_CAPTURE,
44
+ 'label' => Mage::helper('planet_pay')->__('Authorize and Capture')
45
+ )
46
+ );
47
+ }
48
+
49
+ }
app/code/local/Planet/Pay/Model/System/Config/Source/Yesno.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
+ * 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 Planet
22
+ * @package Planet_Pay
23
+ * @copyright Copyright (c) 2013 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
+ * Used in creating options for Yes|No config value selection
29
+ *
30
+ */
31
+ class Planet_Pay_Model_System_Config_Source_Yesno
32
+ {
33
+
34
+ /**
35
+ * Options getter
36
+ *
37
+ * @return array
38
+ */
39
+ public function toOptionArray()
40
+ {
41
+ return array(
42
+ array('value' => 1, 'label'=>Mage::helper('adminhtml')->__('Yes'))
43
+ );
44
+ }
45
+
46
+ /**
47
+ * Get options in "key-value" format
48
+ *
49
+ * @return array
50
+ */
51
+ public function toArray()
52
+ {
53
+ return array(
54
+ 1 => Mage::helper('adminhtml')->__('Yes')
55
+ );
56
+ }
57
+
58
+ }
app/code/local/Planet/Pay/controllers/Adminhtml/BrandController.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ * *
5
+ * * Magento
6
+ *
7
+ *
8
+ * This source file is subject to the Academic Free License (AFL 3.0)
9
+ * that is bundled with this package in the file LICENSE_AFL.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/afl-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
+ * @Namespace : AsiaCheckout
17
+ * @module : Banner
18
+ * @Controller :CategoryController
19
+ *
20
+ * File to show the Banner Form to add new banner, save edit and delete the banners.
21
+ * File to add the wyswing editor and perform mass delete.
22
+ *
23
+ * @author: Chetu
24
+ */
25
+
26
+ class Planet_Pay_Adminhtml_BrandController extends Mage_Adminhtml_Controller_action {
27
+
28
+ protected function _initAction() {
29
+ $this->loadLayout()
30
+ ->_setActiveMenu('planet_pay/items')
31
+ ->_addBreadcrumb(Mage::helper('adminhtml')->__('Items Manager'), Mage::helper('adminhtml')->__('Item Manager'));
32
+
33
+ return $this;
34
+ }
35
+
36
+ public function indexAction() {
37
+ $this->_initAction()
38
+ ->renderLayout();
39
+ }
40
+
41
+ /**
42
+ * Method to Edit the banner in banner module.
43
+ * return object
44
+ *
45
+ */
46
+ public function editAction() {
47
+ $brandId = $this->getRequest()->getParam('id');
48
+ $brandModel = Mage::getModel('planet_pay/method')->load($brandId);
49
+ if ($brandModel->getId() || $brandId == 0) {
50
+ Mage::register('brand_data', $brandModel);
51
+ $this->loadLayout();
52
+ $this->_setActiveMenu('brand/set_time');
53
+ $this->_addBreadcrumb('brand Manager', 'brand Manager');
54
+ $this->_addBreadcrumb('Brand Description', 'Brand Description');
55
+ $this->getLayout()->getBlock('head')
56
+ ->setCanLoadExtJs(true);
57
+ $this->_addContent($this->getLayout()
58
+ ->createBlock('planet_pay/adminhtml_pay_edit'))
59
+ ->_addLeft($this->getLayout()
60
+ ->createBlock('planet_pay/adminhtml_pay_edit_tabs')
61
+ );
62
+ $this->renderLayout();
63
+ } else {
64
+ Mage::getSingleton('adminhtml/session')
65
+ ->addError('Brand does not exist');
66
+ $this->_redirect('*/*/');
67
+ }
68
+ }
69
+
70
+ public function newAction() {
71
+ $this->_redirect('*/*/edit');
72
+ }
73
+
74
+ /**
75
+ * Method to Save the banner in banner module.
76
+ * return object.
77
+ *
78
+ */
79
+ public function saveAction() {
80
+
81
+ if ($this->getRequest()->getPost()) {
82
+ try {
83
+ $postData = $this->getRequest()->getPost();
84
+ $brandModel = Mage::getModel('planet_pay/method');
85
+ if ($this->getRequest()->getParam('id') <= 0)
86
+ $brandModel->setCreatedTime(
87
+ Mage::getSingleton('core/date')
88
+ ->gmtDate()
89
+ );
90
+ $brandModel
91
+ ->addData($postData)
92
+ ->setUpdateTime(
93
+ Mage::getSingleton('core/date')
94
+ ->gmtDate())
95
+ ->setId($this->getRequest()->getParam('id'))
96
+ ->save();
97
+ Mage::getSingleton('adminhtml/session')
98
+ ->addSuccess('successfully saved');
99
+ Mage::getSingleton('adminhtml/session')
100
+ ->settestData(false);
101
+ $this->_redirect('*/*/');
102
+ return;
103
+ } catch (Exception $e) {
104
+ Mage::getSingleton('adminhtml/session')
105
+ ->addError($e->getMessage());
106
+ Mage::getSingleton('adminhtml/session')
107
+ ->settestData($this->getRequest()
108
+ ->getPost()
109
+ );
110
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()
111
+ ->getParam('id')));
112
+ return;
113
+ }
114
+ }
115
+ $this->_redirect('*/*/');
116
+ // $this->renderLayout();
117
+ }
118
+
119
+ public function deleteAction() {
120
+ if ($this->getRequest()->getParam('id') > 0) {
121
+ try {
122
+ $brandModel = Mage::getModel('planet_pay/method');
123
+ $brandModel->setId($this->getRequest()
124
+ ->getParam('id'))
125
+ ->delete();
126
+ Mage::getSingleton('adminhtml/session')
127
+ ->addSuccess('successfully deleted');
128
+ $this->_redirect('*/*/');
129
+ } catch (Exception $e) {
130
+ Mage::getSingleton('adminhtml/session')
131
+ ->addError($e->getMessage());
132
+ $this->_redirect('*/*/edit', array('id' => $this->getRequest()->getParam('id')));
133
+ }
134
+ }
135
+ $this->_redirect('*/*/');
136
+ }
137
+
138
+ }
app/code/local/Planet/Pay/controllers/PaymentController.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Planet_Pay_PaymentController
5
+ */
6
+ class Planet_Pay_PaymentController extends Mage_Core_Controller_Front_Action {
7
+
8
+ /**
9
+ * @return $this
10
+ * @throws Mage_Core_Exception
11
+ */
12
+ public function checkAction() {
13
+ $registerationid = $_REQUEST['regid'];
14
+ if ($registerationid) {
15
+ try {
16
+ $this->processPaymentTokenization($registerationid);
17
+ Mage::getSingleton('checkout/cart')->truncate()->save();
18
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success'));
19
+ } catch (Mage_Core_Exception $e) {
20
+ $message = $e->getMessage();
21
+ Mage::getSingleton('checkout/session')->setErrorMessage('Planet checkout error: ' . $message);
22
+ Mage::getSingleton('checkout/session')->setActiveStep('review');
23
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
24
+ }
25
+ } else {
26
+ $payment = Mage::app()->getRequest()->getParam('payment');
27
+ if ($payment == 'planet_pay') {
28
+ $this->loadLayout(false);
29
+ $token = Mage::app()->getRequest()->getParam('id');
30
+ try {
31
+ $this->processPaymentResponse($token);
32
+ Mage::getSingleton('checkout/cart')->truncate()->save();
33
+ echo '<script>window.top.location = "'.Mage::getUrl('checkout/onepage/success').'";</script>';
34
+ } catch (Mage_Core_Exception $e) {
35
+ $message = $e->getMessage();
36
+ echo '<script>alert("Planet checkout error: '.$message.'");
37
+ window.top.document.querySelector(".new_payon_form").remove();
38
+ window.top.shippingMethod.save();
39
+ //window.top.checkout.changeSection("opc-payment");
40
+ </script>';
41
+ }
42
+ } else {
43
+ throw new Mage_Core_Exception('Error while order processing. Please, contact us.');
44
+ }
45
+ }
46
+ }
47
+
48
+ /**
49
+ *
50
+ * checkAction backup
51
+ *
52
+ */
53
+ /*public function checkAction() {
54
+ $registerationid = $_REQUEST['regid'];
55
+ if ($registerationid) {
56
+ try {
57
+ $this->processPaymentTokenization($registerationid);
58
+ Mage::getSingleton('checkout/cart')->truncate()->save();
59
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success'));
60
+ } catch (Mage_Core_Exception $e) {
61
+ $message = $e->getMessage();
62
+ Mage::getSingleton('checkout/session')->setErrorMessage('Planet checkout error: ' . $message);
63
+ Mage::getSingleton('checkout/session')->setActiveStep('review');
64
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage'));
65
+ }
66
+ } else {
67
+ $payment = Mage::app()->getRequest()->getParam('payment');
68
+ if ($payment == 'planet_pay') {
69
+ $token = Mage::app()->getRequest()->getParam('id');
70
+ try {
71
+ $this->processPaymentResponse($token);
72
+ Mage::getSingleton('checkout/cart')->truncate()->save();
73
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/onepage/success'));
74
+ } catch (Mage_Core_Exception $e) {
75
+ $message = $e->getMessage();
76
+ Mage::getSingleton('checkout/session')->addError('Planet checkout error: ' . $message);
77
+ Mage::getSingleton('checkout/session')->setActiveStep('billing');
78
+ Mage::app()->getResponse()->setRedirect(Mage::getUrl('checkout/cart'));
79
+ }
80
+ } else {
81
+ throw new Mage_Core_Exception('Error while order processing. Please, contact us.');
82
+ }
83
+ }
84
+ }*/
85
+
86
+ /**
87
+ *To handle tokenize request
88
+ *
89
+ * @param type $tokenize
90
+ * @throws Mage_Core_Exception
91
+ */
92
+ private function processPaymentTokenization($tokenize) {
93
+ if (is_null($tokenize)) {
94
+ throw new Mage_Core_Exception('Registration Id can not be null. Please, contact us.');
95
+ }
96
+ /** @var Planet_Pay_Model_Payment $planetPaymentModel */
97
+ $planetPaymentModel = Mage::getModel('planet_pay/payment');
98
+ $planetPaymentModel->processPaymentTokenization($tokenize);
99
+ }
100
+
101
+ /**
102
+ * @param $token
103
+ * @throws Mage_Core_Exception
104
+ */
105
+ private function processPaymentResponse($token) {
106
+ if (is_null($token)) {
107
+ throw new Mage_Core_Exception('Token can not be null. Please, contact us.');
108
+ }
109
+ /** @var Planet_Pay_Model_Payment $planetPaymentModel */
110
+ $planetPaymentModel = Mage::getModel('planet_pay/payment');
111
+ $planetPaymentModel->processPaymentResponse($token);
112
+
113
+ }
114
+
115
+
116
+
117
+ }
app/code/local/Planet/Pay/controllers/Planet/OrderController.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Include the mage order controller
4
+ */
5
+ require_once Mage::getModuleDir('controllers', 'Mage_Adminhtml') . DS . 'Sales' . DS . 'OrderController.php';
6
+
7
+ /**
8
+ * This class used for managing planet order in backend
9
+ *
10
+ * Class Planet_Pay_Planet_OrderController
11
+ */
12
+ class Planet_Pay_Planet_OrderController extends Mage_Adminhtml_Sales_OrderController {
13
+
14
+ /**
15
+ * This to initilize the order sale action
16
+ *
17
+ * @return $this|Mage_Adminhtml_Sales_OrderController
18
+ */
19
+ protected function _initAction() {
20
+ $this->loadLayout()
21
+ ->_setActiveMenu('sales/planet_orders')
22
+ ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
23
+ ->_addBreadcrumb($this->__('Planet Orders'), $this->__('Planet Orders'));
24
+
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ *
30
+ * View order detale
31
+ */
32
+ public function viewAction() {
33
+ $this->_title($this->__('Sales'))->_title($this->__('Orders'));
34
+
35
+ $order = $this->_initOrder();
36
+ $planetOrder = $this->getPlanetOrder($order);
37
+
38
+ if ($order) {
39
+ $isActionsNotPermitted = false;
40
+ $ver = new Mage;
41
+ $version = $ver->getVersion();
42
+ if ($version >= '1.8.1.0') {
43
+ $isActionsNotPermitted = $order->getActionFlag(
44
+ Mage_Sales_Model_Order::ACTION_FLAG_PRODUCTS_PERMISSION_DENIED
45
+ );
46
+ }
47
+ if ($isActionsNotPermitted) {
48
+ $this->_getSession()->addError($this->__('You don\'t have permissions to manage this order because of one or more products are not permitted for your website.'));
49
+ }
50
+
51
+ $this->_initAction();
52
+
53
+ $this->_title(sprintf("#%s", $order->getRealOrderId()));
54
+
55
+ $this->renderLayout();
56
+ }
57
+ }
58
+
59
+ /**
60
+ * send order request action
61
+ */
62
+ public function sendOrderRequestAction() {
63
+ $order = $this->_initOrder();
64
+ $planetOrder = $this->getPlanetOrder($order);
65
+
66
+ if ($planetOrder) {
67
+ try {
68
+ $response = false;
69
+ /** @var Planet_Pay_Model_Handling $orderRequest */
70
+ $orderRequest = Mage::getModel('planet_pay/handling');
71
+ $orderRequest->sendOrderRequest($planetOrder);
72
+ $this->loadLayout('empty');
73
+ $this->renderLayout();
74
+ } catch (Mage_Core_Exception $e) {
75
+ $response = array(
76
+ 'error' => true,
77
+ 'message' => $e->getMessage(),
78
+ );
79
+ } catch (Exception $e) {
80
+ $response = array(
81
+ 'error' => true,
82
+ 'message' => $this->__('Cannot send Order Request: ' . $e->getMessage())
83
+ );
84
+ }
85
+ if (is_array($response)) {
86
+ $response = Mage::helper('core')->jsonEncode($response);
87
+ $this->getResponse()->setBody($response);
88
+ }
89
+ }
90
+ }
91
+
92
+ /**
93
+ * send order delivery note action
94
+ */
95
+ public function sendDeliveryNoteAction() {
96
+ $order = $this->_initOrder();
97
+ $planetOrder = $this->getPlanetOrder($order);
98
+
99
+ if ($planetOrder) {
100
+ try {
101
+ $response = false;
102
+ $data = $this->getRequest()->getPost('delivery');
103
+ /** @var Planet_Pay_Model_Handling $orderRequest */
104
+ $orderRequest = Mage::getModel('planet_pay/handling');
105
+ $orderRequest->sendDeliveryNote($planetOrder, $data);
106
+ $this->loadLayout('empty');
107
+ $this->renderLayout();
108
+ } catch (Mage_Core_Exception $e) {
109
+ $response = array(
110
+ 'error' => true,
111
+ 'message' => $e->getMessage(),
112
+ );
113
+ } catch (Exception $e) {
114
+ $response = array(
115
+ 'error' => true,
116
+ 'message' => $this->__('Cannot send Delivery Note')
117
+ );
118
+ }
119
+ if (is_array($response)) {
120
+ $response = Mage::helper('core')->jsonEncode($response);
121
+ $this->getResponse()->setBody($response);
122
+ }
123
+ }
124
+ }
125
+
126
+ /**
127
+ * send credit note action
128
+ */
129
+ public function sendCreditNoteAction() {
130
+ $order = $this->_initOrder();
131
+ $planetOrder = $this->getPlanetOrder($order);
132
+
133
+ if ($planetOrder) {
134
+ try {
135
+ $response = false;
136
+ /** @var Planet_Pay_Model_Handling $orderRequest */
137
+ $orderRequest = Mage::getModel('planet_pay/handling');
138
+ $orderRequest->sendCreditNote($planetOrder, array());
139
+ $this->loadLayout('empty');
140
+ $this->renderLayout();
141
+ } catch (Mage_Core_Exception $e) {
142
+ $response = array(
143
+ 'error' => true,
144
+ 'message' => $e->getMessage(),
145
+ );
146
+ } catch (Exception $e) {
147
+ $response = array(
148
+ 'error' => true,
149
+ 'message' => $this->__('Cannot send Credit Note')
150
+ );
151
+ }
152
+ if (is_array($response)) {
153
+ $response = Mage::helper('core')->jsonEncode($response);
154
+ $this->getResponse()->setBody($response);
155
+ }
156
+ }
157
+ }
158
+
159
+ /**
160
+ * send product credit note action
161
+ */
162
+ public function sendProductCreditNoteAction() {
163
+ $order = $this->_initOrder();
164
+ $planetOrder = $this->getPlanetOrder($order);
165
+ $itemId = $this->getRequest()->getParam('item_id');
166
+ $requestParams = $this->getRequest()->getParam('credit_request');
167
+
168
+ if ($planetOrder && isset($requestParams['items'][$itemId])) {
169
+ try {
170
+ $response = false;
171
+ /** @var Planet_Pay_Model_Handling $orderRequest */
172
+ $orderRequest = Mage::getModel('planet_pay/handling');
173
+ $orderRequest->sendProductCreditNote($planetOrder, $order, array(
174
+ 'id' => $itemId,
175
+ 'params' => $requestParams['items'][$itemId]
176
+ ));
177
+ $this->loadLayout('empty');
178
+ $this->renderLayout();
179
+ } catch (Mage_Core_Exception $e) {
180
+ $response = array(
181
+ 'error' => true,
182
+ 'message' => $e->getMessage(),
183
+ );
184
+ } catch (Exception $e) {
185
+ $response = array(
186
+ 'error' => true,
187
+ 'message' => $this->__('Cannot send Credit Note')
188
+ );
189
+ }
190
+ if (is_array($response)) {
191
+ $response = Mage::helper('core')->jsonEncode($response);
192
+ $this->getResponse()->setBody($response);
193
+ }
194
+ }
195
+ }
196
+
197
+ /**
198
+ * To get planet order
199
+ *
200
+ * @param $order
201
+ * @return bool|Planet_Pay_Model_Order
202
+ */
203
+ public function getPlanetOrder($order = null) {
204
+ /** @var Planet_Pay_Model_Order $planetOrder */
205
+ $planetOrder = Mage::getModel('planet_pay/order');
206
+ $planetOrder->loadByMageOrder($order);
207
+ if ($planetOrder->getId()) {
208
+ Mage::register('planet_order', $planetOrder);
209
+ return $planetOrder;
210
+ } else {
211
+ return false;
212
+ }
213
+ }
214
+
215
+ }
app/code/local/Planet/Pay/controllers/ProfileController.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * One Pica
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to codemaster@onepica.com so we can send you a copy immediately.
15
+ *
16
+ * @category PlanetPayment
17
+ * @package Planet_Pay
18
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+
22
+ /**
23
+ * Planet Payment - Profile Controller
24
+ *
25
+ * @category PlanetPayment
26
+ * @package Planet_Pay
27
+ * @author One Pica Codemaster <codemaster@onepica.com>
28
+ */
29
+ class Planet_Pay_ProfileController extends Mage_Core_Controller_Front_Action {
30
+
31
+ /**
32
+ * Call the predispatch of parent and set the flag for the same
33
+ */
34
+ public function preDispatch() {
35
+ parent::preDispatch();
36
+ if (!$this->_getSession()->authenticate($this) || !Mage::helper('planet_pay')->isEnabled()) {
37
+ $this->setFlag('', 'no-dispatch', true);
38
+ }
39
+ }
40
+
41
+ /**
42
+ * Store CC profile list action.
43
+ */
44
+ public function indexAction() {
45
+ $this->loadLayout();
46
+ $this->_initLayoutMessages('customer/session');
47
+ $this->renderLayout();
48
+ }
49
+
50
+ /**
51
+ * Edit a payment profile.
52
+ */
53
+ public function editAction() {
54
+ $this->loadLayout();
55
+ $this->_initLayoutMessages('customer/session');
56
+ $navigationBlock = $this->getLayout()->getBlock('customer_account_navigation');
57
+ if ($navigationBlock) {
58
+ $navigationBlock->setActive('planet_pay/profile');
59
+ }
60
+ $this->renderLayout();
61
+ }
62
+
63
+ /**
64
+ * Add a profile.
65
+ */
66
+ public function newAction() {
67
+ $this->_forward('edit');
68
+ }
69
+
70
+ /**
71
+ * Retrieve customer session object
72
+ *
73
+ * @return Mage_Customer_Model_Session
74
+ */
75
+ protected function _getSession() {
76
+ return Mage::getSingleton('customer/session');
77
+ }
78
+
79
+ }
app/code/local/Planet/Pay/data/planet_pay_setup/data-install-1.0.1.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var $installer Mage_Core_Model_Resource_Setup
4
+ */
5
+ $installer = $this;
6
+
7
+ /**
8
+ * @var $model Planet_Pay_Model_Method
9
+ */
10
+ $model = Mage::getModel('planet_pay/method');
11
+
12
+ $autoloader = new Planet_Pay_Model_Autoloader();
13
+ $autoloader->init();
14
+
15
+ $paymentMethods = \PlanetLib\Resources\Content\Brands::getBrands();
16
+
17
+ foreach ($paymentMethods as $brandCode => $brandName) {
18
+ $data = array(
19
+ 'brandname' => $brandName,
20
+ 'brandcode' => $brandCode,
21
+ 'active' => 1
22
+ );
23
+
24
+ $model->setData($data)->setOrigData()->save();
25
+ }
app/code/local/Planet/Pay/data/planet_pay_setup/data-upgrade-1.0.3-1.0.4.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ $methodCodes = array(
9
+ 'VISA' => 6,
10
+ 'MASTER' => 6,
11
+ 'AMEX' => 6,
12
+ 'DISCOVER' => 6,
13
+ 'DINERS' => 6
14
+ );
15
+
16
+ /**
17
+ * @var $model Planet_Pay_Model_Method
18
+ */
19
+ $model = Mage::getModel('planet_pay/method');
20
+ /** @var Planet_Pay_Model_Resource_Method_Collection $collection */
21
+ $collection = $model->getCollection();
22
+ foreach ($collection as $method) {
23
+ if (isset($methodCodes[$method->getBrandcode()])) {
24
+ $method->setBrandid($methodCodes[$method->getBrandcode()]);
25
+ } else {
26
+ $method->setBrandid(99);
27
+ }
28
+ $method->save();
29
+ }
app/code/local/Planet/Pay/data/planet_pay_setup/data-upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var $installer Mage_Core_Model_Resource_Setup
4
+ */
5
+ $installer = $this;
6
+
7
+ $methodCodes = array('VISA', 'MASTER', 'AMEX', 'DISCOVER', 'DINERS');
8
+
9
+ /**
10
+ * @var $model Planet_Pay_Model_Method
11
+ */
12
+ $model = Mage::getModel('planet_pay/method');
13
+ /** @var Planet_Pay_Model_Resource_Method_Collection $collection */
14
+ $collection = $model->getCollection();
15
+ /** @var Planet_Pay_Model_Method $method */
16
+ foreach ($collection as $method) {
17
+ if (!in_array($method->getBrandcode(), $methodCodes)) {
18
+ $method->delete();
19
+ }
20
+ }
app/code/local/Planet/Pay/etc/adminhtml.xml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--<config>
3
+ <menu>
4
+ <sales>
5
+ <children>
6
+ <planet_order translate="title" module="planet_pay">
7
+ <title>Planet Orders Manager</title>
8
+ <action>adminhtml/planet_order/index</action>
9
+ <sort_order>10</sort_order>
10
+ </planet_order>
11
+ </children>
12
+ </sales>
13
+ </menu>
14
+ <acl>
15
+ <resources>
16
+ <admin>
17
+ <children>
18
+ <sales>
19
+ <children>
20
+ <planet_order>
21
+ <title>Planet Orders Manager</title>
22
+ <sort_order>10</sort_order>
23
+ </planet_order>
24
+ </children>
25
+ </sales>
26
+ </children>
27
+ </admin>
28
+ </resources>
29
+ </acl>
30
+ </config>-->
app/code/local/Planet/Pay/etc/config.xml ADDED
@@ -0,0 +1,228 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Planet_Pay>
5
+ <version>1.0.6</version>
6
+ </Planet_Pay>
7
+ </modules>
8
+ <global>
9
+ <currency>
10
+ <import>
11
+ <services>
12
+ <planet_payment_core>
13
+ <name>Planet Payment</name>
14
+ <model>planet_pay/currency_import_planet</model>
15
+ </planet_payment_core>
16
+ </services>
17
+ </import>
18
+ </currency>
19
+ <models>
20
+ <planet_pay>
21
+ <class>Planet_Pay_Model</class>
22
+ <resourceModel>pay_resources</resourceModel>
23
+ </planet_pay>
24
+ <pay_resources>
25
+ <class>Planet_Pay_Model_Resource</class>
26
+ <entities>
27
+ <method>
28
+ <table>planet_pay_method</table>
29
+ </method>
30
+ <order>
31
+ <table>planet_pay_order</table>
32
+ </order>
33
+ <orderlog>
34
+ <table>planet_pay_orderlog</table>
35
+ </orderlog>
36
+ <carddetail>
37
+ <table>planet_pay_carddetail</table>
38
+ </carddetail>
39
+ </entities>
40
+ </pay_resources>
41
+ <checkout>
42
+ <rewrite>
43
+ <type_onepage>Planet_Pay_Model_Checkout_Type_Onepage</type_onepage>
44
+ </rewrite>
45
+ </checkout>
46
+ <!--<sales>
47
+ <rewrite>
48
+ <order_payment>Planet_Pay_Model_Sales_Order_Payment</order_payment>
49
+ </rewrite>
50
+ </sales>-->
51
+ <paygate>
52
+
53
+ <rewrite>
54
+
55
+ <authorizenet>Planet_Pay_Model_Authorizenet</authorizenet>
56
+
57
+ </rewrite>
58
+
59
+ </paygate>
60
+ </models>
61
+ <resources>
62
+ <planet_pay_setup>
63
+ <setup>
64
+ <module>Planet_Pay</module>
65
+ <class>Mage_Core_Model_Resource_Setup</class>
66
+ </setup>
67
+ </planet_pay_setup>
68
+ <planet_pay_write>
69
+ <connection>
70
+ <use>externaldb_database</use>
71
+ </connection>
72
+ </planet_pay_write>
73
+ <planet_pay_read>
74
+ <connection>
75
+ <use>externaldb_database</use>
76
+ </connection>
77
+ </planet_pay_read>
78
+ <planet_pay_setup>
79
+ <connection>
80
+ <use>core_setup</use>
81
+ </connection>
82
+ </planet_pay_setup>
83
+ </resources>
84
+ <blocks>
85
+ <planet_pay>
86
+ <class>Planet_Pay_Block</class>
87
+ </planet_pay>
88
+ <checkout>
89
+ <rewrite>
90
+ <onepage>Planet_Pay_Block_Checkout_Onepage</onepage>
91
+ </rewrite>
92
+ </checkout>
93
+ <checkout>
94
+ <rewrite>
95
+ <onepage_payment_methods>Planet_Pay_Block_Checkout_Onepage_payment_methods</onepage_payment_methods>
96
+ </rewrite>
97
+ </checkout>
98
+ </blocks>
99
+ <helpers>
100
+ <planet_pay>
101
+ <class>Planet_Pay_Helper</class>
102
+ </planet_pay>
103
+
104
+ </helpers>
105
+ <template>
106
+ <email>
107
+ <checkout_payment_failed_template translate="label" module="planet_pay">
108
+ <label>Payment Failed</label>
109
+ <file>planet_pay/payment_failed.html</file>
110
+ <type>html</type>
111
+ </checkout_payment_failed_template>
112
+
113
+ <sales_email_order_template translate="label" module="sales">
114
+ <label>New Order</label>
115
+ <file>sales/planet_pay/order_new.html</file>
116
+ <type>html</type>
117
+ </sales_email_order_template>
118
+ <sales_email_order_guest_template translate="label" module="sales">
119
+ <label>New Order for Guest</label>
120
+ <file>sales/planet_pay/order_new_guest.html</file>
121
+ <type>html</type>
122
+ </sales_email_order_guest_template>
123
+ </email>
124
+ </template>
125
+ <events>
126
+ <checkout_onepage_controller_success_action>
127
+ <observers>
128
+ <planet_pay_checkout_observer>
129
+ <type>singleton</type>
130
+ <class>Planet_Pay_Model_Checkout_Observer</class>
131
+ <method>checkoutSuccessAction</method>
132
+ </planet_pay_checkout_observer>
133
+ </observers>
134
+ </checkout_onepage_controller_success_action>
135
+ </events>
136
+ </global>
137
+ <crontab>
138
+ <jobs>
139
+ <planet_payment_core_currency_rate>
140
+ <schedule>
141
+ <cron_expr>* * * * *</cron_expr>
142
+ </schedule>
143
+ <run>
144
+ <model>planet_pay/currency_import_planet::runExchangeRateQuery</model>
145
+ </run>
146
+ </planet_payment_core_currency_rate>
147
+ </jobs>
148
+ </crontab>
149
+ <frontend>
150
+ <routers>
151
+ <planet>
152
+ <use>standard</use>
153
+ <args>
154
+ <module>Planet_Pay</module>
155
+ <frontName>planet</frontName>
156
+ </args>
157
+ </planet>
158
+ </routers>
159
+ <layout>
160
+ <updates>
161
+ <pay>
162
+ <file>pay.xml</file>
163
+ </pay>
164
+ </updates>
165
+ </layout>
166
+ </frontend>
167
+
168
+ <admin>
169
+ <routers>
170
+ <adminhtml>
171
+ <args>
172
+ <modules>
173
+ <Planet_Pay after="Mage_Adminhtml">Planet_Pay</Planet_Pay>
174
+ </modules>
175
+ </args>
176
+ </adminhtml>
177
+ </routers>
178
+ </admin>
179
+
180
+ <adminhtml>
181
+ <menu>
182
+ <planet module="planet_pay">
183
+ <title>Brand</title>
184
+ <sort_order>100</sort_order>
185
+ <children>
186
+ <items module="planet_pay">
187
+ <title>Manage Brands</title>
188
+ <sort_order>0</sort_order>
189
+ <action>planet/adminhtml_brand</action>
190
+ </items>
191
+ </children>
192
+ </planet>
193
+ </menu>
194
+ <layout>
195
+ <updates>
196
+ <planet_pay>
197
+ <file>planet_pay.xml</file>
198
+ </planet_pay>
199
+ </updates>
200
+ </layout>
201
+ <translate>
202
+ <modules>
203
+ <Custom_Module>
204
+ <files>
205
+ <default>Planet_Pay.csv</default>
206
+ </files>
207
+ </Custom_Module>
208
+ </modules>
209
+ </translate>
210
+ </adminhtml>
211
+
212
+ <default>
213
+ <payment>
214
+ <planet_pay>
215
+ <active>1</active>
216
+ <model>planet_pay/select</model>
217
+ <order_status>processing</order_status>
218
+ <payment_action>authorize</payment_action>
219
+ <title>Planet Payment Method</title>
220
+ <payment_type_live>PA</payment_type_live>
221
+ <payment_type_test>PA</payment_type_test>
222
+ <payment_request_url_live>https://planetpaymentgateway.com</payment_request_url_live>
223
+ <payment_request_url_test>https://test.planetpaymentgateway.com</payment_request_url_test>
224
+ </planet_pay>
225
+ </payment>
226
+
227
+ </default>
228
+ </config>
app/code/local/Planet/Pay/etc/system.xml ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <sections>
4
+ <payment>
5
+ <groups>
6
+ <planet_pay translate="label" module="planet_pay">
7
+ <label>Planet Payment Module</label>
8
+ <sort_order>670</sort_order>
9
+ <show_in_default>1</show_in_default>
10
+ <show_in_website>1</show_in_website>
11
+ <show_in_store>0</show_in_store>
12
+ <fields>
13
+ <active translate="label">
14
+ <label>Enabled</label>
15
+ <frontend_type>select</frontend_type>
16
+ <source_model>adminhtml/system_config_source_yesno</source_model>
17
+ <sort_order>1</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>0</show_in_store>
21
+ </active>
22
+ <order_status translate="label">
23
+ <label>New order status</label>
24
+ <frontend_type>select</frontend_type>
25
+ <source_model>adminhtml/system_config_source_order_status_processing</source_model>
26
+ <sort_order>2</sort_order>
27
+ <show_in_default>1</show_in_default>
28
+ <show_in_website>1</show_in_website>
29
+ <show_in_store>0</show_in_store>
30
+ </order_status>
31
+ <title translate="label">
32
+ <label>Title</label>
33
+ <frontend_type>text</frontend_type>
34
+ <sort_order>3</sort_order>
35
+ <show_in_default>1</show_in_default>
36
+ <show_in_website>1</show_in_website>
37
+ <show_in_store>0</show_in_store>
38
+ </title>
39
+ <payment_action translate="label">
40
+ <label>Payment Action</label>
41
+ <frontend_type>select</frontend_type>
42
+ <source_model>planet_pay/system_config_payment_paymentAction</source_model>
43
+ <sort_order>2</sort_order>
44
+ <show_in_default>1</show_in_default>
45
+ <show_in_website>1</show_in_website>
46
+ <show_in_store>0</show_in_store>
47
+ </payment_action>
48
+ <payment_methods translate="label">
49
+ <label>Active Payment Methods</label>
50
+ <frontend_type>multiselect</frontend_type>
51
+ <sort_order>4</sort_order>
52
+ <source_model>planet_pay/method</source_model>
53
+ <show_in_default>1</show_in_default>
54
+ <show_in_website>1</show_in_website>
55
+ <show_in_store>0</show_in_store>
56
+ <can_be_empty>0</can_be_empty>
57
+ </payment_methods>
58
+ <test_mode translate="label">
59
+ <label>Test mode</label>
60
+ <frontend_type>select</frontend_type>
61
+ <source_model>adminhtml/system_config_source_yesno</source_model>
62
+ <sort_order>5</sort_order>
63
+ <show_in_default>1</show_in_default>
64
+ <show_in_website>1</show_in_website>
65
+ <show_in_store>0</show_in_store>
66
+ </test_mode>
67
+ <authentication_userId translate="label">
68
+ <label>Authentication userID</label>
69
+ <frontend_type>text</frontend_type>
70
+ <sort_order>6</sort_order>
71
+ <show_in_default>1</show_in_default>
72
+ <show_in_website>1</show_in_website>
73
+ <show_in_store>0</show_in_store>
74
+ </authentication_userId>
75
+ <authentication_entityId translate="label">
76
+ <label>Authentication entityId</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>10</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>0</show_in_store>
82
+ </authentication_entityId>
83
+ <authentication_password translate="label">
84
+ <label>Authentication password</label>
85
+ <frontend_type>text</frontend_type>
86
+ <sort_order>7</sort_order>
87
+ <show_in_default>1</show_in_default>
88
+ <show_in_website>1</show_in_website>
89
+ <show_in_store>0</show_in_store>
90
+ </authentication_password>
91
+
92
+ <authentication_userId_test translate="label">
93
+ <label>[Test] Authenticationn UserId</label>
94
+ <frontend_type>text</frontend_type>
95
+ <sort_order>15</sort_order>
96
+ <show_in_default>1</show_in_default>
97
+ <show_in_website>1</show_in_website>
98
+ <show_in_store>0</show_in_store>
99
+ </authentication_userId_test>
100
+ <authentication_entityId_test translate="label">
101
+ <label>[Test] Authentication entityId</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>19</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>1</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ </authentication_entityId_test>
108
+
109
+ <authentication_password_test translate="label">
110
+ <label>[Test] Authentication password</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>16</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>0</show_in_store>
116
+ </authentication_password_test>
117
+
118
+ <show_icons_in_selection translate="label">
119
+ <label>Show icons on Payment step</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>planet_pay/system_config_source_yesno</source_model>
122
+ <sort_order>24</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>0</show_in_store>
126
+ </show_icons_in_selection>
127
+ <!-- <show_icons_on_summary translate="label">
128
+ <label>Show icons on summary page</label>
129
+ <frontend_type>select</frontend_type>
130
+ <source_model>adminhtml/system_config_source_yesno</source_model>
131
+ <sort_order>25</sort_order>
132
+ <show_in_default>1</show_in_default>
133
+ <show_in_website>1</show_in_website>
134
+ <show_in_store>0</show_in_store>
135
+ </show_icons_on_summary>
136
+ <payment_selection_message translate="label">
137
+ <label>Payment selection message</label>
138
+ <frontend_type>textarea</frontend_type>
139
+ <sort_order>26</sort_order>
140
+ <show_in_default>1</show_in_default>
141
+ <show_in_website>1</show_in_website>
142
+ <show_in_store>0</show_in_store>
143
+ </payment_selection_message>-->
144
+ <sort_order translate="label">
145
+ <label>Sort Order</label>
146
+ <frontend_type>text</frontend_type>
147
+ <sort_order>200</sort_order>
148
+ <show_in_default>1</show_in_default>
149
+ <show_in_website>1</show_in_website>
150
+ <show_in_store>0</show_in_store>
151
+ <frontend_class>validate-number</frontend_class>
152
+ </sort_order>
153
+ </fields>
154
+ </planet_pay>
155
+ </groups>
156
+ </payment>
157
+ </sections>
158
+ </config>
app/code/local/Planet/Pay/sql/planet_pay_setup/install-1.0.1.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ /**
9
+ *
10
+ */
11
+ $table = $installer->getConnection()
12
+ ->newTable($installer->getTable('planet_pay/method'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
14
+ 'unsigned' => true,
15
+ 'identity' => true,
16
+ 'nullable' => false,
17
+ 'primary' => true,
18
+ ), 'Entity id')
19
+ ->addColumn('brandname', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
20
+ 'nullable' => false
21
+ ), 'Brand Name')
22
+ ->addColumn('brandcode', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
23
+ 'nullable' => false
24
+ ), 'Brand Code')
25
+ ->addColumn('active', Varien_Db_Ddl_Table::TYPE_TINYINT, 1, array(
26
+ 'nullable' => false,
27
+ 'default' => 1,
28
+ ), 'Active');
29
+
30
+ $installer->getConnection()->createTable($table);
app/code/local/Planet/Pay/sql/planet_pay_setup/mysql4-upgrade-1.0.5-1.0.6.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ $installer = $this;
4
+
5
+ $installer->startSetup();
6
+
7
+ $installer->run("
8
+
9
+ INSERT IGNORE INTO `{$installer->getTable('sales/order_status')}` (status,label) VALUES ('decline','Declined');
10
+
11
+ INSERT IGNORE INTO `{$installer->getTable('sales/order_status_state')}` (status,state) VALUES ('decline','processing');
12
+
13
+ ");
14
+
15
+ $installer->endSetup();
16
+
17
+ /*
18
+ // Required tables
19
+ $statusTable = $installer->getTable('sales/order_status');
20
+ $statusStateTable = $installer->getTable('sales/order_status_state');
21
+
22
+ // Insert statuses
23
+ $installer->getConnection()->insertArray(
24
+ $statusTable,
25
+ array('status', 'label'),
26
+ array(
27
+ array(
28
+ 'status' => 'decline',
29
+ 'label' => 'Declined'
30
+ )
31
+ )
32
+ );
33
+
34
+ // Insert states and mapping of statuses to states
35
+ $installer->getConnection()->insertArray(
36
+ $statusStateTable,
37
+ array('status', 'state', 'is_default'),
38
+ array(
39
+ array(
40
+ 'status' => 'decline',
41
+ 'state' => 'processing',
42
+ 'is_default' => 0
43
+ )
44
+ )
45
+ );
46
+
47
+ */
48
+ ?>
app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.1-1.0.2.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ /**
9
+ *
10
+ */
11
+ $table = $installer->getConnection()
12
+ ->newTable($installer->getTable('planet_pay/order'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
14
+ 'unsigned' => true,
15
+ 'identity' => true,
16
+ 'nullable' => false,
17
+ 'primary' => true,
18
+ ), 'Entity Id')
19
+ ->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
20
+ 'unsigned' => true,
21
+ 'nullable' => false
22
+ ), 'Order Id')
23
+ ->addColumn('payment_status', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
24
+ 'nullable' => false
25
+ ), 'Payment Status')
26
+ ->addColumn('total_order_sum', Varien_Db_Ddl_Table::TYPE_DECIMAL, array(12,4), array(
27
+ 'nullable' => false,
28
+ 'default' => '0.0000'
29
+ ), 'Total Order Sum')
30
+ ->addColumn('payment_request', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
31
+ ), 'Payment Request')
32
+ ->addColumn('payment_response', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
33
+ ), 'Payment Response')
34
+ ->addColumn('create_date', Varien_Db_Ddl_Table::TYPE_DATE, null, array(
35
+ ), 'Create Date')
36
+ ->addColumn('transaction_id', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
37
+ ), 'Transaction Id')
38
+ ->addColumn('brand_name', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
39
+ 'nullable' => false
40
+ ), 'Brand Name');
41
+
42
+ $installer->getConnection()->createTable($table);
app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.2-1.0.3.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ $installer->startSetup();
9
+ /**
10
+ *
11
+ */
12
+ $table = $installer->getConnection()
13
+ ->newTable($installer->getTable('planet_pay/orderlog'))
14
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
15
+ 'unsigned' => true,
16
+ 'identity' => true,
17
+ 'nullable' => false,
18
+ 'primary' => true,
19
+ ), 'Entity Id')
20
+ ->addColumn('planet_order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
21
+ 'unsigned' => true,
22
+ 'nullable' => false
23
+ ), 'Planet Order Id')
24
+ ->addColumn('description', Varien_Db_Ddl_Table::TYPE_TEXT, 64, array(
25
+ ), 'Description')
26
+ ->addColumn('code', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
27
+ 'nullable' => false
28
+ ), 'Code')
29
+ ->addColumn('method_name', Varien_Db_Ddl_Table::TYPE_TEXT, 32, array(
30
+ 'nullable' => false
31
+ ), 'Method Name')
32
+ ->addColumn('success', Varien_Db_Ddl_Table::TYPE_TINYINT, 1, array(
33
+ 'nullable' => false,
34
+ 'default' => 0,
35
+ ), 'Success')
36
+ ->addColumn('request', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
37
+ ), 'Request')
38
+ ->addColumn('response', Varien_Db_Ddl_Table::TYPE_TEXT, '64k', array(
39
+ ), 'Response')
40
+ ->addColumn('date', Varien_Db_Ddl_Table::TYPE_DATETIME, null, array(
41
+ ), 'Date');
42
+
43
+ $installer->getConnection()->createTable($table);
44
+
45
+ $installer->getConnection()->modifyColumn($installer->getTable('planet_pay/order'),
46
+ 'create_date',
47
+ array(
48
+ 'type' => Varien_Db_Ddl_Table::TYPE_DATETIME,
49
+ 'comment' => 'Create Date'
50
+ ));
51
+
52
+ $installer->endSetup();
app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.3-1.0.4.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ $installer->startSetup();
9
+
10
+ $installer->getConnection()->addColumn($installer->getTable('planet_pay/method'),
11
+ 'brandid',
12
+ array(
13
+ 'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
14
+ 'length' => 8,
15
+ 'comment' => 'Brand Id'
16
+ ));
17
+
18
+ $installer->endSetup();
app/code/local/Planet/Pay/sql/planet_pay_setup/upgrade-1.0.4-1.0.5.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * @var $installer Mage_Core_Model_Resource_Setup
5
+ */
6
+ $installer = $this;
7
+
8
+ /**
9
+ *
10
+ */
11
+ $table = $installer->getConnection()
12
+ ->newTable($installer->getTable('planet_pay/carddetail'))
13
+ ->addColumn('id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
14
+ 'unsigned' => true,
15
+ 'identity' => true,
16
+ 'nullable' => false,
17
+ 'primary' => true,
18
+ ), 'Entity id')
19
+ ->addColumn('cust_id', Varien_Db_Ddl_Table::TYPE_INTEGER, 11, array(
20
+ 'nullable' => false
21
+ ), 'Customer Id')
22
+ ->addColumn('registeration_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
23
+ 'nullable' => false
24
+ ), 'Registeration Id')
25
+ ->addColumn('brand_name', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
26
+ 'nullable' => false
27
+ ), 'Payment Brand')
28
+ ->addColumn('payment_type', Varien_Db_Ddl_Table::TYPE_VARCHAR, 50, array(
29
+ 'nullable' => false
30
+ ), 'Payment Type')
31
+ ->addColumn('cc_last_four', Varien_Db_Ddl_Table::TYPE_VARCHAR, 11, array(
32
+ 'nullable' => false
33
+ ), 'Card Number')
34
+ ->addColumn('cc_exp_month', Varien_Db_Ddl_Table::TYPE_INTEGER, 10, array(
35
+ 'nullable' => false
36
+ ), 'Expiry Month')
37
+ ->addColumn('cc_exp_year', Varien_Db_Ddl_Table::TYPE_INTEGER, 4, array(
38
+ 'nullable' => false
39
+ ), 'Expiry Year')
40
+ ->addColumn('holder', Varien_Db_Ddl_Table::TYPE_VARCHAR, 150, array(
41
+ 'nullable' => false
42
+ ), 'Card Holder');
43
+
44
+
45
+ $installer->getConnection()->createTable($table);
app/design/adminhtml/default/default/layout/planet_pay.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+
4
+ <planet_adminhtml_brand_index>
5
+ <reference name="content">
6
+ <block type="planet_pay/adminhtml_pay" name="brand" />
7
+ </reference>
8
+ </planet_adminhtml_brand_index>
9
+ <adminhtml_sales_order_view>
10
+ <reference name="order_totals">
11
+ <action method="setTemplate">
12
+ <template>planet_pay/sales/order/totals.phtml</template>
13
+ </action>
14
+ </reference>
15
+ </adminhtml_sales_order_view>
16
+ </layout>
app/design/adminhtml/default/default/template/planet_pay/order/view/handling/credit.phtml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var Planet_Pay_Block_Adminhtml_Order_View_Handling_Credit $this */?>
2
+ <div id="order_credit_block">
3
+ <div id="handling_form" class="order-handling-form">
4
+ <div class="f-left">
5
+ <?php echo $this->getChildHtml('submit_button') ?>
6
+ </div>
7
+ <div class="f-right">
8
+ </div>
9
+ <div class="clear"></div>
10
+ </div>
11
+ <div class="divider"></div>
12
+ <ul class="note-list">
13
+ <?php foreach ($this->getOrderCreditLogs() as $creditNote): ?>
14
+ <li>
15
+ <strong><?php echo $this->helper('core')->formatDate($creditNote->getDate(), 'medium') ?></strong>
16
+ <?php echo $this->helper('core')->formatTime($creditNote->getDate(), 'medium') ?><span class="separator">|</span><strong><?php echo $creditNote->getCode(); ?></strong><br/>
17
+ <small>
18
+ <?php echo $this->helper('planet_pay')->__('Credit Note Status: ') ?>
19
+ <strong class="subdue">
20
+ <?php if ($creditNote->getSuccess()): ?>
21
+ <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
22
+ <?php echo $this->helper('planet_pay')->__('Success') ?>
23
+ <?php else: ?>
24
+ <?php echo $this->helper('planet_pay')->__('Unsuccess') ?>
25
+ <?php endif; ?>
26
+ </strong>
27
+ </small>
28
+ <br/><?php echo $creditNote->getDescription(); ?>
29
+ </li>
30
+ <?php endforeach; ?>
31
+ </ul>
32
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/handling/delivery.phtml ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="order_delivery_block">
2
+ <div id="handling_form" class="order-handling-form">
3
+ <span class="field-row">
4
+ <label class="normal" for="delivery_tracking"><?php echo Mage::helper('planet_pay')->__('Tracking Number') ?></label><br/>
5
+ <input type="text" name="delivery[tracking]" id="delivery_tracking">
6
+ </span>
7
+ <span class="field-row">
8
+ <label class="normal" for="delivery_carrier"><?php echo Mage::helper('planet_pay')->__('Carrier') ?></label><br/>
9
+ <input type="text" name="delivery[carrier]" id="delivery_carrier">
10
+ </span>
11
+ <div class="f-left">
12
+ <?php echo $this->getChildHtml('submit_button') ?>
13
+ </div>
14
+ <div class="f-right">
15
+ </div>
16
+ <div class="clear"></div>
17
+ </div>
18
+ <div class="divider"></div>
19
+ <ul class="note-list">
20
+ <?php foreach ($this->getOrderDeliveryLogs() as $deliveryNote): ?>
21
+ <li>
22
+ <strong><?php echo $this->helper('core')->formatDate($deliveryNote->getDate(), 'medium') ?></strong>
23
+ <?php echo $this->helper('core')->formatTime($deliveryNote->getDate(), 'medium') ?><span class="separator">|</span><strong><?php echo $deliveryNote->getCode(); ?></strong><br/>
24
+ <small>
25
+ <?php echo $this->helper('planet_pay')->__('Delivery Note Status: ') ?>
26
+ <strong class="subdue">
27
+ <?php if ($deliveryNote->getSuccess()): ?>
28
+ <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
29
+ <?php echo $this->helper('planet_pay')->__('Success') ?>
30
+ <?php else: ?>
31
+ <?php echo $this->helper('planet_pay')->__('Unsuccess') ?>
32
+ <?php endif; ?>
33
+ </strong>
34
+ </small>
35
+ <br/><?php echo $deliveryNote->getDescription(); ?>
36
+ </li>
37
+ <?php endforeach; ?>
38
+ </ul>
39
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/handling/request.phtml ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var Planet_Pay_Block_Adminhtml_Order_View_Handling_Request $this
4
+ */
5
+ ?>
6
+ <div id="order_request_block">
7
+ <div id="handling_form" class="order-handling-form">
8
+ <div><?php echo Mage::helper('planet_pay')->__('') ?></div>
9
+ <div class="f-left">
10
+ <?php echo $this->getChildHtml('submit_button') ?>
11
+ </div>
12
+ <div class="f-right">
13
+ </div>
14
+ <div class="clear"></div>
15
+ </div>
16
+ <div class="divider"></div>
17
+ <ul class="note-list">
18
+ <?php foreach ($this->getOrderRequestLogs() as $orderRequest): ?>
19
+ <li>
20
+ <strong><?php echo $this->helper('core')->formatDate($orderRequest->getDate(), 'medium') ?></strong>
21
+ <?php echo $this->helper('core')->formatTime($orderRequest->getDate(), 'medium') ?><span class="separator">|</span><strong><?php echo $orderRequest->getCode(); ?></strong><br/>
22
+ <small>
23
+ <?php echo $this->helper('planet_pay')->__('Order Request Status: ') ?>
24
+ <strong class="subdue">
25
+ <?php if ($orderRequest->getSuccess()): ?>
26
+ <img src="<?php echo $this->getSkinUrl('images/ico_success.gif') ?>" width="16" height="16" alt="" />
27
+ <?php echo $this->helper('planet_pay')->__('Success') ?>
28
+ <?php else: ?>
29
+ <?php echo $this->helper('planet_pay')->__('Unsuccess') ?>
30
+ <?php endif; ?>
31
+ </strong>
32
+ </small>
33
+ <br/>
34
+ <?php
35
+ echo $orderRequest->getDescription();
36
+ if ($orderRequest->getCode() == '000.400.102') {
37
+ $order = $this->getOrder();
38
+ $email = $order->getCustomerEmail();
39
+ echo '<br /><a class="planet_customer_email" href="mailto:'.$email.'">'.$email.'</a>';
40
+ }
41
+ ?>
42
+ </li>
43
+ <?php endforeach; ?>
44
+ </ul>
45
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/info.phtml ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $_order = $this->getOrder() ?>
2
+ <?php
3
+ $orderAdminDate = $this->formatDate($_order->getCreatedAtDate(), 'medium', true);
4
+ $orderStoreDate = $this->formatDate($_order->getCreatedAtStoreDate(), 'medium', true);
5
+ ?>
6
+ <div class="entry-edit">
7
+ <?php if ($_order->getEmailSent()):
8
+ $_email = Mage::helper('sales')->__('the order confirmation email was sent');
9
+ else:
10
+ $_email = Mage::helper('sales')->__('the order confirmation email is not sent');
11
+ endif; ?>
12
+ <div class="entry-edit-head">
13
+ <?php if ($this->getNoUseOrderLink()): ?>
14
+ <h4 class="icon-head head-account"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?> (<?php echo $_email ?>)</h4>
15
+ <?php else: ?>
16
+ <a href="<?php echo $this->getViewUrl($_order->getId()) ?>"><?php echo Mage::helper('sales')->__('Order # %s', $_order->getRealOrderId()) ?></a>
17
+ <strong>(<?php echo $_email ?>)</strong>
18
+ <?php endif; ?>
19
+ </div>
20
+ <div class="fieldset">
21
+ <table cellspacing="0" class="form-list">
22
+ <tr>
23
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date') ?></label></td>
24
+ <td class="value"><strong><?php echo $orderAdminDate ?></strong></td>
25
+ </tr>
26
+ <?php if ($orderAdminDate != $orderStoreDate):?>
27
+ <tr>
28
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Date (%s)', $_order->getCreatedAtStoreDate()->getTimezone()) ?></label></td>
29
+ <td class="value"><strong><?php echo $orderStoreDate ?></strong></td>
30
+ </tr>
31
+ <?php endif;?>
32
+ <tr>
33
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Order Status') ?></label></td>
34
+ <td class="value"><strong><span id="order_status"><?php echo $_order->getStatusLabel() ?></span></strong></td>
35
+ </tr>
36
+ <tr>
37
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Purchased From') ?></label></td>
38
+ <td class="value"><strong><?php echo $this->getOrderStoreName() ?></strong></td>
39
+ </tr>
40
+ <?php if($_order->getRelationChildId()): ?>
41
+ <tr>
42
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the New Order') ?></label></td>
43
+ <td class="value"><a href="<?php echo $this->getViewUrl($_order->getRelationChildId()) ?>">
44
+ <?php echo $_order->getRelationChildRealId() ?>
45
+ </a></td>
46
+ </tr>
47
+ <?php endif; ?>
48
+ <?php if($_order->getRelationParentId()): ?>
49
+ <tr>
50
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Link to the Previous Order') ?></label></td>
51
+ <td class="value"><a href="<?php echo $this->getViewUrl($_order->getRelationParentId()) ?>">
52
+ <?php echo $_order->getRelationParentRealId() ?>
53
+ </a></td>
54
+ </tr>
55
+ <?php endif; ?>
56
+ <?php if($_order->getRemoteIp() && $this->shouldDisplayCustomerIp()): ?>
57
+ <tr>
58
+ <td class="label"><label><?php echo Mage::helper('sales')->__('Placed from IP') ?></label></td>
59
+ <td class="value"><strong><?php echo $_order->getRemoteIp(); echo ($_order->getXForwardedFor())?' (' . $this->escapeHtml($_order->getXForwardedFor()) . ')':''; ?></strong></td>
60
+ </tr>
61
+ <?php endif; ?>
62
+ <?php if($_order->getGlobalCurrencyCode() != $_order->getBaseCurrencyCode()): ?>
63
+ <tr>
64
+ <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getGlobalCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
65
+ <td class="value"><strong><?php echo $_order->getBaseToGlobalRate() ?></strong></td>
66
+ </tr>
67
+ <?php endif; ?>
68
+ <?php if($_order->getBaseCurrencyCode() != $_order->getOrderCurrencyCode()): ?>
69
+ <tr>
70
+ <td class="label"><label><?php echo Mage::helper('sales')->__('%s / %s rate:', $_order->getOrderCurrencyCode(), $_order->getBaseCurrencyCode()) ?></label></td>
71
+ <td class="value"><strong><?php echo $_order->getBaseToOrderRate() ?></strong></td>
72
+ </tr>
73
+ <?php endif; ?>
74
+ </table>
75
+ </div>
76
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/items.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div class="grid np">
2
+ <div class="hor-scroll">
3
+ <table cellspacing="0" class="data order-tables">
4
+ <col />
5
+ <col width="1" />
6
+ <col width="1" />
7
+ <col width="1" />
8
+ <col width="1" />
9
+ <col width="1" />
10
+ <col width="1" />
11
+ <col width="1" />
12
+ <col width="1" />
13
+ <thead>
14
+ <tr class="headings">
15
+ <th><?php echo $this->helper('sales')->__('Product') ?></th>
16
+ <th><?php echo $this->helper('sales')->__('Price') ?></th>
17
+ <th class="a-center"><?php echo $this->helper('sales')->__('Qty') ?></th>
18
+ <th><?php echo $this->helper('sales')->__('Subtotal') ?></th>
19
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Tax Amount') ?></span></th>
20
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Discount Amount') ?></span></th>
21
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Row Total') ?></span></th>
22
+ <th><span class="nobr"><?php echo $this->helper('sales')->__('Qty to Refund') ?></span></th>
23
+ <th class="last"><span class="nobr"><?php echo $this->helper('sales')->__('Action') ?></span></th>
24
+ </tr>
25
+ </thead>
26
+ <?php $_items = $this->getItemsCollection() ?>
27
+ <?php $i=0;foreach ($_items as $_item):?>
28
+ <?php if ($_item->getParentItem()) continue; else $i++;?>
29
+ <tbody class="<?php echo $i%2?'even':'odd' ?>">
30
+ <?php echo $this->getItemHtml($_item) ?>
31
+ <?php echo $this->getItemExtraInfoHtml($_item) ?>
32
+ </tbody>
33
+ <?php endforeach; ?>
34
+ </table>
35
+ </div>
36
+ </div>
37
+ <br />
app/design/adminhtml/default/default/template/planet_pay/order/view/items/renderer/default.phtml ADDED
@@ -0,0 +1,212 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var Planet_Pay_Block_Adminhtml_Order_View_Items_Renderer_Default $this */?>
2
+ <?php $_item = $this->getItem() ?>
3
+ <?php $this->setPriceDataObject($_item) ?>
4
+ <tr class="border">
5
+ <td><?php echo $this->getColumnHtml($_item, 'name') ?></td>
6
+ <td class="a-right">
7
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
8
+ <span class="price-excl-tax">
9
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
10
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
11
+ <?php endif; ?>
12
+
13
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
14
+ <?php
15
+ echo $this->displayPrices(
16
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
17
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
18
+ );
19
+ ?>
20
+ <?php else: ?>
21
+ <?php echo $this->displayPrices($_item->getBasePrice(), $_item->getPrice()) ?>
22
+ <?php endif; ?>
23
+
24
+
25
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
26
+ <br />
27
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
28
+ <small>
29
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
30
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
31
+ <?php endforeach; ?>
32
+ </small>
33
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
34
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
35
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></small></span>
36
+ <?php endforeach; ?>
37
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
38
+ <small>
39
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
40
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount'], $tax['amount']); ?></span>
41
+ <?php endforeach; ?>
42
+ </small>
43
+ <?php endif; ?>
44
+
45
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
46
+ <br />
47
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
48
+ <?php
49
+ echo $this->displayPrices(
50
+ $_item->getBasePrice()+$_item->getBaseWeeeTaxAppliedAmount()+$_item->getBaseWeeeTaxDisposition(),
51
+ $_item->getPrice()+$_item->getWeeeTaxAppliedAmount()+$_item->getWeeeTaxDisposition()
52
+ );
53
+ ?>
54
+ </span>
55
+ <?php endif; ?>
56
+ <?php endif; ?>
57
+ </span>
58
+ <br />
59
+ <?php endif; ?>
60
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
61
+ <span class="price-incl-tax">
62
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
63
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
64
+ <?php endif; ?>
65
+ <?php $_incl = $this->helper('checkout')->getPriceInclTax($_item); ?>
66
+ <?php $_baseIncl = $this->helper('checkout')->getBasePriceInclTax($_item); ?>
67
+
68
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
69
+ <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?>
70
+ <?php else: ?>
71
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxDisposition(), $_incl-$_item->getWeeeTaxDisposition()) ?>
72
+ <?php endif; ?>
73
+
74
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
75
+ <br />
76
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
77
+ <small>
78
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
79
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
80
+ <?php endforeach; ?>
81
+ </small>
82
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
83
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
84
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></small></span>
85
+ <?php endforeach; ?>
86
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
87
+ <small>
88
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
89
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_amount_incl_tax'], $tax['amount_incl_tax']); ?></span>
90
+ <?php endforeach; ?>
91
+ </small>
92
+ <?php endif; ?>
93
+
94
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
95
+ <br />
96
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseWeeeTaxInclTax($_item) , $_incl + Mage::helper('weee')->getWeeeTaxInclTax($_item)); ?></span>
97
+ <?php endif; ?>
98
+ <?php endif; ?>
99
+ </span>
100
+ <?php endif; ?>
101
+ </td>
102
+ <td><?php echo $this->getColumnHtml($_item, 'qty') ?></td>
103
+ <td class="a-right">
104
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceExclTax()): ?>
105
+ <span class="price-excl-tax">
106
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
107
+ <span class="label"><?php echo $this->__('Excl. Tax'); ?>:</span>
108
+ <?php endif; ?>
109
+
110
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
111
+ <?php
112
+ echo $this->displayPrices(
113
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
114
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
115
+ );
116
+ ?>
117
+ <?php else: ?>
118
+ <?php echo $this->displayPrices($_item->getBaseRowTotal(), $_item->getRowTotal()) ?>
119
+ <?php endif; ?>
120
+
121
+
122
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
123
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
124
+ <small>
125
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
126
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
127
+ <?php endforeach; ?>
128
+ </small>
129
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
130
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
131
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></small></span>
132
+ <?php endforeach; ?>
133
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
134
+ <small>
135
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
136
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount'], $tax['row_amount']); ?></span>
137
+ <?php endforeach; ?>
138
+ </small>
139
+ <?php endif; ?>
140
+
141
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
142
+ <br />
143
+ <span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br />
144
+ <?php
145
+ echo $this->displayPrices(
146
+ $_item->getBaseRowTotal()+$_item->getBaseWeeeTaxAppliedRowAmount()+$_item->getBaseWeeeTaxRowDisposition(),
147
+ $_item->getRowTotal()+$_item->getWeeeTaxAppliedRowAmount()+$_item->getWeeeTaxRowDisposition()
148
+ );
149
+ ?>
150
+ </span>
151
+ <?php endif; ?>
152
+ <?php endif; ?>
153
+ </span>
154
+ <br />
155
+ <?php endif; ?>
156
+ <?php if ($this->helper('tax')->displaySalesBothPrices() || $this->helper('tax')->displaySalesPriceInclTax()): ?>
157
+ <span class="price-incl-tax">
158
+ <?php if ($this->helper('tax')->displaySalesBothPrices()): ?>
159
+ <span class="label"><?php echo $this->__('Incl. Tax'); ?>:</span>
160
+ <?php endif; ?>
161
+ <?php $_incl = $this->helper('checkout')->getSubtotalInclTax($_item); ?>
162
+ <?php $_baseIncl = $this->helper('checkout')->getBaseSubtotalInclTax($_item); ?>
163
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, array(0, 1, 4), 'sales', $_item->getStoreId())): ?>
164
+ <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item), $_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?>
165
+ <?php else: ?>
166
+ <?php echo $this->displayPrices($_baseIncl-$_item->getBaseWeeeTaxRowDisposition(), $_incl-$_item->getWeeeTaxRowDisposition()) ?>
167
+ <?php endif; ?>
168
+
169
+
170
+ <?php if (Mage::helper('weee')->getApplied($_item)): ?>
171
+
172
+ <br />
173
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 1, 'sales', $_item->getStoreId())): ?>
174
+ <small>
175
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
176
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
177
+ <?php endforeach; ?>
178
+ </small>
179
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
180
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
181
+ <span class="nobr"><small><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></small></span>
182
+ <?php endforeach; ?>
183
+ <?php elseif (Mage::helper('weee')->typeOfDisplay($_item, 4, 'sales', $_item->getStoreId())): ?>
184
+ <small>
185
+ <?php foreach (Mage::helper('weee')->getApplied($_item) as $tax): ?>
186
+ <span class="nobr"><?php echo $tax['title']; ?>: <?php echo $this->displayPrices($tax['base_row_amount_incl_tax'], $tax['row_amount_incl_tax']); ?></span>
187
+ <?php endforeach; ?>
188
+ </small>
189
+ <?php endif; ?>
190
+
191
+ <?php if (Mage::helper('weee')->typeOfDisplay($_item, 2, 'sales', $_item->getStoreId())): ?>
192
+ <br /><span class="nobr"><?php echo Mage::helper('weee')->__('Total'); ?>:<br /> <?php echo $this->displayPrices($_baseIncl + Mage::helper('weee')->getBaseRowWeeeTaxInclTax($_item),$_incl + Mage::helper('weee')->getRowWeeeTaxInclTax($_item)); ?></span>
193
+ <?php endif; ?>
194
+ <?php endif; ?>
195
+ </span>
196
+ <?php endif; ?>
197
+ </td>
198
+ <td class="a-right"><?php echo $this->displayPriceAttribute('tax_amount') ?></td>
199
+ <td class="a-right"><?php echo $this->displayPriceAttribute('discount_amount') ?></td>
200
+ <td class="a-right">
201
+ <?php echo $this->displayPrices(
202
+ $_item->getBaseRowTotal() + $_item->getBaseTaxAmount() + $_item->getBaseHiddenTaxAmount() + $_item->getBaseWeeeTaxAppliedRowAmount() - $_item->getBaseDiscountAmount(),
203
+ $_item->getRowTotal() + $_item->getTaxAmount() + $_item->getHiddenTaxAmount() + $_item->getWeeeTaxAppliedRowAmount() - $_item->getDiscountAmount()
204
+ ); ?>
205
+ </td>
206
+ <td class="a-center">
207
+ <input type="text" class="input-text qty-input" name="credit_request[items][<?php echo $_item->getId() ?>][qty]" value="<?php echo $_item->getQty()*1 ?>"/>
208
+ </td>
209
+ <td class="a-center last">
210
+ <?php echo $this->getSubmitButton()->toHtml(); ?>
211
+ </td>
212
+ </tr>
app/design/adminhtml/default/default/template/planet_pay/order/view/loviitinfo.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $_planetOrder Planet_Pay_Model_Order */
3
+ $_planetOrder = $this->getPlanetOrder();
4
+ $planetOrderCreateDate = $this->formatDate($_planetOrder->getCreateDate(), 'medium', true);
5
+ ?>
6
+ <div class="entry-edit">
7
+ <div class="entry-edit-head">
8
+ <h4><?php echo Mage::helper('planet_pay')->__('Planet Order # %s', $_planetOrder->getId()); ?></h4>
9
+ </div>
10
+ <div class="fieldset">
11
+ <table cellspacing="0" class="form-list">
12
+ <tr>
13
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Payment Status') ?></label></td>
14
+ <td class="value"><strong><?php echo $_planetOrder->getPaymentStatus(); ?></strong></td>
15
+ </tr>
16
+ <tr>
17
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Brand Name') ?></label></td>
18
+ <td class="value"><strong><?php echo $_planetOrder->getBrandName(); ?></strong></td>
19
+ </tr>
20
+ <tr>
21
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Create Date') ?></label></td>
22
+ <td class="value"><strong><?php echo $planetOrderCreateDate; ?></strong></td>
23
+ </tr>
24
+ <tr>
25
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Transaction ID') ?></label></td>
26
+ <td class="value"><strong><?php echo $_planetOrder->getTransactionId(); ?></strong></td>
27
+ </tr>
28
+ </table>
29
+ </div>
30
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/planetinfo.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $_planetOrder Planet_Pay_Model_Order */
3
+ $_planetOrder = $this->getPlanetOrder();
4
+ $planetOrderCreateDate = $this->formatDate($_planetOrder->getCreateDate(), 'medium', true);
5
+ ?>
6
+ <div class="entry-edit">
7
+ <div class="entry-edit-head">
8
+ <h4><?php echo Mage::helper('planet_pay')->__('Planet Order # %s', $_planetOrder->getId()); ?></h4>
9
+ </div>
10
+ <div class="fieldset">
11
+ <table cellspacing="0" class="form-list">
12
+ <tr>
13
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Payment Status') ?></label></td>
14
+ <td class="value"><strong><?php echo $_planetOrder->getPaymentStatus(); ?></strong></td>
15
+ </tr>
16
+ <tr>
17
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Brand Name') ?></label></td>
18
+ <td class="value"><strong><?php echo $_planetOrder->getBrandName(); ?></strong></td>
19
+ </tr>
20
+ <tr>
21
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Create Date') ?></label></td>
22
+ <td class="value"><strong><?php echo $planetOrderCreateDate; ?></strong></td>
23
+ </tr>
24
+ <tr>
25
+ <td class="label"><label><?php echo Mage::helper('planet_pay')->__('Transaction ID') ?></label></td>
26
+ <td class="value"><strong><?php echo $_planetOrder->getTransactionId(); ?></strong></td>
27
+ </tr>
28
+ </table>
29
+ </div>
30
+ </div>
app/design/adminhtml/default/default/template/planet_pay/order/view/request/criterions.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Request */
3
+ ?>
4
+ <table cellspacing="0" class="form-list">
5
+ <?php foreach ($this->getOrderRequestCriterionData() as $criterionField): ?>
6
+ <tr>
7
+ <td class="label"><label><?php echo $criterionField['name']; ?></label></td>
8
+ <td class="value"><strong><?php echo $criterionField['value']; ?></strong></td>
9
+ </tr>
10
+ <?php endforeach; ?>
11
+ </table>
12
+ <?php foreach ($this->getOrderRequestOrderItems() as $id => $orderItem): ?>
13
+ <h5> Order Item <?php echo $id; ?> </h5>
14
+ <div class="fieldset">
15
+ <table cellspacing="0" class="form-list">
16
+ <?php foreach ($orderItem as $orderItemField): ?>
17
+ <tr>
18
+ <td class="label"><label><?php echo $orderItemField['name']; ?></label></td>
19
+ <td class="value"><strong><?php echo $orderItemField['value']; ?></strong></td>
20
+ </tr>
21
+ <?php endforeach; ?>
22
+ </table>
23
+ </div>
24
+ <?php endforeach; ?>
app/design/adminhtml/default/default/template/planet_pay/order/view/request/customer.phtml ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Request */
3
+ ?>
4
+ <table cellspacing="0" class="form-list">
5
+ <?php foreach ($this->getOrderRequestCustomer() as $name => $value): ?>
6
+ <tr>
7
+ <td class="label"><label><?php echo $name; ?></label></td>
8
+ <td class="value"><strong><?php echo $value; ?></strong></td>
9
+ </tr>
10
+ <?php endforeach; ?>
11
+ </table>
app/design/adminhtml/default/default/template/planet_pay/order/view/request/options.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Request */
3
+ ?>
4
+ <!--<div class="fieldset">-->
5
+ <table cellspacing="0" class="form-list">
6
+ <?php foreach ($this->getOrderRequestOptions() as $option): ?>
7
+ <tr>
8
+ <td class="label"><label><?php echo $option['name']; ?></label></td>
9
+ <td class="value"><strong><?php echo $option['value']; ?></strong></td>
10
+ </tr>
11
+ <?php endforeach; ?>
12
+ </table>
13
+ <!--</div>-->
app/design/adminhtml/default/default/template/planet_pay/order/view/tab/credit.phtml ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Tab_Credit */ ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <div>
4
+ <div id="order-messages">
5
+ <?php echo $this->getChildHtml('order_messages') ?>
6
+ <?php if(!$this->isDeliveryNoteSent()): ?>
7
+ <div>
8
+ <?php echo Mage::helper('planet_pay')->__('Partial credit note is not possible until delivery note is sent
9
+ and processed by Planet!
10
+ Please send delivery note first or send a full credit note.') ?>
11
+ </div>
12
+ <?php endif; ?>
13
+ </div>
14
+ <div class="entry-edit">
15
+ <div class="entry-edit-head">
16
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
17
+ </div>
18
+ </div>
19
+ <?php echo $this->getItemsHtml() ?>
20
+ <div class="clear"></div>
21
+ <div id="order-credit">
22
+ <?php echo $this->getChildHtml('order_credit') ?>
23
+ </div>
24
+
25
+
26
+ </div>
27
+
app/design/adminhtml/default/default/template/planet_pay/order/view/tab/delivery.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Tab_Delivery */ ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <div>
4
+ <div id="order-messages">
5
+ <?php echo $this->getChildHtml('order_messages') ?>
6
+ </div>
7
+
8
+ <div id="order-delivery">
9
+ <?php echo $this->getChildHtml('order_delivery') ?>
10
+ </div>
11
+
12
+
13
+ </div>
14
+
app/design/adminhtml/default/default/template/planet_pay/order/view/tab/info.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var $this Mage_Adminhtml_Block_Sales_Order_View_Tab_Info */ ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <div>
4
+ <div id="order-messages">
5
+ <?php echo $this->getChildHtml('order_messages') ?>
6
+ </div>
7
+
8
+ <div class="box-left">
9
+ <?php echo $this->getChildHtml('planet_order_info') ?>
10
+ </div>
11
+ <div class="box-right entry-edit">
12
+ <?php echo $this->getChildHtml('order_info') ?>
13
+ </div>
14
+ <div class="clear"></div>
15
+
16
+ <div class="entry-edit">
17
+ <div class="entry-edit-head">
18
+ <h4 class="icon-head head-products"><?php echo Mage::helper('sales')->__('Items Ordered') ?></h4>
19
+ </div>
20
+ </div>
21
+ <?php echo $this->getItemsHtml() ?>
22
+ <div class="clear"></div>
23
+
24
+ <div class="box-right entry-edit">
25
+ <div class="entry-edit-head"><h4><?php echo Mage::helper('sales')->__('Order Totals') ?></h4></div>
26
+ <div class="order-totals"><?php echo $this->getChildHtml('order_totals') ?></div>
27
+ </div>
28
+
29
+ </div>
30
+
31
+ <?php echo $this->getChildHtml('popup_window');?>
32
+ <script type="text/javascript">
33
+ //<![CDATA[
34
+ /**
35
+ * Retrieve gift options tooltip content
36
+ */
37
+ function getGiftOptionsTooltipContent(itemId) {
38
+ var contentLines = [];
39
+ var headerLine = null;
40
+ var contentLine = null;
41
+
42
+ $$('#gift_options_data_' + itemId + ' .gift-options-tooltip-content').each(function (element) {
43
+ if (element.down(0)) {
44
+ headerLine = element.down(0).innerHTML;
45
+ contentLine = element.down(0).next().innerHTML;
46
+ if (contentLine.length > 30) {
47
+ contentLine = contentLine.slice(0,30) + '...';
48
+ }
49
+ contentLines.push(headerLine + ' ' + contentLine);
50
+ }
51
+ });
52
+ return contentLines.join('<br/>');
53
+ }
54
+ giftOptionsTooltip.setTooltipContentLoaderFunction(getGiftOptionsTooltipContent);
55
+ //]]>
56
+ </script>
app/design/adminhtml/default/default/template/planet_pay/order/view/tab/request.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php /** @var $this Planet_Pay_Block_Adminhtml_Order_View_Tab_Request */ ?>
2
+ <?php $_order = $this->getOrder() ?>
3
+ <div>
4
+ <div id="order-messages">
5
+ <?php echo $this->getChildHtml('order_messages') ?>
6
+ </div>
7
+
8
+ <div id="order-request">
9
+ <?php echo $this->getChildHtml('order_request') ?>
10
+ </div>
11
+
12
+
13
+ </div>
14
+
app/design/adminhtml/default/default/template/planet_pay/sales/order/totals.phtml ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package default_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php /*$_source = $this->getSource(); ?>
28
+ <?php $this->setPriceDataObject($_source) ?>
29
+ <?php if ($_source): ?>
30
+ <table cellspacing="0" width="100%">
31
+ <?php echo $this->getChildHtml('main'); ?>
32
+ <?php echo $this->getChildHtml('footer'); ?>
33
+ </table>
34
+ <?php endif;*/ ?>
35
+ <table cellspacing="0" width="100%">
36
+ <col />
37
+ <col width="1" />
38
+ <?php $_totals = $this->getTotals('footer')?>
39
+ <?php if ($_totals):?>
40
+ <tfoot>
41
+ <?php foreach ($this->getTotals('footer') as $_code => $_total): ?>
42
+ <?php if ($_total->getBlockName()): ?>
43
+ <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
44
+ <?php else:?>
45
+ <tr class="<?php echo $_code?>">
46
+ <td <?php echo $this->getLabelProperties()?> class="label">
47
+ <strong><?php echo $this->escapeHtml($_total->getLabel()); ?></strong>
48
+ </td>
49
+ <td <?php echo $this->getValueProperties()?> class="emph">
50
+ <strong><?php echo $this->formatValue($_total) ?></strong>
51
+ </td>
52
+ </tr>
53
+ <?php endif?>
54
+ <?php endforeach?>
55
+ </tfoot>
56
+ <?php endif?>
57
+
58
+ <?php $_totals = $this->getTotals('')?>
59
+ <?php if ($_totals):?>
60
+ <tbody>
61
+ <?php foreach ($_totals as $_code => $_total): ?>
62
+ <?php if ($_total->getBlockName()): ?>
63
+ <?php echo $this->getChildHtml($_total->getBlockName(), false); ?>
64
+ <?php else:?>
65
+ <tr class="<?php echo $_code?>">
66
+ <td <?php echo $this->getLabelProperties()?> class="label">
67
+ <?php if ($_total->getStrong()):?>
68
+ <strong><?php echo $this->escapeHtml($_total->getLabel()); ?></strong>
69
+ <?php else:?>
70
+ <?php echo $this->escapeHtml($_total->getLabel()); ?>
71
+ <?php endif?>
72
+ </td>
73
+ <?php if ($_total->getStrong()):?>
74
+ <td <?php echo $this->getValueProperties()?> class="emph">
75
+ <strong><?php echo $this->formatValue($_total) ?></strong>
76
+ <?php else:?>
77
+ <td <?php echo $this->getValueProperties()?>>
78
+ <?php echo $this->formatValue($_total) ?>
79
+ <?php endif?>
80
+ </td>
81
+ </tr>
82
+ <?php endif?>
83
+ <?php endforeach?>
84
+ </tbody>
85
+ <?php endif?>
86
+ </table>
app/design/frontend/default/default/template/checkout/onepage/review/totals.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+
27
+ /**
28
+ * @see Mage_Checkout_Block_Cart_Totals
29
+ */
30
+ ?>
31
+ <?php if ($this->getTotals()): ?>
32
+ <tfoot>
33
+ <?php $_colspan = $this->helper('tax')->displayCartBothPrices() ? 5 : 3; ?>
34
+ <?php echo $this->renderTotals(null, $_colspan); ?>
35
+ <?php echo $this->renderTotals('footer', $_colspan); ?>
36
+ </tfoot>
37
+ <?php endif; ?>
app/design/frontend/default/default/template/planet_pay/checkoutform.phtml ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Form_Form */
3
+ function prepareCheckout() {
4
+ $data = "authentication.userId=8a8294174b3213ae014b3717ee6a0597" .
5
+ "&authentication.password=demodemo" .
6
+ "&authentication.entityId=ff80808145a7f31c0145ae52b7bc0ab8" .
7
+ "&paymentType=PA" .
8
+ "&currency=EUR" .
9
+ "&amount=10.55";
10
+
11
+ $params = array('http' => array(
12
+ 'method' => 'POST',
13
+ 'content' => $data
14
+ ));
15
+
16
+ // I tend to prefer to use curl over fopen.
17
+
18
+ $ch = curl_init('https://test.oppwa.com/v1/checkouts');
19
+ curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
20
+ curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
21
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
22
+ curl_setopt($ch, CURLOPT_HTTPHEADER, array(
23
+ 'Accept: application/json',
24
+ 'Content-Length: ' . strlen($data))
25
+ );
26
+
27
+ $result = curl_exec($ch);
28
+ $jsonRes = json_decode($result);
29
+ return $jsonRes->id;
30
+
31
+ }
32
+ $token = prepareCheckout();
33
+ ?>
34
+ <form action="http://localhost/practice/testprocess.php" class="paymentWidgets">VISA MASTER</form>
35
+ <script src="https://test.oppwa.com/v1/paymentWidgets.js?checkoutId=<?php echo $token; ?>"></script>
app/design/frontend/default/default/template/planet_pay/email/items.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ echo "Order Items:-\n";
3
+ print_r($this->getItems);
4
+ ?>
app/design/frontend/default/default/template/planet_pay/form/form.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+
2
+
3
+
app/design/frontend/default/default/template/planet_pay/form/pay.phtml ADDED
@@ -0,0 +1,152 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Form_Pay */
3
+ $translatedProcessingMessage = "Processing Planet Payment";
4
+ //$tokeniz = $this->isTokenization();
5
+ $baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
6
+ /* if(!empty($tokeniz)){
7
+ $account_brand = $tokeniz[0]['account_brand'];
8
+ $registeration_id = $tokeniz[0]['registeration_id'];
9
+ $cc_last_four = $tokeniz[0]['cc_last_four'];
10
+ $cc_exp_month = $tokeniz[0]['cc_exp_month'];
11
+ $cc_exp_year = $tokeniz[0]['cc_exp_year'];
12
+ } */
13
+ $toarr = $this->getForm();
14
+ $token = $toarr['token'];
15
+ Mage::log($token, null, 'token.log');
16
+ $urlform = $toarr['url'];
17
+ ?>
18
+ <?php
19
+ // get domain from config
20
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
21
+ if ($testMode) {
22
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
23
+ $mode = "test";
24
+ } else {
25
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
26
+ $mode = "live";
27
+ }
28
+ preg_match('@^(?:https?://)?([^/]+)@i', $url, $hits);
29
+ $host = $hits[1];
30
+
31
+ $scripturl = $url . "/v1/paymentWidgets.js?checkoutId=" . $token;
32
+ ?>
33
+ <?php $_code = $this->getMethodCode() ?>
34
+ <fieldset class="form-list">
35
+ <div class="planet-payment-selection">
36
+ <ul id="payment_form_<?php echo $_code ?>" class="form-list" style="">
37
+ <?php $counter = 0; ?>
38
+ <?php foreach ($this->getCollection() as $methodItem): ?>
39
+ <li style="float: left; text-align: center;">
40
+ <label for="<?php echo $methodItem->getBrandcode(); ?>" style="display:block; float: none; margin: 0 3.5px;">
41
+ <?php if ($this->showIcons()) : ?>
42
+ <img src="<?php echo $this->getImagePath($methodItem); ?>" width="50" />
43
+ <?php endif; ?>
44
+ </label>
45
+ <input type="radio" name="payment[planet_payment_method]" id="ipmethod" class="newmethod" style="clear: both;" value="<?php echo $methodItem->getBrandcode(); ?>"/>
46
+ </li>
47
+ <?php $counter++; ?>
48
+ <?php endforeach; ?>
49
+ </ul>
50
+ </div>
51
+ </fieldset>
52
+
53
+
54
+ <script type="text/javascript">
55
+
56
+ //<![CDATA[
57
+
58
+
59
+
60
+ //]]>
61
+ </script>
62
+ <script type="text/javascript">
63
+ //<![CDATA[
64
+
65
+ var jq = jQuery.noConflict();
66
+ jq("#checkout-step-payment .wpwl-container-card").html('');
67
+ //jq("#payment-buttons-container .required").css("display", "none");
68
+ //jq("#payment-buttons-container .button").css("display", "none");
69
+ // if (jq(".newmethod").click(function() {
70
+
71
+ //}
72
+ // }
73
+ // var buttonch = getCheckedRadio(document.getElementsByName('payment[method]'));
74
+ // if (buttonch & buttonch.value == 'planet_pay') {
75
+
76
+ // jq("#payment-buttons-container .required").css("display", "none");
77
+ // jq("#payment-buttons-container .button").css("display", "none");
78
+
79
+ // }
80
+ /*jq('.payment[method]').change(function() {
81
+ if ($(this).val() == "grijs") {
82
+ $('img').addClass('blackImage');
83
+ }
84
+ else if ($(this).val() == "sepia") {
85
+ $('img').addClass('sepiaImage');
86
+ }
87
+ else if ($(this).val() == "normal") {
88
+ $('img').addClass('normalImage');
89
+ }
90
+ });*/
91
+ // var selbrand = document.getElementsByName('payment[planet_payment_method]');
92
+ //var chobrand = document.getElementById('ipmethod').value;
93
+ // alert(chobrand);
94
+ // for (var i = 0; i < selbrand.length; i++) {
95
+ // if (selbrand[i].checked) {
96
+ // chobrand = selbrand[i].value;
97
+ // }
98
+ //}
99
+ function getCheckedRadio(radio_group) {
100
+ for (var i = 0; i < radio_group.length; i++) {
101
+ var button = radio_group[i];
102
+ if (button.checked) {
103
+ return button;
104
+ }
105
+ }
106
+ return undefined;
107
+ }
108
+ //var chobrand = jq('input[name=payment[planet_payment_method]]:checked').val();
109
+ jq(".newmethod").click(function() {
110
+
111
+ var checkedButton = getCheckedRadio(document.getElementsByName('payment[planet_payment_method]'));
112
+ if (checkedButton) {
113
+ alert("The value is " + checkedButton.value);
114
+ var chobrand = checkedButton.value;
115
+ }
116
+ jq.ajaxSetup({
117
+ cache: true
118
+ });
119
+ jq.ajax({
120
+ url: '<?php echo $baseurl; ?>server.php?token=<?php echo $token; ?>&url=<?php echo $urlform; ?>' + "&chobrand=" + chobrand,
121
+ context: document.body,
122
+ contentType: "text/html",
123
+ dataType: 'html',
124
+ beforeSend: function() {
125
+ // Handle the beforeSend event
126
+ },
127
+ success: function(data) {
128
+ //alert(typeof(data));
129
+ //jq("#checkout-step-payment .wpwl-container-card").html('');
130
+ //jq('#payment-tool-tip').before(data);
131
+ jq("#checkout-step-payment .new_payon_form").remove();
132
+ jq('#payment-tool-tip').before('<div class="new_payon_form">'+data+'</div>');
133
+ //jq("#checkout-step-payment").append(jq("<div>").load(data));
134
+ // Handle the complete event
135
+ },
136
+ complete: function() {
137
+ // Handle the complete event
138
+ //var htmlcont = jq("#payonpaymentform").html();
139
+ // jq("#payonpaymentform").html('');
140
+ // jq("#appendpayonhtml").html(htmlcont);
141
+ /// jq("#appendpayonhtml .wpwl-container-card").css("display","block");
142
+ //jq('#inputid').remove();
143
+ // jq(".wpwl-container-card .wpwl-wrapper-expiry").css("display","none");
144
+ // jq(".wpwl-container-card .wpwl-wrapper-expiry").css("display","none");
145
+ }
146
+ }).done(function() {
147
+ jq(this).addClass("done");
148
+ });
149
+ });
150
+ //]]>
151
+ </script>
152
+ <!-- ending payment form on payment step -->
app/design/frontend/default/default/template/planet_pay/form/pay_backup_1oct.phtml ADDED
@@ -0,0 +1,151 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this Planet_Pay_Block_Form_Pay */
3
+ $translatedProcessingMessage = "Processing Planet Payment";
4
+ //$tokeniz = $this->isTokenization();
5
+ $baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
6
+ /* if(!empty($tokeniz)){
7
+ $account_brand = $tokeniz[0]['account_brand'];
8
+ $registeration_id = $tokeniz[0]['registeration_id'];
9
+ $cc_last_four = $tokeniz[0]['cc_last_four'];
10
+ $cc_exp_month = $tokeniz[0]['cc_exp_month'];
11
+ $cc_exp_year = $tokeniz[0]['cc_exp_year'];
12
+ } */
13
+ $toarr = $this->getForm();
14
+ $token = $toarr['token'];
15
+ Mage::log($token, null, 'token.log');
16
+ $urlform = $toarr['url'];
17
+ ?>
18
+ <?php
19
+ // get domain from config
20
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
21
+ if ($testMode) {
22
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
23
+ $mode = "test";
24
+ } else {
25
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
26
+ $mode = "live";
27
+ }
28
+ preg_match('@^(?:https?://)?([^/]+)@i', $url, $hits);
29
+ $host = $hits[1];
30
+
31
+ $scripturl = $url . "/v1/paymentWidgets.js?checkoutId=" . $token;
32
+ ?>
33
+ <?php $_code = $this->getMethodCode() ?>
34
+ <fieldset class="form-list">
35
+ <div class="planet-payment-selection">
36
+ <ul id="payment_form_<?php echo $_code ?>" class="form-list" style="">
37
+ <?php $counter = 0; ?>
38
+ <?php foreach ($this->getCollection() as $methodItem): ?>
39
+ <li style="float: left; text-align: center;">
40
+ <label for="<?php echo $methodItem->getBrandcode(); ?>" style="display:block; float: none; margin: 0 3.5px;">
41
+ <?php if ($this->showIcons()) : ?>
42
+ <img src="<?php echo $this->getImagePath($methodItem); ?>" width="50" />
43
+ <?php endif; ?>
44
+ </label>
45
+ <input type="radio" name="payment[planet_payment_method]" id="ipmethod" class="newmethod" style="clear: both;" value="<?php echo $methodItem->getBrandcode(); ?>"/>
46
+ </li>
47
+ <?php $counter++; ?>
48
+ <?php endforeach; ?>
49
+ </ul>
50
+ </div>
51
+ </fieldset>
52
+
53
+
54
+ <script type="text/javascript">
55
+
56
+ //<![CDATA[
57
+
58
+
59
+
60
+ //]]>
61
+ </script>
62
+ <script type="text/javascript">
63
+
64
+ //<![CDATA[
65
+
66
+ var jq = jQuery.noConflict();
67
+ jq("#checkout-step-payment .wpwl-container-card").html('');
68
+ //jq("#payment-buttons-container .required").css("display", "none");
69
+ //jq("#payment-buttons-container .button").css("display", "none");
70
+ // if (jq(".newmethod").click(function() {
71
+
72
+ //}
73
+ // }
74
+ // var buttonch = getCheckedRadio(document.getElementsByName('payment[method]'));
75
+ // if (buttonch & buttonch.value == 'planet_pay') {
76
+
77
+ // jq("#payment-buttons-container .required").css("display", "none");
78
+ // jq("#payment-buttons-container .button").css("display", "none");
79
+
80
+ // }
81
+ /*jq('.payment[method]').change(function() {
82
+ if ($(this).val() == "grijs") {
83
+ $('img').addClass('blackImage');
84
+ }
85
+ else if ($(this).val() == "sepia") {
86
+ $('img').addClass('sepiaImage');
87
+ }
88
+ else if ($(this).val() == "normal") {
89
+ $('img').addClass('normalImage');
90
+ }
91
+ });*/
92
+ // var selbrand = document.getElementsByName('payment[planet_payment_method]');
93
+ //var chobrand = document.getElementById('ipmethod').value;
94
+ // alert(chobrand);
95
+ // for (var i = 0; i < selbrand.length; i++) {
96
+ // if (selbrand[i].checked) {
97
+ // chobrand = selbrand[i].value;
98
+ // }
99
+ //}
100
+ function getCheckedRadio(radio_group) {
101
+ for (var i = 0; i < radio_group.length; i++) {
102
+ var button = radio_group[i];
103
+ if (button.checked) {
104
+ return button;
105
+ }
106
+ }
107
+ return undefined;
108
+ }
109
+ //var chobrand = jq('input[name=payment[planet_payment_method]]:checked').val();
110
+ jq(".newmethod").click(function() {
111
+
112
+ var checkedButton = getCheckedRadio(document.getElementsByName('payment[planet_payment_method]'));
113
+ if (checkedButton) {
114
+ alert("The value is " + checkedButton.value);
115
+ var chobrand = checkedButton.value;
116
+ }
117
+ jq.ajaxSetup({
118
+ cache: true
119
+ });
120
+ jq.ajax({
121
+ url: '<?php echo $baseurl; ?>server.php?token=<?php echo $token; ?>&url=<?php echo $urlform; ?>' + "&chobrand=" + chobrand,
122
+ context: document.body,
123
+ contentType: "text/html",
124
+ dataType: 'html',
125
+ beforeSend: function() {
126
+ // Handle the beforeSend event
127
+ },
128
+ success: function(data) {
129
+ //alert(typeof(data));
130
+ jq("#checkout-step-payment .wpwl-container-card").html('');
131
+ jq('#payment-tool-tip').before(data);
132
+ //jq("#checkout-step-payment").append(jq("<div>").load(data));
133
+ // Handle the complete event
134
+ },
135
+ complete: function() {
136
+ // Handle the complete event
137
+ //var htmlcont = jq("#payonpaymentform").html();
138
+ // jq("#payonpaymentform").html('');
139
+ // jq("#appendpayonhtml").html(htmlcont);
140
+ /// jq("#appendpayonhtml .wpwl-container-card").css("display","block");
141
+ //jq('#inputid').remove();
142
+ // jq(".wpwl-container-card .wpwl-wrapper-expiry").css("display","none");
143
+ // jq(".wpwl-container-card .wpwl-wrapper-expiry").css("display","none");
144
+ }
145
+ }).done(function() {
146
+ jq(this).addClass("done");
147
+ });
148
+ });
149
+ //]]>
150
+ </script>
151
+ <!-- ending payment form on payment step -->
app/design/frontend/default/default/template/planet_pay/onepage/payment.phtml ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <style>
28
+ .pay_btn{display: none;}
29
+ </style>
30
+ <script type="text/javascript">
31
+ //<![CDATA[
32
+ var quoteBaseGrandTotal = <?php echo (float)$this->getQuoteBaseGrandTotal(); ?>;
33
+ var checkQuoteBaseGrandTotal = quoteBaseGrandTotal;
34
+ var payment = new Payment('co-payment-form', '<?php echo $this->getUrl('checkout/onepage/savePayment') ?>');
35
+ var lastPrice;
36
+ //]]>
37
+ </script>
38
+ <?php
39
+ $code = $this->getChild('methods')->getSelectedMethodCode();
40
+ ?>
41
+ <form action="" id="co-payment-form">
42
+ <fieldset>
43
+ <?php echo $this->getChildHtml('methods') ?>
44
+ </fieldset>
45
+ </form>
46
+
47
+ <div class="tool-tip" id="payment-tool-tip" style="display:none;">
48
+ <div class="btn-close"><a href="#" id="payment-tool-tip-close" title="<?php echo $this->__('Close') ?>"><?php echo $this->__('Close') ?></a></div>
49
+ <div class="tool-tip-content"><img src="<?php echo $this->getSkinUrl('images/cvv.gif') ?>" alt="<?php echo $this->__('Card Verification Number Visual Reference') ?>" title="<?php echo $this->__('Card Verification Number Visual Reference') ?>" /></div>
50
+ </div>
51
+ <div class="buttons-set" id="payment-buttons-container">
52
+ <p class="required pay_btn"><?php echo $this->__('* Required Fields') ?></p>
53
+ <p class="back-link"><a href="#" onclick="checkout.back(); return false;"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
54
+ <button type="button" class="button pay_btn" onclick="payment.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
55
+ <span class="please-wait" id="payment-please-wait" style="display:none;">
56
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Loading next step...') ?>" title="<?php echo $this->__('Loading next step...') ?>" class="v-middle" /> <?php echo $this->__('Loading next step...') ?>
57
+ </span>
58
+ </div>
59
+ <script type="text/javascript">
60
+ //<![CDATA[
61
+ function toggleToolTip(event){
62
+ if($('payment-tool-tip')){
63
+ $('payment-tool-tip').setStyle({
64
+ top: (Event.pointerY(event)-560)+'px'//,
65
+ //left: (Event.pointerX(event)+100)+'px'
66
+ })
67
+ $('payment-tool-tip').toggle();
68
+ }
69
+ Event.stop(event);
70
+ }
71
+ if($('payment-tool-tip-close')){
72
+ Event.observe($('payment-tool-tip-close'), 'click', toggleToolTip);
73
+ }
74
+ //]]>
75
+ </script>
76
+ <script type="text/javascript">
77
+ //<![CDATA[
78
+ payment.currentMethod = "<?php echo $this->getChild('methods')->getSelectedMethodCode() ?>";
79
+ //]]>
80
+ function hidecontreq(id){
81
+ if(id == "p_method_planet_pay"){
82
+ jQuery(".pay_btn").css("display", "none");
83
+ jQuery(".wpwl-container-card").css("display","block");
84
+ }else{
85
+ jQuery(".pay_btn").css("display", "block");
86
+ jQuery(".wpwl-container-card").css("display","none");
87
+
88
+ }
89
+ }
90
+ </script>
app/design/frontend/default/default/template/planet_pay/onepage/payment/methods.phtml ADDED
@@ -0,0 +1,75 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php
28
+ /**
29
+ * One page checkout payment methods
30
+ *
31
+ * @var $this Mage_Checkout_Block_Onepage_Payment_Methods
32
+ */
33
+ ?>
34
+
35
+ <?php
36
+ $methods = $this->getMethods();
37
+ $oneMethod = count($methods) <= 1;
38
+ ?>
39
+ <?php if (empty($methods)): ?>
40
+ <dt>
41
+ <?php echo $this->__('No Payment Methods') ?>
42
+ </dt>
43
+ <?php else:
44
+ foreach ($methods as $_method):
45
+ $_code = $_method->getCode();
46
+ ?>
47
+ <dt>
48
+ <?php if(!$oneMethod): ?>
49
+ <input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" title="<?php echo $this->escapeHtml($_method->getTitle()) ?>" onclick="payment.switchMethod('<?php echo $_code ?>'), hidecontreq(this.id)"<?php if($this->getSelectedMethodCode()==$_code): ?> checked="checked"<?php endif; ?> class="radio" />
50
+ <?php else: ?>
51
+ <span class="no-display"><input id="p_method_<?php echo $_code ?>" value="<?php echo $_code ?>" type="radio" name="payment[method]" checked="checked" class="radio" onclick="shamim(this.id)" /></span>
52
+ <?php $oneMethod = $_code; ?>
53
+ <?php endif; ?>
54
+ <label for="p_method_<?php echo $_code ?>"><?php echo $this->escapeHtml($this->getMethodTitle($_method)) ?> <?php echo $this->getMethodLabelAfterHtml($_method) ?></label>
55
+ </dt>
56
+ <?php if ($html = $this->getPaymentMethodFormHtml($_method)): ?>
57
+ <dd>
58
+ <?php echo $html; ?>
59
+ </dd>
60
+ <?php endif; ?>
61
+ <?php endforeach;
62
+ endif;
63
+ ?>
64
+ <?php echo $this->getChildChildHtml('additional'); ?>
65
+ <script type="text/javascript">
66
+ //<![CDATA[
67
+ <?php echo $this->getChildChildHtml('scripts'); ?>
68
+ payment.init();
69
+ <?php if (is_string($oneMethod)): ?>
70
+ payment.switchMethod('<?php echo $oneMethod ?>');
71
+ <?php endif; ?>
72
+ //]]>
73
+
74
+
75
+ </script>
app/design/frontend/default/default/template/planet_pay/onepage/review.phtml ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var Planet_Pay_Block_Checkout_Onepage_Review $this
4
+ */
5
+ ?>
6
+ <div class="order-review" id="checkout-review-load">
7
+ <!-- Content loaded dynamically -->
8
+ </div>
9
+
10
+ <?php
11
+ if ($this->loadReview()):
12
+ // get domain from config
13
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
14
+ if ($testMode) {
15
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
16
+ $mode = "test";
17
+ }
18
+ else {
19
+ $url = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
20
+ $mode = "live";
21
+ }
22
+ preg_match('@^(?:https?://)?([^/]+)@i', $url, $hits);
23
+ $host = $hits[1];
24
+ ?>
25
+ <script type="text/javascript">
26
+ //<![CDATA[
27
+ var updater = new Ajax.Updater('checkout-review-load', checkout.reviewUrl,
28
+ {
29
+ method: 'get',
30
+ onFailure: checkout.ajaxFailure.bind(checkout),
31
+ onComplete: function() {
32
+ var planet = new Planet();
33
+ planet.initForm({
34
+ mode: '<?= $mode ?>',
35
+ host: '<?= $host ?>'
36
+ });
37
+ <?php if(!is_null($this->getMessage())) : ?>
38
+ alert('<?php echo $this->getMessage(); ?>');
39
+ <?php endif; ?>
40
+ }
41
+ });
42
+ //]]>
43
+ </script>
44
+ <?php endif; ?>
app/design/frontend/default/default/template/planet_pay/onepage/review/button.phtml ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $paymentCode = Mage::getSingleton('checkout/session')->getQuote()->getPayment()->getMethodInstance()->getCode();
3
+ $token = Mage::getSingleton('core/session')->getGenerateToken();
4
+ Mage::log($token);
5
+ $addJs = null;
6
+ if ($paymentCode != 'planet_pay') {
7
+ $addJs = 'onclick="review.save();"';
8
+ ?>
9
+ <button type="submit" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" <?php echo $addJs; ?>"><span><span><?php echo $this->__('Place Order') ?></span></span></button>
10
+
11
+ <?php } else{ ?>
12
+ <form target="my_iframe" action="https://test.oppwa.com/v1/checkouts/<?php echo $token; ?>/payment" method="POST">
13
+ <input type="submit" value="<?php echo $this->__('Place Order') ?>" title="<?php echo $this->__('Place Order') ?>" class="button btn-checkout" onclick="show_review_processing(this);" style="clear: both;float:right;background-color:#FF7B2F;color:white;" />
14
+ <span class="please-wait" id="review-please-wait" style="display:none;">
15
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Processing please wait...') ?>" title="<?php echo $this->__('Processing please wait...') ?>" class="v-middle" /> <?php echo $this->__('Processing please wait...') ?>
16
+ </span>
17
+ <iframe name="my_iframe" style="visibility: hidden"></iframe>
18
+
19
+ <?php } ?>
app/design/frontend/default/default/template/planet_pay/onepage/review/info.phtml ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Academic Free License (AFL 3.0)
8
+ * that is bundled with this package in the file LICENSE_AFL.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/afl-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 design
22
+ * @package base_default
23
+ * @copyright Copyright (c) 2013 Magento Inc. (http://www.magentocommerce.com)
24
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
25
+ */
26
+ ?>
27
+ <?php echo $this->getChildHtml('items_before'); ?>
28
+ <div id="checkout-review-table-wrapper">
29
+ <table class="data-table" id="checkout-review-table">
30
+ <?php if ($this->helper('tax')->displayCartBothPrices()): $colspan = $rowspan = 2; else: $colspan = $rowspan = 1; endif; ?>
31
+ <col />
32
+ <col width="1" />
33
+ <col width="1" />
34
+ <col width="1" />
35
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
36
+ <col width="1" />
37
+ <col width="1" />
38
+ <?php endif; ?>
39
+ <thead>
40
+ <tr>
41
+ <th rowspan="<?php echo $rowspan ?>"><?php echo $this->__('Product Name') ?></th>
42
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Price') ?></th>
43
+ <th rowspan="<?php echo $rowspan ?>" class="a-center"><?php echo $this->__('Qty') ?></th>
44
+ <th colspan="<?php echo $colspan ?>" class="a-center"><?php echo $this->__('Subtotal') ?></th>
45
+ </tr>
46
+ <?php if ($this->helper('tax')->displayCartBothPrices()): ?>
47
+ <tr>
48
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
49
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
50
+ <th class="a-right"><?php echo $this->helper('tax')->getIncExcTaxLabel(false) ?></th>
51
+ <th><?php echo $this->helper('tax')->getIncExcTaxLabel(true) ?></th>
52
+ </tr>
53
+ <?php endif; ?>
54
+ </thead>
55
+ <?php echo $this->getChildHtml('totals'); ?>
56
+ <tbody>
57
+ <?php foreach($this->getItems() as $_item): ?>
58
+ <?php echo $this->getItemHtml($_item)?>
59
+ <?php endforeach ?>
60
+ </tbody>
61
+ </table>
62
+ </div>
63
+ <?php echo $this->getChildHtml('items_after'); ?>
64
+ <script type="text/javascript">
65
+ //<![CDATA[
66
+ decorateTable('checkout-review-table');
67
+ truncateOptions();
68
+
69
+ show_review_processing = function(el){
70
+ document.querySelector('#review-please-wait').style.display='block';
71
+ el.style.visibility='hidden';
72
+ }
73
+ //]]>
74
+
75
+
76
+ </script>
77
+ <div id="checkout-review-submit">
78
+ <?php echo $this->getChildHtml('agreements') ?>
79
+ <div class="buttons-set" id="review-buttons-container">
80
+ <p class="f-left"><?php echo $this->__('Forgot an Item?') ?> <a href="<?php echo $this->getUrl('checkout/cart') ?>"><?php echo $this->__('Edit Your Cart') ?></a></p>
81
+ <?php echo $this->getChildHtml('button') ?>
82
+ <span class="please-wait" id="review-please-wait" style="display:none;">
83
+ <img src="<?php echo $this->getSkinUrl('images/opc-ajax-loader.gif') ?>" alt="<?php echo $this->__('Processing please wait...') ?>" title="<?php echo $this->__('Processing please wait...') ?>" class="v-middle" /> <?php echo $this->__('Processing please wait...') ?>
84
+ </span>
85
+ </div>
86
+ <script type="text/javascript">
87
+ //<![CDATA[
88
+ review = new Review('<?php echo $this->getUrl('checkout/onepage/saveOrder', array('form_key' => Mage::getSingleton('core/session')->getFormKey())) ?>', '<?php echo $this->getUrl('checkout/onepage/success') ?>', $('checkout-agreements'));
89
+ //]]>
90
+ </script>
91
+ </div>
app/design/frontend/default/default/template/planet_pay/onepage/review/items_after.phtml ADDED
@@ -0,0 +1,2 @@
 
 
1
+ <?php
2
+ echo $this->getChildHtml('planet.checkout.form');
app/design/frontend/default/default/template/planet_pay/profile/edit.phtml ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_IpayGateway
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ /**
29
+ * @see OnePica_IpayGateWay_Block_PaymentProfile_Edit
30
+ */
31
+ ?>
32
+ <?php $profile = $this->getIpayPaymentProfile() ?>
33
+ <?php if ($this->getTitle()): ?>
34
+ <div class="page-title">
35
+ <h1><?php echo $this->getTitle() ?></h1>
36
+ </div>
37
+ <?php endif; ?>
38
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
39
+ <form action="<?php echo $this->getPostUrl() ?>" method="post" id="form-validate">
40
+ <div class="fieldset">
41
+ <?php echo $this->getBlockHtml('formkey') ?>
42
+ <input type="hidden" name="profile_id" value="<?php echo $profile->getId() ?>" />
43
+ <input type="hidden" name="success_url" value="<?php echo $this->getSuccessUrl() ?>" />
44
+ <input type="hidden" name="client_id" value="<?php echo $profile->getClientId() ?>" />
45
+ <input type="hidden" name="account_id" value="<?php echo $profile->getAccountId() ?>" />
46
+ <input type="hidden" name="error_url" value="<?php echo $this->getErrorUrl() ?>" />
47
+ <input type="hidden" name="payment[payment_profile_id]" value="<?php echo $profile->getId() ?>" />
48
+ <input type="hidden" name="payment[is_visible]" value="1" />
49
+
50
+ <h2 class="legend"><?php echo $this->__('Contact Information') ?></h2>
51
+ <ul class="form-list">
52
+ <li>
53
+ <label for="first_name" class="required"><em>*</em><?php echo $this->__('First Name') ?></label>
54
+ <div class="input-box">
55
+ <input type="text" name="first_name" id="first_name" title="<?php echo $this->__('First Name') ?>" value="<?php echo $this->htmlEscape($profile->getFirstName()) ?>" class="input-text required-entry" />
56
+ </div>
57
+ </li>
58
+ <li>
59
+ <label for="last_name" class="required"><em>*</em><?php echo $this->__('Last Name') ?></label>
60
+ <div class="input-box">
61
+ <input type="text" name="last_name" id="last_name" title="<?php echo $this->__('Last Name') ?>" value="<?php echo $this->htmlEscape($profile->getLastName()) ?>" class="input-text required-entry" />
62
+ </div>
63
+ </li>
64
+ <li>
65
+ <label for="company"><?php echo $this->__('Company') ?></label>
66
+ <div class="input-box">
67
+ <input type="text" name="company" id="company" title="<?php echo $this->__('Company') ?>" value="<?php echo $this->htmlEscape($profile->getCompany()) ?>" class="input-text" />
68
+ </div>
69
+ </li>
70
+ <li>
71
+ <label for="phone_number" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
72
+ <div class="input-box">
73
+ <input type="text" name="phone_number" value="<?php echo $this->htmlEscape($profile->getPhoneNumber()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text required-entry" id="phone_number" />
74
+ </div>
75
+ </li>
76
+ <?php /*
77
+ <li>
78
+ <label for="fax_number"><?php echo $this->__('Fax') ?></label>
79
+ <div class="input-box">
80
+ <input type="text" name="fax_number" id="fax_number" title="<?php echo $this->__('Fax') ?>" value="<?php echo $this->htmlEscape($this->getAddress()->getFax()) ?>" class="input-text" />
81
+ </div>
82
+ </li>
83
+ */ ?>
84
+ </ul>
85
+ </div>
86
+ <div class="fieldset">
87
+ <h2 class="legend"><?php echo $this->__('Payment Information') ?></h2>
88
+ <ul class="form-list">
89
+ <li>
90
+ <label for="ipay_cc_type" class="required"><em>*</em><?php echo $this->__('Credit Card Type') ?></label>
91
+ <div class="input-box">
92
+ <select id="ipay_cc_type" name="card_type" class="required-entry validate-cc-type-select">
93
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
94
+ <?php $_ccType = $profile->getData('card_type') ?>
95
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
96
+ <option value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
97
+ <?php endforeach ?>
98
+ </select>
99
+ </div>
100
+ </li>
101
+ <li>
102
+ <label for="ipay_cc_number" class="required"><em>*</em><?php echo $this->__('Credit Card Number') ?></label>
103
+ <div class="input-box">
104
+ <?php $cardNum = $profile->getCardNumberLast4() ? 'XXXX' . $profile->getCardNumberLast4() : '' ?>
105
+ <input type="text" id="ipay_cc_number" name="card_number" title="<?php echo $this->__('Credit Card Number') ?>" class="input-text validate-cc-number validate-cc-type" value="<?php echo $cardNum ?>" />
106
+ </div>
107
+ </li>
108
+ <li>
109
+ <label for="ipay_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
110
+ <div class="input-box">
111
+ <div class="v-fix">
112
+ <?php $_ccExpMonth = $profile->getExpirationMonth() ?>
113
+ <select id="ipay_expiration" name="expiration_month" class="month validate-cc-exp required-entry" style="width: auto;">
114
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
115
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
116
+ <?php endforeach ?>
117
+ </select>
118
+ </div>
119
+ <div class="v-fix" style="margin-left: 5px;">
120
+ <?php $_ccExpYear = $profile->getExpirationYear() ?>
121
+ <select id="ipay_expiration_yr" name="expiration_year" class="year required-entry" style="width: auto;">
122
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
123
+ <option value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
124
+ <?php endforeach ?>
125
+ </select>
126
+ </div>
127
+ </div>
128
+ </li>
129
+ <?php if ($this->hasVerification()): ?>
130
+ <li>
131
+ <label for="ipay_cc_cid" class="required"><em>*</em><?php echo $this->__('Card Verification Number') ?></label>
132
+ <div class="input-box">
133
+ <div class="v-fix">
134
+ <?php $_ccCid = $profile->getId() ? 'XXX' : '' ?>
135
+ <input type="text" id="ipay_cc_cid" name="card_code" title="<?php echo $this->__('Card Verification Number') ?>" class="input-text cvv required-entry validate-cc-cvn" value="<?php echo $_ccCid ?>" />
136
+ </div>
137
+ </div>
138
+ </li>
139
+ <?php endif; ?>
140
+ </ul>
141
+ </div>
142
+ <div class="fieldset">
143
+ <h2 class="legend"><?php echo $this->__('Address') ?></h2>
144
+ <ul class="form-list">
145
+ <li>
146
+ <label for="address" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
147
+ <div class="input-box">
148
+ <input type="text" name="address" value="<?php echo $this->htmlEscape($profile->getAddress()) ?>" title="<?php echo $this->__(' Address') ?>" id="address" class="input-text required-entry" />
149
+ </div>
150
+ </li>
151
+ <li>
152
+ <label for="city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
153
+ <div class="input-box">
154
+ <input type="text" name="city" value="<?php echo $this->htmlEscape($profile->getCity()) ?>" title="<?php echo $this->__('City') ?>" class="input-text required-entry" id="city" />
155
+ </div>
156
+ </li>
157
+ <li>
158
+ <label for="state" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
159
+ <div class="input-box">
160
+ <select id="state" name="state" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
161
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
162
+ </select>
163
+ <script type="text/javascript">
164
+ //<![CDATA[
165
+ $('state').setAttribute('defaultValue', "<?php echo $profile->getState() ?>");
166
+ //]]>
167
+ </script>
168
+ <input type="text" id="region" name="region" value="<?php echo $this->htmlEscape($profile->getState()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text" style="display:none;" />
169
+ </div>
170
+ </li>
171
+ <li>
172
+ <label for="zip" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
173
+ <div class="input-box">
174
+ <input type="text" name="zip" value="<?php echo $this->htmlEscape($profile->getZip()) ?>" title="<?php echo $this->__('Zip/Postal Code') ?>" id="zip" class="input-text validate-zip-international required-entry" />
175
+ </div>
176
+ </li>
177
+ <label for="country" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
178
+ <div class="input-box">
179
+ <?php echo $this->getCountryHtmlSelect($profile->getCountry(), 'country') ?>
180
+ </div>
181
+ </li>
182
+ </ul>
183
+ </div>
184
+ <div class="buttons-set">
185
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
186
+ <p class="back-link"><a href="<?php echo $this->escapeUrl($this->getBackUrl()) ?>"><small>&laquo; </small><?php echo $this->__('Back') ?></a></p>
187
+ <button type="submit" title="<?php echo $this->__('Save Stored Credit Card') ?>" class="button"><span><span><?php echo $this->__('Save Stored Credit Card') ?></span></span></button>
188
+ </div>
189
+ </form>
190
+ <script type="text/javascript">
191
+ //<![CDATA[
192
+ var dataForm = new VarienForm('form-validate', true);
193
+ new RegionUpdater('country', 'region', 'state', <?php echo $this->getRegionsJs() ?>, undefined, 'zip');
194
+ //]]>
195
+ </script>
app/design/frontend/default/default/template/planet_pay/profile/list.phtml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * One Pica
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to codemaster@onepica.com so we can send you a copy immediately.
14
+ *
15
+ * @category PlanetPayment
16
+ * @package PlanetPayment_IpayGateway
17
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ /**
22
+ * Planet Payment
23
+ *
24
+ * @category PlanetPayment
25
+ * @package PlanetPayment_IpayGateway
26
+ * @author One Pica Codemaster <codemaster@onepica.com>
27
+ */
28
+ ?>
29
+ <div class="page-title title-buttons">
30
+ <h1><?php echo $this->__('Stored Credit Card Profiles') ?></h1>
31
+ </div>
32
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
33
+ <ul>
34
+ <?php $profiles = $this->getPaymentProfiles() ?>
35
+ <?php if (count($profiles)): ?>
36
+ <?php foreach ($profiles as $profile): ?>
37
+ <li class="info-box">
38
+ <dl>
39
+ <dt><?php echo $this->__('Name'); ?>:</dt>
40
+ <dd><?php echo $profile->holder; ?></dd>
41
+ <?php if ($profile) { ?>
42
+ <dt><?php echo $this->__('Card Type'); ?>:</dt>
43
+ <dd><?php echo $profile->brand_name; ?></dd>
44
+ <dt><?php echo $this->__('Card Number'); ?>:</dt>
45
+ <dd><?php echo $this->__('Ends in') . ' ' . $profile->cc_last_four; ?></dd>
46
+ <?php } ?>
47
+ <dt><?php echo $this->__('Card Year(Ex)'); ?>:</dt>
48
+ <dd><?php echo $profile->cc_last_four; ?></dd>
49
+ <dt><?php echo $this->__('Card Month(Ex)'); ?>:</dt>
50
+ <dd><?php echo $profile->cc_exp_month; ?></dd>
51
+ </dl>
52
+ <p class="actions">
53
+ </p>
54
+ </li>
55
+ <?php endforeach; ?>
56
+ <?php else: ?>
57
+ <li class="item empty">
58
+ <p><?php echo $this->__('You have no stored credit card profiles.') ?></p>
59
+ </li>
60
+ <?php endif ?>
61
+ </ul>
62
+ <script type="text/javascript">
63
+ //<![CDATA[
64
+ function deleteProfile (profileId) {
65
+ if (confirm('<?php echo $this->__('Are you sure you want to delete this profile?') ?>')) {
66
+ window.location='<?php echo $this->getDeleteUrl() ?>profile_id/' + profileId;
67
+ }
68
+ return false;
69
+ }
70
+ //]]>
71
+ </script>
72
+ <style type="text/css">
73
+ .info-box { float: left; width: 44%; margin-right: 2%; }
74
+ .info-box:nth-child(even) { float: right; margin-right: 0; }
75
+ .info-box dl { margin: 10px 17px 17px; }
76
+ .info-box dt { float: left; clear: left; width: 30%; margin-right: 5%; font-weight: bold; }
77
+ .info-box dd { float: left; width: 65%; }
78
+ p.actions { clear: both; padding: 10px 17px 17px; }
79
+ </style>
app/etc/modules/PlanetPayment_Core.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0" encoding="UTF-8"?>
2
+ <config>
3
+ <modules>
4
+ <PlanetPayment_Core>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </PlanetPayment_Core>
8
+ </modules>
9
+ </config>
app/etc/modules/PlanetPayment_CurrencyManager.xml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Planet Payment
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ *
13
+ * @category PlanetPayment
14
+ * @package PlanetPayment_CurrencyManager
15
+ * @copyright Copyright (c) 2012 Planet Payment Inc. (http://www.planetpayment.com)
16
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
17
+ */
18
+ -->
19
+ <config>
20
+ <modules>
21
+ <PlanetPayment_CurrencyManager>
22
+ <active>true</active>
23
+ <codePool>community</codePool>
24
+ </PlanetPayment_CurrencyManager>
25
+ </modules>
26
+ </config>
app/etc/modules/Planet_Pay.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Planet_Pay>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ </Planet_Pay>
8
+ </modules>
9
+ </config>
lib/PlanetLib/Filter/FilterRound.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Filter;
3
+
4
+ /**
5
+ * Class FilterRound
6
+ * @package PlanetLib\Filter
7
+ */
8
+ class FilterRound
9
+ {
10
+
11
+ /**
12
+ * @param float $value
13
+ * @param int $precision
14
+ * @param bool $convertNull
15
+ * @return float
16
+ */
17
+ public static function round($value, $precision, $convertNull = false)
18
+ {
19
+ if (is_null($value)) {
20
+ if ($convertNull) {
21
+ $value = 0;
22
+ }
23
+ else {
24
+ return null;
25
+ }
26
+ }
27
+ //$value = round($value, $precision, PHP_ROUND_HALF_UP);
28
+ $value = number_format($value, $precision, '.', '');
29
+ return $value;
30
+ }
31
+
32
+ }
lib/PlanetLib/Filter/FilterString.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Filter;
3
+
4
+ /**
5
+ * Class FilterString
6
+ * @package PlanetLib\Filter
7
+ */
8
+ class FilterString
9
+ {
10
+
11
+ /**
12
+ * @param $data
13
+ * @return mixed
14
+ */
15
+ public static function convertValuesToString($data)
16
+ {
17
+ foreach ($data as $name => $value) {
18
+ if (is_array($value)) {
19
+ $data[$name] = self::convertValuesToString($value);
20
+ }
21
+ $data[$name] = (string)$value;
22
+ }
23
+ return $data;
24
+ }
25
+
26
+ }
lib/PlanetLib/Payment.php ADDED
@@ -0,0 +1,386 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PlanetLib;
4
+
5
+ use PlanetLib\Filter\FilterString;
6
+ use PlanetLib\Payment\PaymentCriterion;
7
+ use PlanetLib\Payment\PaymentCustomer;
8
+ use PlanetLib\Filter\FilterRound;
9
+
10
+ /**
11
+ * Object of this class is used as parameter for \PlanetLib\Planet::generateToken for obtaining token from Planet
12
+ * Parameters identical for project can be loaded automatically from config.ini and overwritten using setters
13
+ * Customer data and order data are transmitted as associative arrays useng setCustomerData and setCriterions
14
+ *
15
+ * Class Payment
16
+ * @package PlanetLib
17
+ */
18
+ class Payment {
19
+
20
+ protected $authenticationUserId;
21
+ protected $authenticationEntityId;
22
+ protected $authenticationPassword;
23
+ protected $paymentType;
24
+ protected $Currency;
25
+ protected $Amount;
26
+ protected $Testmode;
27
+ protected $Planetorderid;
28
+ protected $customermerchantCustomerId;
29
+ protected $billingcountry;
30
+
31
+ /**
32
+ * Parameters, identical for whole project can be loaded automatically from config file.
33
+ * They can be overwritten using setters
34
+ */
35
+ public function __construct() {
36
+ if (file_exists("config.ini")) {
37
+ $config = parse_ini_file("config.ini", true);
38
+ $this->fromArray($config['payment']);
39
+ }
40
+ }
41
+
42
+ /**
43
+ * @param array $credentials
44
+ * @throws PlanetException
45
+ * @return Payment
46
+ */
47
+ public function setCredentials($credentials) {
48
+ if (!is_array($credentials)) {
49
+ // if no config and no params available, throw exception
50
+ throw new PlanetException("No valid credentials set.");
51
+ }
52
+
53
+ $this->_setSequritySender($credentials['authenticationUserId']);
54
+ $this->_setTransactionChannel($credentials['authenticationEntityId']);
55
+ $this->_setUserPassword($credentials['authenticationPassword']);
56
+ $this->_setPaymentType($credentials['paymentType']);
57
+ $this->setCurrency($credentials['Currency']);
58
+ $this->_setAmount($credentials['Amount']);
59
+ $this->setTestMode($credentials['testMode']);
60
+ $this->setPlanetOrderId($credentials['merchantInvoiceId']);
61
+ $this->setCustomerMerchantCustomerId($credentials['customermerchantCustomerId']);
62
+ $this->setBillingCountry($credentials['billingcountry']);
63
+
64
+ return $this;
65
+ }
66
+
67
+ /**
68
+ * @param array $config
69
+ * @throws PlanetException
70
+ * @return Payment
71
+ */
72
+ public function setPaymentConfiguration($config) {
73
+ if (!is_array($config)) {
74
+ // if no config and no params available, throw exception
75
+ throw new PlanetException("No valid configuration set.");
76
+ }
77
+
78
+ $this->setCurrency($config['Currency']);
79
+ $this->_setPaymentType($config['paymentType']);
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * @param string $currency
86
+ * @return bool|array
87
+ */
88
+ public function setCurrency($currency) {
89
+ $this->Currency = $currency;
90
+ return true;
91
+ }
92
+ /**
93
+ * To set amount
94
+ *
95
+ * @param int $amount
96
+ * @return boolean
97
+ */
98
+
99
+ public function setAmount($amount) {
100
+ $this->Amount = FilterRound::round($amount, 2);
101
+ return true;
102
+ }
103
+ /**
104
+ * To set test mode
105
+ *
106
+ * @param type $text
107
+ * @return boolean
108
+ */
109
+ public function setTestMode($text) {
110
+ $this->Testmode = $text;
111
+ return true;
112
+ }
113
+ /**
114
+ * To set planet order id
115
+ *
116
+ * @param type $orderid
117
+ * @return boolean
118
+ */
119
+ public function setPlanetOrderId($orderid) {
120
+ $this->Planetorderid = $orderid;
121
+ return true;
122
+ }
123
+ /**
124
+ * To set Customer Merchant id
125
+ *
126
+ * @param type $orderid
127
+ * @return boolean
128
+ */
129
+ public function setCustomerMerchantCustomerId($setCustMerchantCustomerId) {
130
+ $this->customermerchantCustomerId = $setCustMerchantCustomerId;
131
+ return true;
132
+ }
133
+ /**
134
+ * To set billing country
135
+ *
136
+ * @param type $billingcountry
137
+ * @return boolean
138
+ */
139
+ public function setBillingCountry($billingcountry) {
140
+ $this->billingcountry = $billingcountry;
141
+ return true;
142
+ }
143
+
144
+ /**
145
+ * @param string $amount
146
+ * @return bool|array
147
+ */
148
+ protected function _setAmount($amount) {
149
+ $this->Amount = FilterRound::round($amount, 2);
150
+ return true;
151
+ }
152
+ /**
153
+ *
154
+ * @param array $data
155
+ * @return bool|array
156
+ */
157
+ public function setCustomerData($data) {
158
+ $paymentCustomer = new PaymentCustomer();
159
+ $result = $paymentCustomer->setData($data);
160
+ $this->customerData = $paymentCustomer;
161
+ if (is_array($result)) {
162
+ return $result;
163
+ }
164
+ return true;
165
+ }
166
+
167
+ /**
168
+ * Data array like this:
169
+ * <code>
170
+ * $data = array(
171
+ * 'customerAddressAdditionalData' => '',
172
+ * 'merchantId' => '',
173
+ * 'customerId' => '',
174
+ * 'orderShippingCosts' => 0.00,
175
+ * 'orderCurrency' => '',
176
+ * 'orderTransportationCosts' => 0.00,
177
+ * 'orderAdministrationFee' => 0.00,
178
+ * 'orderId' => '',
179
+ * 'orderExternalInvoiceId' => '',
180
+ * 'orderExternalReferenceNumber' => '',
181
+ * 'orderItems' => array(
182
+ * array(
183
+ * 'articleNumber' => '',
184
+ * 'articleDescription' => '',
185
+ * 'price' => 0.0,
186
+ * 'quantity' => 0,
187
+ * 'taxrate' => 0.0,
188
+ * 'discount' => 0.0,
189
+ * 'discountPct' => 0.0,
190
+ * 'ean' => '',
191
+ * 'grossweight' => 0.0,
192
+ * 'netweight' => 0.0
193
+ * )
194
+ * )
195
+ * );
196
+ * </code>
197
+ *
198
+ * @param array $data
199
+ * @return bool|array
200
+ */
201
+ public function setCriterions($data) {
202
+ $paymentCriterion = new PaymentCriterion($this);
203
+ $result = $paymentCriterion->setData($data);
204
+ $this->criterionData = $paymentCriterion;
205
+ //$this->_setAmount($this->criterionData->generateCriterionOrderTotalAmount());
206
+ if (is_array($result)) {
207
+ return $result;
208
+ }
209
+ return true;
210
+ }
211
+
212
+ public function getCriterions() {
213
+ return $this->criterionData;
214
+ }
215
+
216
+ /**
217
+ * @param string $sender
218
+ * @return bool|array
219
+ */
220
+ protected function _setSequritySender($sender) {
221
+ $this->authenticationUserId = $sender;
222
+ return true;
223
+ }
224
+
225
+ /**
226
+ * @param string $channel
227
+ * @return bool|array
228
+ */
229
+ protected function _setTransactionChannel($channel) {
230
+ $this->authenticationEntityId = $channel;
231
+ return true;
232
+ }
233
+
234
+
235
+ /**
236
+ * @param string $pwd
237
+ * @return bool|array
238
+ */
239
+ protected function _setUserPassword($pwd) {
240
+ $this->authenticationPassword = $pwd;
241
+ return true;
242
+ }
243
+
244
+ /**
245
+ * @param string $type
246
+ * @return bool|array
247
+ */
248
+ protected function _setPaymentType($type) {
249
+ $this->paymentType = $type;
250
+ return true;
251
+ }
252
+
253
+ /**
254
+ * Returns all params as array
255
+ *
256
+ * @param bool $converToString
257
+ * @return array
258
+ */
259
+ public function getRequestParams($converToString = false) {
260
+
261
+ if(!empty($this->Testmode)){
262
+ $data = array('authentication.userId' => $this->authenticationUserId,
263
+ 'authentication.entityId' => $this->authenticationEntityId ,
264
+ 'authentication.password' => $this->authenticationPassword ,
265
+ 'paymentType' => $this->paymentType,
266
+ 'amount' => $this->Amount,
267
+ 'currency' => $this->Currency,
268
+ 'testMode' => $this->Testmode,
269
+ 'merchantInvoiceId' => $this->Planetorderid,
270
+ 'customer.merchantCustomerId' => $this->customermerchantCustomerId,
271
+ 'billing.country' => $this->billingcountry);
272
+ }
273
+ else{
274
+ $data = array('authentication.userId' => $this->authenticationUserId,
275
+ 'authentication.entityId' => $this->authenticationEntityId ,
276
+ 'authentication.password' => $this->authenticationPassword ,
277
+ 'paymentType' => $this->paymentType,
278
+ 'amount' => $this->Amount,
279
+ 'currency' => $this->Currency,
280
+ 'merchantInvoiceId' => $this->Planetorderid,
281
+ 'customer.merchantCustomerId' => $this->customermerchantCustomerId,
282
+ 'billing.country' => $this->billingcountry);
283
+
284
+ }
285
+ if ($converToString) {
286
+ $data = FilterString::convertValuesToString($data);
287
+ }
288
+ if (!is_null($this->customerData)) {
289
+ $data = array_merge($data, $this->customerData->toArray(false, $converToString));
290
+ }
291
+ if (!is_null($this->criterionData)) {
292
+ $data = array_merge($data, $this->criterionData->toArray(false, $converToString));
293
+ }
294
+ return $data;
295
+ }
296
+
297
+ /**
298
+ * @param bool $internalNames
299
+ * @param bool $converToString
300
+ * @return array
301
+ */
302
+ public function toArray($internalNames = false, $converToString = false) {
303
+ if ($internalNames) {
304
+
305
+ if(!empty($this->Testmode)){
306
+ $data = array('authentication.userId' => $this->authenticationUserId,
307
+ 'authentication.entityId' => $this->authenticationEntityId,
308
+ 'authentication.password' => $this->authenticationPassword,
309
+ 'paymentType' => $this->paymentType,
310
+ 'amount' => $this->Amount,
311
+ 'currency' => $this->Currency,
312
+ 'testMode' => $this->Testmode,
313
+ 'merchantInvoiceId' => $this->Planetorderid,
314
+ 'customer.merchantCustomerId' => $this->customermerchantCustomerId,
315
+ 'billing.country' => $this->billingcountry);
316
+ }
317
+ else {
318
+ $data = array('authentication.userId' => $this->authenticationUserId,
319
+ 'authentication.entityId' => $this->authenticationEntityId,
320
+ 'authentication.password' => $this->authenticationPassword,
321
+ 'paymentType' => $this->paymentType,
322
+ 'amount' => $this->Amount,
323
+ 'currency' => $this->Currency,
324
+ 'merchantInvoiceId' => $this->Planetorderid,
325
+ 'customer.merchantCustomerId' => $this->customermerchantCustomerId,
326
+ 'billing.country' => $this->billingcountry);
327
+ }
328
+ if ($converToString) {
329
+ $data = FilterString::convertValuesToString($data);
330
+ }
331
+ if (!is_null($this->customerData)) {
332
+ $data['customerData'] = $this->customerData->toArray(true, $converToString);
333
+ }
334
+ if (!is_null($this->criterionData)) {
335
+ $data['criterionData'] = $this->criterionData->toArray(true, $converToString);
336
+ }
337
+ return $data;
338
+ } else {
339
+ return $this->getRequestParams();
340
+ }
341
+ }
342
+
343
+ /**
344
+ * @return mixed
345
+ */
346
+ public function getAmount() {
347
+ return $this->Amount;
348
+ }
349
+
350
+ /**
351
+ * Used for filling all parameters from one array
352
+ *
353
+ * @param $params
354
+ */
355
+ public function fromArray($params) {
356
+ $this->setCredentials($params);
357
+ $this->setPaymentConfiguration($params);
358
+ }
359
+
360
+ /**
361
+ * Returns params as string for GET request. Used internally from /PlanetLib/Planet
362
+ *
363
+ * @return string
364
+ */
365
+ public function getRequestData() {
366
+ $data = '';
367
+ $errors = array();
368
+ foreach ($this->getRequestParams() as $paramName => $paramValue) {
369
+ if (is_null($paramValue)) {
370
+ $errors[$paramName] = "Parameter $paramName is not set";
371
+ }
372
+ $data .= $paramName . '=' . urlencode($paramValue) . '&';
373
+ }
374
+ return rtrim($data, "&");
375
+ }
376
+
377
+ /**
378
+ * @param $merchantId
379
+ * @param $orderId
380
+ * @return string
381
+ */
382
+ private function getIdentificationTransactionId($merchantId, $orderId) {
383
+ return $merchantId . $orderId;
384
+ }
385
+
386
+ }
lib/PlanetLib/Payment/PaymentCriterion.php ADDED
@@ -0,0 +1,215 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PlanetLib\Payment;
4
+
5
+ use PlanetLib\Filter\FilterRound;
6
+ use PlanetLib\Filter\FilterString;
7
+ use PlanetLib\Validator\ValidatorFloat;
8
+ use PlanetLib\Validator\ValidatorInt;
9
+ use PlanetLib\Validator\ValidatorString;
10
+
11
+ /**
12
+ * Class PaymentCriterion
13
+ * @package PlanetLib\Payment
14
+ */
15
+ class PaymentCriterion {
16
+
17
+ protected $mapper;
18
+ protected $merchantItemId;
19
+ protected $discount;
20
+ protected $quantity;
21
+ protected $name;
22
+ protected $price;
23
+ protected $tax;
24
+ protected $orderTransportationCosts;
25
+ protected $orderAdministrationFee;
26
+ protected $orderOrderPositionsCount;
27
+ protected $orderTotalAmount;
28
+ protected $orderId;
29
+ protected $orderExternalInvoiceId;
30
+ protected $orderExternalReferenceNumber;
31
+ protected $orderInstallmentsIir;
32
+ protected $orderInstallmentsZeroInterest;
33
+ protected $orderInstallmentsCount;
34
+ protected $orderInstallmentsAmount;
35
+ protected $orderInstallmentsPromotionAccountId;
36
+ protected $orderPaymentMethod;
37
+ // criterions for shipping address (LOV-293)
38
+ protected $customerDeliveryaddressStreet;
39
+ protected $customerDeliveryaddressCity;
40
+ protected $customerDeliveryaddressState;
41
+ protected $customerDeliveryaddressState2;
42
+ protected $customerDeliveryaddressZip;
43
+ protected $customerDeliveryaddressCountry;
44
+ protected $customerDeliveryaddressAdditionalData;
45
+ protected $customerDeliveryAddressFirstName;
46
+ protected $customerDeliveryAddressLastName;
47
+ protected $orderItems;
48
+ protected $payment;
49
+
50
+ /**
51
+ *
52
+ */
53
+ public function __construct(\PlanetLib\Payment $payment) {
54
+ $this->payment = $payment;
55
+ $this->mapper = $this->fillMapper();
56
+ }
57
+
58
+ /**
59
+ * @param $data
60
+ * @return array|bool
61
+ */
62
+ public function setData($data) {
63
+ $errors = array();
64
+ foreach ($this->mapper as $name) {
65
+ $setterName = 'set' . ucfirst($name);
66
+ if (method_exists($this, $setterName)) {
67
+ $value = isset($data[$name]) ? $data[$name] : null;
68
+ $result = call_user_func_array(array($this, $setterName), array($value));
69
+ if (is_array($result)) {
70
+ $errors[$name] = $result;
71
+ }
72
+ }
73
+ }
74
+
75
+ if (count($errors) == 0) {
76
+ return true;
77
+ }
78
+ return $errors;
79
+ }
80
+
81
+ /**
82
+ * @param bool $internalNames
83
+ * @param bool $converToString
84
+ * @return array
85
+ */
86
+ public function toArray($internalNames = false, $converToString = false) {
87
+ $data = array();
88
+ if ($internalNames) {
89
+ foreach ($this->mapper as $name) {
90
+ $data[$name] = $this->$name;
91
+ }
92
+ } else {
93
+ foreach ($this->mapper as $index => $name) {
94
+ $data[$index] = $this->$name;
95
+ }
96
+ }
97
+ if ($converToString) {
98
+ $data = FilterString::convertValuesToString($data);
99
+ }
100
+
101
+ return $data;
102
+ }
103
+
104
+ /**
105
+ * @param mixed $criterionCustomerAddressAdditionalData
106
+ * @return array|bool
107
+ */
108
+ public function setCustomerAddressAdditionalData($criterionCustomerAddressAdditionalData) {
109
+ $validator = new ValidatorString(array('empty' => true));
110
+ if (!$validator->isValid($criterionCustomerAddressAdditionalData)) {
111
+ return $validator->getErrorMessages();
112
+ }
113
+ $this->customerAddressAdditionalData = $criterionCustomerAddressAdditionalData;
114
+ return true;
115
+ }
116
+
117
+ /**
118
+ * @param $criterionOrderPaymentMethod
119
+ * @return array|bool
120
+ */
121
+ public function setOrderPaymentMethod($criterionOrderPaymentMethod) {
122
+ $validator = new ValidatorString();
123
+ if (!$validator->isValid($criterionOrderPaymentMethod)) {
124
+ return $validator->getErrorMessages();
125
+ }
126
+ $this->orderPaymentMethod = $criterionOrderPaymentMethod;
127
+ return true;
128
+ }
129
+
130
+ /**
131
+ * @param field_type $customerDeliveryaddressStreet
132
+ */
133
+ public function setCustomerDeliveryaddressStreet($customerDeliveryaddressStreet) {
134
+ $this->customerDeliveryaddressStreet = $customerDeliveryaddressStreet;
135
+ return true;
136
+ }
137
+
138
+ /**
139
+ * @param field_type $customerDeliveryaddressCity
140
+ */
141
+ public function setCustomerDeliveryaddressCity($customerDeliveryaddressCity) {
142
+ $this->customerDeliveryaddressCity = $customerDeliveryaddressCity;
143
+ return true;
144
+ }
145
+
146
+ /**
147
+ * @param field_type $customerDeliveryaddressState
148
+ */
149
+ public function setCustomerDeliveryaddressState($customerDeliveryaddressState) {
150
+ $this->customerDeliveryaddressState = $customerDeliveryaddressState;
151
+ return true;
152
+ }
153
+ /**
154
+ * @param field_type $customerDeliveryaddressState
155
+ */
156
+ public function setCustomerDeliveryaddressState2($customerDeliveryaddressState) {
157
+ $this->customerDeliveryaddressState2 = $customerDeliveryaddressState;
158
+ return true;
159
+ }
160
+
161
+ /**
162
+ * @param field_type $customerDeliveryaddressZip
163
+ */
164
+ public function setCustomerDeliveryaddressZip($customerDeliveryaddressZip) {
165
+ $this->customerDeliveryaddressZip = $customerDeliveryaddressZip;
166
+ return true;
167
+ }
168
+
169
+ /**
170
+ * @param field_type $customerDeliveryaddressCountry
171
+ */
172
+ public function setCustomerDeliveryaddressCountry($customerDeliveryaddressCountry) {
173
+ $this->customerDeliveryaddressCountry = $customerDeliveryaddressCountry;
174
+ return true;
175
+ }
176
+
177
+ /**
178
+ * @param field_type $customerDeliveryaddressAdditionalData
179
+ */
180
+ public function setCustomerDeliveryaddressAdditionalData($customerDeliveryaddressAdditionalData) {
181
+ $this->customerDeliveryaddressAdditionalData = $customerDeliveryaddressAdditionalData;
182
+ return true;
183
+ }
184
+
185
+ /**
186
+ * @param mixed $customerDeliveryAddressFirstName
187
+ */
188
+ public function setCustomerDeliveryAddressFirstName($customerDeliveryAddressFirstName) {
189
+ $this->customerDeliveryAddressFirstName = $customerDeliveryAddressFirstName;
190
+ return true;
191
+ }
192
+
193
+ /**
194
+ * @param mixed $customerDeliveryAddressLastName
195
+ */
196
+ public function setCustomerDeliveryAddressLastName($customerDeliveryAddressLastName) {
197
+ $this->customerDeliveryAddressLastName = $customerDeliveryAddressLastName;
198
+ return true;
199
+ }
200
+
201
+ /**
202
+ * @return array
203
+ */
204
+ private function fillMapper() {
205
+ return array('shipping.givenName' => 'customerDeliveryAddressFirstName',
206
+ 'shipping.surname' => 'customerDeliveryAddressLastName',
207
+ //'shipping.street1' => 'customerDeliveryaddressStreet',
208
+ //'shipping.street2' => 'customerDeliveryaddressState2',
209
+ 'shipping.city' => 'customerDeliveryaddressCity',
210
+ 'shipping.state' => 'customerDeliveryaddressState',
211
+ 'shipping.postcode' => 'customerDeliveryaddressZip',
212
+ 'shipping.country' => 'customerDeliveryaddressCountry');
213
+ }
214
+
215
+ }
lib/PlanetLib/Payment/PaymentCustomer.php ADDED
@@ -0,0 +1,260 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PlanetLib\Payment;
4
+
5
+ use PlanetLib\Filter\FilterString;
6
+ use PlanetLib\Validator\ValidatorDate;
7
+ use PlanetLib\Validator\ValidatorEmail;
8
+ use PlanetLib\Validator\ValidatorIp;
9
+ use PlanetLib\Validator\ValidatorPhone;
10
+ use PlanetLib\Validator\ValidatorString;
11
+
12
+ /**
13
+ * Class PaymentCustomer
14
+ * @package PlanetLib\Payment
15
+ */
16
+ class PaymentCustomer {
17
+
18
+ protected $mapper;
19
+ protected $nameSalutation;
20
+ protected $nameGiven;
21
+ protected $nameSurname;
22
+ protected $nameBirthdate;
23
+ protected $addressStreet;
24
+ protected $addressZip;
25
+ protected $addressState;
26
+ protected $addressCity;
27
+ protected $nameBillingCountry;
28
+ protected $contactPhone;
29
+ protected $contactMobile;
30
+ protected $contactIp;
31
+ protected $contactEmail;
32
+ protected $defaultStringValidator;
33
+
34
+ /**
35
+ *
36
+ */
37
+ public function __construct() {
38
+ $this->defaultStringValidator = new ValidatorString(array('min' => 1));
39
+ $this->mapper = $this->fillMapper();
40
+ }
41
+
42
+ /**
43
+ * @param $data
44
+ * @return array|bool
45
+ */
46
+ public function setData($data) {
47
+ $errors = array();
48
+ foreach ($this->mapper as $name) {
49
+ $value = isset($data[$name]) ? $data[$name] : null;
50
+ $result = call_user_func_array(array($this, 'set' . ucfirst($name)), array($value));
51
+ if (is_array($result)) {
52
+ $errors[$name] = $result;
53
+ }
54
+ }
55
+ if (count($errors) == 0) {
56
+ return true;
57
+ }
58
+ return $errors;
59
+ }
60
+
61
+ /**
62
+ * @param bool $internalNames
63
+ * @param bool $converToString
64
+ * @return array
65
+ */
66
+ public function toArray($internalNames = false, $converToString = false) {
67
+ $data = array();
68
+ if ($internalNames) {
69
+ foreach ($this->mapper as $name) {
70
+ $data[$name] = $this->$name;
71
+ }
72
+ } else {
73
+ foreach ($this->mapper as $index => $name) {
74
+ $data[$index] = $this->$name;
75
+ }
76
+ }
77
+ if ($converToString) {
78
+ $data = FilterString::convertValuesToString($data);
79
+ }
80
+ return $data;
81
+ }
82
+
83
+ /**
84
+ * @param mixed $customerAddressCity
85
+ * @return $this|array
86
+ */
87
+ public function setAddressCity($customerAddressCity) {
88
+ if (!$this->defaultStringValidator->isValid($customerAddressCity)) {
89
+ return $this->defaultStringValidator->getErrorMessages();
90
+ }
91
+ $this->addressCity = $customerAddressCity;
92
+ return true;
93
+ }
94
+
95
+ /**
96
+ * @param mixed $customerAddressCountry
97
+ * @return array|bool
98
+ */
99
+ public function setNameBillingCountry($customerAddressCountry) {
100
+ if (!$this->defaultStringValidator->isValid($customerAddressCountry)) {
101
+ return $this->defaultStringValidator->getErrorMessages();
102
+ }
103
+ $this->nameBillingCountry = $customerAddressCountry;
104
+ return true;
105
+ }
106
+
107
+ /**
108
+ * @param mixed $customerAddressState
109
+ * @return array|bool
110
+ */
111
+ public function setAddressState($customerAddressState) {
112
+ if (!$this->defaultStringValidator->isValid($customerAddressState)) {
113
+ return $this->defaultStringValidator->getErrorMessages();
114
+ }
115
+ $this->addressState = $customerAddressState;
116
+ return true;
117
+ }
118
+
119
+ /**
120
+ * @param mixed $customerAddressStreet
121
+ * @return array|bool
122
+ */
123
+ public function setAddressStreet($customerAddressStreet) {
124
+ if (!$this->defaultStringValidator->isValid($customerAddressStreet)) {
125
+ return $this->defaultStringValidator->getErrorMessages();
126
+ }
127
+ $this->addressStreet = $customerAddressStreet;
128
+ return true;
129
+ }
130
+
131
+ /**
132
+ * @param mixed $customerAddressZip
133
+ * @return array|bool
134
+ */
135
+ public function setAddressZip($customerAddressZip) {
136
+ if (!$this->defaultStringValidator->isValid($customerAddressZip)) {
137
+ return $this->defaultStringValidator->getErrorMessages();
138
+ }
139
+ $this->addressZip = $customerAddressZip;
140
+ return true;
141
+ }
142
+
143
+ /**
144
+ * @param mixed $customerContactEmail
145
+ * @return array|bool
146
+ */
147
+ public function setContactEmail($customerContactEmail) {
148
+ $validator = new ValidatorEmail();
149
+ if (!$validator->isValid($customerContactEmail)) {
150
+ return $validator->getErrorMessages();
151
+ }
152
+ $this->contactEmail = $customerContactEmail;
153
+ return true;
154
+ }
155
+
156
+ /**
157
+ * @param mixed $customerContactIp
158
+ * @return array|bool
159
+ */
160
+ public function setContactIp($customerContactIp) {
161
+ $validator = new ValidatorIp();
162
+ if (!$validator->isValid($customerContactIp)) {
163
+ return $validator->getErrorMessages();
164
+ }
165
+ $this->contactIp = $customerContactIp;
166
+ return true;
167
+ }
168
+
169
+ /**
170
+ * @param mixed $customerContactMobile
171
+ * @return array|bool
172
+ */
173
+ public function setContactMobile($customerContactMobile) {
174
+ $validator = new ValidatorPhone(array('empty' => true));
175
+ if (!$validator->isValid($customerContactMobile)) {
176
+ return $validator->getErrorMessages();
177
+ }
178
+ $this->contactMobile = $customerContactMobile;
179
+ return true;
180
+ }
181
+
182
+ /**
183
+ * @param mixed $customerContactPhone
184
+ * @return array|bool
185
+ */
186
+ public function setContactPhone($customerContactPhone) {
187
+ $validator = new ValidatorPhone();
188
+ if (!$validator->isValid($customerContactPhone)) {
189
+ return $validator->getErrorMessages();
190
+ }
191
+ $this->contactPhone = $customerContactPhone;
192
+ return true;
193
+ }
194
+
195
+ /**
196
+ * @param mixed $customerNameBirthdate
197
+ * @return array|bool
198
+ */
199
+ public function setNameBirthdate($customerNameBirthdate) {
200
+ $validator = new ValidatorDate();
201
+ if (!$validator->isValid($customerNameBirthdate)) {
202
+ return $validator->getErrorMessages();
203
+ } else {
204
+ $this->nameBirthdate = $validator->getDate('Y-m-d');
205
+ return true;
206
+ }
207
+ }
208
+
209
+ /**
210
+ * @param mixed $customerNameFamily
211
+ * @return array|bool
212
+ */
213
+ public function setNameSurname($customerNameFamily) {
214
+ if (!$this->defaultStringValidator->isValid($customerNameFamily)) {
215
+ return $this->defaultStringValidator->getErrorMessages();
216
+ }
217
+ $this->nameSurname = $customerNameFamily;
218
+ return true;
219
+ }
220
+
221
+ /**
222
+ * @param mixed $customerNameGiven
223
+ * @return array|bool
224
+ */
225
+ public function setNameGiven($customerNameGiven) {
226
+ if (!$this->defaultStringValidator->isValid($customerNameGiven)) {
227
+ return $this->defaultStringValidator->getErrorMessages();
228
+ }
229
+ $this->nameGiven = $customerNameGiven;
230
+ return true;
231
+ }
232
+
233
+ /**
234
+ * @param mixed $customerNameSalutation
235
+ * @return array|bool
236
+ */
237
+ public function setNameSalutation($customerNameSalutation) {
238
+ if (!$this->defaultStringValidator->isValid($customerNameSalutation)) {
239
+ return $this->defaultStringValidator->getErrorMessages();
240
+ }
241
+ $this->nameSalutation = $customerNameSalutation;
242
+ return true;
243
+ }
244
+
245
+ /**
246
+ * @return array
247
+ */
248
+ private function fillMapper()
249
+ {
250
+ return array('customer.givenName' => 'nameGiven',
251
+ 'customer.surname' => 'nameSurname',
252
+ //'billing.street1' => 'addressStreet',
253
+ 'billing.postcode' => 'addressZip',
254
+ 'billing.state' => 'addressState',
255
+ 'billing.city' => 'addressCity',
256
+ 'customer.ip' => 'contactIp',
257
+ 'customer.email' => 'contactEmail');
258
+ }
259
+
260
+ }
lib/PlanetLib/Payment/PaymentOrderposition.php ADDED
@@ -0,0 +1,428 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Payment;
3
+
4
+ use PlanetLib\Filter\FilterRound;
5
+ use PlanetLib\Filter\FilterString;
6
+ use PlanetLib\Validator\ValidatorFloat;
7
+ use PlanetLib\Validator\ValidatorInt;
8
+ use PlanetLib\Validator\ValidatorString;
9
+
10
+ /**
11
+ * Class PaymentOrderposition
12
+ * @package PlanetLib\Payment
13
+ */
14
+ class PaymentOrderposition
15
+ {
16
+ protected $mapper;
17
+ protected $payment;
18
+
19
+ protected $articleNumber;
20
+ protected $articleDescription;
21
+ protected $price;
22
+ protected $priceOriginal;
23
+ protected $quantity;
24
+ protected $taxrate;
25
+ protected $discount;
26
+ protected $discountPct;
27
+ protected $ean;
28
+ protected $grossweight;
29
+ protected $netweight;
30
+
31
+ // Gross (brutto) price of product.
32
+ // Excluding all other costs. Discount is not subtracted.
33
+ protected $shopPrice;
34
+
35
+ // Index of order item. Necessary because first items are handeled differently.
36
+ protected $index;
37
+
38
+ /**
39
+ *
40
+ */
41
+ public function __construct(\PlanetLib\Payment\PaymentCriterion $payment)
42
+ {
43
+ $this->payment = $payment;
44
+ $this->mapper = $this->fillMapper();
45
+
46
+ }
47
+
48
+ /**
49
+ * @param $orderPositionIndex
50
+ * @return array
51
+ */
52
+ public function setIndex($orderPositionIndex)
53
+ {
54
+ $validator = new ValidatorInt();
55
+ if (!$validator->isValid($orderPositionIndex)) {
56
+ return $validator->getErrorMessages();
57
+ }
58
+
59
+ $this->index = (int) $orderPositionIndex;
60
+ return true;
61
+ }
62
+
63
+ /**
64
+ * @param $data
65
+ * @param null|PaymentCriterion $paymentCriterion
66
+ * @return array|bool
67
+ */
68
+ public function setData($data, $paymentCriterion = null)
69
+ {
70
+ $errors = array();
71
+ foreach ($this->mapper as $name) {
72
+ $value = isset($data[$name]) ? $data[$name] : null;
73
+ $methodName = 'set'.ucfirst($name);
74
+ if (method_exists($this, $methodName)) {
75
+ $result = call_user_func_array(array($this, $methodName) , array($value));
76
+ if (is_array($result)) {
77
+ $errors[$name] = $result;
78
+ }
79
+ }
80
+ }
81
+ $this->_generatePrice();
82
+ if (count($errors) == 0) {
83
+ return true;
84
+ }
85
+ return $errors;
86
+ }
87
+
88
+ /**
89
+ * @param $ord
90
+ * @param bool $internalNames
91
+ * @param bool $converToString
92
+ * @return array
93
+ */
94
+ public function toArray($ord, $internalNames = false, $converToString = false)
95
+ {
96
+ // refresh prices
97
+ $this->_generatePrice();
98
+
99
+ $data = array();
100
+
101
+ if ($internalNames) {
102
+ foreach ($this->mapper as $name) {
103
+ $data[$name] = $this->$name;
104
+ }
105
+ $data['index'] = $this->getIndex();
106
+ }
107
+ else {
108
+ $ordinaryIndexName = 'CRITERION.ORDERPOSITION.' . $ord . '.';
109
+ foreach ($this->mapper as $index => $name) {
110
+ $data[$ordinaryIndexName.$index] = $this->$name;
111
+ }
112
+ $data[$ordinaryIndexName.'index'] = $this->getIndex();
113
+ }
114
+ if ($converToString) {
115
+ $data = FilterString::convertValuesToString($data);
116
+ }
117
+ return $data;
118
+ }
119
+
120
+ /**
121
+ * @param mixed $orderpositionArticleDescription
122
+ * @return array|bool
123
+ */
124
+ public function setArticleDescription($orderpositionArticleDescription)
125
+ {
126
+ $validator = new ValidatorString();
127
+ if (!$validator->isValid($orderpositionArticleDescription)) {
128
+ return $validator->getErrorMessages();
129
+ }
130
+ $this->articleDescription = $orderpositionArticleDescription;
131
+ return true;
132
+ }
133
+
134
+ /**
135
+ * @param mixed $orderpositionArticleNumber
136
+ * @return array|bool
137
+ */
138
+ public function setArticleNumber($orderpositionArticleNumber)
139
+ {
140
+ $validator = new ValidatorString();
141
+ if (!$validator->isValid($orderpositionArticleNumber)) {
142
+ return $validator->getErrorMessages();
143
+ }
144
+ $this->articleNumber = $orderpositionArticleNumber;
145
+ return true;
146
+ }
147
+
148
+ /**
149
+ * @param mixed $orderpositionDiscount
150
+ * @return array|bool
151
+ */
152
+ public function setDiscount($orderpositionDiscount)
153
+ {
154
+ $validator = new ValidatorFloat(array('empty' => true));
155
+ if (!$validator->isValid($orderpositionDiscount)) {
156
+ return $validator->getErrorMessages();
157
+ }
158
+ $this->discount = FilterRound::round($orderpositionDiscount, 2);
159
+ return true;
160
+ }
161
+
162
+ /**
163
+ * @param mixed $orderpositionDiscountPct
164
+ * @return array|bool
165
+ */
166
+ public function setDiscountPct($orderpositionDiscountPct)
167
+ {
168
+ $validator = new ValidatorFloat(array('empty' => true));
169
+ if (!$validator->isValid($orderpositionDiscountPct)) {
170
+ return $validator->getErrorMessages();
171
+ }
172
+ $this->discountPct = FilterRound::round($orderpositionDiscountPct, 2);
173
+ return true;
174
+ }
175
+
176
+ /**
177
+ * @param mixed $orderpositionEan
178
+ * @return array|bool
179
+ */
180
+ public function setEan($orderpositionEan)
181
+ {
182
+ $validator = new ValidatorString();
183
+ if (!$validator->isValid($orderpositionEan)) {
184
+ return $validator->getErrorMessages();
185
+ }
186
+ $this->ean = $orderpositionEan;
187
+ return true;
188
+ }
189
+
190
+ /**
191
+ * @param mixed $orderpositionGrossweight
192
+ * @return array|bool
193
+ */
194
+ public function setGrossweight($orderpositionGrossweight)
195
+ {
196
+ $validator = new ValidatorFloat(array('empty' => true));
197
+ if (!$validator->isValid($orderpositionGrossweight)) {
198
+ return $validator->getErrorMessages();
199
+ }
200
+ $this->grossweight = $orderpositionGrossweight;
201
+ return true;
202
+ }
203
+
204
+ /**
205
+ * @param mixed $orderpositionNetweight
206
+ * @return array|bool
207
+ */
208
+ public function setNetweight($orderpositionNetweight)
209
+ {
210
+ $validator = new ValidatorFloat(array('empty' => true));
211
+ if (!$validator->isValid($orderpositionNetweight)) {
212
+ return $validator->getErrorMessages();
213
+ }
214
+ $this->netweight = $orderpositionNetweight;
215
+ return true;
216
+ }
217
+
218
+ /**
219
+ * @param mixed $orderpositionQuantity
220
+ * @return array|bool
221
+ */
222
+ public function setQuantity($orderpositionQuantity)
223
+ {
224
+ $validator = new ValidatorInt(array('min' => 1));
225
+ if (!$validator->isValid($orderpositionQuantity)) {
226
+ return $validator->getErrorMessages();
227
+ }
228
+ $this->quantity = $orderpositionQuantity;
229
+ return true;
230
+ }
231
+
232
+ /**
233
+ * @param mixed $orderpositionTaxrate
234
+ * @return array|bool
235
+ */
236
+ public function setTaxrate($orderpositionTaxrate)
237
+ {
238
+ $validator = new ValidatorFloat(array('empty' => true));
239
+ if (!$validator->isValid($orderpositionTaxrate)) {
240
+ return $validator->getErrorMessages();
241
+ }
242
+ $this->taxrate = FilterRound::round($orderpositionTaxrate, 2);
243
+ return true;
244
+ }
245
+
246
+ /**
247
+ * @param mixed $orderpositionArticleDescription
248
+ * @return array|bool
249
+ */
250
+ public function setShopPrice($orderpositionShopPrice)
251
+ {
252
+ $validator = new ValidatorFloat();
253
+ if (!$validator->isValid($orderpositionShopPrice)) {
254
+ return $validator->getErrorMessages();
255
+ }
256
+ $this->shopPrice = $orderpositionShopPrice;
257
+
258
+ $this->_generatePrice();
259
+ return true;
260
+ }
261
+
262
+ /**
263
+ * @return float
264
+ */
265
+ public function getShopPrice()
266
+ {
267
+ return FilterRound::round($this->shopPrice, 2);
268
+ }
269
+
270
+ /**
271
+ * @param mixed $orderpositionPrice
272
+ * @return array|bool
273
+ */
274
+ protected function _setPrice($orderpositionPrice)
275
+ {
276
+ $validator = new ValidatorFloat(array('min' => 0.01));
277
+ if (!$validator->isValid($orderpositionPrice)) {
278
+ return $validator->getErrorMessages();
279
+ }
280
+ $this->price = FilterRound::round($orderpositionPrice, 2);
281
+ return true;
282
+ }
283
+
284
+ /**
285
+ * @param $orderpositionPriceOriginal
286
+ * @return array|bool
287
+ */
288
+ protected function _setPriceOriginal($orderpositionPriceOriginal)
289
+ {
290
+ $validator = new ValidatorFloat(array('min' => 0.01));
291
+ if (!$validator->isValid($orderpositionPriceOriginal)) {
292
+ return $validator->getErrorMessages();
293
+ }
294
+ $this->priceOriginal = FilterRound::round($orderpositionPriceOriginal, 2);
295
+ return true;
296
+ }
297
+
298
+
299
+ /**
300
+ * @return mixed
301
+ */
302
+ public function getTaxrate()
303
+ {
304
+ return FilterRound::round($this->taxrate, 2);
305
+ }
306
+
307
+ /**
308
+ * @return mixed
309
+ */
310
+ public function getPrice()
311
+ {
312
+ return FilterRound::round($this->price, 2);
313
+ }
314
+
315
+ /**
316
+ * @return mixed
317
+ */
318
+ public function getPriceOriginal()
319
+ {
320
+ return FilterRound::round($this->priceOriginal, 2);
321
+ }
322
+
323
+ /**
324
+ * @return int
325
+ */
326
+ public function getQuantity()
327
+ {
328
+ return $this->quantity;
329
+ }
330
+
331
+ /**
332
+ * @return mixed
333
+ */
334
+ public function getDiscount()
335
+ {
336
+ return FilterRound::round($this->discount, 2);
337
+ }
338
+
339
+ /**
340
+ * @return mixed
341
+ */
342
+ public function getDiscountPercent()
343
+ {
344
+ return FilterRound::round($this->discountPct, 2);
345
+ }
346
+
347
+ /**
348
+ * @param PaymentCriterion $paymentCriterion
349
+ * @return mixed
350
+ */
351
+ private function _generatePrice()
352
+ {
353
+ $paymentCriterion = $this->payment;
354
+ /*
355
+ * for first order item add shipping costs, administration fee
356
+ * and additional transportation costs in priceOriginal
357
+ */
358
+ $priceOriginal = $this->getShopPrice();
359
+ if($this->getIndex() == 1)
360
+ {
361
+ $orderShippingCosts = $paymentCriterion->getOrderShippingCosts();
362
+ $orderAdministrationFee = $paymentCriterion->getOrderAdministrationFee();
363
+ $orderAdditionalTransportationCosts = $paymentCriterion->getOrderTransportationCosts();
364
+ // add costs from order
365
+ $priceOriginal = $priceOriginal + $orderShippingCosts + $orderAdministrationFee + $orderAdditionalTransportationCosts;
366
+ }
367
+ $this->_setPriceOriginal($priceOriginal);
368
+
369
+ /*
370
+ * calculate price: including installments
371
+ *
372
+ * Discounts:
373
+ * P = gross price of article in shop
374
+ * ORDERPOSITION.X.PRICE = P - (P * $this->discountPct / 100) - $this->discount;
375
+ *
376
+ * installments:
377
+ * P = gross price of article in shop, discount subtracted
378
+ * ORDERPOSITION.X.PRICE = P + P * (InterestRate /12*months) = P + P * (0.139/12*12)
379
+ *
380
+ */
381
+
382
+ $shopPrice = $this->getShopPrice();
383
+ $price = $shopPrice;
384
+ // discounts
385
+ // $price = $shopPrice - ($shopPrice * $this->discountPct / 100) - $this->discount;
386
+
387
+ // installments
388
+ if(!is_null($paymentCriterion) && !is_null($paymentCriterion->getOrderInstallmentsIir()))
389
+ {
390
+ $price = $price + $price * (((float)$paymentCriterion->getOrderInstallmentsIir() / 100) / 12 * $paymentCriterion->getOrderInstallmentsCount());
391
+ }
392
+
393
+
394
+ $this->_setPrice($price);
395
+
396
+ return true;
397
+ }
398
+
399
+ /**
400
+ * returns numeric index of order item (1...n)
401
+ * @return int
402
+ */
403
+ public function getIndex()
404
+ {
405
+ return (int) $this->index;
406
+ }
407
+
408
+ /**
409
+ * @return array
410
+ */
411
+ private function fillMapper()
412
+ {
413
+ return array('ARTICLE_NUMBER' => 'articleNumber',
414
+ 'ARTICLE_DESCRIPTION' => 'articleDescription',
415
+ 'PRICE' => 'price',
416
+ 'ORIG_PRICE' => 'priceOriginal',
417
+ 'QUANTITY' => 'quantity',
418
+ 'TAXRATE' => 'taxrate',
419
+ 'DISCOUNT' => 'discount',
420
+ 'DISCOUNT_PCT' => 'discountPct',
421
+ 'EAN' => 'ean',
422
+ 'GROSSWEIGHT' => 'grossweight',
423
+ 'NETWEIGHT' => 'netweight',
424
+ 'SHOP_PRICE' => 'shopPrice');
425
+ }
426
+
427
+
428
+ }
lib/PlanetLib/Payon.php ADDED
@@ -0,0 +1,134 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib;
3
+ use PlanetLib\Request\Curl;
4
+ use PlanetLib\Request\Stream;
5
+
6
+ /**
7
+ * The Pay.On system is working different for certain payment methods. E.g. for SOFORT.
8
+ *
9
+ * Class Payon
10
+ * @package PlanetLib
11
+ */
12
+ class Payon
13
+ {
14
+ protected $url;
15
+
16
+ protected $sequritySender;
17
+ protected $queryEntity;
18
+ protected $userLogin;
19
+ protected $userPwd;
20
+ protected $transactionMode;
21
+
22
+ /**
23
+ * constructor for class to read from configuration file
24
+ *
25
+ */
26
+ public function __construct()
27
+ {
28
+ if (file_exists("config.ini")) {
29
+ $config = parse_ini_file("config.ini", true);
30
+ $this->setUrl($config['general']['payonUrl']);
31
+ $this->setCredentials($config['payment']);
32
+ }
33
+ }
34
+
35
+ /**
36
+ * This set the credntilas needed for api
37
+ *
38
+ * @param $credentials
39
+ * @return $this
40
+ * @throws PlanetException
41
+ */
42
+ public function setCredentials($credentials)
43
+ {
44
+ if(!is_array($credentials))
45
+ {
46
+ // if no config and no params available, throw exception
47
+ throw new PlanetException("No valid credentials set.");
48
+ }
49
+
50
+ $this->_setSequritySender($credentials['sequritySender']);
51
+ $this->_setQueryEntity($credentials['queryEntity']);
52
+ $this->_setUserLogin($credentials['userLogin']);
53
+ $this->_setUserPassword($credentials['userPwd']);
54
+ $this->_setTransactionMode($credentials['transactionMode']);
55
+
56
+ if (isset($credentials['url'])) {
57
+ $this->setUrl($credentials['url']);
58
+ }
59
+
60
+ return $this;
61
+ }
62
+
63
+ /**
64
+ * To set the URL
65
+ *
66
+ * @param $url
67
+ * @return $this
68
+ */
69
+ public function setUrl($url)
70
+ {
71
+ $this->url = $url;
72
+ return $this;
73
+ }
74
+
75
+ /**
76
+ * To check for Curl version
77
+ *
78
+ * @return bool
79
+ */
80
+ protected function isCurl()
81
+ {
82
+ return function_exists('curl_version');
83
+ }
84
+
85
+ /**
86
+ * To set the sequrity sender
87
+ *
88
+ * @param string $sender
89
+ * @return bool|array
90
+ */
91
+ protected function _setSequritySender($sender)
92
+ {
93
+ $this->sequritySender = $sender;
94
+ return true;
95
+ }
96
+
97
+
98
+ /**
99
+ * To Set the User login
100
+ *
101
+ * @param string $login
102
+ * @return bool|array
103
+ */
104
+ protected function _setUserLogin($login)
105
+ {
106
+ $this->userLogin = $login;
107
+ return true;
108
+ }
109
+
110
+ /**
111
+ * To Set The User Password
112
+ *
113
+ * @param string $pwd
114
+ * @return bool|array
115
+ */
116
+ protected function _setUserPassword($pwd)
117
+ {
118
+ $this->userPwd = $pwd;
119
+ return true;
120
+ }
121
+
122
+ /**
123
+ * To Set The Transaction mode
124
+ *
125
+ * @param string $mode
126
+ * @return bool|array
127
+ */
128
+ protected function _setTransactionMode($mode)
129
+ {
130
+ $this->transactionMode = $mode;
131
+ return true;
132
+ }
133
+
134
+ }
lib/PlanetLib/Planet.php ADDED
@@ -0,0 +1,128 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PlanetLib;
4
+
5
+ use PlanetLib\Writer\WriterSession;
6
+
7
+ /**
8
+ * Class used for token generation and obtaining payment status.
9
+ * For token generation generateToken method is used. It accepts object of \PlanetLib\Payment
10
+ * and returns token. Token also can be saved in store (by default session is used)
11
+ * for automatic obtaining it from \PlanetLib\View for form generation.
12
+ * For obtaining payment status getResult is used. It accepts token from planet callback
13
+ * and returns object of \PlanetLib\Response, which can be used for checking status.
14
+ *
15
+ * Class Planet
16
+ * @package PlanetLib
17
+ *
18
+ */
19
+ class Planet {
20
+
21
+ protected $url;
22
+ protected $writer;
23
+
24
+ /**
25
+ * Writer can be transmited on creation, or later using setter
26
+ *
27
+ * @param WriterInterface $writer
28
+ */
29
+ public function __construct(WriterInterface $writer = null) {
30
+ if (file_exists("config.ini")) {
31
+ $config = parse_ini_file("config.ini", true);
32
+ $this->setUrl($config['general']['url']);
33
+ }
34
+
35
+ if (is_null($writer)) {
36
+ $writer = new WriterSession();
37
+ }
38
+ $this->writer = $writer;
39
+ }
40
+
41
+ /**
42
+ * Method used for token generation.
43
+ * Sends request to planet service and saves obtained token to storage using writer.
44
+ * For request will be used Curl if it's installed or stream if not
45
+ *
46
+ * @param Payment $payment
47
+ * @return string - token, obtained from service
48
+ * @throws PlanetException
49
+ */
50
+ public function generateToken(Payment $payment) {
51
+ if (is_null($this->url)) {
52
+ throw new PlanetException('The url is not set');
53
+ }
54
+ $url = $this->url . '/v1/checkouts';
55
+ if ($this->isCurl()) {
56
+ $responseObj = new \PlanetLib\Request\Curl();
57
+ $options = array(
58
+ CURLOPT_POST => true,
59
+ CURLOPT_POSTFIELDS => $payment->getRequestData()
60
+ );
61
+ } else {
62
+ $responseObj = new \PlanetLib\Request\Stream();
63
+ $options = array('http' => array(
64
+ 'method' => 'POST',
65
+ 'content' => $payment->getRequestData()
66
+ ));
67
+ }
68
+ $response = $responseObj->getResponse($url, $options);
69
+ $response = json_decode($response, true);
70
+ $token = $response['id'];
71
+ $optionexp = explode('&',$options['10015']);
72
+ //$file1 = '../var/log/requestparamters.txt';
73
+ //$file2 = '../var/log/responseparamters.txt';
74
+ file_put_contents("var/log/requestparamters.txt", print_r($optionexp,true),FILE_APPEND);
75
+ file_put_contents("var/log/responseparamters.txt", print_r($response,true),FILE_APPEND);
76
+ if(!empty($response['result']['parameterErrors'])){
77
+ $description = $response['result']['parameterErrors'];
78
+ throw new PlanetException('Response error:-'.$description);
79
+ }
80
+ $this->writer->writeToken($token);
81
+ return $token;
82
+ }
83
+
84
+ /**
85
+ * Method for checking payment status.
86
+ * Token, obtained from planet callback is accepted as param
87
+ * Returns object of \PlanetLib\Response
88
+ *
89
+ * @param string $token
90
+ * @return Response
91
+ */
92
+ public function getResult($token) {
93
+ $url = $this->url . "/v1/checkouts/" . $token . "/payment";
94
+ if ($this->isCurl()) {
95
+ $responseObj = new \PlanetLib\Request\Curl();
96
+ $options = array(
97
+ CURLOPT_FOLLOWLOCATION => 1
98
+ );
99
+ } else {
100
+ $responseObj = new \PlanetLib\Request\Stream();
101
+ $options = null;
102
+ }
103
+ $response = $responseObj->getResponse($url, $options);
104
+ $result = new Response($response);
105
+ return $result;
106
+ }
107
+
108
+ /**
109
+ * To set the Url
110
+ *
111
+ * @param $url
112
+ * @return $this
113
+ */
114
+ public function setUrl($url) {
115
+ $this->url = $url;
116
+ return $this;
117
+ }
118
+
119
+ /**
120
+ * To Check the Curl version
121
+ *
122
+ * @return bool
123
+ */
124
+ protected function isCurl() {
125
+ return function_exists('curl_version');
126
+ }
127
+
128
+ }
lib/PlanetLib/PlanetException.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib;
3
+
4
+ use Exception;
5
+
6
+ /**
7
+ * To Handle the exception in Lib
8
+ *
9
+ * Class PlanetException
10
+ * @package PlanetLib
11
+ */
12
+ class PlanetException extends \Exception
13
+ {
14
+
15
+ }
lib/PlanetLib/Request/Curl.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ namespace PlanetLib\Request;
4
+
5
+ class Curl {
6
+
7
+ /**
8
+ * To get the response from server
9
+ *
10
+ * @param string $url
11
+ * @param null $options
12
+ * @return mixed
13
+ * @throws PlanetException
14
+ */
15
+ public function getResponse($url, $options = null) {
16
+ $ch = curl_init();
17
+ curl_setopt($ch, CURLOPT_URL, $url);
18
+ curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
19
+ curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
20
+ curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
21
+ if (!empty($options) && is_array($options)) {
22
+ foreach ($options as $option => $value) {
23
+ curl_setopt($ch, $option, $value);
24
+ }
25
+ }
26
+ $result = curl_exec($ch);
27
+ curl_close($ch);
28
+ if (is_null($result)) {
29
+ throw new PlanetException("Problem with reading data from $url");
30
+ }
31
+ return $result;
32
+ }
33
+
34
+ }
lib/PlanetLib/Request/Stream.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Request;
3
+
4
+ class Stream
5
+ {
6
+
7
+ /**
8
+ * To Get the response from server
9
+ *
10
+ * @param string $url
11
+ * @param null $options
12
+ * @return mixed
13
+ * @throws PlanetException
14
+ */
15
+ public function getResponse($url, $options = null)
16
+ {
17
+ $ctx = stream_context_create($options);
18
+ $fp = @fopen($url, 'rb', false, $ctx);
19
+
20
+ if (!$fp) {
21
+ throw new PlanetException("Problem with $url, $php_errormsg");
22
+ }
23
+ $response = @stream_get_contents($fp);
24
+
25
+ if ($response === false) {
26
+ throw new PlanetException("Problem reading data from $url, $php_errormsg");
27
+ }
28
+ return $response;
29
+ }
30
+ }
lib/PlanetLib/Resources/Content/Brands.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Content;
3
+
4
+ /**
5
+ * Class Brands
6
+ * @package LoviitLib\Resources\Content
7
+ */
8
+ class Brands
9
+ {
10
+ private static $brands = array(
11
+ 'AMEX' => array(
12
+ 'name' => 'American Express',
13
+ 'code' => 6,
14
+ 'flags' => ''
15
+ ),
16
+ 'MASTER' => array(
17
+ 'name' => 'MasterCard',
18
+ 'code' => 6,
19
+ 'flags' => ''
20
+ ),
21
+ 'VISA' => array(
22
+ 'name' => 'Visa',
23
+ 'code' => 6,
24
+ 'flags' => ''
25
+ ),
26
+ 'DISCOVER' => array(
27
+ 'name' => 'discover',
28
+ 'code' => 6,
29
+ 'flags' => ''
30
+ ),
31
+ 'DINERS' => array(
32
+ 'name' => 'diners',
33
+ 'code' => 6,
34
+ 'flags' => ''
35
+ )
36
+ );
37
+
38
+ /**
39
+ * @return array
40
+ */
41
+ public static function getBrands()
42
+ {
43
+ $brands = array();
44
+ foreach(self::$brands as $brand=>$values){
45
+ $brands[$brand] = $values['name'];
46
+ }
47
+ return $brands;
48
+ }
49
+
50
+ /**
51
+ * @param $brand
52
+ * @return array|null
53
+ */
54
+ public static function getFlags($brand)
55
+ {
56
+ if (!empty(self::$brands[$brand]['flags'])){
57
+ return self::$brands[$brand]['flags'];
58
+ }
59
+ return null;
60
+ }
61
+ }
lib/PlanetLib/Resources/Translation/BrandNames.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Translation;
3
+
4
+ /**
5
+ * Class BrandNames
6
+ * @package PlanetLib\Resources\Translation
7
+ */
8
+ class BrandNames
9
+ {
10
+ protected $locales = array('de');
11
+
12
+ /** @var BrandNames */
13
+ protected $localeClass;
14
+
15
+ /**
16
+ * @param $locale
17
+ */
18
+ public function __construct($locale)
19
+ {
20
+ if (in_array($locale, $this->locales)) {
21
+ $className = '\PlanetLib\Resources\Translation\\'.$locale.'\BrandNames';
22
+ $this->localeClass = new $className;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @return bool
28
+ */
29
+ public function localeExists()
30
+ {
31
+ return is_object($this->localeClass);
32
+ }
33
+
34
+ /**
35
+ * @param $brandCode
36
+ * @return null|string
37
+ */
38
+ public function getBrandName($brandCode)
39
+ {
40
+ if (!is_object($this->localeClass)) {
41
+ return null;
42
+ }
43
+ return $this->localeClass->_getBrandName($brandCode);
44
+ }
45
+
46
+ /**
47
+ * @return null|string
48
+ */
49
+ public function getBrandNames()
50
+ {
51
+ if (!is_object($this->localeClass)) {
52
+ return null;
53
+ }
54
+ return $this->localeClass->_getBrandNames();
55
+ }
56
+
57
+ /**
58
+ * @return mixed
59
+ */
60
+ protected function _getBrandNames()
61
+ {
62
+ return null;
63
+ }
64
+
65
+ /**
66
+ * @param $brandCode
67
+ * @return mixed
68
+ */
69
+ protected function _getBrandName($brandCode)
70
+ {
71
+ return null;
72
+ }
73
+
74
+ }
lib/PlanetLib/Resources/Translation/ErrorCodes.php ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Translation;
3
+
4
+ /**
5
+ * Class ErrorCodes
6
+ * @package PlanetLib\Resources\Translation
7
+ */
8
+ class ErrorCodes
9
+ {
10
+ protected $locales = array('de');
11
+
12
+ /** @var ErrorCodes */
13
+ protected $localeClass;
14
+
15
+ /**
16
+ * @param $locale
17
+ */
18
+ public function __construct($locale)
19
+ {
20
+ if (in_array($locale, $this->locales)) {
21
+ $className = '\PlanetLib\Resources\Translation\\'.$locale.'\ErrorCodes';
22
+ $this->localeClass = new $className;
23
+ }
24
+ }
25
+
26
+ /**
27
+ * @return bool
28
+ */
29
+ public function localeExists()
30
+ {
31
+ return is_object($this->localeClass);
32
+ }
33
+
34
+ /**
35
+ * @param $code
36
+ * @return null|string
37
+ */
38
+ public function getErrorMessage($code)
39
+ {
40
+ if (!is_object($this->localeClass)) {
41
+ return null;
42
+ }
43
+ return $this->localeClass->_getErrorMessage($code);
44
+ }
45
+
46
+ /**
47
+ * @return null|string
48
+ */
49
+ public function getErrorCodes()
50
+ {
51
+ if (!is_object($this->localeClass)) {
52
+ return null;
53
+ }
54
+ return $this->localeClass->_getErrorCodes();
55
+ }
56
+
57
+ /**
58
+ * @return mixed
59
+ */
60
+ protected function _getErrorCodes()
61
+ {
62
+ return null;
63
+ }
64
+
65
+ /**
66
+ * @param $code
67
+ * @return mixed
68
+ */
69
+ protected function _getErrorMessage($code)
70
+ {
71
+ return null;
72
+ }
73
+
74
+ }
lib/PlanetLib/Resources/Translation/de/BrandNames.php ADDED
@@ -0,0 +1,159 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Translation\de;
3
+ use PlanetLib\Resources\Translation\BrandNames as BrandNamesAbstract;
4
+
5
+
6
+ /**
7
+ * Class BrandNames
8
+ * @package PlanetLib\Resources\Translation\de
9
+ */
10
+ class BrandNames extends BrandNamesAbstract
11
+ {
12
+ protected $brandNames = array (
13
+ 'AMEX' => array(
14
+ 'name' => 'American Express',
15
+ ),
16
+ 'BARPAY' => array(
17
+ 'name' => 'BarPay',
18
+ ),
19
+ 'BOLETO' => array(
20
+ 'name' => 'Boleto',
21
+ ),
22
+ 'CARTEBLEUE' => array(
23
+ 'name' => 'Carte Bleue',
24
+ ),
25
+ 'CHINAUNIONPAY' => array(
26
+ 'name' => 'China UnionPay',
27
+ ),
28
+ 'DANKORT' => array(
29
+ 'name' => 'Dankort',
30
+ ),
31
+ 'DINERS' => array(
32
+ 'name' => 'Diners',
33
+ ),
34
+ 'DIRECTDEBIT_SEPA' => array(
35
+ 'name' => 'SEPA Überweisung',
36
+ ),
37
+ 'DIRECTDEBIT_SEPA_MIX_DE' => array(
38
+ 'name' => 'Direct Debit Germany and Sepa',
39
+ ),
40
+ 'DIRECTDEBIT_SEPA_MIX_AT' => array(
41
+ 'name' => 'Direct Debit Austria and Sepa',
42
+ ),
43
+ 'DIRECTDEBIT_DE' => array(
44
+ 'name' => 'Direct Debit Germany',
45
+ ),
46
+ 'DIRECTDEBIT_AT' => array(
47
+ 'name' => 'Direct Debit Austria',
48
+ ),
49
+ 'DISCOVER' => array(
50
+ 'name' => 'Discover',
51
+ ),
52
+ 'GIROPAY' => array(
53
+ 'name' => 'Giropay',
54
+ ),
55
+ 'IDEAL' => array(
56
+ 'name' => 'iDeal',
57
+ ),
58
+ 'INVOICE' => array(
59
+ 'name' => 'Rechnung',
60
+ ),
61
+ 'JCB' => array(
62
+ 'name' => 'JCB',
63
+ ),
64
+ 'MAESTRO' => array(
65
+ 'name' => 'Maestro',
66
+ ),
67
+ 'MASTER' => array(
68
+ 'name' => 'MasterCard',
69
+ ),
70
+ 'PASTEANDPAY_V' => array(
71
+ 'name' => 'PasteAndPay',
72
+ ),
73
+ 'PAYPAL' => array(
74
+ 'name' => 'PayPal',
75
+ ),
76
+ 'POSTEPAY' => array(
77
+ 'name' => 'PostePay',
78
+ ),
79
+ 'SOFORTUEBERWEISUNG' => array(
80
+ 'name' => 'sofort Überweisung',
81
+ ),
82
+ 'UKASH' => array(
83
+ 'name' => 'Ukash',
84
+ ),
85
+ 'VISA' => array(
86
+ 'name' => 'Visa',
87
+ ),
88
+ 'VISADEBIT' => array(
89
+ 'name' => 'Visa Debit',
90
+ ),
91
+ 'VISAELECTRON' => array(
92
+ 'name' => 'Visa Electron',
93
+ ),
94
+ 'VPAY' => array(
95
+ 'name' => 'V PAY',
96
+ ),
97
+ 'VSTATION_V' => array(
98
+ 'name' => 'Voucher Station',
99
+ ),
100
+ 'AXESS' => array(
101
+ 'name' => 'AXESS',
102
+ ),
103
+ 'BONUS' => array(
104
+ 'name' => 'Bonus',
105
+ ),
106
+ 'MAXIMUM' => array(
107
+ 'name' => 'Maximum',
108
+ ),
109
+ 'WORLD' => array(
110
+ 'name' => 'World',
111
+ ),
112
+ 'CARDFINANS' => array(
113
+ 'name' => 'CardFinans',
114
+ ),
115
+ 'ADVANTAGE' => array(
116
+ 'name' => 'Advantage',
117
+ ),
118
+ 'QOOQO' => array(
119
+ 'name' => 'Qooqo',
120
+ ),
121
+ 'KLARNA_INVOICE' => array(
122
+ 'name' => 'Klarna Invoice',
123
+ ),
124
+ 'KLARNA_INSTALLMENTS' => array(
125
+ 'name' => 'Klarna Installments',
126
+ ),
127
+ 'ASYACARD' => array(
128
+ 'name' => 'AsyaCard',
129
+ )
130
+ );
131
+
132
+ /**
133
+ * @return array
134
+ */
135
+ protected function _getBrandNames()
136
+ {
137
+ $brandNames = array();
138
+ foreach ($this->brandNames as $brandCode => $brand) {
139
+ $brandNames[$brandCode] = $brand['name'];
140
+ }
141
+ return $brandNames;
142
+ }
143
+
144
+
145
+ /**
146
+ * @param $key
147
+ * @return null|string
148
+ */
149
+ protected function _getBrandName($key)
150
+ {
151
+ if (isset($this->brandNames[$key])) {
152
+ return $this->brandNames[$key]['name'];
153
+ }
154
+ else {
155
+ return null;
156
+ }
157
+ }
158
+
159
+ }
lib/PlanetLib/Resources/Translation/de/ErrorCodes.php ADDED
@@ -0,0 +1,90 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Translation\de;
3
+ use PlanetLib\Resources\Translation\ErrorCodes as ErrorCodesAbstract;
4
+
5
+
6
+ /**
7
+ * Class ErrorCodes
8
+ * @package PlanetLib\Resources\Translation\de
9
+ */
10
+ class ErrorCodes extends ErrorCodesAbstract
11
+ {
12
+ protected $errorCodes = array (
13
+ '100.100.100' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
14
+ '100.100.101' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
15
+ '100.100.201' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
16
+ '100.100.300' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
17
+ '100.100.400' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
18
+ '100.100.401' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
19
+ '100.100.600' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
20
+ '100.100.601' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
21
+ '100.100.700' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
22
+ '100.100.701' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
23
+ '100.200.103' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
24
+ '100.200.104' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
25
+ '100.350.100' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
26
+ '100.370.100' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
27
+ '100.380.401' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen. ',
28
+ '100.380.501' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
29
+ '100.390.105' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
30
+ '100.396.101' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
31
+ '100.396.103' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
32
+ '100.400.303' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur Adresse, um die Bestellung abzuschließen.',
33
+ '100.400.307' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
34
+ '100.400.308' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
35
+ '100.400.310' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
36
+ '100.900.200' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur Telefonnummer, um die Bestellung abzuschließen.',
37
+ '200.100.103' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
38
+ '200.100.302' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
39
+ '200.100.401' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
40
+ '700.400.700' => 'initial and referencing channel-ids do not match',
41
+ '800.100.151' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
42
+ '800.100.152' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
43
+ '800.100.153' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
44
+ '800.100.155' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
45
+ '800.100.156' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
46
+ '800.100.159' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
47
+ '800.100.165' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
48
+ '800.100.167' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
49
+ '800.100.168' => 'Bitte wenden Sie sich an Ihre Bank. Ihre Kreditkarte kann aktuell nicht genutzt werden.',
50
+ '800.100.190' => 'Bitte überprüfen und korrigieren Sie Ihre Eingaben zur gewählten Zahlart, um die Bestellung abzuschließen.',
51
+ '800.110.100' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
52
+ '900.100.100' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
53
+ '900.100.200' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
54
+ '900.100.201' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
55
+ '900.100.202' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
56
+ '900.100.300' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
57
+ '900.100.600' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
58
+ '900.300.600' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.',
59
+ '000.400.200' => 'Die gewünschte Zahlart steht für Ihre Bestellung aktuell nicht zur Verfügung. Bitte versuchen Sie es zu einem späteren Zeitpunkt erneut oder wählen Sie eine alternative Zahlart, um Ihre Bestellung abzuschließen.',
60
+ '000.400.102' => '3D-Secure Fehler',
61
+ 'default' => 'Die Sitzung wurde abgebrochen. Bitte starten Sie den Bestellprozess neu.'
62
+ );
63
+
64
+ /**
65
+ * @return array
66
+ */
67
+ protected function _getErrorCodes()
68
+ {
69
+ return $this->errorCodes;
70
+ }
71
+
72
+
73
+ /**
74
+ * @param $key
75
+ * @return null|string
76
+ */
77
+ protected function _getErrorMessage($key)
78
+ {
79
+ if (isset($this->errorCodes[$key])) {
80
+ return $this->errorCodes[$key];
81
+ }
82
+ elseif ($key != '000.000.000') {
83
+ return $this->errorCodes['default'];
84
+ }
85
+ else {
86
+ return null;
87
+ }
88
+ }
89
+
90
+ }
lib/PlanetLib/Resources/Translation/de/ServiceMessages.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Resources\Translation\de;
3
+
4
+ /**
5
+ * Class ServiceMessages
6
+ * @package PlanetLib\Resources\Translation\de
7
+ */
8
+ class ServiceMessages extends \PlanetLib\Resources\Translation\ServiceMessages
9
+ {
10
+
11
+ protected $messages = array(
12
+ 'legal-terms' => 'Mit dem Kauf dieses Produktes akzeptieren Sie die <a href="http://www.planet.com/agb" target="_blank"> Geschäftsbedingungen </a> von Planet'
13
+ );
14
+
15
+
16
+
17
+ /**
18
+ *
19
+ */
20
+ public function __construct()
21
+ {
22
+
23
+ }
24
+
25
+ }
lib/PlanetLib/Response.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib;
3
+ use PlanetLib\Resources\Translation\ErrorCodes;
4
+
5
+ /**
6
+ * Class for storage and checking response.
7
+ *
8
+ * Class Response
9
+ * @package PlanetLib
10
+ */
11
+ class Response
12
+ {
13
+ protected $data;
14
+
15
+ /**
16
+ * @param $response
17
+ */
18
+ public function __construct($response)
19
+ {
20
+ $this->data = json_decode($response, true);
21
+ }
22
+
23
+ /**
24
+ * Returns true if response is valid
25
+ *
26
+ * @return bool
27
+ */
28
+ public function isValid()
29
+ {
30
+ $code = $this->data['result']['code'];
31
+
32
+ if (!isset($this->data['result']['code'])){
33
+ return false;
34
+ }
35
+ elseif(substr($this->data["result"]["code"], 0, 3) !== "000"){
36
+ return false;
37
+ }
38
+ else{
39
+ return true;
40
+ }
41
+ }
42
+
43
+ /**
44
+ * Returns message from response
45
+ *
46
+ * @param null $language
47
+ * @return string
48
+ */
49
+ public function getMessage($language = null)
50
+ {
51
+ if (!is_null($language) && !is_null($this->getCode())) {
52
+ $errorCodes = new ErrorCodes($language);
53
+ if ($errorCodes->localeExists()) {
54
+ return $errorCodes->getErrorMessage($this->getCode());
55
+ }
56
+ }
57
+ if (isset($this->data["result"]["description"])){
58
+ return $this->data["result"]['code'].'/'.$this->data["result"]["description"];
59
+ }
60
+ // return $this->data['transaction']['processing']['return']['message'];
61
+ }
62
+
63
+ /**
64
+ *
65
+ * @return string|null
66
+ */
67
+ public function getCode()
68
+ {
69
+ if (isset($this->data["result"]['code'])){
70
+ return $this->data["result"]['code'];
71
+ }
72
+ return null;
73
+ }
74
+
75
+ /**
76
+ * Retunrs timestamp of transaction processing
77
+ *
78
+ * @return string
79
+ */
80
+ public function getTime()
81
+ {
82
+ return $this->data['transaction']['processing']['timestamp'];
83
+ }
84
+
85
+ /**
86
+ * @return null|string
87
+ */
88
+ public function getOrderId()
89
+ {
90
+ $orderId = null;
91
+ if (isset($this->data['transaction']) && is_array($this->data['transaction']['criterions'])) {
92
+ foreach ($this->data['transaction']['criterions'] as $criterion) {
93
+ if ($criterion['name'] == 'ORDER.ID') {
94
+ $orderId = $criterion['value'];
95
+ break;
96
+ }
97
+ }
98
+ }
99
+ return $orderId;
100
+ }
101
+
102
+ /**
103
+ * @return null|string
104
+ */
105
+ public function getTransactionId()
106
+ {
107
+ return $this->data['id'];
108
+ }
109
+
110
+ /**
111
+ * Returns all response as array
112
+ *
113
+ * @return array
114
+ */
115
+ public function toArray()
116
+ {
117
+ return $this->data;
118
+ }
119
+
120
+ }
lib/PlanetLib/Validator/ValidatorDate.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorDate
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorDate implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+ protected $date;
13
+
14
+
15
+ /**
16
+ * @param $item
17
+ * @return bool
18
+ */
19
+ public function isValid($item)
20
+ {
21
+ $this->messages = array();
22
+ $valid = true;
23
+
24
+ $this->date = strtotime($item);
25
+ if ($this->date === false) {
26
+ $valid = false;
27
+ $this->messages[] = 'Incorrect date format';
28
+ }
29
+
30
+ return $valid;
31
+ }
32
+
33
+ /**
34
+ * @param $format
35
+ * @return string
36
+ */
37
+ public function getDate($format)
38
+ {
39
+ return date($format, $this->date);
40
+ }
41
+
42
+ /**
43
+ * @return array
44
+ */
45
+ public function getErrorMessages()
46
+ {
47
+ return $this->messages;
48
+ }
49
+ }
lib/PlanetLib/Validator/ValidatorEmail.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorEmail
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorEmail implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+
13
+ /**
14
+ * @param $item
15
+ * @return bool
16
+ */
17
+ public function isValid($item)
18
+ {
19
+ $this->messages = array();
20
+ if (filter_var($item, FILTER_VALIDATE_EMAIL)) {
21
+ $valid = true;
22
+ }
23
+ else {
24
+ $valid = false;
25
+ $this->messages[] = 'Incorrect e-mail address';
26
+ }
27
+ return $valid;
28
+ }
29
+
30
+ /**
31
+ * @return array
32
+ */
33
+ public function getErrorMessages()
34
+ {
35
+ return $this->messages;
36
+ }
37
+ }
lib/PlanetLib/Validator/ValidatorFloat.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorFloat
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorFloat implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+ protected $empty = false;
13
+ protected $min;
14
+
15
+ public function __construct($parameters = null)
16
+ {
17
+ if (is_array($parameters)) {
18
+ if (isset($parameters['empty'])) {
19
+ $this->empty = $parameters['empty'];
20
+ }
21
+ if (isset($parameters['min'])) {
22
+ $this->min = $parameters['min'];
23
+ }
24
+ }
25
+ }
26
+
27
+
28
+ /**
29
+ * @param $item
30
+ * @return bool
31
+ */
32
+ public function isValid($item)
33
+ {
34
+ $this->messages = array();
35
+ $valid = true;
36
+
37
+ if (is_null($item) && !$this->empty) {
38
+ $valid = false;
39
+ $this->messages[] = 'Value can not be empty';
40
+ }
41
+ else {
42
+ if (!filter_var($item, FILTER_VALIDATE_FLOAT)) {
43
+ $valid = false;
44
+ if (empty($item)) {
45
+ $this->messages[] = 'Value can not be empty';
46
+ }
47
+ else {
48
+ $this->messages[] = 'Value '.$item.' is not a float';
49
+ }
50
+ }
51
+ if (isset($this->min) && $this->min > $item) {
52
+ $valid = false;
53
+ $this->messages[] = 'Value must be bigger than '.$this->min;
54
+ }
55
+ }
56
+
57
+ return $valid;
58
+ }
59
+
60
+ /**
61
+ * @return array
62
+ */
63
+ public function getErrorMessages()
64
+ {
65
+ return $this->messages;
66
+ }
67
+ }
lib/PlanetLib/Validator/ValidatorInt.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorInt
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorInt implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+ protected $empty = false;
13
+ protected $min;
14
+
15
+ public function __construct($parameters = null)
16
+ {
17
+ if (is_array($parameters)) {
18
+ if (isset($parameters['empty'])) {
19
+ $this->empty = $parameters['empty'];
20
+ }
21
+ if (isset($parameters['min'])) {
22
+ $this->min = $parameters['min'];
23
+ }
24
+ }
25
+ }
26
+
27
+
28
+ /**
29
+ * @param $item
30
+ * @return bool
31
+ */
32
+ public function isValid($item)
33
+ {
34
+ $this->messages = array();
35
+ $valid = true;
36
+
37
+ if (is_null($item) && !$this->empty) {
38
+ $valid = false;
39
+ $this->messages[] = 'Value is null';
40
+ }
41
+ else {
42
+ if (!filter_var($item, FILTER_VALIDATE_INT)) {
43
+ $valid = false;
44
+ $this->messages[] = 'Value is not an integer';
45
+ }
46
+ if (isset($this->min) && $this->min > $item) {
47
+ $valid = false;
48
+ $this->messages[] = 'Value must be bigger than '.$this->min;
49
+ }
50
+ }
51
+ return $valid;
52
+ }
53
+
54
+ /**
55
+ * @return array
56
+ */
57
+ public function getErrorMessages()
58
+ {
59
+ return $this->messages;
60
+ }
61
+ }
lib/PlanetLib/Validator/ValidatorInterface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Interface ValidatorInterface
6
+ * @package PlanetLib\Validator
7
+ */
8
+ interface ValidatorInterface
9
+ {
10
+
11
+ /**
12
+ * @param $item
13
+ * @return bool
14
+ */
15
+ public function isValid($item);
16
+
17
+ /**
18
+ * @return array
19
+ */
20
+ public function getErrorMessages();
21
+
22
+ }
lib/PlanetLib/Validator/ValidatorIp.php ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorIp
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorIp implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+
13
+ /**
14
+ * @param $item
15
+ * @return bool
16
+ */
17
+ public function isValid($item)
18
+ {
19
+ $this->messages = array();
20
+ if (filter_var($item, FILTER_VALIDATE_IP)) {
21
+ $valid = true;
22
+ }
23
+ else {
24
+ $valid = false;
25
+ $this->messages[] = 'Incorrect ip address';
26
+ }
27
+ return $valid;
28
+ }
29
+
30
+ /**
31
+ * @return array
32
+ */
33
+ public function getErrorMessages()
34
+ {
35
+ return $this->messages;
36
+ }
37
+ }
lib/PlanetLib/Validator/ValidatorPhone.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorPhone
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorPhone implements ValidatorInterface
9
+ {
10
+ protected $messages = array();
11
+
12
+ protected $min = 6;
13
+ protected $empty = false;
14
+
15
+ public function __construct($parameters = null)
16
+ {
17
+ if (is_array($parameters)) {
18
+ if (isset($parameters['min'])) {
19
+ $this->min = $parameters['min'];
20
+ }
21
+ if (isset($parameters['empty'])) {
22
+ $this->empty = $parameters['empty'];
23
+ }
24
+ }
25
+ }
26
+
27
+ /**
28
+ * @param $item
29
+ * @return bool
30
+ */
31
+ public function isValid($item)
32
+ {
33
+ $this->messages = array();
34
+ $valid = true;
35
+ if (preg_match('/^([0-9\(\)\/\+ \-]*)$/', $item) !== 1) {
36
+ $valid = false;
37
+ $this->messages[] = 'Incorrect phone number';
38
+ }
39
+
40
+ if (strlen($item) < $this->min && !($this->empty && is_null($item))) {
41
+ $valid = false;
42
+ $this->messages[] = 'Phone number is too short';
43
+ }
44
+ return $valid;
45
+ }
46
+
47
+ /**
48
+ * @return array
49
+ */
50
+ public function getErrorMessages()
51
+ {
52
+ return $this->messages;
53
+ }
54
+ }
lib/PlanetLib/Validator/ValidatorString.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Validator;
3
+
4
+ /**
5
+ * Class ValidatorString
6
+ * @package PlanetLib\Validator
7
+ */
8
+ class ValidatorString implements ValidatorInterface
9
+ {
10
+ protected $min = 0;
11
+ protected $max;
12
+ protected $empty = false;
13
+
14
+ protected $messages = array();
15
+
16
+ /**
17
+ * @param array $params
18
+ */
19
+ public function __construct($params = null)
20
+ {
21
+ if (is_array($params)) {
22
+ if (isset($params['min'])) {
23
+ $this->min = $params['min'];
24
+ }
25
+ if (isset($params['max'])) {
26
+ $this->max = $params['max'];
27
+ }
28
+ if (isset($params['empty'])) {
29
+ $this->empty = $params['empty'];
30
+ }
31
+ }
32
+ }
33
+
34
+ /**
35
+ * @param $item
36
+ * @return bool
37
+ */
38
+ public function isValid($item)
39
+ {
40
+ $this->messages = array();
41
+ $valid = true;
42
+ if (!is_string($item)) {
43
+ $valid = false;
44
+ $this->messages[] = 'Value is not a string';
45
+ }
46
+ elseif (!$this->empty && empty($item)) {
47
+ $valid = false;
48
+ $this->messages[] = 'Value can not be empty';
49
+ }
50
+ else {
51
+ if (strlen($item) < $this->min ) {
52
+ $valid = false;
53
+ $this->messages[] = 'Value is too short';
54
+ }
55
+ if (isset($this->max) && strlen($item) > $this->max) {
56
+ $valid = false;
57
+ $this->messages[] = 'Value is too long';
58
+ }
59
+ }
60
+ return $valid;
61
+ }
62
+
63
+ /**
64
+ * @return array
65
+ */
66
+ public function getErrorMessages()
67
+ {
68
+ return $this->messages;
69
+ }
70
+ }
lib/PlanetLib/View.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib;
3
+ use PlanetLib\Writer\WriterSession;
4
+
5
+ /**
6
+ * Class for obtaining form and script for including js
7
+ *
8
+ * Class View
9
+ * @package PlanetLib
10
+ */
11
+ class View
12
+ {
13
+ protected $src;
14
+
15
+ protected $language;
16
+ protected $style;
17
+ protected $brands;
18
+
19
+ protected $action;
20
+
21
+ protected $writer;
22
+
23
+ /**
24
+ * @param WriterInterface $writer
25
+ */
26
+ public function __construct(WriterInterface $writer = null)
27
+ {
28
+ if (file_exists("config.ini")) {
29
+ $config = parse_ini_file("config.ini", true);
30
+
31
+ $this->setSrc($config['view']['src']);
32
+ $this->setStyle($config['view']['style']);
33
+ $this->setLanguage($config['view']['language']);
34
+ $this->setBrands($config['view']['brands']);
35
+ }
36
+
37
+ if (is_null($writer)) {
38
+ $writer = new WriterSession();
39
+ }
40
+ $this->writer = $writer;
41
+ }
42
+
43
+ /**
44
+ * Method for obtaining form. Parameters are obtained from config, but can be configured manually
45
+ *
46
+ * @param null|string $token - If token is null, it will be obtained from Writer (by default from session writer)
47
+ * @param bool $includeScript - If true, script will be connected here, else it can be obtained using getScript
48
+ * @return string
49
+ */
50
+ public function getForm($token = null, $includeScript = false)
51
+ {
52
+ if (is_null($token)) {
53
+ $token = $this->writer->readToken();
54
+ }
55
+
56
+ if ($includeScript) {
57
+ $html = $this->getScript($token);
58
+ }
59
+ else {
60
+ $html = '';
61
+ }
62
+
63
+ $html .= '<form action="' . $this->action . '" class="'.paymentWidgets.'">';
64
+ foreach ($this->brands as $brand) {
65
+ $html.=$brand .' ';
66
+ }
67
+ $html .= '</form>';
68
+
69
+ return $html;
70
+ }
71
+
72
+ /**
73
+ * Method for getting script which includes js
74
+ *
75
+ * @return string
76
+ */
77
+ public function getScript($token = null)
78
+ {
79
+ if (is_null($token)) {
80
+ $token = $this->writer->readToken();
81
+ }
82
+ $html = '<script src="' . $this->src . '?checkoutId=' . $token;
83
+ $html .= '"></script>';
84
+ return $html;
85
+ }
86
+
87
+ /**
88
+ * @param string $language
89
+ * @return $this
90
+ */
91
+ public function setLanguage($language)
92
+ {
93
+ $this->language = $language;
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * @param string $style
99
+ * @return $this
100
+ */
101
+ public function setStyle($style)
102
+ {
103
+ $this->style = $style;
104
+ return $this;
105
+ }
106
+
107
+ /**
108
+ * @param array $brands
109
+ * @return $this
110
+ */
111
+ public function setBrands($brands)
112
+ {
113
+ $this->brands = $brands;
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * @param string $action
119
+ * @return $this
120
+ */
121
+ public function setAction($action)
122
+ {
123
+ $this->action = $action;
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * @param string $src
129
+ * @return $this
130
+ */
131
+ public function setSrc($src)
132
+ {
133
+ $this->src = $src;
134
+ return $this;
135
+ }
136
+ }
lib/PlanetLib/Writer/WriterSession.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib\Writer;
3
+
4
+ use PlanetLib\WriterInterface;
5
+
6
+ /**
7
+ * Class WriterSession
8
+ * @package PlanetLib\Writer
9
+ */
10
+ class WriterSession implements WriterInterface
11
+ {
12
+ /**
13
+ *
14
+ */
15
+ public function __construct()
16
+ {
17
+ if(session_id() == '') {
18
+ session_start();
19
+ }
20
+ }
21
+
22
+ /**
23
+ * @param int $token
24
+ * @return bool
25
+ */
26
+ public function writeToken($token)
27
+ {
28
+ $_SESSION['planet_token'] = $token;
29
+ return true;
30
+ }
31
+
32
+ /**
33
+ * @return string
34
+ */
35
+ public function readToken()
36
+ {
37
+ $token = $_SESSION['planet_token'];
38
+ return $token;
39
+ }
40
+ }
lib/PlanetLib/WriterInterface.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ namespace PlanetLib;
3
+
4
+ /**
5
+ * Interface WriterInterface
6
+ * @package PlanetLib
7
+ */
8
+ interface WriterInterface
9
+ {
10
+ /**
11
+ * Save token to storage
12
+ * @param $token
13
+ * @return bool
14
+ */
15
+ public function writeToken($token);
16
+
17
+ /**
18
+ * Get token from storage
19
+ * @return string
20
+ */
21
+ public function readToken();
22
+ }
lib/PlanetLib/config.ini ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ [general]
2
+ url = ''
3
+ payonUrl = ''
4
+
5
+ [payment]
6
+ sequritySender = ''
7
+ transactionChannel = ''
8
+ transactionMode = ''
9
+ userLogin = ''
10
+ userPwd = ''
11
+ paymentType = ''
12
+ presentationCurrency = ''
13
+ queryEntity = ''
14
+
15
+ [view]
16
+ src = ''
17
+ language = 'en'
18
+ style = 'card'
19
+ brands[] = ''
20
+
media/Planet/img/AMEX.jpg ADDED
Binary file
media/Planet/img/CARTE.jpg ADDED
Binary file
media/Planet/img/DINERS.jpg ADDED
Binary file
media/Planet/img/DINERS.png ADDED
Binary file
media/Planet/img/DISCOVER.jpg ADDED
Binary file
media/Planet/img/HIPERCARD.jpg ADDED
Binary file
media/Planet/img/IDEAL.jpg ADDED
Binary file
media/Planet/img/JCB.jpg ADDED
Binary file
media/Planet/img/JCB.png ADDED
Binary file
media/Planet/img/KLARNA_INSTALLMENTS.jpg ADDED
Binary file
media/Planet/img/KLARNA_INVOICE.jpg ADDED
Binary file
media/Planet/img/MASTER.jpg ADDED
Binary file
media/Planet/img/MASTER.png ADDED
Binary file
media/Planet/img/PAYPAL.png ADDED
Binary file
media/Planet/img/SOFORTUEBERWEISUNG.jpg ADDED
Binary file
media/Planet/img/VISA.jpg ADDED
Binary file
media/Planet/img/VISAELECTRON.jpg ADDED
Binary file
media/Planet/img/maestro.jpg ADDED
Binary file
media/Planet/img/place_order.jpg ADDED
Binary file
media/Planet/img/ukash.jpg ADDED
Binary file
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Planet_Payment_Checkout</name>
4
+ <version>1.0.0</version>
5
+ <stability>devel</stability>
6
+ <license>Open Software License</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Planet Payment module is support more 300 credit and debit cards, and also support back office operation.</summary>
10
+ <description>Planet Payment Extension supports back office operation like Capture, Refund and Reversal. Modules is also support full and partial Capture and Refund. You can use more than 300 credit card and Debit card with Payment processing using Planet Payment Modules.</description>
11
+ <notes>Planet Payment Gateway Integration</notes>
12
+ <authors><author><name>Mayank</name><user>Mayank</user><email>mayank@chetu.com</email></author></authors>
13
+ <date>2016-03-26</date>
14
+ <time>09:58:24</time>
15
+ <contents><target name="magecommunity"><dir name="PlanetPayment"><dir name="Core"><dir name="Block"><dir name="Checkout"><dir name="Cart"><file name="Totals.php" hash="4eff5660231d05f5cd5d68e8e10f5d43"/></dir></dir><dir name="Sales"><dir name="Order"><file name="Totals.php" hash="2b3e5493f7583d06a6e7f6a238b6b1b7"/></dir></dir></dir><dir name="Helper"><file name="Data.php" hash="4220c04875b7919ff9109d01b134e581"/><file name="Error.php" hash="7d0b1f87a90320b5b4d5bcb0ab68b0a3"/></dir><dir name="Model"><dir name="Currency"><file name="Import.php" hash="e031727b143b1ffeee204174f0818ef3"/></dir><dir name="System"><dir name="Config"><dir name="General"><file name="Encryption.php" hash="2ef71d7cde9f815e7ebe7a5a638f7a4e"/><file name="Mode.php" hash="156e7e0f28781e70f828355b00022273"/></dir><dir name="Payment"><file name="Currency.php" hash="1ee36196cb7fa18e9f6b2a3a29fdef60"/></dir><dir name="Source"><file name="Enabledisable.php" hash="5c637385d0c18abc0f8cd77c1dee60b9"/></dir></dir></dir><dir name="Xml"><file name="Abstract.php" hash="82229f7ff645617d8aa70a03818a6841"/><file name="Request.php" hash="1c396b50b79abcb588e21cca72b93875"/><file name="Response.php" hash="6ab903e8a27181d5a24dfab7e9942c36"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="4ae539a893ca913e00a2217f5cf75d4f"/><file name="config.xml" hash="27be39f720a7c00cf8310bdecdb3e8f9"/><file name="system.xml" hash="90edd10aa6728538bcf88ea9f600a205"/></dir></dir><dir name="CurrencyManager"><dir name="Block"><dir name="Adminhtml"><file name="Countrywise.php" hash="384887a75c3da3dc8a8158a3f8cf4808"/><file name="Price.php" hash="7da4d03d99ca9e48114e72e55ccd34a1"/></dir></dir><dir name="Helper"><file name="Data.php" hash="b8170a60ebe48829ddb6820f2b21a630"/><file name="Tax.php" hash="d95b0452574814b7182da6812eaf58b9"/></dir><dir name="Model"><file name="Currency.php" hash="4d73b1957d91bde8e8931d92e668678c"/><file name="Ipay.php" hash="60fb6b4e3a1a007f683719b2d410970d"/><file name="Locale.php" hash="24ec1581820da2d55fd7284cd9ad6829"/><file name="Observer.php" hash="682b0ce2877f7727d87f73a7d092c1a9"/><file name="Store.php" hash="186491dae915b436439e80ef99387cda"/></dir><dir name="etc"><file name="config.xml" hash="6221b244461ac0e233b0988c7fb247b3"/><file name="system.xml" hash="dda95f77642d7462546c0b2db5b41e3f"/></dir><dir name="sql"><dir name="currency_setup"><file name="install-1.0.0.php" hash="49071ca4636bd377824da620bd607a86"/></dir></dir></dir></dir></target><target name="magelocal"><dir name="Planet"><dir name="Pay"><dir name="Block"><dir name="Adminhtml"><dir name="Order"><file name="Info.php" hash="97f631436601620cd9b096f370788f2d"/><dir name="View"><dir name="Handling"><file name="Credit.php" hash="ed2c4a1a7c722a40e1f69ae3625d9690"/><file name="Delivery.php" hash="d9e32545fa63fe0bff4f261e689f76e3"/><file name="Request.php" hash="2acbe786b123873ab62e90fc99a9452c"/></dir><dir name="Items"><dir name="Renderer"><file name="Default.php" hash="3bdab1591224a7828f82b495fb1a4e2a"/></dir></dir><file name="Request.php" hash="9dbb55bdca98c2202f8b168b236d7354"/><dir name="Tab"><file name="Credit.php" hash="56b275ad5d26f7159ba414235dadcb6e"/><file name="Delivery.php" hash="7d01e481120d8cd57df8611ac3c0fafc"/><file name="Request.php" hash="223f7fe08a00da45d18880176e97f874"/></dir></dir><file name="View.php" hash="3fb58c0b4a3542369d20073ca252c9b5"/></dir><file name="Order.php" hash="fd97acb4ce1e40ec4889e615ea39a03c"/><dir name="Pay"><dir name="Edit"><file name="Form.php" hash="69862c027f930045c4fb20ce85a1c32b"/><dir name="Tab"><file name="Form.php" hash="7f36e5d543f7f1ed669e8f307b613c3d"/></dir><file name="Tabs.php" hash="6366d694e347b99a580c0045f2edcea3"/></dir><file name="Edit.php" hash="d3e95d22263475475ad09c0d07d512fd"/><file name="Grid.php" hash="74bdd5e20b0d4efa7e4603cfe7efe2b6"/></dir><file name="Pay.php" hash="dbc1ed1e27dc36c711754909d8176927"/></dir><dir name="Checkout"><dir name="Onepage"><dir name="Payment"><file name="Methods.php" hash="3aa5c129eac5034e6f9c426cf8306786"/></dir><file name="Review.php" hash="56e6c60664eb4fe887b2d7cf1b26fb9a"/></dir><file name="Onepage.php" hash="ef37024efdf075f4e6632b9839cd13e7"/></dir><dir name="Form"><file name="Form.php" hash="4afc09c96a4992e18b2e136828047ef2"/><file name="Pay.php" hash="86d73b0eb325fa8def966bac852cde5e"/></dir><dir name="Info"><file name="Pay.php" hash="6aab90b78e75934d8cbd87f585215182"/></dir><dir name="Method"><file name="List.php" hash="da8a62f696e1d80ece6fe7729f420b38"/></dir><dir name="Planet"><dir name="Order"><file name="Grid.php" hash="dcd52b1a7338c05c80ac326c6426e09d"/></dir></dir><dir name="Profile"><file name="Edit.php" hash="79f6092d3628149289d63aa9fa3b6714"/><file name="List.php" hash="0c6eeec8cd06705467e70c9551bd58ad"/></dir></dir><dir name="Helper"><file name="Data.php" hash="a18aa1ac5fc5e6f43677f64b18712ee9"/></dir><dir name="Model"><file name="Authorizenet.php" hash="2397754a105be9df4b80cd019f345417"/><file name="Autoloader.php" hash="578c4f1c84eb3f0276859f9494661358"/><file name="Carddetail.php" hash="9dda56fe8c34ab80f2acfc5515cf243d"/><dir name="Checkout"><file name="Observer.php" hash="7e8aa4cfadcabbcac5057263b609c2ee"/><dir name="Type"><file name="Onepage.php" hash="5b1bb28e7775d33f579a9aa6b2524d45"/></dir></dir><dir name="Currency"><dir name="Import"><file name="Planet.php" hash="8f56898852c14c831d42406ed3856be6"/></dir></dir><file name="Method.php" hash="824189557a428c27d0ba249cd57e1dda"/><file name="Order.php" hash="25ec39a6f6330138c68ddbf6c3129ca1"/><file name="Orderlog.php" hash="c614fe002121aa03e1d3f66f99cf0a76"/><file name="Payment.php" hash="8505c59f183355b6dfcc537512121b0b"/><dir name="Resource"><dir name="Carddetail"><file name="Collection.php" hash="6b91cf179f62cee1cc151e21c3f2c9a2"/></dir><file name="Carddetail.php" hash="53af42b5cccdd1bf7724ed2b7d127e72"/><dir name="Method"><file name="Collection.php" hash="0ecff0572659f2bdd2417cdd30379ee8"/></dir><file name="Method.php" hash="269e2e10aa514b86298c679d4618de28"/><dir name="Order"><file name="Collection.php" hash="1e406031919656521d59be17e2601519"/></dir><file name="Order.php" hash="3d1d08346984d808f45f1e8b517d774e"/><dir name="Orderlog"><file name="Collection.php" hash="dd8508af9de5e4fd58a9d312d9b860db"/></dir><file name="Orderlog.php" hash="594ba64ba3f1a6bf2cfa55676e36962a"/></dir><dir name="Sales"><dir name="Order"><file name="Payment.php" hash="96cd7c2578fbb65edb48ea9acbb64a6b"/></dir></dir><file name="Select.php" hash="36b1ad1359a6665aa6514dea1914216d"/><dir name="System"><dir name="Config"><dir name="Payment"><file name="PaymentAction.php" hash="ba2af718505bf65ef4694253a905880c"/></dir><dir name="Source"><file name="Yesno.php" hash="96c011e962a23d9a076aeeec300a04b6"/></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="BrandController.php" hash="f5222583c66ba7dc3a196954efd5dd78"/></dir><file name="PaymentController.php" hash="ef4d450e654b90a48c96f9008372a4c4"/><dir name="Planet"><file name="OrderController.php" hash="475aa2c6dcc67d2f1cf968fa91679689"/></dir><file name="ProfileController.php" hash="a4070fe02389e52a53686b6dc8d21a3e"/></dir><dir name="data"><dir name="planet_pay_setup"><file name="data-install-1.0.1.php" hash="1259a880e36f569a6fc625616eee1b60"/><file name="data-upgrade-1.0.3-1.0.4.php" hash="a2d9ced91db7e74d204cc78df7ebc7fb"/><file name="data-upgrade-1.0.4-1.0.5.php" hash="6c350ee84f8893706a6f9012dbc3b34c"/></dir></dir><dir name="etc"><file name="adminhtml.xml" hash="69a66665401c3fc16877a168c9e12dd4"/><file name="config.xml" hash="22bf2495872c9ee2b92bda9b1b1317d7"/><file name="system.xml" hash="c3eeae5f8663742dcad1a3bf6b9f8c33"/></dir><dir name="sql"><dir name="planet_pay_setup"><file name="install-1.0.1.php" hash="08c37f9e66d8561978f77941275d53af"/><file name="mysql4-upgrade-1.0.5-1.0.6.php" hash="167fccdf08b1c1d900a5faccbd44606b"/><file name="upgrade-1.0.1-1.0.2.php" hash="0fa7815c0f9bf1fcbeab2364a0a444fb"/><file name="upgrade-1.0.2-1.0.3.php" hash="e3d0a85d149cd7546b3ecf57684ebf55"/><file name="upgrade-1.0.3-1.0.4.php" hash="e5eb92bc9f6a52cde303096299fed45f"/><file name="upgrade-1.0.4-1.0.5.php" hash="b6c04bfcdd4361c57b8cd09405af4876"/></dir></dir></dir></dir><dir name="app"><dir name="design"><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="pay.xml" hash=""/></dir></dir></dir></dir></dir></dir></target><target name="magemedia"><dir name="Planet"><dir name="img"><file name="AMEX.jpg" hash="18aac2f5e8d1640197cc87892cb4e400"/><file name="CARTE.jpg" hash="f41d274ff077e0f87bf52d1285456d36"/><file name="DINERS.jpg" hash="9511602440511d18187255a5a6ec2177"/><file name="DINERS.png" hash="cef0eda27bf90dd1f988b933cc39e74a"/><file name="DISCOVER.jpg" hash="11ea2e6912f8d4b0a97bfaf4668220d1"/><file name="HIPERCARD.jpg" hash="30dfab080bc2ba752d1e9f299fef88dc"/><file name="IDEAL.jpg" hash="d6bbedffbaa80a240e2c763ce8d24db8"/><file name="JCB.jpg" hash="694cf777af8a15c11b87292acaf9bf7b"/><file name="JCB.png" hash="a1499151401f039c037e3d51527a5b65"/><file name="KLARNA_INSTALLMENTS.jpg" hash="25c83486400220edc5e05e79dd89bfd8"/><file name="KLARNA_INVOICE.jpg" hash="25c83486400220edc5e05e79dd89bfd8"/><file name="MASTER.jpg" hash="b2279dffe461d2926b3fb713309b86a4"/><file name="MASTER.png" hash="1cdc2c919493db1081261bd400c6690c"/><file name="PAYPAL.png" hash="ca5a02951cb4cdde9e46d30fd9d31911"/><file name="SOFORTUEBERWEISUNG.jpg" hash="11905775a2180b7abfda72fd11640af7"/><file name="VISA.jpg" hash="6fad2dd7ddc5ffaad9fd883177ea151d"/><file name="VISAELECTRON.jpg" hash="9ee4b8b90c6f4d4af8da011075b2527e"/><file name="maestro.jpg" hash="6f71a42ece1805f8c5718aa7ce13ef70"/><file name="place_order.jpg" hash="b1365221c5be829eb02b09fb7ad7a0d5"/><file name="ukash.jpg" hash="19c7e7c9da032c758637153242f737e0"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="css"><dir name="planet_pay"><file name="payon.css" hash="afa2f45127f09901597faf3a1ade5175"/></dir></dir><dir name="js"><dir name="planet_pay"><file name="add-summary-script.js" hash="2ff13a5a011d8d6f1d0fd5586a93f5d5"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="."><file name="server.php" hash="a4c9ff7568c14ade17d4247f3b2822f1"/></dir><dir name="lib"><dir name="PlanetLib"><dir name="Filter"><file name="FilterRound.php" hash="0c197653a0e2abf3d48ab8e9bad3a5c5"/><file name="FilterString.php" hash="26555cea292b228931e80e3c3244122b"/></dir><dir name="Payment"><file name="PaymentCriterion.php" hash="1639e70f67b8953b5defe73b412a6873"/><file name="PaymentCustomer.php" hash="3ce997c23ed0222d35786eef3e570302"/><file name="PaymentOrderposition.php" hash="7c6a02d597cc68b198b1ab5ab3322d39"/></dir><file name="Payment.php" hash="38361daa30a64d16b73bc90c9e9d4015"/><file name="Payon.php" hash="6e229c38a52d72948781728dfa81d1be"/><file name="Planet.php" hash="888d2b8312cb83426b54eb85e96cd0b9"/><file name="PlanetException.php" hash="071fb5c28ad897624a5e76aa5c76d235"/><dir name="Request"><file name="Curl.php" hash="765d1bc988317bdd3700ca0035ba200b"/><file name="Stream.php" hash="fabb579fd28d5dcb806faf82b72ef179"/></dir><dir name="Resources"><dir name="Content"><file name="Brands.php" hash="cc3f9e886a908be83e33978dd29e6ae6"/></dir><dir name="Translation"><file name="BrandNames.php" hash="7190b3a3be9cda4155af72139c42ba8f"/><file name="ErrorCodes.php" hash="671f604a716c029b574b6d44d782a6e1"/><dir name="de"><file name="BrandNames.php" hash="d04bd6f35460f314ac04cef77db50c45"/><file name="ErrorCodes.php" hash="00dd5db4c514639d17374f8bedce86e1"/><file name="ServiceMessages.php" hash="de824e096c14e9c283913a49f396a13f"/></dir></dir></dir><file name="Response.php" hash="1cda07b2d5bb9ecadd34951702419e5f"/><dir name="Validator"><file name="ValidatorDate.php" hash="c2ca20602125d5a46e55b795c3698bf5"/><file name="ValidatorEmail.php" hash="b3b81153d8fa62e1337b92ce418437c7"/><file name="ValidatorFloat.php" hash="0ae7476af4c258e2c1b70d49b3fd37c2"/><file name="ValidatorInt.php" hash="3544b064c99ce67928aee386f7c170f9"/><file name="ValidatorInterface.php" hash="645b77c40d6794352a861aad879cf167"/><file name="ValidatorIp.php" hash="3502e87af11b854dfd550a950eb028f4"/><file name="ValidatorPhone.php" hash="59d8748ca526c8b3dcccc8b312aa091e"/><file name="ValidatorString.php" hash="d608d5ff7063bdc903a3227e65797f6f"/></dir><file name="View.php" hash="265513aea7f65a325bdc56ea245f86e1"/><dir name="Writer"><file name="WriterSession.php" hash="cfdb48affbb74ee04c63777c23455d21"/></dir><file name="WriterInterface.php" hash="e1a5f7b6658d2f0c95788c4507caad14"/><file name="config.ini" hash="5960be206f3b06f327b678f78f81cd3f"/></dir></dir><dir name="app"><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="planet_pay.xml" hash="c51697eede135b62ca7679dd5792fddf"/></dir><dir name="template"><dir name="planet_pay"><dir name="order"><dir name="view"><dir name="handling"><file name="credit.phtml" hash="f6eaa5cabf93bb2d40fbae3c532b5a46"/><file name="delivery.phtml" hash="c6326df0ce1fc16d50405438c743d3c5"/><file name="request.phtml" hash="7ceb8dca67862bc96ad57485434383ec"/></dir><file name="info.phtml" hash="35beb0a3faf77b981cd842b43b14f9f7"/><dir name="items"><dir name="renderer"><file name="default.phtml" hash="3fa688c390b6cd8c31be44053c633a1c"/></dir></dir><file name="items.phtml" hash="080e2c966cb300a91fe61dbab7c07e11"/><file name="loviitinfo.phtml" hash="032935622ef91f50e99409c6ca984151"/><file name="planetinfo.phtml" hash="032935622ef91f50e99409c6ca984151"/><dir name="request"><file name="criterions.phtml" hash="9affec693271ad98409be2a1525e7d84"/><file name="customer.phtml" hash="71fd28d1860f098f13aefd799e0bf4e1"/><file name="options.phtml" hash="3fdbed432290d8aec0616fc116474024"/></dir><dir name="tab"><file name="credit.phtml" hash="0ed7bcf6ef5900e0a34e80e3c7fa35c3"/><file name="delivery.phtml" hash="eaa2edf0e1895bbd7c3bd9387d99aa68"/><file name="info.phtml" hash="f51ed375daee884ca6df3ccbee0dd282"/><file name="request.phtml" hash="07f037a6282b750dcc8b1820280c885e"/></dir></dir></dir><dir name="sales"><dir name="order"><file name="totals.phtml" hash="f453f7f3353428ead4a42025bd46cf8b"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="template"><dir name="planet_pay"><file name="checkoutform.phtml" hash="4360cb45eef94bcc048a375feb21adce"/><dir name="email"><file name="items.phtml" hash="e257238b9f8a6347f47bb7481f157892"/></dir><dir name="form"><file name="form.phtml" hash="68f491710cff11e8d759cc53cf2af9f2"/><file name="pay.phtml" hash="d21bdef0fdcd389a64355c4c1797c492"/><file name="pay_backup_1oct.phtml" hash="5bd1b120c795a80d57edd2e7f45b2bde"/></dir><dir name="onepage"><dir name="payment"><file name="methods.phtml" hash="682ac3134fc3948b700756c3f14ec36e"/></dir><file name="payment.phtml" hash="0f1639692aa228295e1122b5dd66d49f"/><dir name="review"><file name="button.phtml" hash="e575404d005f9a358fc5856c430ab455"/><file name="info.phtml" hash="0616c4cdfb1249af0dc4f761bdf4cbf8"/><file name="items_after.phtml" hash="eccfd367f3d2257c34b5281d2c236947"/></dir><file name="review.phtml" hash="db6c40f8330f005785a6bb922a2a9dcd"/></dir><dir name="profile"><file name="edit.phtml" hash="7c9b200657be68275ec7402917de8bda"/><file name="list.phtml" hash="31112e999a7d26c958f074d0498f6d36"/></dir></dir><dir name="checkout"><dir name="onepage"><dir name="review"><file name="totals.phtml" hash="d83a75bd7374513bcbddd858241ff6d6"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Planet_Pay.xml" hash="2fb8f31fab5482d58b8bd94bd2cc6234"/><file name="PlanetPayment_Core.xml" hash="275392d9b26345b22400fb7af6568609"/><file name="PlanetPayment_CurrencyManager.xml" hash="01314f48709526ddf56d3ca055101ec0"/></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.2.3</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
server.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ require_once('./app/Mage.php'); //Path to Magento
3
+ umask(0);
4
+ Mage::app();
5
+ $testMode = Mage::getStoreConfig('payment/planet_pay/test_mode');
6
+ if ($testMode) {
7
+ $javurl = Mage::getStoreConfig('payment/planet_pay/payment_request_url_test');
8
+ } else {
9
+ $javurl = Mage::getStoreConfig('payment/planet_pay/payment_request_url_live');
10
+ }
11
+ $baseurl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB);
12
+ $token = $_REQUEST['token'];
13
+ $urlf = $_REQUEST['url'];
14
+ $scripturl = $javurl . "/v1/paymentWidgets.js?checkoutId=" . $token;
15
+ $chobrand = $_REQUEST['chobrand'];
16
+ ?>
17
+ <script src=<?php echo $scripturl; ?>></script>
18
+ <form action=<?php echo $urlf; ?> class="paymentWidgets">
19
+ <?php echo $chobrand; ?>
20
+ </form>
21
+
22
+
skin/frontend/base/default/css/planet_pay/payon.css ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * {{Planet}}_{{Pay}} extension
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the MIT License
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/mit-license.php
10
+ *
11
+ * @category {{Planet}}
12
+ * @package {{Planet}}_{{Pay}}
13
+ * @copyright Copyright (c) {{2015}}
14
+ * @license http://opensource.org/licenses/mit-license.php MIT License
15
+ */
16
+ .wpwl-container-card .wpwl-form-card{
17
+ background: none !important;
18
+ border: none !important;
19
+ box-shadow: none !important;
20
+ padding: 0 !important;
21
+ }
22
+ /*.wpwl-container-card{ overflow: hidden;
23
+ height:0px;
24
+
25
+ }*/
26
+
27
+ /*div .wpwl-form.wpwl-form-card.wpwl-clearfix
28
+ {
29
+ position: relative;
30
+ margin-left: 8px;
31
+ }*/
32
+ .wpwl-label-brand, .wpwl-wrapper-brand{
33
+ display:none;
34
+ }
35
+
36
+ #ajaxDiv > div > form {
37
+ border: none;
38
+ box-shadow: none;
39
+ }
40
+
41
+ #payment_form_planet_pay li label img {
42
+ max-height: 35px;
43
+ max-width: 50px;
44
+ }
45
+ .wpwl-brand {
46
+ background: none;
47
+ margin: 0 auto;
48
+ }
49
+ #payment-progress-opcheckout table{
50
+
51
+ display: none;
52
+ }
53
+
skin/frontend/base/default/js/planet_pay/add-summary-script.js ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ var wpwlOptions = {
2
+ useSummaryPage: true,
3
+ paymentTarget: 'my_iframe',
4
+ shopperResultTarget: 'my_iframe',
5
+ onSaveTransactionData: function(data){
6
+ //transaction data were sent and saved
7
+ payment.save();
8
+ }
9
+ }
10
+