PayEx_Payments - Version 3.0.1

Version Notes

Version 3.0.1
* Implemented Swish Payment Method
* Financing Invoice: Invoice link
* Fixed payex account problem for multiple stores

Version 3.0.0
* Init release of PayEx Payments module
* Payment modules have been assembled in a single module
* Integrated "Social Security Number" module
* Implemented PayEx Faktura (Financing Invoice)
* Implemented PayEx Delbetala (PartPayment)
* Implemented PayEx Invoice (Ledger Service)
* Implemented MasterPass Payments
* Social Security Number: IWD_Opc support
* Taxable discounts
* Taxable fees
* Option: Send order lines and billing/delivery addresses to PayEx
* Option: Replace illegal characters of product names
* Tune: Use order_id instead customer_id for productNumber
* Improved Transaction Callback
* Install using modman
* Many various code changes and fixes
* Removed deprecated code

Version 2.0.31
* Fixed bug with wrong order state when capture via backend

Version 2.0.30
* Improved update checker

Version 2.0.29
* PayEx Payment Page 2.0 for 'Credit Card' and 'Direct Debit' views

Version 2.0.28
* Improved rounding issue workaround

Version 2.0.27
* Added Reward points support

Version 2.0.26
* Improved transaction processing
* Set correct order state
* Sending mail when failed payments

Version 2.0.25
* Fixed problem with handling of canceled transactions

Version 2.0.24
* Fixed problem "The transaction "xxx" (capture) is already closed"
* Removed unused functions
* Minor changes

Version 2.0.23
* Fixed problems with order state
* Small bugfixes

Version 2.0.22
* Fixed bug with empty invoice totals
* Updated Px library to 2.0.1

Version 2.0.21
* Fixed problem with empty TotalPaid value
* Fixed problem with empty tax for bundled product
* Small bugfixes
* Added version hint

Version 2.0.20
* Fixed problem with downloadable products

Version 2.0.19
* Fixed bug with multiple currencies setup
* Use Initialize8, Capture5, Credit5
* Updated Px library (moved to lib directory)
* Removed deprecated code
* Various bugfixes

Version 2.0.18
* Responsive Skinning

Version 2.0.17
* Fixed rounding issue

Version 2.0.16
* Added PayPal Payment View
* Saving the refunded/canceled/failed transactions.
* Verbose error messages
* Save cart when fails
* Updated translations
* Bugfixes

Version 2.0.15
* Fixed multi store support

Version 2.0.14
* Updated Payex Library

Version 2.0.13
* Enabled Partial Refund in Invoice

Version 2.0.12
* Fixed rounding error bug

Version 2.0.11
* Fixed CodeOrder_AmountNotEqualOrderLinesTotal

Version 2.0.10
* Fix amount bug in AddOrderLine function
* Fixed some bugs in order statuses

Version 2.0.9
* Fixed Tax Calc bug
* Fixed CodeOrder_AmountNotEqualOrderLinesTotal

Version 2.0.8
* Improved Order Info
* Added Order Info in PDF Invoice

Version 2.0.7
* Fixed bug with order (in sale mode the order is not finalized)
* Fixed bug with refund
* Moved design templates in base directory

Version 2.0.6
* Fixed bug with wrong capture/refund amount

Version 2.0.5
* Added options for cleaning time in Payment Config

Version 2.0.4
* Fixed Pending Order Cleaner bug

Version 2.0.3
* Many bugfixes

Version 2.0.2
* Division by zero fix (When Shipping is 0)

Version 2.0.1
* Rewrited API Helper

Version 2.0.0
* Changend namespace
* Rewrited payment engine
* Added Translations
* Bugfixes

Version 1.2.3-r20120329
* Added compatibility with AAIT PayEx Core

Version 1.2.3
* Small bugfixes

Version 1.2.2
* Fixed DirectDebit bug (Payment Cancel)
* Added option "Payment Type" in the settings panel.
* Small bugfixes

Version 1.2.1
* Small bugfixes

Version 1.2.0
* Required PayEx Core module v1.0.1
* Transaction fetching
* Bugfixes

Download this release

Release Info

Developer AAIT
Extension PayEx_Payments
Version 3.0.1
Comparing to
See all releases


Version 3.0.1

Files changed (164) hide show
  1. Changelog_payex.txt +164 -0
  2. app/code/community/PayEx/Payments/Block/Adminhtml/Config/Hint.php +30 -0
  3. app/code/community/PayEx/Payments/Block/Adminhtml/Sales/Order/Create/Totals/Fee.php +16 -0
  4. app/code/community/PayEx/Payments/Block/Bankdebit/Banks.php +60 -0
  5. app/code/community/PayEx/Payments/Block/Checkout/Fee.php +45 -0
  6. app/code/community/PayEx/Payments/Block/Form/Autopay.php +10 -0
  7. app/code/community/PayEx/Payments/Block/Form/Bankdebit.php +10 -0
  8. app/code/community/PayEx/Payments/Block/Form/CC.php +10 -0
  9. app/code/community/PayEx/Payments/Block/Form/Financing.php +32 -0
  10. app/code/community/PayEx/Payments/Block/Form/Invoice.php +32 -0
  11. app/code/community/PayEx/Payments/Block/Form/MasterPass.php +10 -0
  12. app/code/community/PayEx/Payments/Block/Form/PartPayment.php +32 -0
  13. app/code/community/PayEx/Payments/Block/Form/Swish.php +10 -0
  14. app/code/community/PayEx/Payments/Block/Form/Wywallet.php +10 -0
  15. app/code/community/PayEx/Payments/Block/Info/Autopay.php +94 -0
  16. app/code/community/PayEx/Payments/Block/Info/Bankdebit.php +10 -0
  17. app/code/community/PayEx/Payments/Block/Info/CC.php +96 -0
  18. app/code/community/PayEx/Payments/Block/Info/Financing.php +138 -0
  19. app/code/community/PayEx/Payments/Block/Info/Invoice.php +10 -0
  20. app/code/community/PayEx/Payments/Block/Info/MasterPass.php +96 -0
  21. app/code/community/PayEx/Payments/Block/Info/PartPayment.php +96 -0
  22. app/code/community/PayEx/Payments/Block/Info/Swish.php +91 -0
  23. app/code/community/PayEx/Payments/Block/Info/Wywallet.php +96 -0
  24. app/code/community/PayEx/Payments/Block/MasterPass/Button.php +21 -0
  25. app/code/community/PayEx/Payments/Block/Order/Totals/Fee.php +40 -0
  26. app/code/community/PayEx/Payments/Helper/Agreement.php +48 -0
  27. app/code/community/PayEx/Payments/Helper/Api.php +22 -0
  28. app/code/community/PayEx/Payments/Helper/Data.php +6 -0
  29. app/code/community/PayEx/Payments/Helper/Discount.php +170 -0
  30. app/code/community/PayEx/Payments/Helper/Fee.php +43 -0
  31. app/code/community/PayEx/Payments/Helper/Order.php +730 -0
  32. app/code/community/PayEx/Payments/Helper/Tools.php +173 -0
  33. app/code/community/PayEx/Payments/Model/Agreement.php +10 -0
  34. app/code/community/PayEx/Payments/Model/Feed.php +136 -0
  35. app/code/community/PayEx/Payments/Model/Invoice/Total.php +41 -0
  36. app/code/community/PayEx/Payments/Model/Mysql4/Agreement.php +10 -0
  37. app/code/community/PayEx/Payments/Model/Mysql4/Agreement/Collection.php +10 -0
  38. app/code/community/PayEx/Payments/Model/Observer.php +150 -0
  39. app/code/community/PayEx/Payments/Model/Payment/Abstract.php +43 -0
  40. app/code/community/PayEx/Payments/Model/Payment/Autopay.php +422 -0
  41. app/code/community/PayEx/Payments/Model/Payment/Bankdebit.php +326 -0
  42. app/code/community/PayEx/Payments/Model/Payment/CC.php +434 -0
  43. app/code/community/PayEx/Payments/Model/Payment/Financing.php +490 -0
  44. app/code/community/PayEx/Payments/Model/Payment/Invoice.php +484 -0
  45. app/code/community/PayEx/Payments/Model/Payment/MasterPass.php +407 -0
  46. app/code/community/PayEx/Payments/Model/Payment/PartPayment.php +483 -0
  47. app/code/community/PayEx/Payments/Model/Payment/Swish.php +319 -0
  48. app/code/community/PayEx/Payments/Model/Payment/Wywallet.php +432 -0
  49. app/code/community/PayEx/Payments/Model/Quote/Total.php +106 -0
  50. app/code/community/PayEx/Payments/Model/Session.php +9 -0
  51. app/code/community/PayEx/Payments/Model/Source/Banks.php +76 -0
  52. app/code/community/PayEx/Payments/Model/Source/ClientLanguage.php +54 -0
  53. app/code/community/PayEx/Payments/Model/Source/MediaDistribution.php +18 -0
  54. app/code/community/PayEx/Payments/Model/Source/PaymentAction.php +1 -0
  55. app/code/community/PayEx/Payments/Model/Source/PaymentView.php +30 -0
  56. app/code/community/PayEx/Payments/Model/Source/ShippingMethod.php +33 -0
  57. app/code/community/PayEx/Payments/Model/Source/TaxClasses.php +10 -0
  58. app/code/community/PayEx/Payments/controllers/AutopayController.php +546 -0
  59. app/code/community/PayEx/Payments/controllers/BankdebitController.php +315 -0
  60. app/code/community/PayEx/Payments/controllers/FinancingController.php +272 -0
  61. app/code/community/PayEx/Payments/controllers/GetaddrController.php +118 -0
  62. app/code/community/PayEx/Payments/controllers/InvoiceController.php +326 -0
  63. app/code/community/PayEx/Payments/controllers/MasterpassController.php +678 -0
  64. app/code/community/PayEx/Payments/controllers/PartpaymentController.php +270 -0
  65. app/code/community/PayEx/Payments/controllers/PaymentController.php +351 -0
  66. app/code/community/PayEx/Payments/controllers/SwishController.php +281 -0
  67. app/code/community/PayEx/Payments/controllers/TransactionController.php +272 -0
  68. app/code/community/PayEx/Payments/controllers/WywalletController.php +302 -0
  69. app/code/community/PayEx/Payments/data/payex_setup/data-install-3.0.0.php +117 -0
  70. app/code/community/PayEx/Payments/etc/config.xml +419 -0
  71. app/code/community/PayEx/Payments/etc/system.xml +1546 -0
  72. app/code/community/PayEx/Payments/sql/payex_setup/install-3.0.0.php +38 -0
  73. app/design/adminhtml/default/default/layout/payex/adminhtml.xml +8 -0
  74. app/design/adminhtml/default/default/layout/payex/payment_fee.xml +20 -0
  75. app/design/adminhtml/default/default/template/payex/adminhtml/hint.phtml +14 -0
  76. app/design/adminhtml/default/default/template/payex/autopay/form.phtml +61 -0
  77. app/design/adminhtml/default/default/template/payex/autopay/info.phtml +5 -0
  78. app/design/adminhtml/default/default/template/payex/autopay/title.phtml +1 -0
  79. app/design/adminhtml/default/default/template/payex/bankdebit/form.phtml +26 -0
  80. app/design/adminhtml/default/default/template/payex/bankdebit/info.phtml +5 -0
  81. app/design/adminhtml/default/default/template/payex/cc/form.phtml +30 -0
  82. app/design/adminhtml/default/default/template/payex/cc/info.phtml +16 -0
  83. app/design/adminhtml/default/default/template/payex/cc/title.phtml +1 -0
  84. app/design/adminhtml/default/default/template/payex/financing/form.phtml +61 -0
  85. app/design/adminhtml/default/default/template/payex/financing/info.phtml +23 -0
  86. app/design/adminhtml/default/default/template/payex/financing/title.phtml +1 -0
  87. app/design/adminhtml/default/default/template/payex/invoice/form.phtml +119 -0
  88. app/design/adminhtml/default/default/template/payex/invoice/info.phtml +5 -0
  89. app/design/adminhtml/default/default/template/payex/masterpass/button.phtml +4 -0
  90. app/design/adminhtml/default/default/template/payex/masterpass/form.phtml +17 -0
  91. app/design/adminhtml/default/default/template/payex/masterpass/info.phtml +16 -0
  92. app/design/adminhtml/default/default/template/payex/masterpass/title.phtml +1 -0
  93. app/design/adminhtml/default/default/template/payex/partpayment/form.phtml +61 -0
  94. app/design/adminhtml/default/default/template/payex/partpayment/info.phtml +16 -0
  95. app/design/adminhtml/default/default/template/payex/partpayment/title.phtml +1 -0
  96. app/design/adminhtml/default/default/template/payex/swish/form.phtml +17 -0
  97. app/design/adminhtml/default/default/template/payex/swish/info.phtml +16 -0
  98. app/design/adminhtml/default/default/template/payex/swish/title.phtml +1 -0
  99. app/design/adminhtml/default/default/template/payex/wywallet/form.phtml +17 -0
  100. app/design/adminhtml/default/default/template/payex/wywallet/info.phtml +16 -0
  101. app/design/frontend/base/default/layout/payex/masterpass.xml +29 -0
  102. app/design/frontend/base/default/layout/payex/payment_fee.xml +38 -0
  103. app/design/frontend/base/default/layout/payex/social_security_number.xml +28 -0
  104. app/design/frontend/base/default/template/payex/autopay/form.phtml +61 -0
  105. app/design/frontend/base/default/template/payex/autopay/info.phtml +5 -0
  106. app/design/frontend/base/default/template/payex/autopay/pdf/info.phtml +13 -0
  107. app/design/frontend/base/default/template/payex/autopay/title.phtml +1 -0
  108. app/design/frontend/base/default/template/payex/bankdebit/form.phtml +26 -0
  109. app/design/frontend/base/default/template/payex/bankdebit/info.phtml +5 -0
  110. app/design/frontend/base/default/template/payex/cc/form.phtml +30 -0
  111. app/design/frontend/base/default/template/payex/cc/info.phtml +16 -0
  112. app/design/frontend/base/default/template/payex/cc/pdf/info.phtml +13 -0
  113. app/design/frontend/base/default/template/payex/cc/title.phtml +1 -0
  114. app/design/frontend/base/default/template/payex/checkout/fee.phtml +49 -0
  115. app/design/frontend/base/default/template/payex/checkout/onepage/billing_with_ssn.phtml +257 -0
  116. app/design/frontend/base/default/template/payex/financing/form.phtml +61 -0
  117. app/design/frontend/base/default/template/payex/financing/info.phtml +23 -0
  118. app/design/frontend/base/default/template/payex/financing/pdf/info.phtml +13 -0
  119. app/design/frontend/base/default/template/payex/financing/title.phtml +1 -0
  120. app/design/frontend/base/default/template/payex/invoice/form.phtml +119 -0
  121. app/design/frontend/base/default/template/payex/invoice/info.phtml +5 -0
  122. app/design/frontend/base/default/template/payex/iwd_opc/billing_with_ssn.phtml +225 -0
  123. app/design/frontend/base/default/template/payex/masterpass/button.phtml +4 -0
  124. app/design/frontend/base/default/template/payex/masterpass/form.phtml +17 -0
  125. app/design/frontend/base/default/template/payex/masterpass/info.phtml +16 -0
  126. app/design/frontend/base/default/template/payex/masterpass/pdf/info.phtml +13 -0
  127. app/design/frontend/base/default/template/payex/masterpass/title.phtml +1 -0
  128. app/design/frontend/base/default/template/payex/partpayment/form.phtml +61 -0
  129. app/design/frontend/base/default/template/payex/partpayment/info.phtml +16 -0
  130. app/design/frontend/base/default/template/payex/partpayment/pdf/info.phtml +13 -0
  131. app/design/frontend/base/default/template/payex/partpayment/title.phtml +1 -0
  132. app/design/frontend/base/default/template/payex/swish/form.phtml +17 -0
  133. app/design/frontend/base/default/template/payex/swish/info.phtml +5 -0
  134. app/design/frontend/base/default/template/payex/swish/pdf/info.phtml +13 -0
  135. app/design/frontend/base/default/template/payex/swish/title.phtml +1 -0
  136. app/design/frontend/base/default/template/payex/wywallet/form.phtml +17 -0
  137. app/design/frontend/base/default/template/payex/wywallet/info.phtml +16 -0
  138. app/design/frontend/base/default/template/payex/wywallet/pdf/info.phtml +13 -0
  139. app/etc/modules/PayEx_Payments.xml +16 -0
  140. app/locale/en_US/PayEx_Payments.csv +0 -0
  141. app/locale/sv_SE/PayEx_Payments.csv +180 -0
  142. js/payex/iwd_opc/social_security_number.js +46 -0
  143. js/payex/social_security_number.js +70 -0
  144. lib/Px/Px.php +253 -0
  145. lib/Px/parser.php +388 -0
  146. package.xml +182 -0
  147. skin/adminhtml/base/default/images/payex/swish.png +0 -0
  148. skin/adminhtml/base/default/payex/payex-logo.png +0 -0
  149. skin/adminhtml/base/default/payex/payex_admin.css +23 -0
  150. skin/frontend/base/default/css/payex/masterpass.css +3 -0
  151. skin/frontend/base/default/images/payex/american_express_64.png +0 -0
  152. skin/frontend/base/default/images/payex/diners_club_64.png +0 -0
  153. skin/frontend/base/default/images/payex/financing-logo.gif +0 -0
  154. skin/frontend/base/default/images/payex/jcb_64.png +0 -0
  155. skin/frontend/base/default/images/payex/mastercard_64.png +0 -0
  156. skin/frontend/base/default/images/payex/masterpass-140.png +0 -0
  157. skin/frontend/base/default/images/payex/masterpass.png +0 -0
  158. skin/frontend/base/default/images/payex/partpayment-logo.gif +0 -0
  159. skin/frontend/base/default/images/payex/payex-invoice.png +0 -0
  160. skin/frontend/base/default/images/payex/payex-small.gif +0 -0
  161. skin/frontend/base/default/images/payex/payex.gif +0 -0
  162. skin/frontend/base/default/images/payex/swish.png +0 -0
  163. skin/frontend/base/default/images/payex/visa_64.png +0 -0
  164. skin/frontend/base/default/images/payex/ww_logo.png +0 -0
Changelog_payex.txt ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ Version 3.0.1
2
+ * Implemented Swish Payment Method
3
+ * Financing Invoice: Invoice link
4
+ * Fixed payex account problem for multiple stores
5
+
6
+ Version 3.0.0
7
+ * Init release of PayEx Payments module
8
+ * Payment modules have been assembled in a single module
9
+ * Integrated "Social Security Number" module
10
+ * Implemented PayEx Faktura (Financing Invoice)
11
+ * Implemented PayEx Delbetala (PartPayment)
12
+ * Implemented PayEx Invoice (Ledger Service)
13
+ * Implemented MasterPass Payments
14
+ * Social Security Number: IWD_Opc support
15
+ * Taxable discounts
16
+ * Taxable fees
17
+ * Option: Send order lines and billing/delivery addresses to PayEx
18
+ * Option: Replace illegal characters of product names
19
+ * Tune: Use order_id instead customer_id for productNumber
20
+ * Improved Transaction Callback
21
+ * Install using modman
22
+ * Many various code changes and fixes
23
+ * Removed deprecated code
24
+
25
+ Version 2.0.31
26
+ * Fixed bug with wrong order state when capture via backend
27
+
28
+ Version 2.0.30
29
+ * Improved update checker
30
+
31
+ Version 2.0.29
32
+ * PayEx Payment Page 2.0 for 'Credit Card' and 'Direct Debit' views
33
+
34
+ Version 2.0.28
35
+ * Improved rounding issue workaround
36
+
37
+ Version 2.0.27
38
+ * Added Reward points support
39
+
40
+ Version 2.0.26
41
+ * Improved transaction processing
42
+ * Set correct order state
43
+ * Sending mail when failed payments
44
+
45
+ Version 2.0.25
46
+ * Fixed problem with handling of canceled transactions
47
+
48
+ Version 2.0.24
49
+ * Fixed problem "The transaction "xxx" (capture) is already closed"
50
+ * Removed unused functions
51
+ * Minor changes
52
+
53
+ Version 2.0.23
54
+ * Fixed problems with order state
55
+ * Small bugfixes
56
+
57
+ Version 2.0.22
58
+ * Fixed bug with empty invoice totals
59
+ * Updated Px library to 2.0.1
60
+
61
+ Version 2.0.21
62
+ * Fixed problem with empty TotalPaid value
63
+ * Fixed problem with empty tax for bundled product
64
+ * Small bugfixes
65
+ * Added version hint
66
+
67
+ Version 2.0.20
68
+ * Fixed problem with downloadable products
69
+
70
+ Version 2.0.19
71
+ * Fixed bug with multiple currencies setup
72
+ * Use Initialize8, Capture5, Credit5
73
+ * Updated Px library (moved to lib directory)
74
+ * Removed deprecated code
75
+ * Various bugfixes
76
+
77
+ Version 2.0.18
78
+ * Responsive Skinning
79
+
80
+ Version 2.0.17
81
+ * Fixed rounding issue
82
+
83
+ Version 2.0.16
84
+ * Added PayPal Payment View
85
+ * Saving the refunded/canceled/failed transactions.
86
+ * Verbose error messages
87
+ * Save cart when fails
88
+ * Updated translations
89
+ * Bugfixes
90
+
91
+ Version 2.0.15
92
+ * Fixed multi store support
93
+
94
+ Version 2.0.14
95
+ * Updated Payex Library
96
+
97
+ Version 2.0.13
98
+ * Enabled Partial Refund in Invoice
99
+
100
+ Version 2.0.12
101
+ * Fixed rounding error bug
102
+
103
+ Version 2.0.11
104
+ * Fixed CodeOrder_AmountNotEqualOrderLinesTotal
105
+
106
+ Version 2.0.10
107
+ * Fix amount bug in AddOrderLine function
108
+ * Fixed some bugs in order statuses
109
+
110
+ Version 2.0.9
111
+ * Fixed Tax Calc bug
112
+ * Fixed CodeOrder_AmountNotEqualOrderLinesTotal
113
+
114
+ Version 2.0.8
115
+ * Improved Order Info
116
+ * Added Order Info in PDF Invoice
117
+
118
+ Version 2.0.7
119
+ * Fixed bug with order (in sale mode the order is not finalized)
120
+ * Fixed bug with refund
121
+ * Moved design templates in base directory
122
+
123
+ Version 2.0.6
124
+ * Fixed bug with wrong capture/refund amount
125
+
126
+ Version 2.0.5
127
+ * Added options for cleaning time in Payment Config
128
+
129
+ Version 2.0.4
130
+ * Fixed Pending Order Cleaner bug
131
+
132
+ Version 2.0.3
133
+ * Many bugfixes
134
+
135
+ Version 2.0.2
136
+ * Division by zero fix (When Shipping is 0)
137
+
138
+ Version 2.0.1
139
+ * Rewrited API Helper
140
+
141
+ Version 2.0.0
142
+ * Changend namespace
143
+ * Rewrited payment engine
144
+ * Added Translations
145
+ * Bugfixes
146
+
147
+ Version 1.2.3-r20120329
148
+ * Added compatibility with AAIT PayEx Core
149
+
150
+ Version 1.2.3
151
+ * Small bugfixes
152
+
153
+ Version 1.2.2
154
+ * Fixed DirectDebit bug (Payment Cancel)
155
+ * Added option "Payment Type" in the settings panel.
156
+ * Small bugfixes
157
+
158
+ Version 1.2.1
159
+ * Small bugfixes
160
+
161
+ Version 1.2.0
162
+ * Required PayEx Core module v1.0.1
163
+ * Transaction fetching
164
+ * Bugfixes
app/code/community/PayEx/Payments/Block/Adminhtml/Config/Hint.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Adminhtml_Config_Hint extends Mage_Adminhtml_Block_Abstract implements Varien_Data_Form_Element_Renderer_Interface
4
+ {
5
+
6
+ protected $_template = 'payex/adminhtml/hint.phtml';
7
+
8
+ /**
9
+ * Render fieldset html
10
+ * @param Varien_Data_Form_Element_Abstract $element element
11
+ * @return string
12
+ */
13
+ public function render(Varien_Data_Form_Element_Abstract $element)
14
+ {
15
+ $current_version = Mage::getConfig()->getModuleConfig('PayEx_Payments')->version->asArray();
16
+ $last_version = $current_version;
17
+
18
+ // Load cached available versions info
19
+ $availableVersions = Mage::app()->loadCache('payex_available_versions');
20
+ $availableVersions = $availableVersions ? @unserialize($availableVersions) : array();
21
+ if (isset($availableVersions['PayEx_Payments'])) {
22
+ $last_version = $availableVersions['PayEx_Payments']['version'];
23
+ }
24
+
25
+ $this->assign('current_version', $current_version);
26
+ $this->assign('last_version', $last_version);
27
+ Mage::getSingleton('adminhtml/session')->setIsPayexHintShowed(true);
28
+ return $this->toHtml();
29
+ }
30
+ }
app/code/community/PayEx/Payments/Block/Adminhtml/Sales/Order/Create/Totals/Fee.php ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Adminhtml_Sales_Order_Create_Totals_Fee extends Mage_Core_Block_Abstract
4
+ {
5
+ protected $_template = 'payex/sales/order/create/totals/fee.phtml';
6
+
7
+ /**
8
+ * Get Payment fee
9
+ * @return float
10
+ */
11
+ public function getPaymentFee()
12
+ {
13
+ // @todo
14
+ return 0;
15
+ }
16
+ }
app/code/community/PayEx/Payments/Block/Bankdebit/Banks.php ADDED
@@ -0,0 +1,60 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Bankdebit_Banks extends Mage_Core_Block_Abstract implements Mage_Widget_Block_Interface
4
+ {
5
+ protected $_options = array();
6
+
7
+ /**
8
+ * Get Block Html
9
+ * @return mixed
10
+ */
11
+ protected function _toHtml() {
12
+ $options = $this->getOptions();
13
+
14
+ $select = Mage::app()->getLayout()->createBlock('core/html_select')
15
+ ->setName('payexbank')
16
+ ->setId('payexbank')
17
+ ->setValue(null)
18
+ ->setExtraParams(null)
19
+ ->setOptions($options);
20
+ $html = $select->getHtml();
21
+ return $html;
22
+ }
23
+
24
+ /**
25
+ * Set Options
26
+ * @param $options
27
+ */
28
+ public function setOptions($options) {
29
+ $this->_options = $options;
30
+ }
31
+
32
+ /**
33
+ * Get Options
34
+ * @return array|null
35
+ */
36
+ public function getOptions() {
37
+ if ( count($this->_options) === 0 ) {
38
+ return $this->getAvailableBanks();
39
+ }
40
+ return $this->_options;
41
+ }
42
+
43
+ /**
44
+ * Get Available Banks
45
+ * @return array
46
+ */
47
+ public function getAvailableBanks() {
48
+ $selected_banks = Mage::getStoreConfig('payment/payex_bankdebit/banks');
49
+ $selected_banks = explode(',', $selected_banks);
50
+ $banks = Mage::getModel('payex/source_banks')->toOptionArray();
51
+
52
+ $result = array();
53
+ foreach($banks as $current) {
54
+ if ( in_array($current['value'], $selected_banks) ) {
55
+ $result[] = $current;
56
+ }
57
+ }
58
+ return $result;
59
+ }
60
+ }
app/code/community/PayEx/Payments/Block/Checkout/Fee.php ADDED
@@ -0,0 +1,45 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Checkout_Fee extends Mage_Checkout_Block_Total_Default
4
+ {
5
+ protected $_template = 'payex/checkout/fee.phtml';
6
+
7
+ protected static $_allowed_methods = array(
8
+ 'payex_financing',
9
+ 'payex_partpayment',
10
+ 'payex_invoice'
11
+ );
12
+
13
+ /**
14
+ * Get Payment fee
15
+ * @return float
16
+ */
17
+ public function getPaymentFee()
18
+ {
19
+ $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
20
+ $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
21
+ if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($this->getQuote()->getPaymentsCollection()) || !$this->getQuote()->getPayment()->hasMethodInstance())) {
22
+ return $this;
23
+ }
24
+
25
+ $paymentMethod = $this->getQuote()->getPayment()->getMethodInstance();
26
+ if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
27
+ return $this;
28
+ }
29
+
30
+ $price = (float) $paymentMethod->getConfigData('paymentfee');
31
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
32
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
33
+ return $fee;
34
+ }
35
+
36
+ /**
37
+ * Get Quote
38
+ * @return Mage_Sales_Model_Quote
39
+ */
40
+ public function getQuote()
41
+ {
42
+ return Mage::getModel('checkout/cart')->getQuote();
43
+ }
44
+
45
+ }
app/code/community/PayEx/Payments/Block/Form/Autopay.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Autopay extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/autopay/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Form/Bankdebit.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Bankdebit extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/bankdebit/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Form/CC.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_CC extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/cc/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Form/Financing.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Financing extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/financing/form.phtml');
9
+ }
10
+
11
+ /**
12
+ * Get Saved SSN from SSN extension
13
+ * @return mixed
14
+ */
15
+ public function getPayexSSN()
16
+ {
17
+ return Mage::getSingleton('checkout/session')->getPayexSSN();
18
+ }
19
+
20
+ /**
21
+ * Get Payment Fee
22
+ * @return Varien_Object
23
+ */
24
+ public function getPayexPaymentFee()
25
+ {
26
+ $paymentMethod = Mage::getModel('payex/payment_financing');
27
+ $price = (float) $paymentMethod->getConfigData('paymentfee');
28
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
29
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
30
+ return $fee;
31
+ }
32
+ }
app/code/community/PayEx/Payments/Block/Form/Invoice.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Invoice extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/invoice/form.phtml');
9
+ }
10
+
11
+ /**
12
+ * Get Saved SSN from SSN extension
13
+ * @return mixed
14
+ */
15
+ public function getPayexSSN()
16
+ {
17
+ return Mage::getSingleton('checkout/session')->getPayexSSN();
18
+ }
19
+
20
+ /**
21
+ * Get Payment Fee
22
+ * @return Varien_Object
23
+ */
24
+ public function getPayexPaymentFee()
25
+ {
26
+ $paymentMethod = Mage::getModel('payex/payment_invoice');
27
+ $price = (float) $paymentMethod->getConfigData('paymentfee');
28
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
29
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
30
+ return $fee;
31
+ }
32
+ }
app/code/community/PayEx/Payments/Block/Form/MasterPass.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_MasterPass extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/masterpass/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Form/PartPayment.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_PartPayment extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/partpayment/form.phtml');
9
+ }
10
+
11
+ /**
12
+ * Get Saved SSN from SSN extension
13
+ * @return mixed
14
+ */
15
+ public function getPayexSSN()
16
+ {
17
+ return Mage::getSingleton('checkout/session')->getPayexSSN();
18
+ }
19
+
20
+ /**
21
+ * Get Payment Fee
22
+ * @return Varien_Object
23
+ */
24
+ public function getPayexPaymentFee()
25
+ {
26
+ $paymentMethod = Mage::getModel('payex/payment_partPayment');
27
+ $price = (float) $paymentMethod->getConfigData('paymentfee');
28
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
29
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
30
+ return $fee;
31
+ }
32
+ }
app/code/community/PayEx/Payments/Block/Form/Swish.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Swish extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/swish/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Form/Wywallet.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Form_Wywallet extends Mage_Payment_Block_Form
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/wywallet/form.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Info/Autopay.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Autopay extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/autopay/info.phtml');
9
+ // Template for Checkout page
10
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
11
+ $this->setTemplate('payex/autopay/title.phtml');
12
+ }
13
+ }
14
+
15
+ /**
16
+ * Returns code of payment method
17
+ *
18
+ * @return string
19
+ */
20
+ public function getMethodCode()
21
+ {
22
+ return $this->getInfo()->getMethodInstance()->getCode();
23
+ }
24
+
25
+ /**
26
+ * Get some specific information in format of array($label => $value)
27
+ *
28
+ * @return array
29
+ */
30
+ public function getSpecificInformation()
31
+ {
32
+ // Get Payment Info
33
+ $_info = $this->getInfo();
34
+
35
+ // Transaction Fields
36
+ $fields = array(
37
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
38
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
39
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
40
+ 'Bank Reference' => array('bankReference'),
41
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
42
+ 'Transaction Ref' => array('transactionRef'),
43
+ 'PayEx Transaction Number' => array('transactionNumber'),
44
+ 'PayEx Transaction Status' => array('transactionStatus'),
45
+ 'Transaction Error Code' => array('transactionErrorCode'),
46
+ 'Transaction Error Description' => array('transactionErrorDescription'),
47
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
48
+ );
49
+
50
+ if ($_info) {
51
+ $transactionId = $_info->getLastTransId();
52
+
53
+ if ($transactionId) {
54
+ // Load transaction
55
+ $transaction = $_info->getTransaction($transactionId);
56
+ if ($transaction) {
57
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
58
+ if (!$transaction_data) {
59
+ $payment = $_info->getOrder()->getPayment();
60
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
61
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
62
+ $transaction->save();
63
+ }
64
+
65
+ $result = array();
66
+ foreach ($fields as $description => $list) {
67
+ foreach ($list as $key => $value) {
68
+ if (!empty($transaction_data[$value])) {
69
+ $result[$description] = $transaction_data[$value];
70
+ break;
71
+ }
72
+ }
73
+ }
74
+
75
+ return $result;
76
+ }
77
+ }
78
+ }
79
+
80
+ // @todo Info in email when invoicing
81
+ return $this->_prepareSpecificInformation()->getData();
82
+ }
83
+
84
+ /**
85
+ * Build PDF content of info block
86
+ *
87
+ * @return string
88
+ */
89
+ public function toPdf()
90
+ {
91
+ $this->setTemplate('payex/autopay/pdf/info.phtml');
92
+ return $this->toHtml();
93
+ }
94
+ }
app/code/community/PayEx/Payments/Block/Info/Bankdebit.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Bankdebit extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/bankdebit/info.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Info/CC.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_CC extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('payex/cc/info.phtml');
10
+ // Template for Checkout page
11
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
12
+ $this->setTemplate('payex/cc/title.phtml');
13
+ }
14
+
15
+ }
16
+
17
+ /**
18
+ * Returns code of payment method
19
+ *
20
+ * @return string
21
+ */
22
+ public function getMethodCode()
23
+ {
24
+ return $this->getInfo()->getMethodInstance()->getCode();
25
+ }
26
+
27
+ /**
28
+ * Get some specific information in format of array($label => $value)
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSpecificInformation()
33
+ {
34
+ // Get Payment Info
35
+ $_info = $this->getInfo();
36
+
37
+ // Transaction Fields
38
+ $fields = array(
39
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
40
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
41
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
42
+ 'Bank Reference' => array('bankReference'),
43
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
44
+ 'Transaction Ref' => array('transactionRef'),
45
+ 'PayEx Transaction Number' => array('transactionNumber'),
46
+ 'PayEx Transaction Status' => array('transactionStatus'),
47
+ 'Transaction Error Code' => array('transactionErrorCode'),
48
+ 'Transaction Error Description' => array('transactionErrorDescription'),
49
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
50
+ );
51
+
52
+ if ($_info) {
53
+ $transactionId = $_info->getLastTransId();
54
+
55
+ if ($transactionId) {
56
+ // Load transaction
57
+ $transaction = $_info->getTransaction($transactionId);
58
+ if ($transaction) {
59
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
60
+ if (!$transaction_data) {
61
+ $payment = $_info->getOrder()->getPayment();
62
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
64
+ $transaction->save();
65
+ }
66
+
67
+ $result = array();
68
+ foreach ($fields as $description => $list) {
69
+ foreach ($list as $key => $value) {
70
+ if (!empty($transaction_data[$value])) {
71
+ $result[$description] = $transaction_data[$value];
72
+ break;
73
+ }
74
+ }
75
+ }
76
+
77
+ return $result;
78
+ }
79
+ }
80
+ }
81
+
82
+ // @todo Info in email when invoicing
83
+ return $this->_prepareSpecificInformation()->getData();
84
+ }
85
+
86
+ /**
87
+ * Build PDF content of info block
88
+ *
89
+ * @return string
90
+ */
91
+ public function toPdf()
92
+ {
93
+ $this->setTemplate('payex/cc/pdf/info.phtml');
94
+ return $this->toHtml();
95
+ }
96
+ }
app/code/community/PayEx/Payments/Block/Info/Financing.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Financing extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('payex/financing/info.phtml');
10
+ // Template for Checkout page
11
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
12
+ $this->setTemplate('payex/financing/title.phtml');
13
+ }
14
+
15
+ }
16
+
17
+ /**
18
+ * Returns code of payment method
19
+ *
20
+ * @return string
21
+ */
22
+ public function getMethodCode()
23
+ {
24
+ return $this->getInfo()->getMethodInstance()->getCode();
25
+ }
26
+
27
+ /**
28
+ * Get some specific information in format of array($label => $value)
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSpecificInformation()
33
+ {
34
+ // Get Payment Info
35
+ $_info = $this->getInfo();
36
+
37
+ // Transaction Fields
38
+ $fields = array(
39
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
40
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
41
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
42
+ 'Bank Reference' => array('bankReference'),
43
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
44
+ 'Transaction Ref' => array('transactionRef'),
45
+ 'PayEx Transaction Number' => array('transactionNumber'),
46
+ 'PayEx Transaction Status' => array('transactionStatus'),
47
+ 'Transaction Error Code' => array('transactionErrorCode'),
48
+ 'Transaction Error Description' => array('transactionErrorDescription'),
49
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
50
+ );
51
+
52
+ if ($_info) {
53
+ $transactionId = $_info->getLastTransId();
54
+
55
+ if ($transactionId) {
56
+ // Load transaction
57
+ $transaction = $_info->getTransaction($transactionId);
58
+ if ($transaction) {
59
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
60
+ if (!$transaction_data) {
61
+ $payment = $_info->getOrder()->getPayment();
62
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
64
+ $transaction->save();
65
+ }
66
+
67
+ $result = array();
68
+ foreach ($fields as $description => $list) {
69
+ foreach ($list as $key => $value) {
70
+ if (!empty($transaction_data[$value])) {
71
+ $result[$description] = $transaction_data[$value];
72
+ break;
73
+ }
74
+ }
75
+ }
76
+
77
+ // Add Invoice Url
78
+ if (in_array($transaction_data['transactionStatus'], array(0, 6))) {
79
+ $invoice_url = $this->getInvoiceLink();
80
+ if ($invoice_url) {
81
+ $result['Invoice'] = $this->getInvoiceLink();
82
+ }
83
+ }
84
+
85
+ return $result;
86
+ }
87
+ }
88
+ }
89
+
90
+ // @todo Info in email when invoicing
91
+ return $this->_prepareSpecificInformation()->getData();
92
+ }
93
+
94
+ /**
95
+ * Build PDF content of info block
96
+ *
97
+ * @return string
98
+ */
99
+ public function toPdf()
100
+ {
101
+ $this->setTemplate('payex/financing/pdf/info.phtml');
102
+ return $this->toHtml();
103
+ }
104
+
105
+ /**
106
+ * Get Invoice Url
107
+ * @return bool|string
108
+ */
109
+ public function getInvoiceLink()
110
+ {
111
+ $_info = $this->getInfo();
112
+ if ($_info) {
113
+ $transactionId = $_info->getLastTransId();
114
+ if ($transactionId) {
115
+ $transaction = $_info->getTransaction($transactionId);
116
+
117
+ // Get Invoice Url from Payment
118
+ $payment = $transaction->getOrderPaymentObject(true);
119
+ $invoice_url = $payment->getAdditionalInformation('payex_invoice_url');
120
+ if (!$invoice_url) {
121
+ $result = Mage::helper('payex/order')->getInvoiceLink($transactionId);
122
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
123
+ return false;
124
+ }
125
+
126
+ $invoice_url = $result['url'];
127
+
128
+ // Save Invoice Url in Payment
129
+ $payment->setAdditionalInformation('payex_invoice_url', $invoice_url);
130
+ }
131
+
132
+ return $invoice_url;
133
+ }
134
+ }
135
+
136
+ return false;
137
+ }
138
+ }
app/code/community/PayEx/Payments/Block/Info/Invoice.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Invoice extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/invoice/info.phtml');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Block/Info/MasterPass.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_MasterPass extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('payex/masterpass/info.phtml');
10
+ // Template for Checkout page
11
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
12
+ $this->setTemplate('payex/masterpass/title.phtml');
13
+ }
14
+
15
+ }
16
+
17
+ /**
18
+ * Returns code of payment method
19
+ *
20
+ * @return string
21
+ */
22
+ public function getMethodCode()
23
+ {
24
+ return $this->getInfo()->getMethodInstance()->getCode();
25
+ }
26
+
27
+ /**
28
+ * Get some specific information in format of array($label => $value)
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSpecificInformation()
33
+ {
34
+ // Get Payment Info
35
+ $_info = $this->getInfo();
36
+
37
+ // Transaction Fields
38
+ $fields = array(
39
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
40
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
41
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
42
+ 'Bank Reference' => array('bankReference'),
43
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
44
+ 'Transaction Ref' => array('transactionRef'),
45
+ 'PayEx Transaction Number' => array('transactionNumber'),
46
+ 'PayEx Transaction Status' => array('transactionStatus'),
47
+ 'Transaction Error Code' => array('transactionErrorCode'),
48
+ 'Transaction Error Description' => array('transactionErrorDescription'),
49
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
50
+ );
51
+
52
+ if ($_info) {
53
+ $transactionId = $_info->getLastTransId();
54
+
55
+ if ($transactionId) {
56
+ // Load transaction
57
+ $transaction = $_info->getTransaction($transactionId);
58
+ if ($transaction) {
59
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
60
+ if (!$transaction_data) {
61
+ $payment = $_info->getOrder()->getPayment();
62
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
64
+ $transaction->save();
65
+ }
66
+
67
+ $result = array();
68
+ foreach ($fields as $description => $list) {
69
+ foreach ($list as $key => $value) {
70
+ if (!empty($transaction_data[$value])) {
71
+ $result[$description] = $transaction_data[$value];
72
+ break;
73
+ }
74
+ }
75
+ }
76
+
77
+ return $result;
78
+ }
79
+ }
80
+ }
81
+
82
+ // @todo Info in email when invoicing
83
+ return $this->_prepareSpecificInformation()->getData();
84
+ }
85
+
86
+ /**
87
+ * Build PDF content of info block
88
+ *
89
+ * @return string
90
+ */
91
+ public function toPdf()
92
+ {
93
+ $this->setTemplate('payex/masterpass/pdf/info.phtml');
94
+ return $this->toHtml();
95
+ }
96
+ }
app/code/community/PayEx/Payments/Block/Info/PartPayment.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_PartPayment extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('payex/partpayment/info.phtml');
10
+ // Template for Checkout page
11
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
12
+ $this->setTemplate('payex/partpayment/title.phtml');
13
+ }
14
+
15
+ }
16
+
17
+ /**
18
+ * Returns code of payment method
19
+ *
20
+ * @return string
21
+ */
22
+ public function getMethodCode()
23
+ {
24
+ return $this->getInfo()->getMethodInstance()->getCode();
25
+ }
26
+
27
+ /**
28
+ * Get some specific information in format of array($label => $value)
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSpecificInformation()
33
+ {
34
+ // Get Payment Info
35
+ $_info = $this->getInfo();
36
+
37
+ // Transaction Fields
38
+ $fields = array(
39
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
40
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
41
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
42
+ 'Bank Reference' => array('bankReference'),
43
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
44
+ 'Transaction Ref' => array('transactionRef'),
45
+ 'PayEx Transaction Number' => array('transactionNumber'),
46
+ 'PayEx Transaction Status' => array('transactionStatus'),
47
+ 'Transaction Error Code' => array('transactionErrorCode'),
48
+ 'Transaction Error Description' => array('transactionErrorDescription'),
49
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
50
+ );
51
+
52
+ if ($_info) {
53
+ $transactionId = $_info->getLastTransId();
54
+
55
+ if ($transactionId) {
56
+ // Load transaction
57
+ $transaction = $_info->getTransaction($transactionId);
58
+ if ($transaction) {
59
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
60
+ if (!$transaction_data) {
61
+ $payment = $_info->getOrder()->getPayment();
62
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
64
+ $transaction->save();
65
+ }
66
+
67
+ $result = array();
68
+ foreach ($fields as $description => $list) {
69
+ foreach ($list as $key => $value) {
70
+ if (!empty($transaction_data[$value])) {
71
+ $result[$description] = $transaction_data[$value];
72
+ break;
73
+ }
74
+ }
75
+ }
76
+
77
+ return $result;
78
+ }
79
+ }
80
+ }
81
+
82
+ // @todo Info in email when invoicing
83
+ return $this->_prepareSpecificInformation()->getData();
84
+ }
85
+
86
+ /**
87
+ * Build PDF content of info block
88
+ *
89
+ * @return string
90
+ */
91
+ public function toPdf()
92
+ {
93
+ $this->setTemplate('payex/partpayment/pdf/info.phtml');
94
+ return $this->toHtml();
95
+ }
96
+ }
app/code/community/PayEx/Payments/Block/Info/Swish.php ADDED
@@ -0,0 +1,91 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Swish extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->setTemplate('payex/swish/info.phtml');
9
+ }
10
+
11
+
12
+ /**
13
+ * Returns code of payment method
14
+ *
15
+ * @return string
16
+ */
17
+ public function getMethodCode()
18
+ {
19
+ return $this->getInfo()->getMethodInstance()->getCode();
20
+ }
21
+
22
+ /**
23
+ * Get some specific information in format of array($label => $value)
24
+ *
25
+ * @return array
26
+ */
27
+ public function getSpecificInformation()
28
+ {
29
+ // Get Payment Info
30
+ $_info = $this->getInfo();
31
+
32
+ // Transaction Fields
33
+ $fields = array(
34
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
35
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
36
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
37
+ //'Bank Reference' => array('bankReference'),
38
+ //'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
39
+ 'Transaction Ref' => array('transactionRef'),
40
+ 'PayEx Transaction Number' => array('transactionNumber'),
41
+ 'PayEx Transaction Status' => array('transactionStatus'),
42
+ 'Transaction Error Code' => array('transactionErrorCode'),
43
+ 'Transaction Error Description' => array('transactionErrorDescription'),
44
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
45
+ );
46
+
47
+ if ($_info) {
48
+ $transactionId = $_info->getLastTransId();
49
+
50
+ if ($transactionId) {
51
+ // Load transaction
52
+ $transaction = $_info->getTransaction($transactionId);
53
+ if ($transaction) {
54
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
55
+ if (!$transaction_data) {
56
+ $payment = $_info->getOrder()->getPayment();
57
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
58
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
59
+ $transaction->save();
60
+ }
61
+
62
+ $result = array();
63
+ foreach ($fields as $description => $list) {
64
+ foreach ($list as $key => $value) {
65
+ if (!empty($transaction_data[$value])) {
66
+ $result[$description] = $transaction_data[$value];
67
+ break;
68
+ }
69
+ }
70
+ }
71
+
72
+ return $result;
73
+ }
74
+ }
75
+ }
76
+
77
+ // @todo Info in email when invoicing
78
+ return $this->_prepareSpecificInformation()->getData();
79
+ }
80
+
81
+ /**
82
+ * Build PDF content of info block
83
+ *
84
+ * @return string
85
+ */
86
+ public function toPdf()
87
+ {
88
+ $this->setTemplate('payex/swish/pdf/info.phtml');
89
+ return $this->toHtml();
90
+ }
91
+ }
app/code/community/PayEx/Payments/Block/Info/Wywallet.php ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Info_Wywallet extends Mage_Payment_Block_Info
4
+ {
5
+ protected function _construct()
6
+ {
7
+ parent::_construct();
8
+
9
+ $this->setTemplate('payex/wywallet/info.phtml');
10
+ // Template for Checkout page
11
+ if ($this->getRequest()->getRequestedActionName() === 'progress') {
12
+ $this->setTemplate('payex/wywallet/title.phtml');
13
+ }
14
+
15
+ }
16
+
17
+ /**
18
+ * Returns code of payment method
19
+ *
20
+ * @return string
21
+ */
22
+ public function getMethodCode()
23
+ {
24
+ return $this->getInfo()->getMethodInstance()->getCode();
25
+ }
26
+
27
+ /**
28
+ * Get some specific information in format of array($label => $value)
29
+ *
30
+ * @return array
31
+ */
32
+ public function getSpecificInformation()
33
+ {
34
+ // Get Payment Info
35
+ $_info = $this->getInfo();
36
+
37
+ // Transaction Fields
38
+ $fields = array(
39
+ 'PayEx Payment Method' => array('paymentMethod', 'cardProduct'),
40
+ //'Masked Number' => array('maskedNumber', 'maskedCard'),
41
+ //'Bank Hash' => array('BankHash', 'csId', 'panId'),
42
+ 'Bank Reference' => array('bankReference'),
43
+ 'Authenticated Status' => array('AuthenticatedStatus', 'authenticatedStatus'),
44
+ 'Transaction Ref' => array('transactionRef'),
45
+ 'PayEx Transaction Number' => array('transactionNumber'),
46
+ 'PayEx Transaction Status' => array('transactionStatus'),
47
+ 'Transaction Error Code' => array('transactionErrorCode'),
48
+ 'Transaction Error Description' => array('transactionErrorDescription'),
49
+ 'Transaction ThirdParty Error' => array('transactionThirdPartyError')
50
+ );
51
+
52
+ if ($_info) {
53
+ $transactionId = $_info->getLastTransId();
54
+
55
+ if ($transactionId) {
56
+ // Load transaction
57
+ $transaction = $_info->getTransaction($transactionId);
58
+ if ($transaction) {
59
+ $transaction_data = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
60
+ if (!$transaction_data) {
61
+ $payment = $_info->getOrder()->getPayment();
62
+ $transaction_data = $payment->getMethodInstance()->fetchTransactionInfo($payment, $transactionId);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $transaction_data);
64
+ $transaction->save();
65
+ }
66
+
67
+ $result = array();
68
+ foreach ($fields as $description => $list) {
69
+ foreach ($list as $key => $value) {
70
+ if (!empty($transaction_data[$value])) {
71
+ $result[$description] = $transaction_data[$value];
72
+ break;
73
+ }
74
+ }
75
+ }
76
+
77
+ return $result;
78
+ }
79
+ }
80
+ }
81
+
82
+ // @todo Info in email when invoicing
83
+ return $this->_prepareSpecificInformation()->getData();
84
+ }
85
+
86
+ /**
87
+ * Build PDF content of info block
88
+ *
89
+ * @return string
90
+ */
91
+ public function toPdf()
92
+ {
93
+ $this->setTemplate('payex/wywallet/pdf/info.phtml');
94
+ return $this->toHtml();
95
+ }
96
+ }
app/code/community/PayEx/Payments/Block/MasterPass/Button.php ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_MasterPass_Button extends Mage_Core_Block_Template {
4
+ /**
5
+ * Get MasterPass Checkout URL
6
+ * @return string
7
+ */
8
+ public function getCheckoutUrl()
9
+ {
10
+ return Mage::getUrl('payex/masterpass/checkout', array('_secure' => true));
11
+ }
12
+
13
+ /**
14
+ * Get MasterPass Logo
15
+ * @return string
16
+ */
17
+ public function getImageUrl()
18
+ {
19
+ return $this->getSkinUrl('images/payex/masterpass.png', array('_secure' => true));
20
+ }
21
+ }
app/code/community/PayEx/Payments/Block/Order/Totals/Fee.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Block_Order_Totals_Fee extends Mage_Core_Block_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function initTotals()
12
+ {
13
+ $parent = $this->getParentBlock();
14
+ $paymentMethod = $parent->getOrder()->getPayment()->getMethodInstance()->getCode();
15
+
16
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
17
+ return $this;
18
+ }
19
+
20
+ if ($parent->getOrder()->getBasePayexPaymentFeeTax()) {
21
+ $total = new Varien_Object();
22
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Incl.Tax)'));
23
+ $total->setValue($parent->getOrder()->getPayexPaymentFee() + $parent->getOrder()->getPayexPaymentFeeTax());
24
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee() + $parent->getOrder()->getPayexBasePaymentFeeTax());
25
+ $total->setCode('payex_payment_fee_with_tax');
26
+ $parent->addTotalBefore($total, 'tax');
27
+ }
28
+
29
+ if ($parent->getOrder()->getBasePayexPaymentFee()) {
30
+ $total = new Varien_Object();
31
+ $total->setLabel(Mage::helper('payex')->__('Payment fee (Excl.Tax)'));
32
+ $total->setValue($parent->getOrder()->getPayexPaymentFee());
33
+ $total->setBaseValue($parent->getOrder()->getPayexBasePaymentFee());
34
+ $total->setCode('payex_payment_fee');
35
+ $parent->addTotalBefore($total, 'payex_payment_fee_with_tax');
36
+ }
37
+
38
+ return $this;
39
+ }
40
+ }
app/code/community/PayEx/Payments/Helper/Agreement.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Helper_Agreement extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Get Customer Agreement ID from Database
7
+ * @return bool
8
+ */
9
+ public function getCustomerAgreement()
10
+ {
11
+ $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
12
+ $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
13
+ return $agreement->getId() ? $agreement->getAgreementRef() : false;
14
+ }
15
+
16
+ /**
17
+ * Check status Customer Agreement
18
+ * @param $agreement_ref
19
+ * @return bool | int
20
+ */
21
+ public function getPxAgreementStatus($agreement_ref)
22
+ {
23
+ if (!$agreement_ref) {
24
+ return PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
25
+ }
26
+
27
+ // Init Environment
28
+ Mage::getSingleton('payex/payment_autopay');
29
+
30
+ // Call PxAgreement.AgreementCheck
31
+ $params = array(
32
+ 'accountNumber' => '',
33
+ 'agreementRef' => $agreement_ref,
34
+ );
35
+ $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
36
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
37
+
38
+ // Check Errors
39
+ if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
40
+ return PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
41
+ }
42
+
43
+ $agreement_status = (int)$result['agreementStatus'];
44
+ Mage::helper('payex/tools')->addToDebug('PxAgreement.AgreementCheck Status is ' . $agreement_status . ' (NotVerified = 0, Verified = 1, Deleted = 2)');
45
+ return $agreement_status;
46
+ }
47
+
48
+ }
app/code/community/PayEx/Payments/Helper/Api.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ require_once(Mage::getBaseDir('lib') . '/Px/Px.php');
4
+
5
+ class PayEx_Payments_Helper_Api extends Mage_Core_Helper_Abstract
6
+ {
7
+ protected static $_px = null;
8
+
9
+ /**
10
+ * Get PayEx Api Handler
11
+ * @static
12
+ * @return Px
13
+ */
14
+ public static function getPx()
15
+ {
16
+ // Use Singleton
17
+ if (is_null(self::$_px)) {
18
+ self::$_px = new Px();
19
+ }
20
+ return self::$_px;
21
+ }
22
+ }
app/code/community/PayEx/Payments/Helper/Data.php ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Helper_Data extends Mage_Core_Helper_Abstract
4
+ {
5
+ //
6
+ }
app/code/community/PayEx/Payments/Helper/Discount.php ADDED
@@ -0,0 +1,170 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class AAIT_Shared_Helper_Discount
5
+ *
6
+ * Helps to figure out correct tax for discounts on quotes and orders
7
+ *
8
+ * Note: this is a complete copy from our (eValent.com) internal module
9
+ * Ecom_Utils. Original class name is Ecom_Utils_Helper_Discount
10
+ *
11
+ * @author: Andre Klang <andre.klang@evalent.com>
12
+ *
13
+ */
14
+ class PayEx_Payments_Helper_Discount extends Mage_Core_Helper_Abstract
15
+ {
16
+
17
+ /**
18
+ * Return total discount incl OR excl tax, depending on settings
19
+ * @param Mage_Sales_Model_Quote $quote
20
+ * @return int
21
+ */
22
+ public function getDiscount($quote)
23
+ {
24
+ if (Mage::getStoreConfig('tax/cart_display/subtotal') > 1) {
25
+ return $this->getDiscountData($quote)->getDiscountInclTax();
26
+ }
27
+
28
+ return $this->getDiscountData($quote)->getDiscountExclTax();
29
+ }
30
+
31
+ /**
32
+ * Gets the total discount from $quote
33
+ * inkl. and excl. tax
34
+ * Data is returned as a Varien_Object with these data-keys set:
35
+ * - discount_incl_tax
36
+ * - discount_excl_tax
37
+ *
38
+ *
39
+ * @param Mage_Sales_Model_Quote $quote
40
+ *
41
+ * @return Varien_Object
42
+ */
43
+ public function getDiscountData(Mage_Sales_Model_Quote $quote)
44
+ {
45
+ // if catalog-prices includes tax
46
+ $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX);
47
+
48
+ /** @var Mage_Sales_Model_Quote_Address $shippingAddress */
49
+ $shippingAddress = $quote->getShippingAddress();
50
+
51
+ $discountIncl = 0;
52
+ $discountExcl = 0;
53
+
54
+ // find discount on the items
55
+ foreach ($quote->getItemsCollection() as $item) {
56
+ /** @var Mage_Sales_Model_Quote_Item $item */
57
+ if (!$CatPriceIncl) {
58
+ $discountExcl += $item->getDiscountAmount();
59
+ $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
60
+ } else {
61
+ $discountExcl += $item->getDiscountAmount() / (($item->getTaxPercent() / 100) + 1);
62
+ $discountIncl += $item->getDiscountAmount();
63
+ }
64
+ }
65
+
66
+ // find out tax-rate for the shipping
67
+ if ((float)$shippingAddress->getShippingInclTax() && (float)$shippingAddress->getShippingAmount()) {
68
+ $shippingTaxRate = $shippingAddress->getShippingInclTax() / $shippingAddress->getShippingAmount();
69
+ } else {
70
+ $shippingTaxRate = 1;
71
+ }
72
+
73
+ // how much differs between $discountExcl and total discount?
74
+ // (the difference is due to discount on the shipping)
75
+ if (!$CatPriceIncl) {
76
+ $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountExcl;
77
+ } else {
78
+ $shippingDiscount = abs($quote->getShippingAddress()->getDiscountAmount()) - $discountIncl;
79
+ }
80
+
81
+ // apply/remove tax to shipping-discount
82
+ if (!$CatPriceIncl) {
83
+ $discountIncl += $shippingDiscount * $shippingTaxRate;
84
+ $discountExcl += $shippingDiscount;
85
+ } else {
86
+ $discountIncl += $shippingDiscount;
87
+ $discountExcl += $shippingDiscount / $shippingTaxRate;
88
+ }
89
+
90
+ $return = new Varien_Object();
91
+ return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
92
+ }
93
+
94
+ /**
95
+ * Return total discount incl OR excl tax, depending on view settings
96
+ * This is used to display total discount for customer
97
+ * @param Mage_Sales_Model_Order $order
98
+ * @return int
99
+ */
100
+ public function getOrderDiscount(Mage_Sales_Model_Order $order)
101
+ {
102
+ if (Mage::getStoreConfig('tax/cart_display/subtotal', $order->getStore()) > 1) {
103
+ return $this->getOrderDiscountData($order)->getDiscountInclTax();
104
+ }
105
+
106
+ return $this->getOrderDiscountData($order)->getDiscountExclTax();
107
+ }
108
+
109
+ /**
110
+ * Gets the total discount from $order
111
+ * inkl. and excl. tax
112
+ * Data is returned as a Varien_Object with these data-keys set:
113
+ * - discount_incl_tax
114
+ * - discount_excl_tax
115
+ *
116
+ * @param Mage_Sales_Model_Order $order
117
+ *
118
+ * @return Varien_Object
119
+ */
120
+ public function getOrderDiscountData(Mage_Sales_Model_Order $order)
121
+ {
122
+ // if catalog-prices includes tax
123
+ $CatPriceIncl = Mage::getStoreConfig(Mage_Tax_Model_Config::CONFIG_XML_PATH_PRICE_INCLUDES_TAX, $order->getStore());
124
+
125
+ $discountIncl = 0;
126
+ $discountExcl = 0;
127
+
128
+ // find discount on the items
129
+ foreach ($order->getItemsCollection() as $item) {
130
+ /** @var Mage_Sales_Model_Quote_Item $item */
131
+ if (!$CatPriceIncl) {
132
+ $discountExcl += $item->getDiscountAmount();
133
+ $discountIncl += $item->getDiscountAmount() * (($item->getTaxPercent() / 100) + 1);
134
+ } else {
135
+ $discountExcl += $item->getDiscountAmount() / (($item->getTaxPercent() / 100) + 1);
136
+ $discountIncl += $item->getDiscountAmount();
137
+ }
138
+ }
139
+
140
+ // find out tax-rate for the shipping
141
+ if ((float)$order->getShippingInclTax() && (float)$order->getShippingAmount()) {
142
+ $shippingTaxRate = $order->getShippingInclTax() / $order->getShippingAmount();
143
+ } else {
144
+ $shippingTaxRate = 1;
145
+ }
146
+
147
+ // get discount amount for shipping
148
+ $shippingDiscount = (float)$order->getShippingDiscountAmount();
149
+
150
+ // apply/remove tax to shipping-discount
151
+ if (!$CatPriceIncl) {
152
+ $discountIncl += $shippingDiscount * $shippingTaxRate;
153
+ $discountExcl += $shippingDiscount;
154
+ } else {
155
+ $discountIncl += $shippingDiscount;
156
+ $discountExcl += $shippingDiscount / $shippingTaxRate;
157
+ }
158
+
159
+ // Workaround: Apply Customer Tax: Before Discount + Apply Discount On Prices: Including Tax
160
+ if (!Mage::helper('tax')->applyTaxAfterDiscount($order->getStore()) && Mage::helper('tax')->discountTax($order->getStore())) {
161
+ // Use Discount + Tax to get correct discount for order total
162
+ $discountVatPercent = round((($discountIncl / $discountExcl) - 1) * 100);
163
+ $discountIncl = $discountExcl + $order->getTaxAmount();
164
+ $discountExcl = $discountIncl / (($discountVatPercent / 100) + 1);
165
+ }
166
+
167
+ $return = new Varien_Object();
168
+ return $return->setDiscountInclTax($discountIncl)->setDiscountExclTax($discountExcl);
169
+ }
170
+ }
app/code/community/PayEx/Payments/Helper/Fee.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Helper_Fee extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Get Payment Fee Price
7
+ * @param float $fee
8
+ * @param int $tax_class
9
+ * @return Varien_Object
10
+ */
11
+ public function getPaymentFeePrice($fee, $tax_class)
12
+ {
13
+ // Get Tax Rate
14
+ $request = Mage::getSingleton('tax/calculation')->getRateRequest(
15
+ $this->getQuote()->getShippingAddress(),
16
+ $this->getQuote()->getBillingAddress(),
17
+ $this->getQuote()->getCustomerTaxClassId(),
18
+ $this->getQuote()->getStore()
19
+ );
20
+ $taxRate = Mage::getSingleton('tax/calculation')
21
+ ->getRate($request->setProductClassId($tax_class));
22
+
23
+ $priceIncludeTax = Mage::helper('tax')->priceIncludesTax($this->getQuote()->getStore());
24
+ $taxAmount = Mage::getSingleton('tax/calculation')->calcTaxAmount($fee, $taxRate, $priceIncludeTax, true);
25
+
26
+ if ($priceIncludeTax) {
27
+ $fee -= $taxAmount;
28
+ }
29
+
30
+ $result = new Varien_Object();
31
+ return $result->setPaymentFeePrice($fee)
32
+ ->setPaymentFeeTax($taxAmount);
33
+ }
34
+
35
+ /**
36
+ * Get Quote
37
+ * @return Mage_Sales_Model_Quote
38
+ */
39
+ public function getQuote()
40
+ {
41
+ return Mage::getModel('checkout/cart')->getQuote();
42
+ }
43
+ }
app/code/community/PayEx/Payments/Helper/Order.php ADDED
@@ -0,0 +1,730 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Helper_Order extends Mage_Core_Helper_Abstract
4
+ {
5
+
6
+ /**
7
+ * Process Payment Transaction
8
+ * @param Mage_Sales_Model_Order $order
9
+ * @param array $fields
10
+ *
11
+ * @return Mage_Sales_Model_Order_Payment_Transaction|null
12
+ * @throws Exception
13
+ */
14
+ public function processPaymentTransaction(Mage_Sales_Model_Order $order, array $fields)
15
+ {
16
+ // Lookup Transaction
17
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
18
+ ->addAttributeToFilter('txn_id', $fields['transactionNumber']);
19
+ if (count($collection) > 0) {
20
+ Mage::helper('payex/tools')->addToDebug(sprintf('Transaction %s already processed.', $fields['transactionNumber']), $order->getIncrementId());
21
+ return $collection->getFirstItem();
22
+ }
23
+
24
+ // Set Payment Transaction Id
25
+ $payment = $order->getPayment();
26
+ $payment->setTransactionId($fields['transactionNumber']);
27
+
28
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
29
+ $transaction_status = isset($fields['transactionStatus']) ? (int)$fields['transactionStatus'] : null;
30
+ switch ($transaction_status) {
31
+ case 1:
32
+ // From PayEx PIM:
33
+ // "If PxOrder.Complete returns transactionStatus = 1, then check pendingReason for status."
34
+ // See http://www.payexpim.com/payment-methods/paypal/
35
+ if ($fields['pending'] === 'true') {
36
+ $message = Mage::helper('payex')->__('Transaction Status: %s.', $transaction_status);
37
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, $message);
38
+ $transaction->setIsClosed(0);
39
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
40
+ $transaction->setMessage($message);
41
+ $transaction->save();
42
+ break;
43
+ }
44
+
45
+ $message = Mage::helper('payex')->__('Transaction Status: %s.', $transaction_status);
46
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true, $message);
47
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
48
+ $transaction->setMessage($message);
49
+ $transaction->save();
50
+ break;
51
+ case 3:
52
+ $message = Mage::helper('payex')->__('Transaction Status: %s.', $transaction_status);
53
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH, null, true, $message);
54
+ $transaction->setIsClosed(0);
55
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
56
+ $transaction->setMessage($message);
57
+ $transaction->save();
58
+ break;
59
+ case 0;
60
+ case 6:
61
+ $message = Mage::helper('payex')->__('Transaction Status: %s.', $transaction_status);
62
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, null, true, $message);
63
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
64
+ $transaction->isFailsafe(true)->close(false);
65
+ $transaction->setMessage($message);
66
+ $transaction->save();
67
+ break;
68
+ case 2:
69
+ $message = Mage::helper('payex')->__('Detected an abnormal payment process (Transaction Status: %s).', $transaction_status);
70
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true, $message);
71
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
72
+ $transaction->setMessage($message);
73
+ $transaction->setIsCancel(true);
74
+ $transaction->save();
75
+ break;
76
+ case 4;
77
+ $message = Mage::helper('payex')->__('Order automatically canceled. Transaction is canceled.');
78
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true);
79
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
80
+ $transaction->setMessage($message);
81
+ $transaction->setIsCancel(true);
82
+ $transaction->save();
83
+ break;
84
+ case 5;
85
+ $message = Mage::helper('payex')->__('Order automatically canceled. Transaction is failed.');
86
+ $message .= ' ' . Mage::helper('payex/tools')->getVerboseErrorMessage($fields);
87
+ $transaction = $payment->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_PAYMENT, null, true);
88
+ $transaction->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $fields);
89
+ $transaction->setMessage($message);
90
+ $transaction->setIsCancel(true);
91
+ $transaction->save();
92
+ break;
93
+ default:
94
+ $message = Mage::helper('payex')->__('Invalid transaction status.');
95
+ $transaction = Mage::getModel('sales/order_payment_transaction');
96
+ $transaction->setMessage($message);
97
+ $transaction->setIsCancel(true);
98
+ break;
99
+ }
100
+
101
+ try {
102
+ $order->save();
103
+ Mage::helper('payex/tools')->addToDebug($message, $order->getIncrementId());
104
+ } catch (Exception $e) {
105
+ Mage::helper('payex/tools')->addToDebug('Error: ' . $e->getMessage(), $order->getIncrementId());
106
+ }
107
+
108
+ return $transaction;
109
+ }
110
+
111
+ /**
112
+ * Create Invoice
113
+ * @param $order
114
+ * @param bool $online
115
+ * @return Mage_Sales_Model_Order_Invoice
116
+ */
117
+ public function makeInvoice(&$order, $online = false)
118
+ {
119
+ // Prepare Invoice
120
+ $magento_version = Mage::getVersion();
121
+ if (version_compare($magento_version, '1.4.2', '>=')) {
122
+ $invoice = Mage::getModel('sales/order_invoice_api_v2');
123
+ $invoice_id = $invoice->create($order->getIncrementId(), $order->getAllItems(), Mage::helper('payex')->__('Auto-generated from PayEx module'), false, false);
124
+ $invoice = Mage::getModel('sales/order_invoice')->loadByIncrementId($invoice_id);
125
+
126
+ if ($online) {
127
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
128
+ $invoice->capture()->save();
129
+ } else {
130
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
131
+ $invoice->pay()->save();
132
+ }
133
+ } else {
134
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
135
+ $invoice->addComment(Mage::helper('payex')->__('Auto-generated from PayEx module'), false, false);
136
+ $invoice->setRequestedCaptureCase($online ? Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE : Mage_Sales_Model_Order_Invoice::CAPTURE_OFFLINE);
137
+ $invoice->register();
138
+
139
+ $invoice->getOrder()->setIsInProcess(true);
140
+
141
+ try {
142
+ $transactionSave = Mage::getModel('core/resource_transaction')
143
+ ->addObject($invoice)
144
+ ->addObject($invoice->getOrder());
145
+ $transactionSave->save();
146
+ } catch (Mage_Core_Exception $e) {
147
+ // Save Error Message
148
+ $order->addStatusToHistory(
149
+ $order->getStatus(),
150
+ 'Failed to create invoice: ' . $e->getMessage(),
151
+ true
152
+ );
153
+ Mage::throwException($e->getMessage());
154
+ }
155
+ }
156
+
157
+ $invoice->setIsPaid(true);
158
+
159
+ // Assign Last Transaction Id with Invoice
160
+ $transactionId = $invoice->getOrder()->getPayment()->getLastTransId();
161
+ if ($transactionId) {
162
+ $invoice->setTransactionId($transactionId);
163
+ $invoice->save();
164
+ }
165
+
166
+ return $invoice;
167
+ }
168
+
169
+ /**
170
+ * Get First Transaction ID
171
+ * @param $order Mage_Sales_Model_Order
172
+ * @return bool
173
+ */
174
+ static public function getFirstTransactionId(&$order)
175
+ {
176
+ $order_id = $order->getId();
177
+ if (!$order_id) {
178
+ return false;
179
+ }
180
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
181
+ ->addOrderIdFilter($order_id)
182
+ ->setOrder('transaction_id', 'ASC')
183
+ ->setPageSize(1)
184
+ ->setCurPage(1);
185
+ return $collection->getFirstItem()->getTxnId();
186
+ }
187
+
188
+ /**
189
+ * Create CreditMemo
190
+ * @param $order
191
+ * @param $invoice
192
+ * @param $amount
193
+ * @param bool $online
194
+ * @param null $transactionId
195
+ * @return Mage_Sales_Model_Order_Creditmemo
196
+ */
197
+ public function makeCreditMemo(&$order, &$invoice, $amount, $online = false, $transactionId = null)
198
+ {
199
+ $service = Mage::getModel('sales/service_order', $order);
200
+
201
+ // Prepare CreditMemo
202
+ if ($invoice) {
203
+ $creditmemo = $service->prepareInvoiceCreditmemo($invoice);
204
+ } else {
205
+ $creditmemo = $service->prepareCreditmemo();
206
+ }
207
+ $creditmemo->addComment(Mage::helper('payex')->__('Auto-generated from PayEx module'));
208
+
209
+ // Refund
210
+ if (!$online) {
211
+ $creditmemo->setPaymentRefundDisallowed(true);
212
+ }
213
+ //$creditmemo->setRefundRequested(true);
214
+ $invoice->getOrder()->setBaseTotalRefunded(0);
215
+ $creditmemo->setBaseGrandTotal($amount);
216
+ $creditmemo->register()->refund();
217
+ $creditmemo->save();
218
+
219
+ // Add transaction Id
220
+ if ($transactionId) {
221
+ $creditmemo->setTransactionId($transactionId);
222
+ }
223
+ // Save CreditMemo
224
+ $transactionSave = Mage::getModel('core/resource_transaction')
225
+ ->addObject($creditmemo)
226
+ ->addObject($creditmemo->getOrder());
227
+ if ($creditmemo->getInvoice()) {
228
+ $transactionSave->addObject($creditmemo->getInvoice());
229
+ }
230
+ $transactionSave->save();
231
+
232
+ return $creditmemo;
233
+ }
234
+
235
+ /**
236
+ * Calculate Order amount
237
+ * With rounding issue detection
238
+ * @param Mage_Sales_Model_Order $order
239
+ * @param int $order_amount
240
+ * @return Varien_Object
241
+ */
242
+ public function getCalculatedOrderAmount($order, $order_amount = 0)
243
+ {
244
+ // Order amount calculated by shop
245
+ if ($order_amount === 0) {
246
+ $order_amount = $order->getGrandTotal();
247
+ }
248
+
249
+ // Order amount calculated manually
250
+ $amount = 0;
251
+
252
+ // add Order Items
253
+ $items = $order->getAllVisibleItems();
254
+ /** @var $item Mage_Sales_Model_Order_Item */
255
+ foreach ($items as $item) {
256
+ if ($item->getParentItem()) {
257
+ continue;
258
+ }
259
+
260
+ $amount += (int)(100 * $item->getRowTotalInclTax());
261
+ }
262
+
263
+ // add Shipping
264
+ if (!$order->getIsVirtual()) {
265
+ $shippingIncTax = $order->getShippingInclTax();
266
+ $amount += (int)(100 * $shippingIncTax);
267
+ }
268
+
269
+ // add Discount
270
+ $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
271
+ $discountInclTax = (int) (100 * $discountData->getDiscountInclTax());
272
+ $amount += -1 * $discountInclTax;
273
+
274
+ // Add reward points
275
+ $amount += -1 * (int)(100 * $order->getBaseRewardCurrencyAmount());
276
+
277
+ // add Fee
278
+ $fee = $order->getPayexPaymentFee() + $order->getPayexPaymentFeeTax();
279
+ if ($fee > 0) {
280
+ $amount += (int)(100 * $fee);
281
+ }
282
+
283
+ // Detect Rounding Issue
284
+ $rounded_total = sprintf("%.2f", $order_amount);
285
+ $rounded_control_amount = sprintf("%.2f", ($amount / 100));
286
+ $rounding = 0;
287
+ if ($rounded_total !== $rounded_control_amount) {
288
+ if ($rounded_total > $rounded_control_amount) {
289
+ $rounding = $rounded_total - $rounded_control_amount;
290
+ } else {
291
+ $rounding = -1 * ($rounded_control_amount - $rounded_total);
292
+ }
293
+ $rounding = sprintf("%.2f", $rounding);
294
+ }
295
+
296
+ $result = new Varien_Object();
297
+ return $result->setAmount($rounded_control_amount)->setRounding($rounding);
298
+ }
299
+
300
+ /**
301
+ * Add PayEx Single Order Line
302
+ * @param string $orderRef
303
+ * @param Mage_Sales_Model_Order $order
304
+ * @return bool
305
+ */
306
+ public function addOrderLine($orderRef, $order)
307
+ {
308
+ // add Order Items
309
+ $items = $order->getAllVisibleItems();
310
+ $i = 1;
311
+ /** @var $item Mage_Sales_Model_Order_Item */
312
+ foreach ($items as $item) {
313
+ $itemQty = (int)$item->getQtyOrdered();
314
+ $priceWithTax = $item->getRowTotalInclTax();
315
+ $priceWithoutTax = $item->getRowTotal();
316
+ $taxPercent = (($priceWithTax / $priceWithoutTax) - 1) * 100; // works for all types
317
+ $taxPrice = $priceWithTax - $priceWithoutTax;
318
+
319
+ $params = array(
320
+ 'accountNumber' => '',
321
+ 'orderRef' => $orderRef,
322
+ 'itemNumber' => $i,
323
+ 'itemDescription1' => $item->getName(),
324
+ 'itemDescription2' => '',
325
+ 'itemDescription3' => '',
326
+ 'itemDescription4' => '',
327
+ 'itemDescription5' => '',
328
+ 'quantity' => $itemQty,
329
+ 'amount' => (int)(100 * $priceWithTax), //must include tax
330
+ 'vatPrice' => (int)(100 * $taxPrice),
331
+ 'vatPercent' => (int)(100 * $taxPercent)
332
+ );
333
+
334
+ $result = Mage::helper('payex/api')->getPx()->AddSingleOrderLine2($params);
335
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
336
+ $i++;
337
+ }
338
+
339
+ // add Shipping
340
+ if (!$order->getIsVirtual()) {
341
+ $shippingExclTax = (int) (100 * $order->getShippingAmount());
342
+ $shippingIncTax = (int) (100 * $order->getShippingInclTax());
343
+ $shippingTax = $shippingIncTax - $shippingExclTax;
344
+
345
+ // find out tax-rate for the shipping
346
+ if ((float) $shippingIncTax && (float) $shippingExclTax) {
347
+ $shippingTaxRate = (($shippingIncTax / $shippingExclTax) - 1) * 100;
348
+ } else {
349
+ $shippingTaxRate = 0;
350
+ }
351
+
352
+ $params = array(
353
+ 'accountNumber' => '',
354
+ 'orderRef' => $orderRef,
355
+ 'itemNumber' => $i,
356
+ 'itemDescription1' => $order->getShippingDescription(),
357
+ 'itemDescription2' => '',
358
+ 'itemDescription3' => '',
359
+ 'itemDescription4' => '',
360
+ 'itemDescription5' => '',
361
+ 'quantity' => 1,
362
+ 'amount' => (int)($shippingIncTax),
363
+ 'vatPrice' => (int)($shippingTax),
364
+ 'vatPercent' => (int)(100 * $shippingTaxRate)
365
+ );
366
+
367
+ $result = Mage::helper('payex/api')->getPx()->AddSingleOrderLine2($params);
368
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
369
+ $i++;
370
+ }
371
+
372
+ // add Discount
373
+ $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
374
+ $discountInclTax = (int) (100 * $discountData->getDiscountInclTax());
375
+ $discountExclTax = (int) (100 * $discountData->getDiscountExclTax());
376
+ $discountVatAmount = $discountInclTax - $discountExclTax;
377
+
378
+ if (abs($discountInclTax) > 0) {
379
+ $discountVatPercent = (($discountInclTax / $discountExclTax) - 1) * 100;
380
+
381
+ $params = array(
382
+ 'accountNumber' => '',
383
+ 'orderRef' => $orderRef,
384
+ 'itemNumber' => $i,
385
+ 'itemDescription1' => ($order->getDiscountDescription() !== null) ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount'),
386
+ 'itemDescription2' => '',
387
+ 'itemDescription3' => '',
388
+ 'itemDescription4' => '',
389
+ 'itemDescription5' => '',
390
+ 'quantity' => 1,
391
+ 'amount' => -1 * (int)($discountInclTax),
392
+ 'vatPrice' => -1 * (int) ($discountVatAmount),
393
+ 'vatPercent' => (int) (100 * $discountVatPercent)
394
+ );
395
+
396
+ $result = Mage::helper('payex/api')->getPx()->AddSingleOrderLine2($params);
397
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
398
+ $i++;
399
+ }
400
+
401
+ // add Payment Fee
402
+ if ((float)$order->getPayexPaymentFee() > 0) {
403
+ $feeExclTax = $order->getPayexPaymentFee();
404
+ $feeTax = $order->getPayexPaymentFeeTax();
405
+ $feeIncTax = $feeExclTax + $feeTax;
406
+
407
+ // find out tax-rate for the fee
408
+ if ((float) $feeIncTax && (float) $feeExclTax) {
409
+ $feeTaxRate = Mage::app()->getStore()->roundPrice((($feeIncTax / $feeExclTax) - 1) * 100);
410
+ } else {
411
+ $feeTaxRate = 0;
412
+ }
413
+
414
+ $params = array(
415
+ 'accountNumber' => '',
416
+ 'orderRef' => $orderRef,
417
+ 'itemNumber' => $i,
418
+ 'itemDescription1' => Mage::helper('payex')->__('Payment fee'),
419
+ 'itemDescription2' => '',
420
+ 'itemDescription3' => '',
421
+ 'itemDescription4' => '',
422
+ 'itemDescription5' => '',
423
+ 'quantity' => 1,
424
+ 'amount' => (int)(100 * $feeIncTax), //must include tax
425
+ 'vatPrice' => (int) (100 * $feeTax),
426
+ 'vatPercent' => (int) (100 * $feeTaxRate)
427
+ );
428
+
429
+ $result = Mage::helper('payex/api')->getPx()->AddSingleOrderLine2($params);
430
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
431
+ $i++;
432
+ }
433
+
434
+ // Add reward points
435
+ if ((float)$order->getBaseRewardCurrencyAmount() > 0) {
436
+ $params = array(
437
+ 'accountNumber' => '',
438
+ 'orderRef' => $orderRef,
439
+ 'itemNumber' => $i,
440
+ 'itemDescription1' => Mage::helper('payex')->__('Reward points'),
441
+ 'itemDescription2' => '',
442
+ 'itemDescription3' => '',
443
+ 'itemDescription4' => '',
444
+ 'itemDescription5' => '',
445
+ 'quantity' => 1,
446
+ 'amount' => -1 * (int)(100 * $order->getBaseRewardCurrencyAmount()), //must include tax
447
+ 'vatPrice' => 0,
448
+ 'vatPercent' => 0
449
+ );
450
+
451
+ $result = Mage::helper('payex/api')->getPx()->AddSingleOrderLine2($params);
452
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddSingleOrderLine2');
453
+ $i++;
454
+ }
455
+
456
+ return true;
457
+ }
458
+
459
+ /**
460
+ * Add Payex Order Address
461
+ * @param $orderRef
462
+ * @param Mage_Sales_Model_Order $order
463
+ * @return bool
464
+ */
465
+ public function addOrderAddress($orderRef, $order)
466
+ {
467
+ $billingAddress = $order->getBillingAddress()->getStreet();
468
+ $billingCountryCode = $order->getBillingAddress()->getCountry();
469
+ $billingCountry = Mage::getModel('directory/country')->load($billingCountryCode)->getName();
470
+
471
+ $params = array(
472
+ 'accountNumber' => '',
473
+ 'orderRef' => $orderRef,
474
+ 'billingFirstName' => $order->getBillingAddress()->getFirstname(),
475
+ 'billingLastName' => $order->getBillingAddress()->getLastname(),
476
+ 'billingAddress1' => $billingAddress[0],
477
+ 'billingAddress2' => (isset($billingAddress[1])) ? $billingAddress[1] : '',
478
+ 'billingAddress3' => '',
479
+ 'billingPostNumber' => (string)$order->getBillingAddress()->getPostcode(),
480
+ 'billingCity' => (string)$order->getBillingAddress()->getCity(),
481
+ 'billingState' => (string)$order->getBillingAddress()->getRegion(),
482
+ 'billingCountry' => $billingCountry,
483
+ 'billingCountryCode' => $billingCountryCode,
484
+ 'billingEmail' => (string)$order->getBillingAddress()->getEmail(),
485
+ 'billingPhone' => (string)$order->getBillingAddress()->getTelephone(),
486
+ 'billingGsm' => '',
487
+ );
488
+
489
+ // add Shipping
490
+ $shipping_params = array(
491
+ 'deliveryFirstName' => '',
492
+ 'deliveryLastName' => '',
493
+ 'deliveryAddress1' => '',
494
+ 'deliveryAddress2' => '',
495
+ 'deliveryAddress3' => '',
496
+ 'deliveryPostNumber' => '',
497
+ 'deliveryCity' => '',
498
+ 'deliveryState' => '',
499
+ 'deliveryCountry' => '',
500
+ 'deliveryCountryCode' => '',
501
+ 'deliveryEmail' => '',
502
+ 'deliveryPhone' => '',
503
+ 'deliveryGsm' => '',
504
+ );
505
+
506
+ if (!$order->getIsVirtual()) {
507
+ $deliveryAddress = $order->getShippingAddress()->getStreet();
508
+ $deliveryCountryCode = $order->getShippingAddress()->getCountry();
509
+ $deliveryCountry = Mage::getModel('directory/country')->load($deliveryCountryCode)->getName();
510
+
511
+ $shipping_params = array(
512
+ 'deliveryFirstName' => $order->getShippingAddress()->getFirstname(),
513
+ 'deliveryLastName' => $order->getShippingAddress()->getLastname(),
514
+ 'deliveryAddress1' => $deliveryAddress[0],
515
+ 'deliveryAddress2' => (isset($deliveryAddress[1])) ? $deliveryAddress[1] : '',
516
+ 'deliveryAddress3' => '',
517
+ 'deliveryPostNumber' => (string)$order->getShippingAddress()->getPostcode(),
518
+ 'deliveryCity' => (string)$order->getShippingAddress()->getCity(),
519
+ 'deliveryState' => (string)$order->getShippingAddress()->getRegion(),
520
+ 'deliveryCountry' => $deliveryCountry,
521
+ 'deliveryCountryCode' => $deliveryCountryCode,
522
+ 'deliveryEmail' => (string)$order->getShippingAddress()->getEmail(),
523
+ 'deliveryPhone' => (string)$order->getShippingAddress()->getTelephone(),
524
+ 'deliveryGsm' => '',
525
+ );
526
+ }
527
+ $params += $shipping_params;
528
+
529
+ $result = Mage::helper('payex/api')->getPx()->AddOrderAddress2($params);
530
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.AddOrderAddress2');
531
+ return true;
532
+ }
533
+
534
+ /**
535
+ * Get Shopping Cart XML for MasterPass
536
+ * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote
537
+ * @return string
538
+ */
539
+ public function getShoppingCartXML($quote)
540
+ {
541
+ $dom = new DOMDocument('1.0', 'utf-8');
542
+ $ShoppingCart = $dom->createElement('ShoppingCart');
543
+ $dom->appendChild($ShoppingCart);
544
+
545
+ if ($quote instanceof Mage_Sales_Model_Order) {
546
+ $currency = $quote->getOrderCurrencyCode();
547
+ } else {
548
+ $currency = $quote->getQuoteCurrencyCode();
549
+ }
550
+
551
+ $ShoppingCart->appendChild($dom->createElement('CurrencyCode', $currency));
552
+ $ShoppingCart->appendChild($dom->createElement('Subtotal', (int)(100 * $quote->getGrandTotal())));
553
+
554
+ // Add Order Lines
555
+ $items = $quote->getAllVisibleItems();
556
+ /** @var $item Mage_Sales_Model_Quote_Item */
557
+ foreach ($items as $item) {
558
+ $product = $item->getProduct();
559
+ if ($quote instanceof Mage_Sales_Model_Order) {
560
+ $qty = $item->getQtyOrdered();
561
+ } else {
562
+ $qty = $item->getQty();
563
+ }
564
+
565
+ $ShoppingCartItem = $dom->createElement('ShoppingCartItem');
566
+ $ShoppingCartItem->appendChild($dom->createElement('Description', $item->getName()));
567
+ $ShoppingCartItem->appendChild($dom->createElement('Quantity', (float)$qty));
568
+ $ShoppingCartItem->appendChild($dom->createElement('Value', (int)bcmul($product->getFinalPrice(), 100)));
569
+ $ShoppingCartItem->appendChild($dom->createElement('ImageURL', $product->getThumbnailUrl()));
570
+ $ShoppingCart->appendChild($ShoppingCartItem);
571
+ }
572
+
573
+ return str_replace("\n", '', $dom->saveXML());
574
+ }
575
+
576
+ /**
577
+ * Generate Invoice Print XML
578
+ * (only used for Factoring & PartPayment)
579
+ * @param Mage_Sales_Model_Order $order
580
+ * @return mixed
581
+ */
582
+ public function getInvoiceExtraPrintBlocksXML($order)
583
+ {
584
+ mb_regex_encoding('utf-8');
585
+ $replace_illegal = $order->getPayment()->getMethodInstance()->getConfigData('replace_illegal');
586
+ $replacement_char = $order->getPayment()->getMethodInstance()->getConfigData('replacement_char');
587
+ if (empty($replacement_char)) {
588
+ $replacement_char = '-';
589
+ }
590
+
591
+ $dom = new DOMDocument('1.0', 'utf-8');
592
+ $OnlineInvoice = $dom->createElement('OnlineInvoice');
593
+ $dom->appendChild($OnlineInvoice);
594
+ $OnlineInvoice->setAttributeNS('http://www.w3.org/2000/xmlns/', 'xmlns:xsi', 'http://www.w3.org/2001/XMLSchema-instance');
595
+ $OnlineInvoice->setAttributeNS('http://www.w3.org/2001/XMLSchema-instance', 'xsd', 'http://www.w3.org/2001/XMLSchema');
596
+
597
+ $OrderLines = $dom->createElement('OrderLines');
598
+ $OnlineInvoice->appendChild($OrderLines);
599
+
600
+ // Add Order Lines
601
+ $items = $order->getAllVisibleItems();
602
+ /** @var $item Mage_Sales_Model_Order_Item */
603
+ foreach ($items as $item) {
604
+ $itemQty = (int)$item->getQtyOrdered();
605
+ $priceWithTax = $item->getRowTotalInclTax();
606
+ $priceWithoutTax = $item->getRowTotal();
607
+ $taxPercent = round((($priceWithTax / $priceWithoutTax) - 1) * 100); // works for all types
608
+ $taxPrice = $priceWithTax - $priceWithoutTax;
609
+
610
+ $OrderLine = $dom->createElement('OrderLine');
611
+ $OrderLine->appendChild($dom->createElement('Product', trim(!$replace_illegal ? $item->getName() : mb_ereg_replace('[^a-zA-Z0-9_:!#=?\[\]@{}´ %-\/À-ÖØ-öø-ú]', $replacement_char, $item->getName()))));
612
+ $OrderLine->appendChild($dom->createElement('Qty', $itemQty));
613
+ $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $priceWithoutTax / $itemQty)));
614
+ $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $taxPercent)));
615
+ $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $taxPrice)));
616
+ $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $priceWithTax)));
617
+ $OrderLines->appendChild($OrderLine);
618
+ }
619
+
620
+ // Add Shipping Line
621
+ if (!$order->getIsVirtual()) {
622
+ $shippingExclTax = $order->getShippingAmount();
623
+ $shippingIncTax = $order->getShippingInclTax();
624
+ $shippingTax = $shippingIncTax - $shippingExclTax;
625
+
626
+ // find out tax-rate for the shipping
627
+ if ((float) $shippingIncTax && (float) $shippingExclTax) {
628
+ $shippingTaxRate = round((($shippingIncTax / $shippingExclTax) - 1) * 100);
629
+ } else {
630
+ $shippingTaxRate = 0;
631
+ }
632
+
633
+ $OrderLine = $dom->createElement('OrderLine');
634
+ $OrderLine->appendChild($dom->createElement('Product', trim(!$replace_illegal ? $order->getShippingDescription() : mb_ereg_replace('[^a-zA-Z0-9_:!#=?\[\]@{}´ %-\/À-ÖØ-öø-ú]', $replacement_char, $order->getShippingDescription()))));
635
+ $OrderLine->appendChild($dom->createElement('Qty', 1));
636
+ $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $shippingExclTax)));
637
+ $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $shippingTaxRate)));
638
+ $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", $shippingTax)));
639
+ $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $shippingIncTax)));
640
+ $OrderLines->appendChild($OrderLine);
641
+ }
642
+
643
+ // add Payment Fee
644
+ $fee = $order->getPayexPaymentFee();
645
+ if ($fee > 0) {
646
+ $feeExclTax = $order->getPayexPaymentFee();
647
+ $feeTax = $order->getPayexPaymentFeeTax();
648
+ $feeIncTax = $feeExclTax + $feeTax;
649
+
650
+ // find out tax-rate for the fee
651
+ if ((float) $feeIncTax && (float) $feeExclTax) {
652
+ $feeTaxRate = round((($feeIncTax / $feeExclTax) - 1) * 100);
653
+ } else {
654
+ $feeTaxRate = 0;
655
+ }
656
+
657
+ $OrderLine = $dom->createElement('OrderLine');
658
+ $OrderLine->appendChild($dom->createElement('Product', Mage::helper('payex')->__('Payment fee')));
659
+ $OrderLine->appendChild($dom->createElement('Qty', 1));
660
+ $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", $feeExclTax)));
661
+ $OrderLine->appendChild($dom->createElement('VatRate', $feeTaxRate));
662
+ $OrderLine->appendChild($dom->createElement('VatAmount', $feeTax));
663
+ $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", $feeIncTax)));
664
+ $OrderLines->appendChild($OrderLine);
665
+ }
666
+
667
+ // add Discount
668
+ $discountData = Mage::helper('payex/discount')->getOrderDiscountData($order);
669
+ $discountInclTax = $discountData->getDiscountInclTax();
670
+ $discountExclTax = $discountData->getDiscountExclTax();
671
+ $discountVatAmount = $discountInclTax - $discountExclTax;
672
+ $discountVatPercent = round((($discountInclTax / $discountExclTax) - 1) * 100);
673
+
674
+ if (abs($discountInclTax) > 0) {
675
+ $discount_description = ($order->getDiscountDescription() !== null) ? Mage::helper('sales')->__('Discount (%s)', $order->getDiscountDescription()) : Mage::helper('sales')->__('Discount');
676
+
677
+ $OrderLine = $dom->createElement('OrderLine');
678
+ $OrderLine->appendChild($dom->createElement('Product', trim(!$replace_illegal ? $discount_description : mb_ereg_replace('[^a-zA-Z0-9_:!#=?\[\]@{}´ %-\/À-ÖØ-öø-ú]', $replacement_char, $discount_description))));
679
+ $OrderLine->appendChild($dom->createElement('Qty', 1));
680
+ $OrderLine->appendChild($dom->createElement('UnitPrice', sprintf("%.2f", -1 * $discountExclTax)));
681
+ $OrderLine->appendChild($dom->createElement('VatRate', sprintf("%.2f", $discountVatPercent)));
682
+ $OrderLine->appendChild($dom->createElement('VatAmount', sprintf("%.2f", -1 * $discountVatAmount)));
683
+ $OrderLine->appendChild($dom->createElement('Amount', sprintf("%.2f", -1 * $discountInclTax)));
684
+ $OrderLines->appendChild($OrderLine);
685
+ }
686
+
687
+ // Add reward points
688
+ if ((float)$order->getBaseRewardCurrencyAmount() > 0) {
689
+ $OrderLine = $dom->createElement('OrderLine');
690
+ $OrderLine->appendChild($dom->createElement('Product', Mage::helper('payex')->__('Reward points')));
691
+ $OrderLine->appendChild($dom->createElement('Qty', 1));
692
+ $OrderLine->appendChild($dom->createElement('UnitPrice', -1 * $order->getBaseRewardCurrencyAmount()));
693
+ $OrderLine->appendChild($dom->createElement('VatRate', 0));
694
+ $OrderLine->appendChild($dom->createElement('VatAmount', 0));
695
+ $OrderLine->appendChild($dom->createElement('Amount', -1 * $order->getBaseRewardCurrencyAmount()));
696
+ $OrderLines->appendChild($OrderLine);
697
+ }
698
+
699
+ return str_replace("\n", '', $dom->saveXML());
700
+ }
701
+
702
+ /**
703
+ * Get Assigned Status
704
+ * @param $status
705
+ * @return Mage_Sales_Model_Order_Status
706
+ */
707
+ public function getAssignedStatus($status) {
708
+ $status = Mage::getModel('sales/order_status')
709
+ ->getCollection()
710
+ ->joinStates()
711
+ ->addFieldToFilter('main_table.status', $status)
712
+ ->getFirstItem();
713
+ return $status;
714
+ }
715
+
716
+ /**
717
+ * Get Invoice URL for Financing Invoice transaction
718
+ * @param string|int $transaction_id
719
+ * @return array
720
+ */
721
+ public function getInvoiceLink($transaction_id) {
722
+ // Call PxOrder.InvoiceLinkGet
723
+ $params = array (
724
+ 'accountNumber' => '',
725
+ 'transactionNumber' => $transaction_id
726
+ );
727
+ $result = Mage::helper('payex/api')->getPx()->InvoiceLinkGet($params);
728
+ return $result;
729
+ }
730
+ }
app/code/community/PayEx/Payments/Helper/Tools.php ADDED
@@ -0,0 +1,173 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Helper_Tools extends Mage_Core_Helper_Abstract
4
+ {
5
+ /**
6
+ * Throws PayEx Exception
7
+ * @param $message
8
+ * @param string $pxfunction
9
+ * @return void
10
+ */
11
+ public function throwPayExException($message, $pxfunction = '')
12
+ {
13
+ $error_message = $this->debugApi($message, $pxfunction);
14
+ Mage::throwException($error_message);
15
+ }
16
+
17
+ /**
18
+ * Add PayEx Api Result to Debug Log
19
+ * @param $message
20
+ * @param string $pxfunction
21
+ * @return string
22
+ */
23
+ public function debugApi($message, $pxfunction = '')
24
+ {
25
+ $error_message = '';
26
+ if (is_array($message)) {
27
+ if (isset($message['code']) && isset($message['description'])) {
28
+ $error_message = Mage::helper('payex')->__($message['code']) . ' (' . Mage::helper('payex')->__($message['description']) . ')';
29
+
30
+ } else {
31
+ $error_message = Mage::helper('payex')->__('Unknown error');
32
+ }
33
+
34
+ if (!empty($message['thirdPartyError'])) {
35
+ $error_message .= ' Third Party Error: ' . Mage::helper('payex')->__($message['thirdPartyError']);
36
+ }
37
+ if (!empty($message['transactionErrorCode']) && !empty($message['transactionErrorDescription'])) {
38
+ $error_message .= ' Transaction Error: ' . Mage::helper('payex')->__($message['transactionErrorCode']) . ' (' . $message['transactionErrorDescription'] . ')';
39
+ }
40
+ } else {
41
+ $error_message = Mage::helper('payex')->__($message);
42
+ }
43
+
44
+ $error_message = 'PayEx: ' . $pxfunction . ' ' . $error_message;
45
+ $this->addToDebug($error_message);
46
+ return $error_message;
47
+ }
48
+
49
+ /**
50
+ * Add to Debug Log
51
+ * @param string $message
52
+ * @param string $order_id
53
+ */
54
+ public function addToDebug($message = '', $order_id = '')
55
+ {
56
+ if (!empty($order_id)) {
57
+ $message .= ' OrderId: ' . $order_id;
58
+ }
59
+ Mage::log($message, null, 'payment_payex.log');
60
+ }
61
+
62
+ /**
63
+ * Get verbose error message by Error Code
64
+ * @param $errorCode
65
+ * @return string | false
66
+ */
67
+ public function getErrorMessageByCode($errorCode)
68
+ {
69
+ $errorMessages = array(
70
+ 'REJECTED_BY_ACQUIRER' => Mage::helper('payex')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'),
71
+ //'Error_Generic' => Mage::helper('payex')->__('An unhandled exception occurred'),
72
+ '3DSecureDirectoryServerError' => Mage::helper('payex')->__('A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification'),
73
+ 'AcquirerComunicationError' => Mage::helper('payex')->__('Communication error with the acquiring bank'),
74
+ 'AmountNotEqualOrderLinesTotal' => Mage::helper('payex')->__('The sum of your order lines is not equal to the price set in initialize'),
75
+ 'CardNotEligible' => Mage::helper('payex')->__('Your customers card is not eligible for this kind of purchase, your customer can contact their bank for more information'),
76
+ 'CreditCard_Error' => Mage::helper('payex')->__('Some problem occurred with the credit card, your customer can contact their bank for more information'),
77
+ 'PaymentRefusedByFinancialInstitution' => Mage::helper('payex')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'),
78
+ 'Merchant_InvalidAccountNumber' => Mage::helper('payex')->__('The merchant account number sent in on request is invalid'),
79
+ 'Merchant_InvalidIpAddress' => Mage::helper('payex')->__('The IP address the request comes from is not registered in PayEx, you can set it up in PayEx Admin under Merchant profile'),
80
+ 'Access_MissingAccessProperties' => Mage::helper('payex')->__('The merchant does not have access to requested functionality'),
81
+ 'Access_DuplicateRequest' => Mage::helper('payex')->__('Your customers bank declined the transaction, your customer can contact their bank for more information'),
82
+ 'Admin_AccountTerminated' => Mage::helper('payex')->__('The merchant account is not active'),
83
+ 'Admin_AccountDisabled' => Mage::helper('payex')->__('The merchant account is not active'),
84
+ 'ValidationError_AccountLockedOut' => Mage::helper('payex')->__('The merchant account is locked out'),
85
+ 'ValidationError_Generic' => Mage::helper('payex')->__('Generic validation error'),
86
+ 'ValidationError_HashNotValid' => Mage::helper('payex')->__('The hash on request is not valid, this might be due to the encryption key being incorrect'),
87
+ //'ValidationError_InvalidParameter' => Mage::helper('payex')->__('One of the input parameters has invalid data. See paramName and description for more information'),
88
+ 'OperationCancelledbyCustomer' => Mage::helper('payex')->__('The operation was cancelled by the client'),
89
+ 'PaymentDeclinedDoToUnspecifiedErr' => Mage::helper('payex')->__('Unexpecter error at 3rd party'),
90
+ 'InvalidAmount' => Mage::helper('payex')->__('The amount is not valid for this operation'),
91
+ 'NoRecordFound' => Mage::helper('payex')->__('No data found'),
92
+ 'OperationNotAllowed' => Mage::helper('payex')->__('The operation is not allowed, transaction is in invalid state'),
93
+ 'ACQUIRER_HOST_OFFLINE' => Mage::helper('payex')->__('Could not get in touch with the card issuer'),
94
+ 'ARCOT_MERCHANT_PLUGIN_ERROR' => Mage::helper('payex')->__('The card could not be verified'),
95
+ 'REJECTED_BY_ACQUIRER_CARD_BLACKLISTED' => Mage::helper('payex')->__('There is a problem with this card'),
96
+ 'REJECTED_BY_ACQUIRER_CARD_EXPIRED' => Mage::helper('payex')->__('The card expired'),
97
+ 'REJECTED_BY_ACQUIRER_INSUFFICIENT_FUNDS' => Mage::helper('payex')->__('Insufficient funds'),
98
+ 'REJECTED_BY_ACQUIRER_INVALID_AMOUNT' => Mage::helper('payex')->__('Incorrect amount'),
99
+ 'USER_CANCELED' => Mage::helper('payex')->__('Payment cancelled'),
100
+ 'CardNotAcceptedForThisPurchase' => Mage::helper('payex')->__('Your Credit Card not accepted for this purchase'),
101
+ 'CreditCheckNotApproved' => Mage::helper('payex')->__('Credit check was declined, please try another payment option')
102
+ );
103
+ $errorMessages = array_change_key_case($errorMessages, CASE_UPPER);
104
+
105
+ $errorCode = mb_strtoupper($errorCode);
106
+ return isset($errorMessages[$errorCode]) ? $errorMessages[$errorCode] : false;
107
+ }
108
+
109
+ /**
110
+ * Get Verbose Error Message
111
+ * @param array $details
112
+ * @return string
113
+ */
114
+ public function getVerboseErrorMessage(array $details)
115
+ {
116
+ $errorCode = isset($details['transactionErrorCode']) ? $details['transactionErrorCode'] : $details['errorCode'];
117
+ $errorMessage = $this->getErrorMessageByCode($errorCode);
118
+ if ($errorMessage) {
119
+ return $errorMessage;
120
+ }
121
+
122
+ $errorCode = $details['code'];
123
+ $errorDescription = $details['description'];
124
+
125
+ if (!empty($details['transactionErrorCode'])) {
126
+ $errorCode = $details['transactionErrorCode'];
127
+ }
128
+
129
+ if (!empty($details['transactionThirdPartyError'])) {
130
+ $errorDescription = $details['transactionThirdPartyError'];
131
+ }
132
+
133
+ return Mage::helper('payex')->__('PayEx error: %s', $errorCode . ' (' . $errorDescription . ')');
134
+ }
135
+
136
+ /**
137
+ * Get Country Code by SSN
138
+ * @param $ssn
139
+ *
140
+ * @return string|bool
141
+ */
142
+ public function getCountryCodeBySSN($ssn) {
143
+ $rules = array(
144
+ 'NO' => '/^[0-9]{6,6}((-[0-9]{5,5})|([0-9]{2,2}((-[0-9]{5,5})|([0-9]{1,1})|([0-9]{3,3})|([0-9]{5,5))))$/',
145
+ 'SE' => '/^[0-9]{6,6}(([0-9]{2,2}[-\+]{1,1}[0-9]{4,4})|([-\+]{1,1}[0-9]{4,4})|([0-9]{4,6}))$/',
146
+ //'FI' => '/^[0-9]{6,6}(([A\+-]{1,1}[0-9]{3,3}[0-9A-FHJK-NPR-Y]{1,1})|([0-9]{3,3}[0-9A-FHJK-NPR-Y]{1,1})|([0-9]{1,1}-{0,1}[0-9A-FHJK-NPR-Y]{1,1}))$/i',
147
+ //'DK' => '/^[0-9]{8,8}([0-9]{2,2})?$/',
148
+ //'NL' => '/^[0-9]{7,9}$/'
149
+ );
150
+
151
+ foreach ($rules as $country_code => $pattern) {
152
+ if ((bool)preg_match($pattern, $ssn)) {
153
+ return $country_code;
154
+ }
155
+ }
156
+
157
+ return false;
158
+ }
159
+
160
+ /**
161
+ * Get Name Parser Instance
162
+ * @see https://github.com/joshfraser/PHP-Name-Parser
163
+ * @return FullNameParser
164
+ */
165
+ public function getNameParser()
166
+ {
167
+ if (!class_exists('FullNameParser', false)) {
168
+ require_once Mage::getBaseDir('lib') . '/Px/parser.php';
169
+ }
170
+
171
+ return new FullNameParser();
172
+ }
173
+ }
app/code/community/PayEx/Payments/Model/Agreement.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Agreement extends Mage_Core_Model_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('payex/agreement');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Model/Feed.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Feed extends Mage_AdminNotification_Model_Feed
4
+ {
5
+ const URL_NEWS = 'http://payex.aait.se/application/meta/check?key=V004t905i8O171l';
6
+
7
+ /**
8
+ * Check Updates
9
+ * @return mixed
10
+ */
11
+ public static function check()
12
+ {
13
+ return Mage::getModel('payex/feed')->checkUpdate();
14
+ }
15
+
16
+ /**
17
+ * Check Updates
18
+ * @return $this
19
+ */
20
+ public function checkUpdate()
21
+ {
22
+ if (($this->getFrequency() + $this->getLastUpdate()) > time()) {
23
+ return $this;
24
+ }
25
+
26
+ $this->setLastUpdate();
27
+
28
+ // cURL extension required to get feed
29
+ if (!extension_loaded('curl')) {
30
+ return $this;
31
+ }
32
+
33
+ $feedData = array();
34
+ $availableVersions = array();
35
+
36
+ // Get Notifications
37
+ $this->_feedUrl = $this->getFeedUrl();
38
+ $feedXml = $this->getFeedData();
39
+ if ($feedXml && $feedXml->channel && $feedXml->channel->item) {
40
+ foreach ($feedXml->channel->item as $item) {
41
+ // is Version Notification
42
+ if ($item->code && $item->version) {
43
+ $code = (string) $item->code;
44
+ $version = (string) $item->version;
45
+
46
+ if (empty($availableVersions[$code])
47
+ || version_compare($version, $availableVersions[$code]['version'], '>'))
48
+ {
49
+ $availableVersions[$code] = array(
50
+ 'code' => $code,
51
+ 'version' => $version,
52
+ 'title' => (string)$item->title,
53
+ 'description' => (string)$item->description,
54
+ 'url' => (string)$item->link,
55
+ );
56
+ }
57
+
58
+ continue;
59
+ }
60
+
61
+ // is Generic Notification
62
+ $feedData[] = array(
63
+ 'severity' => 3,
64
+ 'date_added' => $this->getDate((string) $item->date),
65
+ 'title' => (string)$item->title,
66
+ 'description' => (string)$item->description,
67
+ 'url' => (string)$item->link,
68
+ );
69
+ }
70
+
71
+ if (count($feedData) > 0) {
72
+ $inbox = Mage::getModel('adminnotification/inbox');
73
+
74
+ if ($inbox) {
75
+ $inbox->parse($feedData);
76
+ }
77
+ }
78
+
79
+ if (count($availableVersions) > 0) {
80
+ Mage::app()->saveCache(serialize($availableVersions), 'payex_available_versions');
81
+ }
82
+ }
83
+
84
+ return $this;
85
+ }
86
+
87
+ public function getFrequency()
88
+ {
89
+ /**
90
+ * if adminnotification is disabled, parent::getFrequency() returns 0
91
+ * resulting in a new request on every admin page reload
92
+ */
93
+ if(parent::getFrequency()) return parent::getFrequency();
94
+
95
+ return 24*3600;
96
+ }
97
+
98
+ /**
99
+ * Get Last Update time
100
+ * @return mixed
101
+ */
102
+ public function getLastUpdate()
103
+ {
104
+ return Mage::app()->loadCache('payex_notifications_last_check');
105
+ }
106
+
107
+ /**
108
+ * Set Last Update time
109
+ * @return $this
110
+ */
111
+ public function setLastUpdate()
112
+ {
113
+ Mage::app()->saveCache(time(), 'payex_notifications_last_check');
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Get Feed URL
119
+ * @return string
120
+ * @throws Zend_Uri_Exception
121
+ */
122
+ public function getFeedUrl()
123
+ {
124
+ $version = Mage::getConfig()->getModuleConfig('PayEx_Payments')->version->asArray();
125
+ $params = array(
126
+ 'site_url' => Mage::getStoreConfig('web/unsecure/base_url'),
127
+ 'installed_version' => $version,
128
+ 'mage_ver' => Mage::getVersion(),
129
+ 'edition' => Mage::getEdition()
130
+ );
131
+
132
+ $uri = Zend_Uri::factory(self::URL_NEWS);
133
+ $uri->addReplaceQueryParameters($params);
134
+ return $uri->getUri();
135
+ }
136
+ }
app/code/community/PayEx/Payments/Model/Invoice/Total.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Invoice_Total extends Mage_Sales_Model_Order_Invoice_Total_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
12
+ {
13
+ $order = $invoice->getOrder();
14
+ $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
15
+ if (!in_array($paymentMethod, self::$_allowed_methods)) {
16
+ return $this;
17
+ }
18
+
19
+ if ($order->getBasePayexPaymentFee()) {
20
+ $baseInvoiceTotal = $invoice->getBaseGrandTotal();
21
+ $invoiceTotal = $invoice->getGrandTotal();
22
+
23
+ $baseInvoiceTotal = $baseInvoiceTotal + $order->getBasePayexPaymentFee();
24
+ $invoiceTotal = $invoiceTotal + $order->getPayexPaymentFee();
25
+
26
+ $invoice->setBaseGrandTotal($baseInvoiceTotal);
27
+ $invoice->setGrandTotal($invoiceTotal);
28
+ }
29
+
30
+ if ($order->getBasePayexPaymentFeeTax()) {
31
+ $baseInvoiceTotal = $invoice->getBaseGrandTotal();
32
+ $invoiceTotal = $invoice->getGrandTotal();
33
+
34
+ $baseInvoiceTotal = $baseInvoiceTotal + $order->getBasePayexPaymentFeeTax();
35
+ $invoiceTotal = $invoiceTotal + $order->getPayexPaymentFeeTax();
36
+
37
+ $invoice->setBaseGrandTotal($baseInvoiceTotal);
38
+ $invoice->setGrandTotal($invoiceTotal);
39
+ }
40
+ }
41
+ }
app/code/community/PayEx/Payments/Model/Mysql4/Agreement.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Mysql4_Agreement extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Note that "agreement_id" refers to the key field in your database table.
8
+ $this->_init('payex/payex_agreement', 'agreement_id');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Model/Mysql4/Agreement/Collection.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Mysql4_Agreement_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ parent::_construct();
8
+ $this->_init('payex/agreement');
9
+ }
10
+ }
app/code/community/PayEx/Payments/Model/Observer.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Observer extends Mage_Core_Model_Abstract
4
+ {
5
+ /**
6
+ * Clear Pending Orders via Cron
7
+ * @return $this
8
+ */
9
+ public function clear_pending_orders()
10
+ {
11
+ $orders = Mage::getModel('sales/order')->getCollection();
12
+ $orders->getSelect()->join(
13
+ array('p' => $orders->getResource()->getTable('sales/order_payment')),
14
+ 'p.parent_id = main_table.entity_id',
15
+ array()
16
+ );
17
+ $orders->addFieldToFilter('method', array('like' => 'payex_%'));
18
+ $orders->addFieldToFilter('status', array('in' => array('pending_payment')));
19
+ //$orders->addFieldToFilter('created_at', array('from' => $from, 'to' => $to));
20
+ foreach ($orders as $order) {
21
+ /** @var $order Mage_Sales_Model_Order */
22
+ // Check order state
23
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
24
+ try {
25
+ $clean_time = -1 * (int)$order->getPayment()->getMethodInstance()->getConfigData('cleantime');
26
+ if ($clean_time !== 0) {
27
+ $clean_time = strtotime($clean_time . ' minutes');
28
+ $order_created_time = strtotime($order->getCreatedAt());
29
+ if ($clean_time > $order_created_time) {
30
+ // Cancel order
31
+ $order->cancel()->save();
32
+
33
+ // Add to Log
34
+ Mage::helper('payex/tools')->addToDebug('Pending Clean: OrderID ' . $order->getIncrementId() . ' is canceled.');
35
+ }
36
+ }
37
+ } catch (Exception $e) {
38
+ continue;
39
+ }
40
+ }
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Change Order Status on Invoice Generation
48
+ * @param Varien_Event_Observer $observer
49
+ * @return $this
50
+ */
51
+ public function sales_order_invoice_save_after(Varien_Event_Observer $observer)
52
+ {
53
+ $invoice = $observer->getEvent()->getInvoice();
54
+ $order = $invoice->getOrder();
55
+ $payment = $order->getPayment();
56
+ $method = $payment->getMethodInstance();
57
+
58
+ $code = $method->getCode();
59
+ if (strpos($code, 'payex_') === false) {
60
+ return $this;
61
+ }
62
+
63
+ // is Captured
64
+ if (!$payment->getIsTransactionPending()) {
65
+ // Load Invoice transaction Data
66
+ if (!$invoice->getTransactionId()) {
67
+ return $this;
68
+ }
69
+
70
+ $transactionId = $invoice->getTransactionId();
71
+ $details = $method->fetchTransactionInfo($payment, $transactionId);
72
+
73
+ if (!isset($details['transactionStatus'])) {
74
+ return $this;
75
+ }
76
+
77
+ // Get Order Status
78
+ if ($code === 'payex_bankdebit') {
79
+ // Bankdebit
80
+ $new_status = $method->getConfigData('order_status');
81
+ } elseif (in_array((int)$details['transactionStatus'], array(0, 6))) {
82
+ // For Capture
83
+ $new_status = $method->getConfigData('order_status_capture');
84
+ } elseif ((int)$details['transactionStatus'] === 3) {
85
+ // For Authorize
86
+ $new_status = $method->getConfigData('order_status_authorize');
87
+ } else {
88
+ $new_status = $order->getStatus();
89
+ }
90
+
91
+ // Get Order Status
92
+ /** @var Mage_Sales_Model_Order_Status $status */
93
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
94
+
95
+ // Change order status
96
+ $order->setData('state', $status->getState());
97
+ $order->setStatus($status->getStatus());
98
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
99
+ $order->save();
100
+ }
101
+ return $this;
102
+ }
103
+
104
+ /**
105
+ * Collects Payment Fee from quote/addresses to quote
106
+ * @param Varien_Event_Observer $observer
107
+ * @return $this
108
+ */
109
+ public function sales_quote_collect_totals_after(Varien_Event_Observer $observer)
110
+ {
111
+ $quote = $observer->getEvent()->getQuote();
112
+ $quote->setBasePayexPaymentFee(0);
113
+ $quote->setBasePayexPaymentFeeTax(0);
114
+ $quote->setPayexPaymentFee(0);
115
+ $quote->setPayexPaymentFeeTax(0);
116
+
117
+ foreach ($quote->getAllAddresses() as $address) {
118
+ $quote->setBasePayexPaymentFee((float)($quote->getBasePayexPaymentFee() + $address->getBasePayexPaymentFee()));
119
+ $quote->setBasePayexPaymentFeeTax((float)($quote->getBasePayexPaymentFeeTax() + $address->getBasePayexPaymentFeeTax()));
120
+ $quote->setPayexPaymentFee((float)($quote->getPayexPaymentFee() + $address->getPayexPaymentFee()));
121
+ $quote->setPayexPaymentFeeTax((float)($quote->getPayexPaymentFeeTax() + $address->getPayexPaymentFeeTax()));
122
+ }
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * Adds Payment Fee to order
128
+ * @param Varien_Event_Observer $observer
129
+ */
130
+ public function sales_order_payment_place_end(Varien_Event_Observer $observer)
131
+ {
132
+ $_allowed_methods = array(
133
+ 'payex_financing',
134
+ 'payex_partpayment',
135
+ 'payex_invoice'
136
+ );
137
+
138
+ $payment = $observer->getPayment();
139
+ if (!in_array($payment->getMethodInstance()->getCode(), $_allowed_methods)) {
140
+ return;
141
+ }
142
+
143
+ $order = $payment->getOrder();
144
+ $order->setBasePayexPaymentFee($order->getQuote()->getBasePayexPaymentFee());
145
+ $order->setBasePayexPaymentFeeTax($order->getQuote()->getBasePayexPaymentFeeTax());
146
+ $order->setPayexPaymentFee($order->getQuote()->getPayexPaymentFee());
147
+ $order->setPayexPaymentFeeTax($order->getQuote()->getPayexPaymentFeeTax());
148
+ $order->save();
149
+ }
150
+ }
app/code/community/PayEx/Payments/Model/Payment/Abstract.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ abstract class PayEx_Payments_Model_Payment_Abstract extends Mage_Payment_Model_Method_Abstract
4
+ {
5
+ /**
6
+ * Init Class
7
+ */
8
+ public function __construct()
9
+ {
10
+ $accountnumber = $this->getConfigData('accountnumber');
11
+ $encryptionkey = $this->getConfigData('encryptionkey');
12
+ $debug = (bool)$this->getConfigData('debug');
13
+
14
+ Mage::helper('payex/api')->getPx()->setEnvironment($accountnumber, $encryptionkey, $debug);
15
+ }
16
+
17
+ public function getCheckout()
18
+ {
19
+ return Mage::getSingleton('checkout/session');
20
+ }
21
+
22
+ public function getQuote()
23
+ {
24
+ return $this->getCheckout()->getQuote();
25
+ }
26
+
27
+ /**
28
+ * Fetch transaction info
29
+ *
30
+ * @param Mage_Payment_Model_Info $payment
31
+ * @param string $transactionId
32
+ * @return array
33
+ */
34
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
35
+ {
36
+ // Init PayEx Environment
37
+ $accountnumber = $this->getConfigData('accountnumber', $payment->getOrder()->getStoreId());
38
+ $encryptionkey = $this->getConfigData('encryptionkey', $payment->getOrder()->getStoreId());
39
+ $debug = (bool)$this->getConfigData('debug', $payment->getOrder()->getStoreId());
40
+
41
+ Mage::helper('payex/api')->getPx()->setEnvironment($accountnumber, $encryptionkey, $debug);
42
+ }
43
+ }
app/code/community/PayEx/Payments/Model/Payment/Autopay.php ADDED
@@ -0,0 +1,422 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Autopay extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_autopay';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_autopay';
29
+ protected $_formBlockType = 'payex/form_autopay';
30
+
31
+ const AGREEMENT_NOTVERIFIED = 0;
32
+ const AGREEMENT_VERIFIED = 1;
33
+ const AGREEMENT_DELETED = 2;
34
+ const AGREEMENT_NOTEXISTS = 3;
35
+
36
+ /**
37
+ * Get initialized flag status
38
+ * @return true
39
+ */
40
+ public function isInitializeNeeded()
41
+ {
42
+ return true;
43
+ }
44
+
45
+ /**
46
+ * Instantiate state and set it to state onject
47
+ * @param $paymentAction
48
+ * @param $stateObject
49
+ * @return void
50
+ */
51
+ public function initialize($paymentAction, $stateObject)
52
+ {
53
+ // Set Initial Order Status
54
+ $state = Mage_Sales_Model_Order::STATE_NEW;
55
+ $stateObject->setState($state);
56
+ $stateObject->setStatus($state);
57
+ $stateObject->setIsNotified(false);
58
+ }
59
+
60
+ /**
61
+ * Get config action to process initialization
62
+ * @return string
63
+ */
64
+ public function getConfigPaymentAction()
65
+ {
66
+ $paymentAction = $this->getConfigData('payment_action');
67
+ return empty($paymentAction) ? true : $paymentAction;
68
+ }
69
+
70
+ /**
71
+ * Check whether payment method can be used
72
+ * @param Mage_Sales_Model_Quote $quote
73
+ * @return bool
74
+ */
75
+ public function isAvailable($quote = null)
76
+ {
77
+ // is Disabled
78
+ if (parent::isAvailable($quote) === false) {
79
+ return false;
80
+ }
81
+
82
+ if (Mage::app()->getStore()->isAdmin() == true) {
83
+ return true; // Available for Admin only
84
+ }
85
+
86
+ // Check currency
87
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
88
+ if (!in_array($quote->getQuoteCurrencyCode(), $allowedCurrency)) {
89
+ return false;
90
+ }
91
+
92
+ // Available only for Logged
93
+ return Mage::getSingleton('customer/session')->isLoggedIn();
94
+ }
95
+
96
+ /**
97
+ * Validate
98
+ * @return bool
99
+ */
100
+ public function validate()
101
+ {
102
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
103
+ return parent::validate();
104
+ }
105
+
106
+ /**
107
+ * Get the redirect url
108
+ * @return string
109
+ */
110
+ public function getOrderPlaceRedirectUrl()
111
+ {
112
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
113
+ return Mage::getUrl('payex/autopay/autopay', array('_secure' => true));
114
+ }
115
+
116
+ /**
117
+ * Capture payment
118
+ * @param Varien_Object $payment
119
+ * @param $amount
120
+ * @return $this
121
+ */
122
+ public function capture(Varien_Object $payment, $amount)
123
+ {
124
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
125
+
126
+ parent::capture($payment, $amount);
127
+
128
+ if ($amount <= 0) {
129
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
130
+ }
131
+
132
+ if (!$payment->getLastTransId()) {
133
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
134
+ }
135
+
136
+ $payment->setAmount($amount);
137
+
138
+ // Load transaction Data
139
+ $transactionId = $payment->getLastTransId();
140
+ $transaction = $payment->getTransaction($transactionId);
141
+ if (!$transaction) {
142
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
143
+ }
144
+
145
+ // Get Transaction Details
146
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
147
+
148
+ // Not to execute for Sale transactions
149
+ if ($details['transactionStatus'] !== 3) {
150
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
151
+ }
152
+
153
+ $transactionNumber = $details['transactionNumber'];
154
+ $order_id = $details['orderId'];
155
+ if (!$order_id) {
156
+ $order_id = $payment->getOrder()->getIncrementId();
157
+ }
158
+
159
+ // Call PXOrder.Capture5
160
+ $params = array(
161
+ 'accountNumber' => '',
162
+ 'transactionNumber' => $transactionNumber,
163
+ 'amount' => round($amount * 100),
164
+ 'orderId' => $order_id,
165
+ 'vatAmount' => 0,
166
+ 'additionalValues' => ''
167
+ );
168
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
169
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
170
+
171
+ // Check Results
172
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
173
+ // Note: Order Status will be changed in Observer
174
+
175
+ // Add Capture Transaction
176
+ $payment->setStatus(self::STATUS_APPROVED)
177
+ ->setTransactionId($result['transactionNumber'])
178
+ ->setIsTransactionClosed(0);
179
+
180
+ // Add Transaction fields
181
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
182
+ return $this;
183
+ }
184
+
185
+ // Show Error
186
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
187
+ return $this;
188
+ }
189
+
190
+ /**
191
+ * Cancel payment
192
+ * @param Varien_Object $payment
193
+ * @return $this
194
+ */
195
+ public function cancel(Varien_Object $payment)
196
+ {
197
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
198
+
199
+ if (!$payment->getLastTransId()) {
200
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
201
+ }
202
+
203
+ // Load transaction Data
204
+ $transactionId = $payment->getLastTransId();
205
+ $transaction = $payment->getTransaction($transactionId);
206
+ if (!$transaction) {
207
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
208
+ }
209
+
210
+ // Get Transaction Details
211
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
212
+
213
+ // Not to execute for Sale transactions
214
+ if ((int)$details['transactionStatus'] !== 3) {
215
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
216
+ }
217
+
218
+ $transactionNumber = $details['transactionNumber'];
219
+ $order_id = $details['orderId'];
220
+ if (!$order_id) {
221
+ $order_id = $payment->getOrder()->getId();
222
+ }
223
+
224
+ // Call PXOrder.Cancel2
225
+ $params = array(
226
+ 'accountNumber' => '',
227
+ 'transactionNumber' => $transactionNumber
228
+ );
229
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
230
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
231
+
232
+ // Check Results
233
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
234
+ // Add Cancel Transaction
235
+ $payment->setStatus(self::STATUS_DECLINED)
236
+ ->setTransactionId($result['transactionNumber'])
237
+ ->setIsTransactionClosed(1); // Closed
238
+
239
+ // Add Transaction fields
240
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
241
+ return $this;
242
+ }
243
+
244
+ // Show Error
245
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * Refund capture
251
+ * @param Varien_Object $payment
252
+ * @param $amount
253
+ * @return $this
254
+ */
255
+ public function refund(Varien_Object $payment, $amount)
256
+ {
257
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
258
+
259
+ parent::refund($payment, $amount);
260
+
261
+ if ($amount <= 0) {
262
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
263
+ }
264
+
265
+ if (!$payment->getLastTransId()) {
266
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
267
+ }
268
+
269
+ // Load transaction Data
270
+ $transactionId = $payment->getLastTransId();
271
+ $transaction = $payment->getTransaction($transactionId);
272
+ if (!$transaction) {
273
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
274
+ }
275
+
276
+ // Get Transaction Details
277
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
278
+
279
+ // Check for Capture and Authorize transaction only
280
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
281
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
282
+ }
283
+
284
+ $transactionNumber = $details['transactionNumber'];
285
+ $order_id = $details['orderId'];
286
+ if (!$order_id) {
287
+ $order_id = $payment->getOrder()->getId();
288
+ }
289
+
290
+ // Call PXOrder.PXOrder.Credit5
291
+ $params = array(
292
+ 'accountNumber' => '',
293
+ 'transactionNumber' => $transactionNumber,
294
+ 'amount' => round(100 * $amount),
295
+ 'orderId' => $order_id,
296
+ 'vatAmount' => 0,
297
+ 'additionalValues' => ''
298
+ );
299
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
300
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
301
+
302
+ // Check Results
303
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
304
+ // Add Credit Transaction
305
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
306
+ $payment->setAmount($amount);
307
+
308
+ $payment->setStatus(self::STATUS_APPROVED)
309
+ ->setTransactionId($result['transactionNumber'])
310
+ ->setIsTransactionClosed(0); // No-Closed
311
+
312
+ // Add Transaction fields
313
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
314
+ return $this;
315
+ }
316
+
317
+ // Show Error
318
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
319
+ return $this;
320
+ }
321
+
322
+ /**
323
+ * Void payment
324
+ * @param Varien_Object $payment
325
+ * @return $this
326
+ */
327
+ public function void(Varien_Object $payment)
328
+ {
329
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
330
+ return $this->cancel($payment);
331
+ }
332
+
333
+ /**
334
+ * Fetch transaction details info
335
+ * @param Mage_Payment_Model_Info $payment
336
+ * @param string $transactionId
337
+ * @return array
338
+ */
339
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
340
+ {
341
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
342
+
343
+ parent::fetchTransactionInfo($payment, $transactionId);
344
+
345
+ // Get Transaction Details
346
+ $params = array(
347
+ 'accountNumber' => '',
348
+ 'transactionNumber' => $transactionId,
349
+ );
350
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
351
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
352
+
353
+ // Check Results
354
+ if ($details['code'] == 'OK' && $details['errorCode'] == 'OK' && $details['description'] == 'OK') {
355
+ // Filter details
356
+ foreach ($details as $key => $value) {
357
+ if (empty($value)) {
358
+ unset($details[$key]);
359
+ }
360
+ }
361
+ return $details;
362
+ }
363
+
364
+ // Show Error
365
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
366
+ }
367
+
368
+ public function getStandardCheckoutFormFields()
369
+ {
370
+ return array();
371
+ }
372
+
373
+ /**
374
+ * Check void availability
375
+ * @param Varien_Object $payment
376
+ * @return bool
377
+ */
378
+ public function canVoid(Varien_Object $payment)
379
+ {
380
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
381
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
382
+ ) {
383
+ return false;
384
+ }
385
+ return $this->_canVoid;
386
+ }
387
+
388
+ public function canEdit()
389
+ {
390
+ return false;
391
+ }
392
+
393
+ public function canUseInternal()
394
+ {
395
+ return $this->_canUseInternal;
396
+ }
397
+
398
+ public function canUseForMultishipping()
399
+ {
400
+ return $this->_canUseForMultishipping;
401
+ }
402
+
403
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
404
+ {
405
+ return $this;
406
+ }
407
+
408
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
409
+ {
410
+ }
411
+
412
+ public function canCapture()
413
+ {
414
+ return $this->_canCapture;
415
+ }
416
+
417
+ public function canFetchTransactionInfo()
418
+ {
419
+ return $this->_canFetchTransactionInfo;
420
+ }
421
+
422
+ }
app/code/community/PayEx/Payments/Model/Payment/Bankdebit.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Bankdebit extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_bankdebit';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+ //protected $_canCancelInvoice = true;
25
+
26
+ /**
27
+ * Payment method blocks
28
+ */
29
+ protected $_infoBlockType = 'payex/info_bankdebit';
30
+ protected $_formBlockType = 'payex/form_bankdebit';
31
+
32
+ /**
33
+ * Get initialized flag status
34
+ * @return true
35
+ */
36
+ public function isInitializeNeeded()
37
+ {
38
+ return true;
39
+ }
40
+
41
+ /**
42
+ * Instantiate state and set it to state object
43
+ * @param $paymentAction
44
+ * @param $stateObject
45
+ * @return void
46
+ */
47
+ public function initialize($paymentAction, $stateObject)
48
+ {
49
+ // Set Initial Order Status
50
+ $state = Mage_Sales_Model_Order::STATE_NEW;
51
+ $stateObject->setState($state);
52
+ $stateObject->setStatus($state);
53
+ $stateObject->setIsNotified(false);
54
+ }
55
+
56
+ /**
57
+ * Get config action to process initialization
58
+ * @return string
59
+ */
60
+ public function getConfigPaymentAction()
61
+ {
62
+ $paymentAction = $this->getConfigData('payment_action');
63
+ return empty($paymentAction) ? true : $paymentAction;
64
+ }
65
+
66
+ /**
67
+ * Check whether payment method can be used
68
+ * @param Mage_Sales_Model_Quote
69
+ * @return bool
70
+ */
71
+ public function isAvailable($quote = null)
72
+ {
73
+ if (parent::isAvailable($quote) === false) {
74
+ return false;
75
+ }
76
+
77
+ // Check currency
78
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
79
+ return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
80
+ }
81
+
82
+ /**
83
+ * Validate
84
+ * @return bool
85
+ */
86
+ public function validate()
87
+ {
88
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
89
+ return parent::validate();
90
+ }
91
+
92
+ /**
93
+ * Get the redirect url
94
+ * @return string
95
+ */
96
+ public function getOrderPlaceRedirectUrl()
97
+ {
98
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
99
+
100
+ // Save Bank Id
101
+ $bank_id = Mage::app()->getRequest()->getParam('payexbank');
102
+ $this->getCheckout()->setBankId($bank_id);
103
+
104
+ return Mage::getUrl('payex/bankdebit/redirect', array('_secure' => true));
105
+ }
106
+
107
+ /**
108
+ * Capture payment
109
+ * @note In BankDebit used auto-capture
110
+ * @param Varien_Object $payment
111
+ * @param $amount
112
+ * @return $this
113
+ */
114
+ public function capture(Varien_Object $payment, $amount)
115
+ {
116
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
117
+
118
+ parent::capture($payment, $amount);
119
+
120
+ $transactionId = $payment->getLastTransId();
121
+ //$transactionId = $transactionId . '-capture';
122
+
123
+ // Add Capture Transaction
124
+ $payment->setStatus(self::STATUS_APPROVED)
125
+ ->setTransactionId($transactionId)
126
+ ->setIsTransactionClosed(0);
127
+
128
+ // Do nothing
129
+
130
+ return $this;
131
+ }
132
+
133
+ /**
134
+ * Cancel payment
135
+ * @param Varien_Object $payment
136
+ * @return $this
137
+ */
138
+ public function cancel(Varien_Object $payment)
139
+ {
140
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
141
+
142
+ $transactionId = $payment->getLastTransId();
143
+
144
+ // Add Cancel Transaction
145
+ $payment->setStatus(self::STATUS_DECLINED)
146
+ ->setTransactionId($transactionId)
147
+ ->setIsTransactionClosed(1); // Closed
148
+
149
+ // Do nothing
150
+
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Refund capture
156
+ * @param Varien_Object $payment
157
+ * @param $amount
158
+ * @return $this
159
+ */
160
+ public function refund(Varien_Object $payment, $amount)
161
+ {
162
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
163
+
164
+ parent::refund($payment, $amount);
165
+
166
+ if ($amount <= 0) {
167
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
168
+ }
169
+
170
+ if (!$payment->getLastTransId()) {
171
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
172
+ }
173
+
174
+ // Load transaction Data
175
+ $transactionId = $payment->getLastTransId();
176
+ $transaction = $payment->getTransaction($transactionId);
177
+ if (!$transaction) {
178
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
179
+ }
180
+
181
+ // Get Transaction Details
182
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
183
+
184
+ // Check for Capture and Authorize transaction only
185
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
186
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
187
+ }
188
+
189
+ $transactionNumber = $details['transactionNumber'];
190
+ $order_id = $details['orderId'];
191
+ if (!$order_id) {
192
+ $order_id = $payment->getOrder()->getId();
193
+ }
194
+
195
+ // Call PxOrder.Credit5
196
+ $params = array(
197
+ 'accountNumber' => '',
198
+ 'transactionNumber' => $transactionNumber,
199
+ 'amount' => round($amount * 100),
200
+ 'orderId' => $order_id,
201
+ 'vatAmount' => 0,
202
+ 'additionalValues' => ''
203
+ );
204
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
205
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
206
+
207
+ // Check Results
208
+ if ($result['code'] == 'OK' && $result['errorCode'] == 'OK' && $result['description'] == 'OK') {
209
+ // Add Credit Transaction
210
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
211
+ $payment->setAmount($amount);
212
+
213
+ $payment->setStatus(self::STATUS_APPROVED)
214
+ ->setTransactionId($result['transactionNumber'])
215
+ ->setIsTransactionClosed(0); // No-Closed
216
+
217
+ // Add Transaction fields
218
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
219
+ return $this;
220
+ }
221
+
222
+ // Show Error
223
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
224
+ }
225
+
226
+ /**
227
+ * Void payment
228
+ * @param Varien_Object $payment
229
+ * @return $this
230
+ */
231
+ public function void(Varien_Object $payment)
232
+ {
233
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
234
+ return $this->cancel($payment);
235
+ }
236
+
237
+ /**
238
+ * Fetch transaction details info
239
+ * @param Mage_Payment_Model_Info $payment
240
+ * @param string $transactionId
241
+ * @return array
242
+ */
243
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
244
+ {
245
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
246
+
247
+ parent::fetchTransactionInfo($payment, $transactionId);
248
+
249
+ // Get Transaction Details
250
+ $params = array(
251
+ 'accountNumber' => '',
252
+ 'transactionNumber' => $transactionId,
253
+ );
254
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
255
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
256
+
257
+ // Check Results
258
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
259
+ // Filter details
260
+ foreach ($details as $key => $value) {
261
+ if (empty($value)) {
262
+ unset($details[$key]);
263
+ }
264
+ }
265
+ return $details;
266
+ }
267
+
268
+ // Show Error
269
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
270
+ }
271
+
272
+ public function getStandardCheckoutFormFields()
273
+ {
274
+ return array();
275
+ }
276
+
277
+ /**
278
+ * Check void availability
279
+ * @param Varien_Object $payment
280
+ * @return bool
281
+ */
282
+ public function canVoid(Varien_Object $payment)
283
+ {
284
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
285
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
286
+ ) {
287
+ return false;
288
+ }
289
+ return $this->_canVoid;
290
+ }
291
+
292
+ public function canEdit()
293
+ {
294
+ return false;
295
+ }
296
+
297
+ public function canUseInternal()
298
+ {
299
+ return $this->_canUseInternal;
300
+ }
301
+
302
+ public function canUseForMultishipping()
303
+ {
304
+ return $this->_canUseForMultishipping;
305
+ }
306
+
307
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
308
+ {
309
+ return $this;
310
+ }
311
+
312
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
313
+ {
314
+ }
315
+
316
+ public function canCapture()
317
+ {
318
+ return $this->_canCapture;
319
+ }
320
+
321
+ public function canFetchTransactionInfo()
322
+ {
323
+ return $this->_canFetchTransactionInfo;
324
+ }
325
+
326
+ }
app/code/community/PayEx/Payments/Model/Payment/CC.php ADDED
@@ -0,0 +1,434 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_CC extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_cc';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_CC';
29
+ protected $_formBlockType = 'payex/form_CC';
30
+
31
+ /**
32
+ * Get initialized flag status
33
+ * @return true
34
+ */
35
+ public function isInitializeNeeded()
36
+ {
37
+ return true;
38
+ }
39
+
40
+ /**
41
+ * Instantiate state and set it to state object
42
+ * @param $paymentAction
43
+ * @param $stateObject
44
+ * @return void
45
+ */
46
+ public function initialize($paymentAction, $stateObject)
47
+ {
48
+ // Set Initial Order Status
49
+ $state = Mage_Sales_Model_Order::STATE_NEW;
50
+ $stateObject->setState($state);
51
+ $stateObject->setStatus($state);
52
+ $stateObject->setIsNotified(false);
53
+ }
54
+
55
+ /**
56
+ * Get config action to process initialization
57
+ * @return string
58
+ */
59
+ public function getConfigPaymentAction()
60
+ {
61
+ $paymentAction = $this->getConfigData('payment_action');
62
+ return empty($paymentAction) ? true : $paymentAction;
63
+ }
64
+
65
+ /**
66
+ * Check whether payment method can be used
67
+ * @param Mage_Sales_Model_Quote $quote
68
+ * @return bool
69
+ */
70
+ public function isAvailable($quote = null)
71
+ {
72
+ if (parent::isAvailable($quote) === false) {
73
+ return false;
74
+ }
75
+
76
+ // Check currency
77
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
+ //if ($this->getConfigData('paymentview') === 'DIRECTDEBIT') {
79
+ // $allowedCurrency = array('NOK', 'SEK', 'USD');
80
+ //}
81
+
82
+ return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
83
+ }
84
+
85
+ /**
86
+ * Validate
87
+ * @return bool
88
+ */
89
+ public function validate()
90
+ {
91
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
92
+ return parent::validate();
93
+ }
94
+
95
+ /**
96
+ * Get the redirect url
97
+ * @return string
98
+ */
99
+ public function getOrderPlaceRedirectUrl()
100
+ {
101
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
102
+ return Mage::getUrl('payex/payment/redirect', array('_secure' => true));
103
+ }
104
+
105
+ /**
106
+ * Capture payment
107
+ * @param Varien_Object $payment
108
+ * @param $amount
109
+ * @return $this
110
+ */
111
+ public function capture(Varien_Object $payment, $amount)
112
+ {
113
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
114
+
115
+ parent::capture($payment, $amount);
116
+
117
+ if ($amount <= 0) {
118
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
119
+ }
120
+
121
+ if (!$payment->getLastTransId()) {
122
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
123
+ }
124
+
125
+ $payment->setAmount($amount);
126
+
127
+ // Load transaction Data
128
+ $transactionId = $payment->getLastTransId();
129
+ $transaction = $payment->getTransaction($transactionId);
130
+ if (!$transaction) {
131
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
132
+ }
133
+
134
+ // Get Transaction Details
135
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
136
+
137
+ // Not to execute for Sale transactions
138
+ if ((int)$details['transactionStatus'] !== 3) {
139
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
140
+ //return $this;
141
+ }
142
+
143
+ $transactionNumber = $details['transactionNumber'];
144
+ $order_id = $details['orderId'];
145
+ if (!$order_id) {
146
+ $order_id = $payment->getOrder()->getIncrementId();
147
+ }
148
+
149
+ // Prevent Rounding Issue
150
+ // Difference can be ~0.0099999999999909
151
+ $order_amount = Mage::helper('payex/order')->getCalculatedOrderAmount($payment->getOrder())->getAmount();
152
+ $value = abs(sprintf("%.2f", $order_amount) - sprintf("%.2f", $amount));
153
+ if ($value > 0 && $value < 0.011) {
154
+ $amount = $order_amount;
155
+ }
156
+
157
+ // Call PxOrder.Capture5
158
+ $params = array(
159
+ 'accountNumber' => '',
160
+ 'transactionNumber' => $transactionNumber,
161
+ 'amount' => round(100 * $amount),
162
+ 'orderId' => $order_id,
163
+ 'vatAmount' => 0,
164
+ 'additionalValues' => ''
165
+ );
166
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
167
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
168
+
169
+ // Check Results
170
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
171
+ // Note: Order Status will be changed in Observer
172
+
173
+ // Add Capture Transaction
174
+ $payment->setStatus(self::STATUS_APPROVED)
175
+ ->setTransactionId($result['transactionNumber'])
176
+ ->setIsTransactionClosed(0);
177
+
178
+ // Add Transaction fields
179
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
180
+ return $this;
181
+ }
182
+
183
+ // Show Error
184
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
185
+ return $this;
186
+ }
187
+
188
+ /**
189
+ * Cancel payment
190
+ * @param Varien_Object $payment
191
+ * @return $this
192
+ */
193
+ public function cancel(Varien_Object $payment)
194
+ {
195
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
196
+
197
+ if (!$payment->getLastTransId()) {
198
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
199
+ }
200
+
201
+ // Load transaction Data
202
+ $transactionId = $payment->getLastTransId();
203
+ $transaction = $payment->getTransaction($transactionId);
204
+ if (!$transaction) {
205
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
206
+ }
207
+
208
+ // Get Transaction Details
209
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
210
+
211
+ // Not to execute for Sale transactions
212
+ if ((int)$details['transactionStatus'] !== 3) {
213
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
214
+ }
215
+
216
+ $transactionNumber = $details['transactionNumber'];
217
+ $order_id = $details['orderId'];
218
+ if (!$order_id) {
219
+ $order_id = $payment->getOrder()->getId();
220
+ }
221
+
222
+ // Call PXOrder.Cancel2
223
+ $params = array(
224
+ 'accountNumber' => '',
225
+ 'transactionNumber' => $transactionNumber
226
+ );
227
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
228
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
229
+
230
+ // Check Results
231
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
232
+ // Add Cancel Transaction
233
+ $payment->setStatus(self::STATUS_DECLINED)
234
+ ->setTransactionId($result['transactionNumber'])
235
+ ->setIsTransactionClosed(1); // Closed
236
+
237
+ // Add Transaction fields
238
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
239
+ return $this;
240
+ }
241
+
242
+ // Show Error
243
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
244
+ return $this;
245
+ }
246
+
247
+ /**
248
+ * Refund capture
249
+ * @param Varien_Object $payment
250
+ * @param $amount
251
+ * @return $this
252
+ */
253
+ public function refund(Varien_Object $payment, $amount)
254
+ {
255
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
256
+
257
+ parent::refund($payment, $amount);
258
+
259
+ if ($amount <= 0) {
260
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
261
+ }
262
+
263
+ if (!$payment->getLastTransId()) {
264
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
265
+ }
266
+
267
+ // Load transaction Data
268
+ $transactionId = $payment->getLastTransId();
269
+ $transaction = $payment->getTransaction($transactionId);
270
+ if (!$transaction) {
271
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
272
+ }
273
+
274
+ // Get Transaction Details
275
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
276
+
277
+ // Check for Capture and Authorize transaction only
278
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
279
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
280
+ }
281
+
282
+ $transactionNumber = $details['transactionNumber'];
283
+ $order_id = $details['orderId'];
284
+ if (!$order_id) {
285
+ $order_id = $payment->getOrder()->getId();
286
+ }
287
+
288
+ // Call PXOrder.PXOrder.Credit5
289
+ $params = array(
290
+ 'accountNumber' => '',
291
+ 'transactionNumber' => $transactionNumber,
292
+ 'amount' => round(100 * $amount),
293
+ 'orderId' => $order_id,
294
+ 'vatAmount' => 0,
295
+ 'additionalValues' => ''
296
+ );
297
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
298
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
299
+
300
+ // Check Results
301
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
302
+ // Add Credit Transaction
303
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
304
+ $payment->setAmount($amount);
305
+
306
+ $payment->setStatus(self::STATUS_APPROVED)
307
+ ->setTransactionId($result['transactionNumber'])
308
+ ->setIsTransactionClosed(0); // No-Closed
309
+
310
+ // Add Transaction fields
311
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
312
+ return $this;
313
+ }
314
+
315
+ // Show Error
316
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
317
+ return $this;
318
+ }
319
+
320
+ /**
321
+ * Void payment
322
+ * @param Varien_Object $payment
323
+ * @return $this
324
+ */
325
+ public function void(Varien_Object $payment)
326
+ {
327
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
328
+ return $this->cancel($payment);
329
+ }
330
+
331
+ /**
332
+ * Fetch transaction details info
333
+ * @param Mage_Payment_Model_Info $payment
334
+ * @param string $transactionId
335
+ * @return array
336
+ */
337
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
338
+ {
339
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
340
+
341
+ parent::fetchTransactionInfo($payment, $transactionId);
342
+
343
+ // Get Transaction Details
344
+ $params = array(
345
+ 'accountNumber' => '',
346
+ 'transactionNumber' => $transactionId,
347
+ );
348
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
349
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
350
+
351
+ // Check Results
352
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
353
+ // Filter details
354
+ foreach ($details as $key => $value) {
355
+ if (empty($value)) {
356
+ unset($details[$key]);
357
+ }
358
+ }
359
+ return $details;
360
+ }
361
+
362
+ // Show Error
363
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
364
+ }
365
+
366
+ /**
367
+ * Create Payment Block
368
+ * @param $name
369
+ * @return mixed
370
+ */
371
+ /* public function createFormBlock($name)
372
+ {
373
+ $block = $this->getLayout()->createBlock('payex/form', $name)
374
+ ->setMethod('payex')
375
+ ->setPayment($this->getPayment())
376
+ ->setTemplate('payex/form.phtml');
377
+ return $block;
378
+ } */
379
+
380
+ public function getStandardCheckoutFormFields()
381
+ {
382
+ return array();
383
+ }
384
+
385
+ /**
386
+ * Check void availability
387
+ * @param Varien_Object $payment
388
+ * @return bool
389
+ */
390
+ public function canVoid(Varien_Object $payment)
391
+ {
392
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
393
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
394
+ ) {
395
+ return false;
396
+ }
397
+ return $this->_canVoid;
398
+ }
399
+
400
+ public function canEdit()
401
+ {
402
+ return false;
403
+ }
404
+
405
+ public function canUseInternal()
406
+ {
407
+ return $this->_canUseInternal;
408
+ }
409
+
410
+ public function canUseForMultishipping()
411
+ {
412
+ return $this->_canUseForMultishipping;
413
+ }
414
+
415
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
416
+ {
417
+ return $this;
418
+ }
419
+
420
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
421
+ {
422
+ }
423
+
424
+ public function canCapture()
425
+ {
426
+ return $this->_canCapture;
427
+ }
428
+
429
+
430
+ public function canFetchTransactionInfo()
431
+ {
432
+ return $this->_canFetchTransactionInfo;
433
+ }
434
+ }
app/code/community/PayEx/Payments/Model/Payment/Financing.php ADDED
@@ -0,0 +1,490 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Financing extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_financing';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = false;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_financing';
29
+ protected $_formBlockType = 'payex/form_financing';
30
+
31
+ /**
32
+ * Supported currencies
33
+ * See http://pim.payex.com/Section3/currencycodes.htm
34
+ */
35
+ static protected $_allowCurrencyCode = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
36
+
37
+ /**
38
+ * Get initialized flag status
39
+ * @return true
40
+ */
41
+ public function isInitializeNeeded()
42
+ {
43
+ return true;
44
+ }
45
+
46
+ /**
47
+ * Instantiate state and set it to state object
48
+ * @param $paymentAction
49
+ * @param $stateObject
50
+ * @return void
51
+ */
52
+ public function initialize($paymentAction, $stateObject)
53
+ {
54
+ // Set Initial Order Status
55
+ $state = Mage_Sales_Model_Order::STATE_NEW;
56
+ $stateObject->setState($state);
57
+ $stateObject->setStatus($state);
58
+ $stateObject->setIsNotified(false);
59
+ }
60
+
61
+ /**
62
+ * Get config action to process initialization
63
+ * @return string
64
+ */
65
+ public function getConfigPaymentAction()
66
+ {
67
+ $paymentAction = $this->getConfigData('payment_action');
68
+ return empty($paymentAction) ? true : $paymentAction;
69
+ }
70
+
71
+ /**
72
+ * Check whether payment method can be used
73
+ * @param Mage_Sales_Model_Quote
74
+ * @return bool
75
+ */
76
+ public function isAvailable($quote = null)
77
+ {
78
+ if (parent::isAvailable($quote) === false) {
79
+ return false;
80
+ }
81
+
82
+ return true;
83
+ }
84
+
85
+ /**
86
+ * Validate
87
+ * @return bool
88
+ */
89
+ public function validate()
90
+ {
91
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
92
+
93
+ // Get the iso2 Country Code from the billing section
94
+ $country_code = $this->getQuote()->getBillingAddress()->getCountry();
95
+
96
+ $postcode = $this->getQuote()->getBillingAddress()->getPostcode();
97
+
98
+ // Get current currency
99
+ $paymentInfo = $this->getInfoInstance();
100
+
101
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
102
+ $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
103
+ } else {
104
+ //$currency_code = $this->getQuote()->getBaseCurrencyCode();
105
+ $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
106
+ }
107
+
108
+ // Check supported currency
109
+ if (!in_array($currency_code, self::$_allowCurrencyCode)) {
110
+ Mage::throwException(Mage::helper('payex')->__('Selected currency code (%s) is not compatible with PayEx', $currency_code));
111
+ }
112
+
113
+ // Validate Product names
114
+ if (!$this->getConfigData('replace_illegal')) {
115
+ if ($paymentInfo->getQuote()) {
116
+ $items = $paymentInfo->getQuote()->getAllVisibleItems();
117
+ /** @var $item Mage_Sales_Model_Quote_Item */
118
+ foreach ($items as $item) {
119
+ $re = "/[a-zA-Z0-9_:!#=?\\[\\]@{}´ %-À-ÖØ-öø-ú]*/u";
120
+ $product_name = $item->getName();
121
+
122
+ $matches = array();
123
+ preg_match($re, $product_name, $matches);
124
+ $test = implode('', $matches);
125
+ if (md5($product_name) !== md5($test)) {
126
+ Mage::throwException(Mage::helper('payex')->__('Product name "%s" contains invalid characters.', $product_name));
127
+ }
128
+ }
129
+ }
130
+ }
131
+
132
+ if (empty($country_code)) {
133
+ Mage::throwException(Mage::helper('payex')->__('Please select country.'));
134
+ }
135
+
136
+ if (empty($postcode)) {
137
+ Mage::throwException(Mage::helper('payex')->__('Please enter postcode.'));
138
+ }
139
+
140
+ // Get Social Security Number
141
+ // You can use 8111032382 in Test Environment
142
+ $ssn = Mage::app()->getRequest()->getParam('social-security-number');
143
+
144
+ $params = array(
145
+ 'accountNumber' => '',
146
+ 'paymentMethod' => $country_code === 'SE' ? 'PXFINANCINGINVOICESE' : 'PXFINANCINGINVOICENO',
147
+ 'ssn' => $ssn,
148
+ 'zipcode' => $postcode,
149
+ 'countryCode' => $country_code,
150
+ 'ipAddress' => Mage::helper('core/http')->getRemoteAddr()
151
+ );
152
+ $result = Mage::helper('payex/api')->getPx()->GetAddressByPaymentMethod($params);
153
+ Mage::helper('payex/tools')->addToDebug('PxOrder.GetAddressByPaymentMethod:' . $result['description']);
154
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
155
+ // Show Error Message
156
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.GetAddressByPaymentMethod');
157
+ }
158
+
159
+ // Save Social Security Number
160
+ $this->getCheckout()->setSocialSecurityNumber($ssn);
161
+ }
162
+
163
+ /**
164
+ * Get the redirect url
165
+ * @return string
166
+ */
167
+ public function getOrderPlaceRedirectUrl()
168
+ {
169
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
170
+
171
+ return Mage::getUrl('payex/financing/redirect', array('_secure' => true));
172
+ }
173
+
174
+ /**
175
+ * Capture payment
176
+ * @param Varien_Object $payment
177
+ * @param $amount
178
+ * @return $this
179
+ */
180
+ public function capture(Varien_Object $payment, $amount)
181
+ {
182
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
183
+
184
+ parent::capture($payment, $amount);
185
+
186
+ if ($amount <= 0) {
187
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
188
+ }
189
+
190
+ if (!$payment->getLastTransId()) {
191
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
192
+ }
193
+
194
+ $payment->setAmount($amount);
195
+
196
+ // Load transaction Data
197
+ $transactionId = $payment->getLastTransId();
198
+ $transaction = $payment->getTransaction($transactionId);
199
+ if (!$transaction) {
200
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
201
+ }
202
+
203
+ // Get Transaction Details
204
+ $this->fetchTransactionInfo($payment, $transactionId);
205
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
206
+
207
+ // Not to execute for Sale transactions
208
+ if ((int)$details['transactionStatus'] !== 3) {
209
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
210
+ //return $this;
211
+ }
212
+
213
+ $transactionNumber = $details['transactionNumber'];
214
+ $order_id = $payment->getOrder()->getIncrementId();
215
+
216
+ // Prevent Rounding Issue
217
+ // Difference can be ~0.0099999999999909
218
+ $order_amount = Mage::helper('payex/order')->getCalculatedOrderAmount($payment->getOrder())->getAmount();
219
+ $value = abs(sprintf("%.2f", $order_amount) - sprintf("%.2f", $amount));
220
+ if ($value > 0 && $value < 0.011) {
221
+ $amount = $order_amount;
222
+ }
223
+
224
+ $xml = Mage::helper('payex/order')->getInvoiceExtraPrintBlocksXML($payment->getOrder());
225
+
226
+ // Call PxOrder.Capture5
227
+ $params = array(
228
+ 'accountNumber' => '',
229
+ 'transactionNumber' => $transactionNumber,
230
+ 'amount' => round(100 * $amount),
231
+ 'orderId' => $order_id,
232
+ 'vatAmount' => 0,
233
+ 'additionalValues' => 'FINANCINGINVOICE_ORDERLINES=' . urlencode($xml)
234
+ );
235
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
236
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
237
+
238
+ // Check Results
239
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
240
+ // Note: Order Status will be changed in Observer
241
+
242
+ // Add Capture Transaction
243
+ $payment->setStatus(self::STATUS_APPROVED)
244
+ ->setTransactionId($result['transactionNumber'])
245
+ ->setIsTransactionClosed(0);
246
+
247
+ // Add Transaction fields
248
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
249
+ return $this;
250
+ }
251
+
252
+ // Show Error
253
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
254
+ return $this;
255
+ }
256
+
257
+ /**
258
+ * Cancel payment
259
+ * @param Varien_Object $payment
260
+ * @return $this
261
+ */
262
+ public function cancel(Varien_Object $payment)
263
+ {
264
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
265
+
266
+ if (!$payment->getLastTransId()) {
267
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
268
+ }
269
+
270
+ // Load transaction Data
271
+ $transactionId = $payment->getLastTransId();
272
+ $transaction = $payment->getTransaction($transactionId);
273
+ if (!$transaction) {
274
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
275
+ }
276
+
277
+ // Get Transaction Details
278
+ $this->fetchTransactionInfo($payment, $transactionId);
279
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
280
+
281
+ // Not to execute for Sale transactions
282
+ if ((int)$details['transactionStatus'] !== 3) {
283
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
284
+ }
285
+
286
+ $transactionNumber = $details['transactionNumber'];
287
+ $order_id = $details['orderId'];
288
+ if (!$order_id) {
289
+ $order_id = $payment->getOrder()->getId();
290
+ }
291
+
292
+ // Call PXOrder.Cancel2
293
+ $params = array(
294
+ 'accountNumber' => '',
295
+ 'transactionNumber' => $transactionNumber
296
+ );
297
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
298
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
299
+
300
+ // Check Results
301
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
302
+ // Add Cancel Transaction
303
+ $payment->setStatus(self::STATUS_DECLINED)
304
+ ->setTransactionId($result['transactionNumber'])
305
+ ->setIsTransactionClosed(1); // Closed
306
+
307
+ // Add Transaction fields
308
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
309
+ return $this;
310
+ }
311
+
312
+ // Show Error
313
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
314
+ return $this;
315
+ }
316
+
317
+ /**
318
+ * Refund capture
319
+ * @param Varien_Object $payment
320
+ * @param $amount
321
+ * @return $this
322
+ */
323
+ public function refund(Varien_Object $payment, $amount)
324
+ {
325
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
326
+
327
+ parent::refund($payment, $amount);
328
+
329
+ if ($amount <= 0) {
330
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
331
+ }
332
+
333
+ if (!$payment->getLastTransId()) {
334
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
335
+ }
336
+
337
+ // Load transaction Data
338
+ $transactionId = $payment->getLastTransId();
339
+ $transaction = $payment->getTransaction($transactionId);
340
+ if (!$transaction) {
341
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
342
+ }
343
+
344
+ // Get Transaction Details
345
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
346
+ //$details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
347
+
348
+ // Check for Capture and Authorize transaction only
349
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
350
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
351
+ }
352
+
353
+ $transactionNumber = $details['transactionNumber'];
354
+ $order_id = $details['orderId'];
355
+ if (!$order_id) {
356
+ $order_id = $payment->getOrder()->getId();
357
+ }
358
+
359
+ // Call PXOrder.PXOrder.Credit5
360
+ $params = array(
361
+ 'accountNumber' => '',
362
+ 'transactionNumber' => $transactionNumber,
363
+ 'amount' => round(100 * $amount),
364
+ 'orderId' => $order_id,
365
+ 'vatAmount' => 0,
366
+ 'additionalValues' => ''
367
+ );
368
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
369
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Credit5:' . $result['description'], $order_id);
370
+
371
+ // Check Results
372
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
373
+ // Add Credit Transaction
374
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
375
+ $payment->setAmount($amount);
376
+
377
+ $payment->setStatus(self::STATUS_APPROVED)
378
+ ->setTransactionId($result['transactionNumber'])
379
+ ->setIsTransactionClosed(0); // No-Closed
380
+
381
+ // Add Transaction fields
382
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
383
+ return $this;
384
+ }
385
+
386
+ // Show Error
387
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
388
+ return $this;
389
+ }
390
+
391
+ /**
392
+ * Void payment
393
+ * @param Varien_Object $payment
394
+ * @return Mage_Payment_Model_Abstract
395
+ */
396
+ public function void(Varien_Object $payment)
397
+ {
398
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
399
+ return $this->cancel($payment);
400
+ }
401
+
402
+ /**
403
+ * Fetch transaction details info
404
+ * @param Mage_Payment_Model_Info $payment
405
+ * @param string $transactionId
406
+ * @return array
407
+ */
408
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
409
+ {
410
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
411
+
412
+ parent::fetchTransactionInfo($payment, $transactionId);
413
+
414
+ // Get Transaction Details
415
+ $params = array(
416
+ 'accountNumber' => '',
417
+ 'transactionNumber' => $transactionId,
418
+ );
419
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
420
+ Mage::helper('payex/tools')->addToDebug('PxOrder.GetTransactionDetails2:' . $details['description']);
421
+
422
+ // Check Results
423
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
424
+ // Filter details
425
+ foreach ($details as $key => $value) {
426
+ if (empty($value)) {
427
+ unset($details[$key]);
428
+ }
429
+ }
430
+ return $details;
431
+ }
432
+
433
+ // Show Error
434
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
435
+ }
436
+
437
+ public function getStandardCheckoutFormFields()
438
+ {
439
+ return array();
440
+ }
441
+
442
+ /**
443
+ * Check void availability
444
+ * @param Varien_Object $payment
445
+ * @return bool
446
+ */
447
+ public function canVoid(Varien_Object $payment)
448
+ {
449
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
450
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
451
+ ) {
452
+ return false;
453
+ }
454
+ return $this->_canVoid;
455
+ }
456
+
457
+ public function canEdit()
458
+ {
459
+ return false;
460
+ }
461
+
462
+ public function canUseInternal()
463
+ {
464
+ return $this->_canUseInternal;
465
+ }
466
+
467
+ public function canUseForMultishipping()
468
+ {
469
+ return $this->_canUseForMultishipping;
470
+ }
471
+
472
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
473
+ {
474
+ return $this;
475
+ }
476
+
477
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
478
+ {
479
+ }
480
+
481
+ public function canCapture()
482
+ {
483
+ return $this->_canCapture;
484
+ }
485
+
486
+ public function canFetchTransactionInfo()
487
+ {
488
+ return $this->_canFetchTransactionInfo;
489
+ }
490
+ }
app/code/community/PayEx/Payments/Model/Payment/Invoice.php ADDED
@@ -0,0 +1,484 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Invoice extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_invoice';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = false;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_invoice';
29
+ protected $_formBlockType = 'payex/form_invoice';
30
+
31
+ /**
32
+ * Get initialized flag status
33
+ * @return true
34
+ */
35
+ public function isInitializeNeeded()
36
+ {
37
+ return true;
38
+ }
39
+
40
+ /**
41
+ * Instantiate state and set it to state onject
42
+ * @param $paymentAction
43
+ * @param $stateObject
44
+ * @return void
45
+ */
46
+ public function initialize($paymentAction, $stateObject)
47
+ {
48
+ // Set Initial Order Status
49
+ $state = Mage_Sales_Model_Order::STATE_NEW;
50
+ $stateObject->setState($state);
51
+ $stateObject->setStatus($state);
52
+ $stateObject->setIsNotified(false);
53
+ }
54
+
55
+ /**
56
+ * Get config action to process initialization
57
+ * @return string
58
+ */
59
+ public function getConfigPaymentAction()
60
+ {
61
+ $paymentAction = $this->getConfigData('payment_action');
62
+ return empty($paymentAction) ? true : $paymentAction;
63
+ }
64
+
65
+ /**
66
+ * Check whether payment method can be used
67
+ * @param Mage_Sales_Model_Quote
68
+ * @return bool
69
+ */
70
+ public function isAvailable($quote = null)
71
+ {
72
+ if (parent::isAvailable($quote) === false) {
73
+ return false;
74
+ }
75
+
76
+ // Check currency
77
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
+ return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
79
+ }
80
+
81
+ /**
82
+ * Validate
83
+ * @return bool
84
+ */
85
+ public function validate()
86
+ {
87
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
88
+
89
+ // Get Total Amount
90
+ $amount = $this->getQuote()->getGrandTotal();
91
+
92
+ // Get Invoice Type
93
+ $type = Mage::app()->getRequest()->getParam('pxinvoice_method');
94
+ switch ($type) {
95
+ case 'private':
96
+ $ssn = Mage::app()->getRequest()->getParam('socialSecurityNumber');
97
+ $firstName = Mage::app()->getRequest()->getParam('firstName');
98
+ $lastName = Mage::app()->getRequest()->getParam('lastName');
99
+
100
+ // Call PxVerification.CreditCheckPrivate
101
+ $params = array(
102
+ 'accountNumber' => '',
103
+ 'countryCode' => $this->getQuote()->getBillingAddress()->getCountry(),
104
+ 'socialSecurityNumber' => $ssn,
105
+ 'firstName' => $firstName,
106
+ 'lastName' => $lastName,
107
+ 'amount' => round($amount * 100),
108
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr()
109
+ );
110
+ $status = Mage::helper('payex/api')->getPx()->CreditCheckPrivate2($params);
111
+ Mage::helper('payex/tools')->addToDebug('PxVerification.CreditCheckPrivate2:' . $status['description']);
112
+ break;
113
+ case 'corporate':
114
+ $orgnum = Mage::app()->getRequest()->getParam('organizationNumber');
115
+
116
+ // Call PxVerification.CreditCheckCorporate
117
+ $params = array(
118
+ 'accountNumber' => '',
119
+ 'countryCode' => $this->getQuote()->getBillingAddress()->getCountry(),
120
+ 'organizationNumber' => $orgnum,
121
+ 'amount' => round($amount * 100)
122
+ );
123
+ $status = Mage::helper('payex/api')->getPx()->CreditCheckCorporate2($params);
124
+ Mage::helper('payex/tools')->addToDebug('PxVerification.CreditCheckCorporate:' . $status['description']);
125
+ break;
126
+ default:
127
+ $status = array();
128
+ break;
129
+ }
130
+
131
+ if ($status['code'] == 'OK' && $status['description'] == 'OK' && $status['errorCode'] == 'OK') {
132
+ // Check if credit check went ok
133
+ if ($status['creditStatus'] === 'True') {
134
+ $this->getCheckout()->setCreditData($status);
135
+ Mage::helper('payex/tools')->addToDebug('Credit status: ok');
136
+ return true;
137
+ } elseif ($this->getConfigData('unapproved')) {
138
+ // Allow unapproved
139
+ $this->getCheckout()->setCreditData($status);
140
+ Mage::helper('payex/tools')->addToDebug('Credit status: not approved. Ignore this.');
141
+ } else {
142
+ // Declining payment
143
+ Mage::helper('payex/tools')->addToDebug('Credit status: not approved. Abort payment.');
144
+ Mage::throwException('Unfortunately PayEx did not grant you Invoice credit. Please try other means of payment');
145
+ }
146
+ }
147
+ // Show Error Message
148
+ Mage::helper('payex/tools')->throwPayExException($status, 'PxVerification.CreditCheck');
149
+ return false;
150
+ }
151
+
152
+ /**
153
+ * Get the redirect url
154
+ * @return string
155
+ */
156
+ public function getOrderPlaceRedirectUrl()
157
+ {
158
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
159
+
160
+ // Save Data
161
+ $method = Mage::app()->getRequest()->getParam('pxinvoice_method');
162
+ $this->getCheckout()->setMethod($method);
163
+
164
+ $ssn = ($method === 'private') ? Mage::app()->getRequest()->getParam('socialSecurityNumber') : Mage::app()->getRequest()->getParam('organizationNumber');
165
+ $this->getCheckout()->setSocialSecurtyNumber($ssn);
166
+
167
+ return Mage::getUrl('payex/invoice/redirect', array('_secure' => true));
168
+ }
169
+
170
+ /**
171
+ * Capture payment
172
+ * @param Varien_Object $payment
173
+ * @param $amount
174
+ * @return $this
175
+ */
176
+ public function capture(Varien_Object $payment, $amount)
177
+ {
178
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
179
+
180
+ parent::capture($payment, $amount);
181
+
182
+ if ($amount <= 0) {
183
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
184
+ }
185
+
186
+ if (!$payment->getLastTransId()) {
187
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
188
+ }
189
+
190
+ $payment->setAmount($amount);
191
+
192
+ // Load transaction Data
193
+ $transactionId = $payment->getLastTransId();
194
+ $transaction = $payment->getTransaction($transactionId);
195
+ if (!$transaction) {
196
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
197
+ }
198
+
199
+ // Get Transaction Details
200
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
201
+
202
+ // Not to execute for Sale transactions
203
+ if ((int)$details['transactionStatus'] !== 3) {
204
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
205
+ //return $this;
206
+ }
207
+
208
+ $transactionNumber = $details['transactionNumber'];
209
+ $order_id = $details['orderId'];
210
+ if (!$order_id) {
211
+ $order_id = $payment->getOrder()->getIncrementId();
212
+ }
213
+
214
+ // Prevent Rounding Issue
215
+ // Difference can be ~0.0099999999999909
216
+ $order_amount = Mage::helper('payex/order')->getCalculatedOrderAmount($payment->getOrder())->getAmount();
217
+ $value = abs(sprintf("%.2f", $order_amount) - sprintf("%.2f", $amount));
218
+ if ($value > 0 && $value < 0.011) {
219
+ $amount = $order_amount;
220
+ }
221
+
222
+ // Call PxOrder.Capture5
223
+ $params = array(
224
+ 'accountNumber' => '',
225
+ 'transactionNumber' => $transactionNumber,
226
+ 'amount' => round(100 * $amount),
227
+ 'orderId' => $order_id,
228
+ 'vatAmount' => 0,
229
+ 'additionalValues' => ''
230
+ );
231
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
232
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
233
+
234
+ // Check Results
235
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
236
+ // Note: Order Status will be changed in Observer
237
+
238
+ // Add Capture Transaction
239
+ $payment->setStatus(self::STATUS_APPROVED)
240
+ ->setTransactionId($result['transactionNumber'])
241
+ ->setIsTransactionClosed(0);
242
+
243
+ // Add Transaction fields
244
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
245
+ return $this;
246
+ }
247
+
248
+ // Show Error
249
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
250
+ return $this;
251
+ }
252
+
253
+ /**
254
+ * Cancel payment
255
+ * @param Varien_Object $payment
256
+ * @return $this
257
+ */
258
+ public function cancel(Varien_Object $payment)
259
+ {
260
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
261
+
262
+ if (!$payment->getLastTransId()) {
263
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
264
+ }
265
+
266
+ // Load transaction Data
267
+ $transactionId = $payment->getLastTransId();
268
+ $transaction = $payment->getTransaction($transactionId);
269
+ if (!$transaction) {
270
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
271
+ }
272
+
273
+ // Get Transaction Details
274
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
275
+
276
+ // Not to execute for Sale transactions
277
+ if ((int)$details['transactionStatus'] !== 3) {
278
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
279
+ }
280
+
281
+ $transactionNumber = $details['transactionNumber'];
282
+ $order_id = $details['orderId'];
283
+ if (!$order_id) {
284
+ $order_id = $payment->getOrder()->getId();
285
+ }
286
+
287
+ // Call PXOrder.Cancel2
288
+ $params = array(
289
+ 'accountNumber' => '',
290
+ 'transactionNumber' => $transactionNumber
291
+ );
292
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
293
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
294
+
295
+ // Check Results
296
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
297
+ // Add Cancel Transaction
298
+ $payment->setStatus(self::STATUS_DECLINED)
299
+ ->setTransactionId($result['transactionNumber'])
300
+ ->setIsTransactionClosed(1); // Closed
301
+
302
+ // Add Transaction fields
303
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
304
+ return $this;
305
+ }
306
+
307
+ // Show Error
308
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
309
+ return $this;
310
+ }
311
+
312
+ /**
313
+ * Refund capture
314
+ * @param Varien_Object $payment
315
+ * @param $amount
316
+ * @return $this
317
+ */
318
+ public function refund(Varien_Object $payment, $amount)
319
+ {
320
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
321
+
322
+ parent::refund($payment, $amount);
323
+
324
+ if ($amount <= 0) {
325
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
326
+ }
327
+
328
+ if (!$payment->getLastTransId()) {
329
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
330
+ }
331
+
332
+ // Load transaction Data
333
+ $transactionId = $payment->getLastTransId();
334
+ $transaction = $payment->getTransaction($transactionId);
335
+ if (!$transaction) {
336
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
337
+ }
338
+
339
+ // Get Transaction Details
340
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
341
+
342
+ // Check for Capture and Authorize transaction only
343
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
344
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
345
+ }
346
+
347
+ $transactionNumber = $details['transactionNumber'];
348
+ $order_id = $details['orderId'];
349
+ if (!$order_id) {
350
+ $order_id = $payment->getOrder()->getId();
351
+ }
352
+
353
+ // Call PxOrder.Credit5
354
+ $params = array(
355
+ 'accountNumber' => '',
356
+ 'transactionNumber' => $transactionNumber,
357
+ 'amount' => round(100 * $amount),
358
+ 'orderId' => $order_id,
359
+ 'vatAmount' => 0,
360
+ 'additionalValues' => ''
361
+ );
362
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
363
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
364
+
365
+ // Check Results
366
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
367
+ // Add Credit Transaction
368
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
369
+ $payment->setAmount($amount);
370
+
371
+ $payment->setStatus(self::STATUS_APPROVED)
372
+ ->setTransactionId($result['transactionNumber'])
373
+ ->setIsTransactionClosed(0); // No-Closed
374
+
375
+ // Add Transaction fields
376
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
377
+ return $this;
378
+ }
379
+
380
+ // Show Error
381
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
382
+ return $this;
383
+ }
384
+
385
+ /**
386
+ * Void payment
387
+ * @param Varien_Object $payment
388
+ * @return $this
389
+ */
390
+ public function void(Varien_Object $payment)
391
+ {
392
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
393
+ return $this->cancel($payment);
394
+ }
395
+
396
+ /**
397
+ * Fetch transaction details info
398
+ * @param Mage_Payment_Model_Info $payment
399
+ * @param string $transactionId
400
+ * @return array
401
+ */
402
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
403
+ {
404
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
405
+
406
+ parent::fetchTransactionInfo($payment, $transactionId);
407
+
408
+ // Get Transaction Details
409
+ $params = array(
410
+ 'accountNumber' => '',
411
+ 'transactionNumber' => $transactionId,
412
+ );
413
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
414
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
415
+
416
+ // Check Results
417
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
418
+ // Filter details
419
+ foreach ($details as $key => $value) {
420
+ if (empty($value)) {
421
+ unset($details[$key]);
422
+ }
423
+ }
424
+ return $details;
425
+ }
426
+
427
+ // Show Error
428
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
429
+ }
430
+
431
+ public function getStandardCheckoutFormFields()
432
+ {
433
+ return array();
434
+ }
435
+
436
+ /**
437
+ * Check void availability
438
+ * @param Varien_Object $payment
439
+ * @return bool
440
+ */
441
+ public function canVoid(Varien_Object $payment)
442
+ {
443
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
444
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
445
+ ) {
446
+ return false;
447
+ }
448
+ return $this->_canVoid;
449
+ }
450
+
451
+ public function canEdit()
452
+ {
453
+ return false;
454
+ }
455
+
456
+ public function canUseInternal()
457
+ {
458
+ return $this->_canUseInternal;
459
+ }
460
+
461
+ public function canUseForMultishipping()
462
+ {
463
+ return $this->_canUseForMultishipping;
464
+ }
465
+
466
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
467
+ {
468
+ return $this;
469
+ }
470
+
471
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
472
+ {
473
+ }
474
+
475
+ public function canCapture()
476
+ {
477
+ return $this->_canCapture;
478
+ }
479
+
480
+ public function canFetchTransactionInfo()
481
+ {
482
+ return $this->_canFetchTransactionInfo;
483
+ }
484
+ }
app/code/community/PayEx/Payments/Model/Payment/MasterPass.php ADDED
@@ -0,0 +1,407 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_MasterPass extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_masterpass';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_MasterPass';
29
+ protected $_formBlockType = 'payex/form_MasterPass';
30
+
31
+ /**
32
+ * Get initialized flag status
33
+ * @return true
34
+ */
35
+ public function isInitializeNeeded()
36
+ {
37
+ return true;
38
+ }
39
+
40
+ /**
41
+ * Instantiate state and set it to state onject
42
+ * @param $paymentAction
43
+ * @param $stateObject
44
+ * @return void
45
+ */
46
+ public function initialize($paymentAction, $stateObject)
47
+ {
48
+ // Set Initial Order Status
49
+ $state = Mage_Sales_Model_Order::STATE_NEW;
50
+ $stateObject->setState($state);
51
+ $stateObject->setStatus($state);
52
+ $stateObject->setIsNotified(false);
53
+ }
54
+
55
+ /**
56
+ * Get config action to process initialization
57
+ * @return string
58
+ */
59
+ public function getConfigPaymentAction()
60
+ {
61
+ $paymentAction = $this->getConfigData('payment_action');
62
+ return empty($paymentAction) ? true : $paymentAction;
63
+ }
64
+
65
+ /**
66
+ * Check whether payment method can be used
67
+ * @param Mage_Sales_Model_Quote $quote
68
+ * @return bool
69
+ */
70
+ public function isAvailable($quote = null)
71
+ {
72
+ if (parent::isAvailable($quote) === false) {
73
+ return false;
74
+ }
75
+
76
+ // Check currency
77
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
78
+ return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
79
+ }
80
+
81
+ /**
82
+ * Validate
83
+ * @return bool
84
+ */
85
+ public function validate()
86
+ {
87
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
88
+ return parent::validate();
89
+ }
90
+
91
+ /**
92
+ * Get the redirect url
93
+ * @return string
94
+ */
95
+ public function getOrderPlaceRedirectUrl()
96
+ {
97
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
98
+ return Mage::getUrl('payex/masterpass/redirect', array('_secure' => true));
99
+ }
100
+
101
+ /**
102
+ * Capture payment
103
+ * @param Varien_Object $payment
104
+ * @param $amount
105
+ * @return $this
106
+ */
107
+ public function capture(Varien_Object $payment, $amount)
108
+ {
109
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
110
+
111
+ parent::capture($payment, $amount);
112
+
113
+ if ($amount <= 0) {
114
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
115
+ }
116
+
117
+ if (!$payment->getLastTransId()) {
118
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
119
+ }
120
+
121
+ $payment->setAmount($amount);
122
+
123
+ // Load transaction Data
124
+ $transactionId = $payment->getLastTransId();
125
+ $transaction = $payment->getTransaction($transactionId);
126
+ if (!$transaction) {
127
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
128
+ }
129
+
130
+ // Get Transaction Details
131
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
132
+
133
+ // Not to execute for Sale transactions
134
+ if ((int)$details['transactionStatus'] !== 3) {
135
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
136
+ //return $this;
137
+ }
138
+
139
+ $transactionNumber = $details['transactionNumber'];
140
+ $order_id = $details['orderId'];
141
+ if (!$order_id) {
142
+ $order_id = $payment->getOrder()->getIncrementId();
143
+ }
144
+
145
+ // Call PxOrder.Capture5
146
+ $params = array(
147
+ 'accountNumber' => '',
148
+ 'transactionNumber' => $transactionNumber,
149
+ 'amount' => round(100 * $amount),
150
+ 'orderId' => $order_id,
151
+ 'vatAmount' => 0,
152
+ 'additionalValues' => ''
153
+ );
154
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
155
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
156
+
157
+ // Check Results
158
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
159
+ // Note: Order Status will be changed in Observer
160
+
161
+ // Add Capture Transaction
162
+ $payment->setStatus(self::STATUS_APPROVED)
163
+ ->setTransactionId($result['transactionNumber'])
164
+ ->setIsTransactionClosed(0);
165
+
166
+ // Add Transaction fields
167
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
168
+ return $this;
169
+ }
170
+
171
+ // Show Error
172
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
173
+ return $this;
174
+ }
175
+
176
+ /**
177
+ * Cancel payment
178
+ * @param Varien_Object $payment
179
+ * @return $this
180
+ */
181
+ public function cancel(Varien_Object $payment)
182
+ {
183
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
184
+
185
+ if (!$payment->getLastTransId()) {
186
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
187
+ }
188
+
189
+ // Load transaction Data
190
+ $transactionId = $payment->getLastTransId();
191
+ $transaction = $payment->getTransaction($transactionId);
192
+ if (!$transaction) {
193
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
194
+ }
195
+
196
+ // Get Transaction Details
197
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
198
+
199
+ // Not to execute for Sale transactions
200
+ if ((int)$details['transactionStatus'] !== 3) {
201
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
202
+ }
203
+
204
+ $transactionNumber = $details['transactionNumber'];
205
+ $order_id = $details['orderId'];
206
+ if (!$order_id) {
207
+ $order_id = $payment->getOrder()->getId();
208
+ }
209
+
210
+ // Call PXOrder.Cancel2
211
+ $params = array(
212
+ 'accountNumber' => '',
213
+ 'transactionNumber' => $transactionNumber
214
+ );
215
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
216
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
217
+
218
+ // Check Results
219
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
220
+ // Add Cancel Transaction
221
+ $payment->setStatus(self::STATUS_DECLINED)
222
+ ->setTransactionId($result['transactionNumber'])
223
+ ->setIsTransactionClosed(1); // Closed
224
+
225
+ // Add Transaction fields
226
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
227
+ return $this;
228
+ }
229
+
230
+ // Show Error
231
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
232
+ return $this;
233
+ }
234
+
235
+ /**
236
+ * Refund capture
237
+ * @param Varien_Object $payment
238
+ * @param $amount
239
+ * @return $this
240
+ */
241
+ public function refund(Varien_Object $payment, $amount)
242
+ {
243
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
244
+
245
+ parent::refund($payment, $amount);
246
+
247
+ if ($amount <= 0) {
248
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
249
+ }
250
+
251
+ if (!$payment->getLastTransId()) {
252
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
253
+ }
254
+
255
+ // Load transaction Data
256
+ $transactionId = $payment->getLastTransId();
257
+ $transaction = $payment->getTransaction($transactionId);
258
+ if (!$transaction) {
259
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
260
+ }
261
+
262
+ // Get Transaction Details
263
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
264
+
265
+ // Check for Capture and Authorize transaction only
266
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
267
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
268
+ }
269
+
270
+ $transactionNumber = $details['transactionNumber'];
271
+ $order_id = $details['orderId'];
272
+ if (!$order_id) {
273
+ $order_id = $payment->getOrder()->getId();
274
+ }
275
+
276
+ // Call PXOrder.PXOrder.Credit5
277
+ $params = array(
278
+ 'accountNumber' => '',
279
+ 'transactionNumber' => $transactionNumber,
280
+ 'amount' => round(100 * $amount),
281
+ 'orderId' => $order_id,
282
+ 'vatAmount' => 0,
283
+ 'additionalValues' => ''
284
+ );
285
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
286
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
287
+
288
+ // Check Results
289
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
290
+ // Add Credit Transaction
291
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
292
+ $payment->setAmount($amount);
293
+
294
+ $payment->setStatus(self::STATUS_APPROVED)
295
+ ->setTransactionId($result['transactionNumber'])
296
+ ->setIsTransactionClosed(0); // No-Closed
297
+
298
+ // Add Transaction fields
299
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
300
+ return $this;
301
+ }
302
+
303
+ // Show Error
304
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
305
+ return $this;
306
+ }
307
+
308
+ /**
309
+ * Void payment
310
+ * @param Varien_Object $payment
311
+ * @return $this
312
+ */
313
+ public function void(Varien_Object $payment)
314
+ {
315
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
316
+ return $this->cancel($payment);
317
+ }
318
+
319
+ /**
320
+ * Fetch transaction details info
321
+ * @param Mage_Payment_Model_Info $payment
322
+ * @param string $transactionId
323
+ * @return array
324
+ */
325
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
326
+ {
327
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
328
+
329
+ parent::fetchTransactionInfo($payment, $transactionId);
330
+
331
+ // Get Transaction Details
332
+ $params = array(
333
+ 'accountNumber' => '',
334
+ 'transactionNumber' => $transactionId,
335
+ );
336
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
337
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
338
+
339
+ // Check Results
340
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
341
+ // Filter details
342
+ foreach ($details as $key => $value) {
343
+ if (empty($value)) {
344
+ unset($details[$key]);
345
+ }
346
+ }
347
+ return $details;
348
+ }
349
+
350
+ // Show Error
351
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
352
+ }
353
+
354
+ public function getStandardCheckoutFormFields()
355
+ {
356
+ return array();
357
+ }
358
+
359
+ /**
360
+ * Check void availability
361
+ * @param Varien_Object $payment
362
+ * @return bool
363
+ */
364
+ public function canVoid(Varien_Object $payment)
365
+ {
366
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
367
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
368
+ ) {
369
+ return false;
370
+ }
371
+ return $this->_canVoid;
372
+ }
373
+
374
+ public function canEdit()
375
+ {
376
+ return false;
377
+ }
378
+
379
+ public function canUseInternal()
380
+ {
381
+ return $this->_canUseInternal;
382
+ }
383
+
384
+ public function canUseForMultishipping()
385
+ {
386
+ return $this->_canUseForMultishipping;
387
+ }
388
+
389
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
390
+ {
391
+ return $this;
392
+ }
393
+
394
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
395
+ {
396
+ }
397
+
398
+ public function canCapture()
399
+ {
400
+ return $this->_canCapture;
401
+ }
402
+
403
+ public function canFetchTransactionInfo()
404
+ {
405
+ return $this->_canFetchTransactionInfo;
406
+ }
407
+ }
app/code/community/PayEx/Payments/Model/Payment/PartPayment.php ADDED
@@ -0,0 +1,483 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_PartPayment extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_partpayment';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = false;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_PartPayment';
29
+ protected $_formBlockType = 'payex/form_PartPayment';
30
+
31
+ /**
32
+ * Supported currencies
33
+ * See http://pim.payex.com/Section3/currencycodes.htm
34
+ */
35
+ static protected $_allowCurrencyCode = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
36
+
37
+ /**
38
+ * Get initialized flag status
39
+ * @return true
40
+ */
41
+ public function isInitializeNeeded()
42
+ {
43
+ return true;
44
+ }
45
+
46
+ /**
47
+ * Instantiate state and set it to state object
48
+ * @param $paymentAction
49
+ * @param $stateObject
50
+ * @return void
51
+ */
52
+ public function initialize($paymentAction, $stateObject)
53
+ {
54
+ // Set Initial Order Status
55
+ $state = Mage_Sales_Model_Order::STATE_NEW;
56
+ $stateObject->setState($state);
57
+ $stateObject->setStatus($state);
58
+ $stateObject->setIsNotified(false);
59
+ }
60
+
61
+ /**
62
+ * Get config action to process initialization
63
+ * @return string
64
+ */
65
+ public function getConfigPaymentAction()
66
+ {
67
+ $paymentAction = $this->getConfigData('payment_action');
68
+ return empty($paymentAction) ? true : $paymentAction;
69
+ }
70
+
71
+ /**
72
+ * Check whether payment method can be used
73
+ * @param Mage_Sales_Model_Quote
74
+ * @return bool
75
+ */
76
+ public function isAvailable($quote = null)
77
+ {
78
+ if (parent::isAvailable($quote) === false) {
79
+ return false;
80
+ }
81
+
82
+ return true;
83
+ }
84
+
85
+ /**
86
+ * Validate
87
+ * @return bool
88
+ */
89
+ public function validate()
90
+ {
91
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
92
+
93
+ // Get the iso2 Country Code from the billing section
94
+ $country_code = $this->getQuote()->getBillingAddress()->getCountry();
95
+
96
+ // Get Postcode
97
+ $postcode = $this->getQuote()->getBillingAddress()->getPostcode();
98
+
99
+ // Get current currency
100
+ $paymentInfo = $this->getInfoInstance();
101
+
102
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
103
+ $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
104
+ } else {
105
+ //$currency_code = $this->getQuote()->getBaseCurrencyCode();
106
+ $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
107
+ }
108
+
109
+ // Check supported currency
110
+ if (!in_array($currency_code, self::$_allowCurrencyCode)) {
111
+ Mage::throwException(Mage::helper('payex')->__('Selected currency code (%s) is not compatible with PayEx', $currency_code));
112
+ }
113
+
114
+ // Validate Product names
115
+ if (!$this->getConfigData('replace_illegal')) {
116
+ if ($paymentInfo->getQuote()) {
117
+ $items = $paymentInfo->getQuote()->getAllVisibleItems();
118
+ /** @var $item Mage_Sales_Model_Quote_Item */
119
+ foreach ($items as $item) {
120
+ $re = "/[a-zA-Z0-9_:!#=?\\[\\]@{}´ %-À-ÖØ-öø-ú]*/u";
121
+ $product_name = $item->getName();
122
+
123
+ $matches = array();
124
+ preg_match($re, $product_name, $matches);
125
+ $test = implode('', $matches);
126
+ if (md5($product_name) !== md5($test)) {
127
+ Mage::throwException(Mage::helper('payex')->__('Product name "%s" contains invalid characters.', $product_name));
128
+ }
129
+ }
130
+ }
131
+ }
132
+
133
+ // Get Social Security Number
134
+ // You can use 8111032382 in Test Environment
135
+ $ssn = Mage::app()->getRequest()->getParam('social-security-number');
136
+
137
+ $params = array(
138
+ 'accountNumber' => '',
139
+ 'paymentMethod' => $country_code === 'SE' ? 'PXFINANCINGINVOICESE' : 'PXFINANCINGINVOICENO',
140
+ 'ssn' => $ssn,
141
+ 'zipcode' => $postcode,
142
+ 'countryCode' => $country_code,
143
+ 'ipAddress' => Mage::helper('core/http')->getRemoteAddr()
144
+ );
145
+ $result = Mage::helper('payex/api')->getPx()->GetAddressByPaymentMethod($params);
146
+ Mage::helper('payex/tools')->addToDebug('PxOrder.GetAddressByPaymentMethod:' . $result['description']);
147
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
148
+ // Show Error Message
149
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.GetAddressByPaymentMethod');
150
+ }
151
+
152
+ // Save Social Security Number
153
+ $this->getCheckout()->setSocialSecurityNumber($ssn);
154
+ }
155
+
156
+ /**
157
+ * Get the redirect url
158
+ * @return string
159
+ */
160
+ public function getOrderPlaceRedirectUrl()
161
+ {
162
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
163
+ return Mage::getUrl('payex/partpayment/redirect', array('_secure' => true));
164
+ }
165
+
166
+ /**
167
+ * Capture payment
168
+ * @param Varien_Object $payment
169
+ * @param $amount
170
+ * @return $this
171
+ */
172
+ public function capture(Varien_Object $payment, $amount)
173
+ {
174
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
175
+
176
+ parent::capture($payment, $amount);
177
+
178
+ if ($amount <= 0) {
179
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
180
+ }
181
+
182
+ if (!$payment->getLastTransId()) {
183
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
184
+ }
185
+
186
+ $payment->setAmount($amount);
187
+
188
+ // Load transaction Data
189
+ $transactionId = $payment->getLastTransId();
190
+ $transaction = $payment->getTransaction($transactionId);
191
+ if (!$transaction) {
192
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
193
+ }
194
+
195
+ // Get Transaction Details
196
+ $this->fetchTransactionInfo($payment, $transactionId);
197
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
198
+
199
+ // Not to execute for Sale transactions
200
+ if ((int)$details['transactionStatus'] !== 3) {
201
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
202
+ //return $this;
203
+ }
204
+
205
+ $transactionNumber = $details['transactionNumber'];
206
+ $order_id = $payment->getOrder()->getIncrementId();
207
+
208
+ // Prevent Rounding Issue
209
+ // Difference can be ~0.0099999999999909
210
+ $order_amount = Mage::helper('payex/order')->getCalculatedOrderAmount($payment->getOrder())->getAmount();
211
+ $value = abs(sprintf("%.2f", $order_amount) - sprintf("%.2f", $amount));
212
+ if ($value > 0 && $value < 0.011) {
213
+ $amount = $order_amount;
214
+ }
215
+
216
+ $xml = Mage::helper('payex/order')->getInvoiceExtraPrintBlocksXML($payment->getOrder());
217
+
218
+ // Call PxOrder.Capture5
219
+ $params = array(
220
+ 'accountNumber' => '',
221
+ 'transactionNumber' => $transactionNumber,
222
+ 'amount' => round(100 * $amount),
223
+ 'orderId' => $order_id,
224
+ 'vatAmount' => 0,
225
+ 'additionalValues' => 'FINANCINGINVOICE_ORDERLINES=' . urlencode($xml)
226
+ );
227
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
228
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
229
+
230
+ // Check Results
231
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
232
+ // Note: Order Status will be changed in Observer
233
+
234
+ // Add Capture Transaction
235
+ $payment->setStatus(self::STATUS_APPROVED)
236
+ ->setTransactionId($result['transactionNumber'])
237
+ ->setIsTransactionClosed(0);
238
+
239
+ // Add Transaction fields
240
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
241
+ return $this;
242
+ }
243
+
244
+ // Show Error
245
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * Cancel payment
251
+ * @param Varien_Object $payment
252
+ * @return $this
253
+ */
254
+ public function cancel(Varien_Object $payment)
255
+ {
256
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
257
+
258
+ if (!$payment->getLastTransId()) {
259
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
260
+ }
261
+
262
+ // Load transaction Data
263
+ $transactionId = $payment->getLastTransId();
264
+ $transaction = $payment->getTransaction($transactionId);
265
+ if (!$transaction) {
266
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
267
+ }
268
+
269
+ // Get Transaction Details
270
+ $this->fetchTransactionInfo($payment, $transactionId);
271
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
272
+
273
+ // Not to execute for Sale transactions
274
+ if ((int)$details['transactionStatus'] !== 3) {
275
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
276
+ }
277
+
278
+ $transactionNumber = $details['transactionNumber'];
279
+ $order_id = $details['orderId'];
280
+ if (!$order_id) {
281
+ $order_id = $payment->getOrder()->getId();
282
+ }
283
+
284
+ // Call PXOrder.Cancel2
285
+ $params = array(
286
+ 'accountNumber' => '',
287
+ 'transactionNumber' => $transactionNumber
288
+ );
289
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
290
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
291
+
292
+ // Check Results
293
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
294
+ // Add Cancel Transaction
295
+ $payment->setStatus(self::STATUS_DECLINED)
296
+ ->setTransactionId($result['transactionNumber'])
297
+ ->setIsTransactionClosed(1); // Closed
298
+
299
+ // Add Transaction fields
300
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
301
+ return $this;
302
+ }
303
+
304
+ // Show Error
305
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
306
+ return $this;
307
+ }
308
+
309
+ /**
310
+ * Refund capture
311
+ * @param Varien_Object $payment
312
+ * @param $amount
313
+ * @return $this
314
+ */
315
+ public function refund(Varien_Object $payment, $amount)
316
+ {
317
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
318
+
319
+ parent::refund($payment, $amount);
320
+
321
+ if ($amount <= 0) {
322
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
323
+ }
324
+
325
+ if (!$payment->getLastTransId()) {
326
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
327
+ }
328
+
329
+ // Load transaction Data
330
+ $transactionId = $payment->getLastTransId();
331
+ $transaction = $payment->getTransaction($transactionId);
332
+ if (!$transaction) {
333
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
334
+ }
335
+
336
+ // Get Transaction Details
337
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
338
+ //$details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
339
+
340
+ // Check for Capture and Authorize transaction only
341
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
342
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
343
+ }
344
+
345
+ $transactionNumber = $details['transactionNumber'];
346
+ $order_id = $details['orderId'];
347
+ if (!$order_id) {
348
+ $order_id = $payment->getOrder()->getId();
349
+ }
350
+
351
+ // Call PXOrder.PXOrder.Credit5
352
+ $params = array(
353
+ 'accountNumber' => '',
354
+ 'transactionNumber' => $transactionNumber,
355
+ 'amount' => round(100 * $amount),
356
+ 'orderId' => $order_id,
357
+ 'vatAmount' => 0,
358
+ 'additionalValues' => ''
359
+ );
360
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
361
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Credit5:' . $result['description'], $order_id);
362
+
363
+ // Check Results
364
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
365
+ // Add Credit Transaction
366
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
367
+ $payment->setAmount($amount);
368
+
369
+ $payment->setStatus(self::STATUS_APPROVED)
370
+ ->setTransactionId($result['transactionNumber'])
371
+ ->setIsTransactionClosed(0); // No-Closed
372
+
373
+ // Add Transaction fields
374
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
375
+ return $this;
376
+ }
377
+
378
+ // Show Error
379
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
380
+ return $this;
381
+ }
382
+
383
+ /**
384
+ * Void payment
385
+ * @param Varien_Object $payment
386
+ * @return Mage_Payment_Model_Abstract
387
+ */
388
+ public function void(Varien_Object $payment)
389
+ {
390
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
391
+ return $this->cancel($payment);
392
+ }
393
+
394
+ /**
395
+ * Fetch transaction details info
396
+ * @param Mage_Payment_Model_Info $payment
397
+ * @param string $transactionId
398
+ * @return array
399
+ */
400
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
401
+ {
402
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
403
+
404
+ parent::fetchTransactionInfo($payment, $transactionId);
405
+
406
+ // Get Transaction Details
407
+ $params = array(
408
+ 'accountNumber' => '',
409
+ 'transactionNumber' => $transactionId,
410
+ );
411
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
412
+ Mage::helper('payex/tools')->addToDebug('PxOrder.GetTransactionDetails2:' . $details['description']);
413
+
414
+ // Check Results
415
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
416
+ // Filter details
417
+ foreach ($details as $key => $value) {
418
+ if (empty($value)) {
419
+ unset($details[$key]);
420
+ }
421
+ }
422
+ return $details;
423
+ }
424
+
425
+ // Show Error
426
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
427
+ }
428
+
429
+ public function getStandardCheckoutFormFields()
430
+ {
431
+ return array();
432
+ }
433
+
434
+ /**
435
+ * Check void availability
436
+ * @param Varien_Object $payment
437
+ * @return bool
438
+ */
439
+ public function canVoid(Varien_Object $payment)
440
+ {
441
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
442
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
443
+ ) {
444
+ return false;
445
+ }
446
+ return $this->_canVoid;
447
+ }
448
+
449
+ public function canEdit()
450
+ {
451
+ return false;
452
+ }
453
+
454
+ public function canUseInternal()
455
+ {
456
+ return $this->_canUseInternal;
457
+ }
458
+
459
+ public function canUseForMultishipping()
460
+ {
461
+ return $this->_canUseForMultishipping;
462
+ }
463
+
464
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
465
+ {
466
+ return $this;
467
+ }
468
+
469
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
470
+ {
471
+ }
472
+
473
+ public function canCapture()
474
+ {
475
+ return $this->_canCapture;
476
+ }
477
+
478
+ public function canFetchTransactionInfo()
479
+ {
480
+ return $this->_canFetchTransactionInfo;
481
+ }
482
+
483
+ }
app/code/community/PayEx/Payments/Model/Payment/Swish.php ADDED
@@ -0,0 +1,319 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Swish extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_swish';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = true;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+ //protected $_canCancelInvoice = true;
25
+
26
+ /**
27
+ * Payment method blocks
28
+ */
29
+ protected $_infoBlockType = 'payex/info_swish';
30
+ protected $_formBlockType = 'payex/form_swish';
31
+
32
+ /**
33
+ * Get initialized flag status
34
+ * @return true
35
+ */
36
+ public function isInitializeNeeded()
37
+ {
38
+ return true;
39
+ }
40
+
41
+ /**
42
+ * Instantiate state and set it to state object
43
+ * @param $paymentAction
44
+ * @param $stateObject
45
+ * @return void
46
+ */
47
+ public function initialize($paymentAction, $stateObject)
48
+ {
49
+ // Set Initial Order Status
50
+ $state = Mage_Sales_Model_Order::STATE_NEW;
51
+ $stateObject->setState($state);
52
+ $stateObject->setStatus($state);
53
+ $stateObject->setIsNotified(false);
54
+ }
55
+
56
+ /**
57
+ * Get config action to process initialization
58
+ * @return string
59
+ */
60
+ public function getConfigPaymentAction()
61
+ {
62
+ $paymentAction = $this->getConfigData('payment_action');
63
+ return empty($paymentAction) ? true : $paymentAction;
64
+ }
65
+
66
+ /**
67
+ * Check whether payment method can be used
68
+ * @param Mage_Sales_Model_Quote
69
+ * @return bool
70
+ */
71
+ public function isAvailable($quote = null)
72
+ {
73
+ if (parent::isAvailable($quote) === false) {
74
+ return false;
75
+ }
76
+
77
+ // Check currency
78
+ $allowedCurrency = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
79
+ return in_array($quote->getQuoteCurrencyCode(), $allowedCurrency);
80
+ }
81
+
82
+ /**
83
+ * Validate
84
+ * @return bool
85
+ */
86
+ public function validate()
87
+ {
88
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
89
+ return parent::validate();
90
+ }
91
+
92
+ /**
93
+ * Get the redirect url
94
+ * @return string
95
+ */
96
+ public function getOrderPlaceRedirectUrl()
97
+ {
98
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
99
+ return Mage::getUrl('payex/swish/redirect', array('_secure' => true));
100
+ }
101
+
102
+ /**
103
+ * Capture payment
104
+ * @note In BankDebit used auto-capture
105
+ * @param Varien_Object $payment
106
+ * @param $amount
107
+ * @return $this
108
+ */
109
+ public function capture(Varien_Object $payment, $amount)
110
+ {
111
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
112
+
113
+ parent::capture($payment, $amount);
114
+
115
+ $transactionId = $payment->getLastTransId();
116
+ //$transactionId = $transactionId . '-capture';
117
+
118
+ // Add Capture Transaction
119
+ $payment->setStatus(self::STATUS_APPROVED)
120
+ ->setTransactionId($transactionId)
121
+ ->setIsTransactionClosed(0);
122
+
123
+ // Do nothing
124
+
125
+ return $this;
126
+ }
127
+
128
+ /**
129
+ * Cancel payment
130
+ * @param Varien_Object $payment
131
+ * @return $this
132
+ */
133
+ public function cancel(Varien_Object $payment)
134
+ {
135
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
136
+
137
+ $transactionId = $payment->getLastTransId();
138
+
139
+ // Add Cancel Transaction
140
+ $payment->setStatus(self::STATUS_DECLINED)
141
+ ->setTransactionId($transactionId)
142
+ ->setIsTransactionClosed(1); // Closed
143
+
144
+ // Do nothing
145
+
146
+ return $this;
147
+ }
148
+
149
+ /**
150
+ * Refund capture
151
+ * @param Varien_Object $payment
152
+ * @param $amount
153
+ * @return $this
154
+ */
155
+ public function refund(Varien_Object $payment, $amount)
156
+ {
157
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
158
+
159
+ parent::refund($payment, $amount);
160
+
161
+ if ($amount <= 0) {
162
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
163
+ }
164
+
165
+ if (!$payment->getLastTransId()) {
166
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
167
+ }
168
+
169
+ // Load transaction Data
170
+ $transactionId = $payment->getLastTransId();
171
+ $transaction = $payment->getTransaction($transactionId);
172
+ if (!$transaction) {
173
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
174
+ }
175
+
176
+ // Get Transaction Details
177
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
178
+
179
+ // Check for Capture and Authorize transaction only
180
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
181
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
182
+ }
183
+
184
+ $transactionNumber = $details['transactionNumber'];
185
+ $order_id = $details['orderId'];
186
+ if (!$order_id) {
187
+ $order_id = $payment->getOrder()->getId();
188
+ }
189
+
190
+ // Call PxOrder.Credit5
191
+ $params = array(
192
+ 'accountNumber' => '',
193
+ 'transactionNumber' => $transactionNumber,
194
+ 'amount' => round($amount * 100),
195
+ 'orderId' => $order_id,
196
+ 'vatAmount' => 0,
197
+ 'additionalValues' => ''
198
+ );
199
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
200
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Credit');
201
+
202
+ // Check Results
203
+ if ($result['code'] == 'OK' && $result['errorCode'] == 'OK' && $result['description'] == 'OK') {
204
+ // Add Credit Transaction
205
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
206
+ $payment->setAmount($amount);
207
+
208
+ $payment->setStatus(self::STATUS_APPROVED)
209
+ ->setTransactionId($result['transactionNumber'])
210
+ ->setIsTransactionClosed(0); // No-Closed
211
+
212
+ // Add Transaction fields
213
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
214
+ return $this;
215
+ }
216
+
217
+ // Show Error
218
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
219
+ }
220
+
221
+ /**
222
+ * Void payment
223
+ * @param Varien_Object $payment
224
+ * @return $this
225
+ */
226
+ public function void(Varien_Object $payment)
227
+ {
228
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
229
+ return $this->cancel($payment);
230
+ }
231
+
232
+ /**
233
+ * Fetch transaction details info
234
+ * @param Mage_Payment_Model_Info $payment
235
+ * @param string $transactionId
236
+ * @return array
237
+ */
238
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
239
+ {
240
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
241
+
242
+ // Get Transaction Details
243
+ $params = array(
244
+ 'accountNumber' => '',
245
+ 'transactionNumber' => $transactionId,
246
+ );
247
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
248
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
249
+
250
+ // Check Results
251
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
252
+ // Filter details
253
+ foreach ($details as $key => $value) {
254
+ if (empty($value)) {
255
+ unset($details[$key]);
256
+ }
257
+ }
258
+ return $details;
259
+ }
260
+
261
+ // Show Error
262
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
263
+ }
264
+
265
+ public function getStandardCheckoutFormFields()
266
+ {
267
+ return array();
268
+ }
269
+
270
+ /**
271
+ * Check void availability
272
+ * @param Varien_Object $payment
273
+ * @return bool
274
+ */
275
+ public function canVoid(Varien_Object $payment)
276
+ {
277
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
278
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
279
+ ) {
280
+ return false;
281
+ }
282
+ return $this->_canVoid;
283
+ }
284
+
285
+ public function canEdit()
286
+ {
287
+ return false;
288
+ }
289
+
290
+ public function canUseInternal()
291
+ {
292
+ return $this->_canUseInternal;
293
+ }
294
+
295
+ public function canUseForMultishipping()
296
+ {
297
+ return $this->_canUseForMultishipping;
298
+ }
299
+
300
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
301
+ {
302
+ return $this;
303
+ }
304
+
305
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
306
+ {
307
+ }
308
+
309
+ public function canCapture()
310
+ {
311
+ return $this->_canCapture;
312
+ }
313
+
314
+ public function canFetchTransactionInfo()
315
+ {
316
+ return $this->_canFetchTransactionInfo;
317
+ }
318
+
319
+ }
app/code/community/PayEx/Payments/Model/Payment/Wywallet.php ADDED
@@ -0,0 +1,432 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Payment_Wywallet extends PayEx_Payments_Model_Payment_Abstract
4
+ {
5
+ /**
6
+ * Payment method code
7
+ */
8
+ public $_code = 'payex_wywallet';
9
+
10
+ /**
11
+ * Availability options
12
+ */
13
+ protected $_isGateway = true;
14
+ protected $_canAuthorize = true;
15
+ protected $_canCapture = true;
16
+ protected $_canCapturePartial = false;
17
+ protected $_canRefund = true;
18
+ protected $_canRefundInvoicePartial = false;
19
+ protected $_canVoid = true;
20
+ protected $_canUseInternal = true;
21
+ protected $_canUseCheckout = true;
22
+ protected $_canUseForMultishipping = false;
23
+ protected $_canFetchTransactionInfo = true;
24
+
25
+ /**
26
+ * Payment method blocks
27
+ */
28
+ protected $_infoBlockType = 'payex/info_wywallet';
29
+ protected $_formBlockType = 'payex/form_wywallet';
30
+
31
+ /**
32
+ * Supported currencies
33
+ * See http://pim.payex.com/Section3/currencycodes.htm
34
+ */
35
+ static protected $_allowCurrencyCode = array('DKK', 'EUR', 'GBP', 'NOK', 'SEK', 'USD');
36
+
37
+ /**
38
+ * Get initialized flag status
39
+ * @return true
40
+ */
41
+ public function isInitializeNeeded()
42
+ {
43
+ return true;
44
+ }
45
+
46
+ /**
47
+ * Instantiate state and set it to state object
48
+ * @param $paymentAction
49
+ * @param $stateObject
50
+ * @return void
51
+ */
52
+ public function initialize($paymentAction, $stateObject)
53
+ {
54
+ // Set Initial Order Status
55
+ $state = Mage_Sales_Model_Order::STATE_NEW;
56
+ $stateObject->setState($state);
57
+ $stateObject->setStatus($state);
58
+ $stateObject->setIsNotified(false);
59
+ }
60
+
61
+ /**
62
+ * Get config action to process initialization
63
+ * @return string
64
+ */
65
+ public function getConfigPaymentAction()
66
+ {
67
+ $paymentAction = $this->getConfigData('payment_action');
68
+ return empty($paymentAction) ? true : $paymentAction;
69
+ }
70
+
71
+ /**
72
+ * Check whether payment method can be used
73
+ * @param Mage_Sales_Model_Quote
74
+ * @return bool
75
+ */
76
+ public function isAvailable($quote = null)
77
+ {
78
+ if (parent::isAvailable($quote) === false) {
79
+ return false;
80
+ }
81
+
82
+ return true;
83
+ }
84
+
85
+ /**
86
+ * Validate
87
+ * @return bool
88
+ */
89
+ public function validate()
90
+ {
91
+ Mage::helper('payex/tools')->addToDebug('Action: Validate');
92
+
93
+ // Get the iso2 Country Code from the billing section
94
+ $country_code = $this->getQuote()->getBillingAddress()->getCountry();
95
+
96
+ // Get current currency
97
+ $paymentInfo = $this->getInfoInstance();
98
+
99
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
100
+ $currency_code = $paymentInfo->getOrder()->getBaseCurrencyCode();
101
+ } else {
102
+ //$currency_code = $this->getQuote()->getBaseCurrencyCode();
103
+ $currency_code = $paymentInfo->getQuote()->getBaseCurrencyCode();
104
+ }
105
+
106
+ // Check supported currency
107
+ if (!in_array($currency_code, self::$_allowCurrencyCode)) {
108
+ Mage::throwException(Mage::helper('payex')->__('Selected currency code (%s) is not compatible with PayEx', $currency_code));
109
+ }
110
+ }
111
+
112
+ /**
113
+ * Get the redirect url
114
+ * @return string
115
+ */
116
+ public function getOrderPlaceRedirectUrl()
117
+ {
118
+ Mage::helper('payex/tools')->addToDebug('Action: getOrderPlaceRedirectUrl');
119
+
120
+ return Mage::getUrl('payex/wywallet/redirect', array('_secure' => true));
121
+ }
122
+
123
+ /**
124
+ * Capture payment
125
+ * @param Varien_Object $payment
126
+ * @param $amount
127
+ * @return $this
128
+ */
129
+ public function capture(Varien_Object $payment, $amount)
130
+ {
131
+ Mage::helper('payex/tools')->addToDebug('Action: Capture');
132
+
133
+ parent::capture($payment, $amount);
134
+
135
+ if ($amount <= 0) {
136
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for capture.'));
137
+ }
138
+
139
+ if (!$payment->getLastTransId()) {
140
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
141
+ }
142
+
143
+ $payment->setAmount($amount);
144
+
145
+ // Load transaction Data
146
+ $transactionId = $payment->getLastTransId();
147
+ $transaction = $payment->getTransaction($transactionId);
148
+ if (!$transaction) {
149
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
150
+ }
151
+
152
+ // Get Transaction Details
153
+ $this->fetchTransactionInfo($payment, $transactionId);
154
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
155
+
156
+ // Not to execute for Sale transactions
157
+ if ((int)$details['transactionStatus'] !== 3) {
158
+ Mage::throwException(Mage::helper('payex')->__('Can\'t capture captured order.'));
159
+ //return $this;
160
+ }
161
+
162
+ $transactionNumber = $details['transactionNumber'];
163
+ $order_id = $details['orderId'];
164
+ if (!$order_id) {
165
+ $order_id = $payment->getOrder()->getIncrementId();
166
+ }
167
+
168
+ // Call PxOrder.Capture5
169
+ $params = array(
170
+ 'accountNumber' => '',
171
+ 'transactionNumber' => $transactionNumber,
172
+ 'amount' => round(100 * $amount),
173
+ 'orderId' => $order_id,
174
+ 'vatAmount' => 0,
175
+ 'additionalValues' => ''
176
+ );
177
+ $result = Mage::helper('payex/api')->getPx()->Capture5($params);
178
+ Mage::helper('payex/tools')->addToDebug('PXOrder.Capture5:' . $result['description'], $order_id);
179
+
180
+ // Check Results
181
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
182
+ // Note: Order Status will be changed in Observer
183
+
184
+ // Add Capture Transaction
185
+ $payment->setStatus(self::STATUS_APPROVED)
186
+ ->setTransactionId($result['transactionNumber'])
187
+ ->setIsTransactionClosed(0);
188
+
189
+ // Add Transaction fields
190
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
191
+ return $this;
192
+ }
193
+
194
+ // Show Error
195
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Capture5');
196
+ return $this;
197
+ }
198
+
199
+ /**
200
+ * Cancel payment
201
+ * @param Varien_Object $payment
202
+ * @return $this
203
+ */
204
+ public function cancel(Varien_Object $payment)
205
+ {
206
+ Mage::helper('payex/tools')->addToDebug('Action: Cancel');
207
+
208
+ if (!$payment->getLastTransId()) {
209
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
210
+ }
211
+
212
+ // Load transaction Data
213
+ $transactionId = $payment->getLastTransId();
214
+ $transaction = $payment->getTransaction($transactionId);
215
+ if (!$transaction) {
216
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
217
+ }
218
+
219
+ // Get Transaction Details
220
+ $this->fetchTransactionInfo($payment, $transactionId);
221
+ $details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
222
+
223
+ // Not to execute for Sale transactions
224
+ if ((int)$details['transactionStatus'] !== 3) {
225
+ Mage::throwException(Mage::helper('payex')->__('Unable to execute cancel.'));
226
+ }
227
+
228
+ $transactionNumber = $details['transactionNumber'];
229
+ $order_id = $details['orderId'];
230
+ if (!$order_id) {
231
+ $order_id = $payment->getOrder()->getId();
232
+ }
233
+
234
+ // Call PXOrder.Cancel2
235
+ $params = array(
236
+ 'accountNumber' => '',
237
+ 'transactionNumber' => $transactionNumber
238
+ );
239
+ $result = Mage::helper('payex/api')->getPx()->Cancel2($params);
240
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Cancel2:' . $result['description'], $order_id);
241
+
242
+ // Check Results
243
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
244
+ // Add Cancel Transaction
245
+ $payment->setStatus(self::STATUS_DECLINED)
246
+ ->setTransactionId($result['transactionNumber'])
247
+ ->setIsTransactionClosed(1); // Closed
248
+
249
+ // Add Transaction fields
250
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
251
+ return $this;
252
+ }
253
+
254
+ // Show Error
255
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Cancel2');
256
+ return $this;
257
+ }
258
+
259
+ /**
260
+ * Refund capture
261
+ * @param Varien_Object $payment
262
+ * @param $amount
263
+ * @return $this
264
+ */
265
+ public function refund(Varien_Object $payment, $amount)
266
+ {
267
+ Mage::helper('payex/tools')->addToDebug('Action: Refund');
268
+
269
+ parent::refund($payment, $amount);
270
+
271
+ if ($amount <= 0) {
272
+ Mage::throwException(Mage::helper('paygate')->__('Invalid amount for refund.'));
273
+ }
274
+
275
+ if (!$payment->getLastTransId()) {
276
+ Mage::throwException(Mage::helper('paygate')->__('Invalid transaction ID.'));
277
+ }
278
+
279
+ // Load transaction Data
280
+ $transactionId = $payment->getLastTransId();
281
+ $transaction = $payment->getTransaction($transactionId);
282
+ if (!$transaction) {
283
+ Mage::throwException(Mage::helper('payex')->__('Can\'t load last transaction.'));
284
+ }
285
+
286
+ // Get Transaction Details
287
+ $details = $this->fetchTransactionInfo($payment, $transactionId);
288
+ //$details = $transaction->getAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS);
289
+
290
+ // Check for Capture and Authorize transaction only
291
+ if ((int)$details['transactionStatus'] !== 6 && (int)$details['transactionStatus'] !== 0) {
292
+ Mage::throwException(Mage::helper('payex')->__('This payment has not yet captured.'));
293
+ }
294
+
295
+ $transactionNumber = $details['transactionNumber'];
296
+ $order_id = $details['orderId'];
297
+ if (!$order_id) {
298
+ $order_id = $payment->getOrder()->getId();
299
+ }
300
+
301
+ // Call PXOrder.PXOrder.Credit5
302
+ $params = array(
303
+ 'accountNumber' => '',
304
+ 'transactionNumber' => $transactionNumber,
305
+ 'amount' => round(100 * $amount),
306
+ 'orderId' => $order_id,
307
+ 'vatAmount' => 0,
308
+ 'additionalValues' => ''
309
+ );
310
+ $result = Mage::helper('payex/api')->getPx()->Credit5($params);
311
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Credit5:' . $result['description'], $order_id);
312
+
313
+ // Check Results
314
+ if ($result['code'] === 'OK' && $result['errorCode'] === 'OK' && $result['description'] === 'OK') {
315
+ // Add Credit Transaction
316
+ $payment->setAnetTransType(Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND);
317
+ $payment->setAmount($amount);
318
+
319
+ $payment->setStatus(self::STATUS_APPROVED)
320
+ ->setTransactionId($result['transactionNumber'])
321
+ ->setIsTransactionClosed(0); // No-Closed
322
+
323
+ // Add Transaction fields
324
+ $payment->setAdditionalInformation(Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS, $result);
325
+ return $this;
326
+ }
327
+
328
+ // Show Error
329
+ Mage::helper('payex/tools')->throwPayExException($result, 'PxOrder.Credit5');
330
+ return $this;
331
+ }
332
+
333
+ /**
334
+ * Void payment
335
+ * @param Varien_Object $payment
336
+ * @return $this
337
+ */
338
+ public function void(Varien_Object $payment)
339
+ {
340
+ Mage::helper('payex/tools')->addToDebug('Action: Void');
341
+ return $this->cancel($payment);
342
+ }
343
+
344
+ /**
345
+ * Fetch transaction details info
346
+ * @param Mage_Payment_Model_Info $payment
347
+ * @param string $transactionId
348
+ * @return array
349
+ */
350
+ public function fetchTransactionInfo(Mage_Payment_Model_Info $payment, $transactionId)
351
+ {
352
+ Mage::helper('payex/tools')->addToDebug('Action: fetchTransactionInfo. ID ' . $transactionId);
353
+
354
+ parent::fetchTransactionInfo($payment, $transactionId);
355
+
356
+ // Get Transaction Details
357
+ $params = array(
358
+ 'accountNumber' => '',
359
+ 'transactionNumber' => $transactionId,
360
+ );
361
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
362
+ Mage::helper('payex/tools')->addToDebug('PxOrder.GetTransactionDetails2:' . $details['description']);
363
+
364
+ // Check Results
365
+ if ($details['code'] === 'OK' && $details['errorCode'] === 'OK' && $details['description'] === 'OK') {
366
+ // Filter details
367
+ foreach ($details as $key => $value) {
368
+ if (empty($value)) {
369
+ unset($details[$key]);
370
+ }
371
+ }
372
+ return $details;
373
+ }
374
+
375
+ // Show Error
376
+ Mage::helper('payex/tools')->throwPayExException($details, 'GetTransactionDetails2');
377
+ }
378
+
379
+ public function getStandardCheckoutFormFields()
380
+ {
381
+ return array();
382
+ }
383
+
384
+ /**
385
+ * Check void availability
386
+ * @param Varien_Object $payment
387
+ * @return bool
388
+ */
389
+ public function canVoid(Varien_Object $payment)
390
+ {
391
+ if ($payment instanceof Mage_Sales_Model_Order_Invoice
392
+ || $payment instanceof Mage_Sales_Model_Order_Creditmemo
393
+ ) {
394
+ return false;
395
+ }
396
+ return $this->_canVoid;
397
+ }
398
+
399
+ public function canEdit()
400
+ {
401
+ return false;
402
+ }
403
+
404
+ public function canUseInternal()
405
+ {
406
+ return $this->_canUseInternal;
407
+ }
408
+
409
+ public function canUseForMultishipping()
410
+ {
411
+ return $this->_canUseForMultishipping;
412
+ }
413
+
414
+ public function onOrderValidate(Mage_Sales_Model_Order_Payment $payment)
415
+ {
416
+ return $this;
417
+ }
418
+
419
+ public function onInvoiceCreate(Mage_Sales_Model_Order_Invoice $payment)
420
+ {
421
+ }
422
+
423
+ public function canCapture()
424
+ {
425
+ return $this->_canCapture;
426
+ }
427
+
428
+ public function canFetchTransactionInfo()
429
+ {
430
+ return $this->_canFetchTransactionInfo;
431
+ }
432
+ }
app/code/community/PayEx/Payments/Model/Quote/Total.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Quote_Total extends Mage_Sales_Model_Quote_Address_Total_Abstract
4
+ {
5
+ protected static $_allowed_methods = array(
6
+ 'payex_financing',
7
+ 'payex_partpayment',
8
+ 'payex_invoice'
9
+ );
10
+
11
+ public function getCode()
12
+ {
13
+ return 'payex_payment_fee';
14
+ }
15
+
16
+ public function collect(Mage_Sales_Model_Quote_Address $address)
17
+ {
18
+ $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
19
+ $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
20
+ if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())) {
21
+ return $this;
22
+ }
23
+
24
+ $paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
25
+ if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
26
+ return $this;
27
+ }
28
+
29
+ $items = $address->getAllItems();
30
+ if (!count($items)) {
31
+ return $this;
32
+ }
33
+
34
+ $address->setBasePayexPaymentFee(0);
35
+ $address->setBasePayexPaymentFeeTax(0);
36
+ $address->setPayexPaymentFee(0);
37
+ $address->setPayexPaymentFeeTax(0);
38
+
39
+ // Get totals
40
+ $address1 = clone $address;
41
+ foreach ($address1->getTotalCollector()->getCollectors() as $model) {
42
+ if ($model->getCode() !== $this->getCode()) {
43
+ $model->collect($address1);
44
+ }
45
+ }
46
+
47
+ // Address is the reference for grand total
48
+ // Calculated total is $address1->getGrandTotal()
49
+ $price = (float)$paymentMethod->getConfigData('paymentfee');
50
+ $tax_class = $paymentMethod->getConfigData('paymentfee_tax_class');
51
+ if (!$price) {
52
+ return $this;
53
+ }
54
+
55
+ // Get Payment Fee
56
+ $fee = Mage::helper('payex/fee')->getPaymentFeePrice($price, $tax_class);
57
+
58
+ $baseTotal = $address->getBaseGrandTotal();
59
+ $baseTotal += $fee->getPaymentFeePrice() + $fee->getPaymentFeeTax();
60
+
61
+ $address->setBasePayexPaymentFee($fee->getPaymentFeePrice());
62
+ $address->setBasePayexPaymentFeeTax($fee->getPaymentFeeTax());
63
+ $address->setPayexPaymentFee($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeePrice(), false));
64
+ $address->setPayexPaymentFeeTax($address->getQuote()->getStore()->convertPrice($fee->getPaymentFeeTax(), false));
65
+
66
+ // update totals
67
+ $address->setBaseGrandTotal($baseTotal);
68
+ $address->setGrandTotal($address->getQuote()->getStore()->convertPrice($baseTotal, false));
69
+
70
+ return $this;
71
+ }
72
+
73
+ public function fetch(Mage_Sales_Model_Quote_Address $address)
74
+ {
75
+ $paymentMethod = Mage::app()->getFrontController()->getRequest()->getParam('payment');
76
+ $paymentMethod = Mage::app()->getStore()->isAdmin() && isset($paymentMethod['method']) ? $paymentMethod['method'] : null;
77
+ if (!in_array($paymentMethod, self::$_allowed_methods) && (!count($address->getQuote()->getPaymentsCollection()) || !$address->getQuote()->getPayment()->hasMethodInstance())) {
78
+ return $this;
79
+ }
80
+
81
+ $paymentMethod = $address->getQuote()->getPayment()->getMethodInstance();
82
+ if (!in_array($paymentMethod->getCode(), self::$_allowed_methods)) {
83
+ return $this;
84
+ }
85
+
86
+ $fee = $address->getPayexPaymentFee();
87
+ if ($fee > 0) {
88
+ $address->addTotal(array(
89
+ 'code' => $this->getCode(),
90
+ 'title' => Mage::helper('payex')->__('Payment fee'),
91
+ 'value' => $fee,
92
+ ));
93
+ }
94
+
95
+ $fee_tax = $address->getPayexPaymentFeeTax();
96
+ if ($fee_tax > 0) {
97
+ $address->addTotal(array(
98
+ 'code' => $this->getCode() . '_tax',
99
+ 'title' => Mage::helper('payex')->__('Payment fee (tax)'),
100
+ 'value' => $fee_tax,
101
+ ));
102
+ }
103
+
104
+ return $this;
105
+ }
106
+ }
app/code/community/PayEx/Payments/Model/Session.php ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Session extends Mage_Core_Model_Session_Abstract
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->init('payex');
8
+ }
9
+ }
app/code/community/PayEx/Payments/Model/Source/Banks.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_Banks
4
+ {
5
+ protected $_options;
6
+
7
+ public function toOptionArray($isMultiselect=false)
8
+ {
9
+ return array(
10
+ // Sweden (SEK)
11
+ array(
12
+ 'value' => 'NB',
13
+ 'label' => Mage::helper('payex')->__('Nordea Bank')
14
+ ),
15
+ array(
16
+ 'value' => 'FSPA',
17
+ 'label' => Mage::helper('payex')->__('Swedbank')
18
+ ),
19
+ array(
20
+ 'value' => 'SEB',
21
+ 'label' => Mage::helper('payex')->__('Svenska Enskilda Bank')
22
+ ),
23
+ array(
24
+ 'value' => 'SHB',
25
+ 'label' => Mage::helper('payex')->__('Handelsbanken')
26
+ ),
27
+ // Denmark (DKK)
28
+ array(
29
+ 'value' => 'NB:DK',
30
+ 'label' => Mage::helper('payex')->__('Nordea Bank DK')
31
+ ),
32
+ array(
33
+ 'value' => 'DDB',
34
+ 'label' => Mage::helper('payex')->__('Den Danske Bank')
35
+ ),
36
+ // Norway (NOK)
37
+ array(
38
+ 'value' => 'BAX',
39
+ 'label' => Mage::helper('payex')->__('BankAxess')
40
+ ),
41
+ // Finland (EUR)
42
+ array(
43
+ 'value' => 'SAMPO',
44
+ 'label' => Mage::helper('payex')->__('Sampo')
45
+ ),
46
+ array(
47
+ 'value' => 'AKTIA',
48
+ 'label' => Mage::helper('payex')->__('Aktia, Säästöpankki')
49
+ ),
50
+ array(
51
+ 'value' => 'OP',
52
+ 'label' => Mage::helper('payex')->__('Osuuspanki, Pohjola, Oko')
53
+ ),
54
+ array(
55
+ 'value' => 'NB:FI',
56
+ 'label' => Mage::helper('payex')->__('Nordea Bank Finland')
57
+ ),
58
+ array(
59
+ 'value' => 'SHB:FI',
60
+ 'label' => Mage::helper('payex')->__('SHB:FI')
61
+ ),
62
+ array(
63
+ 'value' => 'SPANKKI',
64
+ 'label' => Mage::helper('payex')->__('SPANKKI')
65
+ ),
66
+ array(
67
+ 'value' => 'TAPIOLA',
68
+ 'label' => Mage::helper('payex')->__('TAPIOLA')
69
+ ),
70
+ array(
71
+ 'value' => 'AALAND',
72
+ 'label' => Mage::helper('payex')->__('Ålandsbanken')
73
+ )
74
+ );
75
+ }
76
+ }
app/code/community/PayEx/Payments/Model/Source/ClientLanguage.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_ClientLanguage
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 'en-US',
10
+ 'label' => Mage::helper('payex')->__('English')
11
+ ),
12
+ array(
13
+ 'value' => 'sv-SE',
14
+ 'label' => Mage::helper('payex')->__('Swedish')
15
+ ),
16
+ array(
17
+ 'value' => 'nb-NO',
18
+ 'label' => Mage::helper('payex')->__('Norway')
19
+ ),
20
+ array(
21
+ 'value' => 'da-DK',
22
+ 'label' => Mage::helper('payex')->__('Danish')
23
+ ),
24
+ array(
25
+ 'value' => 'es-ES',
26
+ 'label' => Mage::helper('payex')->__('Spanish')
27
+ ),
28
+ array(
29
+ 'value' => 'de-DE',
30
+ 'label' => Mage::helper('payex')->__('German')
31
+ ),
32
+ array(
33
+ 'value' => 'fi-FI',
34
+ 'label' => Mage::helper('payex')->__('Finnish')
35
+ ),
36
+ array(
37
+ 'value' => 'fr-FR',
38
+ 'label' => Mage::helper('payex')->__('French')
39
+ ),
40
+ array(
41
+ 'value' => 'pl-PL',
42
+ 'label' => Mage::helper('payex')->__('Polish')
43
+ ),
44
+ array(
45
+ 'value' => 'cs-CZ',
46
+ 'label' => Mage::helper('payex')->__('Czech')
47
+ ),
48
+ array(
49
+ 'value' => 'hu-HU',
50
+ 'label' => Mage::helper('payex')->__('Hungarian')
51
+ ),
52
+ );
53
+ }
54
+ }
app/code/community/PayEx/Payments/Model/Source/MediaDistribution.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_MediaDistribution
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 1,
10
+ 'label' => Mage::helper('payex')->__('Paper by mail')
11
+ ),
12
+ array(
13
+ 'value' => 11,
14
+ 'label' => Mage::helper('payex')->__('PDF by e-mail')
15
+ ),
16
+ );
17
+ }
18
+ }
app/code/community/PayEx/Payments/Model/Source/PaymentAction.php ADDED
@@ -0,0 +1 @@
 
0
  public function toOptionArray()
1
  {
2
  return array(
3
  array(
4
  'value' => 0,
5
  'label' => Mage::helper('payex')->__('Authorize')
6
  ),
7
  array(
8
  'value' => 1,
9
  'label' => Mage::helper('payex')->__('Sale')
10
  ),
11
  );
12
  }
1
+ <?php
2
  public function toOptionArray()
3
  {
4
  return array(
5
  array(
6
  'value' => 0,
7
  'label' => Mage::helper('payex')->__('Authorize')
8
  ),
9
  array(
10
  'value' => 1,
11
  'label' => Mage::helper('payex')->__('Sale')
12
  ),
13
  );
14
  }
app/code/community/PayEx/Payments/Model/Source/PaymentView.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_PaymentView
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ return array(
8
+ array(
9
+ 'value' => 'PX',
10
+ 'label' => Mage::helper('payex')->__('Payment Menu')
11
+ ),
12
+ array(
13
+ 'value' => 'CREDITCARD',
14
+ 'label' => Mage::helper('payex')->__('Credit Card')
15
+ ),
16
+ array(
17
+ 'value' => 'INVOICE',
18
+ 'label' => Mage::helper('payex')->__('Invoice (Ledger Service)')
19
+ ),
20
+ array(
21
+ 'value' => 'DIRECTDEBIT',
22
+ 'label' => Mage::helper('payex')->__('Direct Debit')
23
+ ),
24
+ array(
25
+ 'value' => 'PAYPAL',
26
+ 'label' => Mage::helper('payex')->__('PayPal')
27
+ )
28
+ );
29
+ }
30
+ }
app/code/community/PayEx/Payments/Model/Source/ShippingMethod.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_ShippingMethod
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $methods = array(
8
+ array(
9
+ 'value' => '',
10
+ 'label' => Mage::helper('adminhtml')->__('--Please Select--')
11
+ )
12
+ );
13
+
14
+ $activeCarriers = Mage::getSingleton('shipping/config')->getActiveCarriers();
15
+ foreach ($activeCarriers as $carrierCode => $carrierModel) {
16
+ $options = array();
17
+
18
+ $carrierTitle = sprintf('Carrier "%s"', $carrierCode);
19
+ if ($carrierMethods = $carrierModel->getAllowedMethods()) {
20
+ foreach ($carrierMethods as $methodCode => $method) {
21
+ $code = $carrierCode . '_' . $methodCode;
22
+ $options[] = array('value' => $code, 'label' => $method);
23
+
24
+ }
25
+ $carrierTitle = Mage::getStoreConfig('carriers/' . $carrierCode . '/title');
26
+ }
27
+
28
+ $methods[] = array('value' => $options, 'label' => $carrierTitle);
29
+ }
30
+
31
+ return $methods;
32
+ }
33
+ }
app/code/community/PayEx/Payments/Model/Source/TaxClasses.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_Model_Source_TaxClasses
4
+ {
5
+ public function toOptionArray()
6
+ {
7
+ $options = Mage::getModel('tax/class_source_product')->toOptionArray();
8
+ return $options;
9
+ }
10
+ }
app/code/community/PayEx/Payments/controllers/AutopayController.php ADDED
@@ -0,0 +1,546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_AutopayController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_autopay');
9
+ }
10
+
11
+ public function autopayAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: autopay');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ // Set quote to inactive
26
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
27
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
28
+ Mage::getSingleton('checkout/session')->clear();
29
+
30
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
31
+ $method = $order->getPayment()->getMethodInstance();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Operation Type (AUTHORIZATION / SALE)
37
+ $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
38
+
39
+ // Get CustomerId
40
+ $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
41
+
42
+ // Get Amount
43
+ //$amount = $order->getGrandTotal();
44
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
45
+
46
+ // Get Current Customer Agreement
47
+ $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
48
+ $agreement_status = PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS;
49
+
50
+ // Get Agreement Status
51
+ if ($agreement->getId()) {
52
+ // Call PxAgreement.AgreementCheck
53
+ $params = array(
54
+ 'accountNumber' => '',
55
+ 'agreementRef' => $agreement->getAgreementRef(),
56
+ );
57
+ $result = Mage::helper('payex/api')->getPx()->AgreementCheck($params);
58
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AgreementCheck');
59
+
60
+ // Check Errors
61
+ if ($result['code'] !== 'OK' && $result['description'] !== 'OK') {
62
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
63
+
64
+ // Cancel order
65
+ $order->cancel();
66
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
67
+ $order->save();
68
+
69
+ // Set quote to active
70
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
71
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
72
+ if ($quote->getId()) {
73
+ $quote->setIsActive(true)->save();
74
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
75
+ }
76
+ }
77
+
78
+ Mage::getSingleton('checkout/session')->addError($message);
79
+ $this->_redirect('checkout/cart');
80
+ return;
81
+ }
82
+
83
+ $agreement_status = (int)$result['agreementStatus'];
84
+ Mage::helper('payex/tools')->addToDebug('PxAgreement.AgreementCheck Status is ' . $agreement_status . ' (NotVerified = 0, Verified = 1, Deleted = 2)');
85
+ Mage::helper('payex/tools')->addToDebug('Reserved Order for CustomerId #' . $customer_id, $order_id);
86
+ Mage::helper('payex/tools')->addToDebug('Current Agreement Status for CustomerId #' . $customer_id . ' is ' . var_export($agreement_status, true));
87
+ }
88
+
89
+ // Check Agreement Status
90
+ switch ($agreement_status) {
91
+ case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_DELETED):
92
+ // Remove Deleted Agreement ID
93
+ $agreement->delete();
94
+ case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS):
95
+ // Create Agreement ID
96
+ // Call PxAgreement.CreateAgreement3
97
+ $params = array(
98
+ 'accountNumber' => '',
99
+ 'merchantRef' => $method->getConfigData('agreementurl'),
100
+ 'description' => Mage::app()->getStore()->getName(),
101
+ 'purchaseOperation' => $operation,
102
+ 'maxAmount' => round($method->getConfigData('maxamount') * 100),
103
+ 'notifyUrl' => '',
104
+ 'startDate' => '',
105
+ 'stopDate' => ''
106
+ );
107
+ $result = Mage::helper('payex/api')->getPx()->CreateAgreement3($params);
108
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.CreateAgreement3');
109
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
110
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
111
+
112
+ // Cancel order
113
+ $order->cancel();
114
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
115
+ $order->save();
116
+
117
+ // Set quote to active
118
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
119
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
120
+ if ($quote->getId()) {
121
+ $quote->setIsActive(true)->save();
122
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
123
+ }
124
+ }
125
+
126
+ Mage::getSingleton('checkout/session')->addError($message);
127
+ $this->_redirect('checkout/cart');
128
+ return;
129
+ }
130
+
131
+ // Save Customer Agreement ID
132
+ $model = Mage::getModel('payex/agreement');
133
+ $model->setCustomerId($customer_id)
134
+ ->setAgreementRef($result['agreementRef'])
135
+ ->setCreatedAt(date('Y-m-d H:i:s', time()))
136
+ ->save();
137
+
138
+ Mage::helper('payex/tools')->addToDebug('Agreement for CustomerId #' . $customer_id . ' created');
139
+ case (PayEx_Payments_Model_Payment_Autopay::AGREEMENT_VERIFIED):
140
+ // Call PxAgreement.AutoPay3
141
+ $params = array(
142
+ 'accountNumber' => '',
143
+ 'agreementRef' => $agreement->getAgreementRef(),
144
+ 'price' => round($amount * 100),
145
+ 'productNumber' => $order_id,
146
+ 'description' => Mage::app()->getStore()->getName(),
147
+ 'orderId' => $order_id,
148
+ 'purchaseOperation' => $operation,
149
+ 'currency' => $currency_code
150
+ );
151
+ $result = Mage::helper('payex/api')->getPx()->AutoPay3($params);
152
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.AutoPay3');
153
+
154
+ // Check errors
155
+ if ($result['errorCodeSimple'] !== 'OK') {
156
+ // AutoPay: NOT successful
157
+ // Reset Customer Agreement
158
+ Mage::helper('payex/tools')->addToDebug('Warning: AgreementId ' . $agreement->getAgreementRef() . ' of CustomerId ' . $customer_id . ' is removed!');
159
+ $agreement->delete();
160
+
161
+ // Try to pay again using PayEx Credit Card
162
+ $redirectUrl = Mage::getUrl('payex/autopay/redirect', array('_secure' => true));
163
+ $this->_redirectUrl($redirectUrl);
164
+ return;
165
+ }
166
+
167
+ // Validate transactionStatus value
168
+ if (!isset($result['transactionStatus']) || !is_numeric($result['transactionStatus'])) {
169
+ // AutoPay: No transactionsStatus in response
170
+ Mage::helper('payex/tools')->addToDebug('Error: No transactionsStatus in response.', $order->getIncrementId());
171
+
172
+ // Reset Customer Agreement
173
+ Mage::helper('payex/tools')->addToDebug('Warning: AgreementId ' . $agreement->getAgreementRef() . ' of CustomerId ' . $customer_id . ' is removed!');
174
+ $agreement->delete();
175
+
176
+ // Try to pay again using PayEx Credit Card
177
+ $redirectUrl = Mage::getUrl('payex/autopay/redirect', array('_secure' => true));
178
+ $this->_redirectUrl($redirectUrl);
179
+ return;
180
+ }
181
+
182
+ // Redirect to Success Action
183
+ Mage::getSingleton('checkout/session')->setTransaction($result);
184
+ $redirectUrl = Mage::getUrl('payex/autopay/success', array('_secure' => true));
185
+ $this->_redirectUrl($redirectUrl);
186
+ return;
187
+ }
188
+
189
+ // Show Error
190
+ $message = Mage::helper('payex')->__('Failed to process order');
191
+
192
+ // Cancel order
193
+ $order->cancel();
194
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
195
+ $order->save();
196
+
197
+ // Set quote to active
198
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
199
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
200
+ if ($quote->getId()) {
201
+ $quote->setIsActive(true)->save();
202
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
203
+ }
204
+ }
205
+
206
+ Mage::getSingleton('checkout/session')->addError($message);
207
+ $this->_redirect('checkout/cart');
208
+ }
209
+
210
+ public function redirectAction()
211
+ {
212
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
213
+
214
+ // Load Order
215
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
216
+
217
+ /** @var Mage_Sales_Model_Order $order */
218
+ $order = Mage::getModel('sales/order');
219
+ $order->loadByIncrementId($order_id);
220
+ if (!$order->getId()) {
221
+ Mage::throwException('No order for processing found');
222
+ }
223
+
224
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
225
+ $method = $order->getPayment()->getMethodInstance();
226
+
227
+ // Get Currency code
228
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
229
+
230
+ // Get Operation Type (AUTHORIZATION / SALE)
231
+ $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
232
+
233
+ // Get CustomerId
234
+ $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
235
+
236
+ // Get Additional Values
237
+ $additional = '';
238
+
239
+ // Responsive Skinning
240
+ if ($method->getConfigData('responsive') === '1') {
241
+ $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
242
+ $additional .= $separator . 'USECSS=RESPONSIVEDESIGN';
243
+ }
244
+
245
+ // Get Amount
246
+ //$amount = $order->getGrandTotal();
247
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
248
+
249
+ // Get Current Customer Agreement
250
+ $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
251
+
252
+ // Call PxOrder.Initialize8
253
+ $params = array(
254
+ 'accountNumber' => '',
255
+ 'purchaseOperation' => $operation,
256
+ 'price' => round($amount * 100),
257
+ 'priceArgList' => '',
258
+ 'currency' => $currency_code,
259
+ 'vat' => 0,
260
+ 'orderID' => $order_id,
261
+ 'productNumber' => $order_id,
262
+ 'description' => Mage::app()->getStore()->getName(),
263
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
264
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
265
+ 'additionalValues' => $additional,
266
+ 'externalID' => '',
267
+ 'returnUrl' => Mage::getUrl('payex/autopay/success', array('_secure' => true)),
268
+ 'view' => 'CREDITCARD',
269
+ 'agreementRef' => $agreement->getAgreementRef(),
270
+ 'cancelUrl' => Mage::getUrl('payex/autopay/cancel', array('_secure' => true)),
271
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
272
+ );
273
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
274
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
275
+
276
+ // Check Errors
277
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
278
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
279
+
280
+ // Cancel order
281
+ $order->cancel();
282
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
283
+ $order->save();
284
+
285
+ // Set quote to active
286
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
287
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
288
+ if ($quote->getId()) {
289
+ $quote->setIsActive(true)->save();
290
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
291
+ }
292
+ }
293
+
294
+ Mage::getSingleton('checkout/session')->addError($message);
295
+ $this->_redirect('checkout/cart');
296
+ return;
297
+ }
298
+ $order_ref = $result['orderRef'];
299
+ $redirectUrl = $result['redirectUrl'];
300
+
301
+ // Add Order Lines and Orders Address
302
+ if ($method->getConfigData('checkoutinfo')) {
303
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
304
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
305
+ }
306
+
307
+ // Set Pending Payment status
308
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
309
+ $order->save();
310
+
311
+ // Redirect to PayEx
312
+ header('Location: ' . $redirectUrl);
313
+ exit();
314
+ }
315
+
316
+ public function successAction()
317
+ {
318
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
319
+
320
+ // Load Order
321
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
322
+
323
+ /** @var Mage_Sales_Model_Order $order */
324
+ $order = Mage::getModel('sales/order');
325
+ $order->loadByIncrementId($order_id);
326
+ if (!$order->getId()) {
327
+ Mage::throwException('No order for processing found');
328
+ }
329
+
330
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
331
+ $method = $order->getPayment()->getMethodInstance();
332
+
333
+ $result = Mage::getSingleton('checkout/session')->getTransaction();
334
+ if (!$result) {
335
+ // Check OrderRef
336
+ if (empty($_GET['orderRef'])) {
337
+ $this->_redirect('checkout/cart');
338
+ return;
339
+ }
340
+
341
+ // Call PxOrder.Complete
342
+ $params = array(
343
+ 'accountNumber' => '',
344
+ 'orderRef' => $_GET['orderRef']
345
+ );
346
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
347
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
348
+ if ($result['errorCodeSimple'] !== 'OK') {
349
+ // Cancel order
350
+ $order->cancel();
351
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
352
+ $order->save();
353
+
354
+ // Set quote to active
355
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
356
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
357
+ if ($quote->getId()) {
358
+ $quote->setIsActive(true)->save();
359
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
360
+ }
361
+ }
362
+
363
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
364
+ Mage::getSingleton('checkout/session')->addError($message);
365
+ $this->_redirect('checkout/cart');
366
+ return;
367
+ }
368
+ }
369
+
370
+ // Prevent Order cancellation when used TC
371
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
372
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
373
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
374
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
375
+ $order->save();
376
+
377
+ foreach ($order->getAllItems() as $item) {
378
+ $item->setQtyCanceled(0);
379
+ $item->save();
380
+ }
381
+ }
382
+
383
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
384
+ }
385
+
386
+ // Process Transaction
387
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
388
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
389
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
390
+
391
+ // Check Order and Transaction Result
392
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
393
+ switch ($transaction_status) {
394
+ case 0;
395
+ case 1;
396
+ case 3;
397
+ case 6:
398
+ // Select Order Status
399
+ if (in_array($transaction_status, array(0, 6))) {
400
+ $new_status = $method->getConfigData('order_status_capture');
401
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
402
+ $new_status = $method->getConfigData('order_status_authorize');
403
+ } else {
404
+ $new_status = $order->getStatus();
405
+ }
406
+
407
+ // Get Order Status
408
+ /** @var Mage_Sales_Model_Order_Status $status */
409
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
410
+
411
+ // Change order status
412
+ $order->setData('state', $status->getState());
413
+ $order->setStatus($status->getStatus());
414
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
415
+
416
+ // Create Invoice for Sale Transaction
417
+ if (in_array($transaction_status, array(0, 6))) {
418
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
419
+ $invoice->setTransactionId($result['transactionNumber']);
420
+ $invoice->save();
421
+
422
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
423
+ if ($transaction_status === 0) {
424
+ $order->setTotalPaid($order->getTotalDue());
425
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
426
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
427
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
428
+
429
+ // Update Order Totals because API V2 don't update order totals
430
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
431
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
432
+ ->setOrderFilter($order->getId())->getFirstItem();
433
+
434
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
435
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
436
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
437
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
438
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
439
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
440
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
441
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
442
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
443
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
444
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
445
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
446
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
447
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
448
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
449
+ }
450
+ }
451
+
452
+ $order->save();
453
+ $order->sendNewOrderEmail();
454
+
455
+ // Redirect to Success Page
456
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
457
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
458
+ break;
459
+ default:
460
+ // Cancel order
461
+ if ($transaction->getIsCancel()) {
462
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
463
+
464
+ $order->cancel();
465
+ $order->addStatusHistoryComment($transaction->getMessage());
466
+ $order->save();
467
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
468
+ }
469
+
470
+ // Set quote to active
471
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
472
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
473
+ if ($quote->getId()) {
474
+ $quote->setIsActive(true)->save();
475
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
476
+ }
477
+ }
478
+
479
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
480
+ $this->_redirect('checkout/cart');
481
+ }
482
+ }
483
+
484
+ public function cancelAction()
485
+ {
486
+ Mage::helper('payex/tools')->addToDebug('Controller: cancel');
487
+
488
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
489
+
490
+ /** @var Mage_Sales_Model_Order $order */
491
+ $order = Mage::getModel('sales/order');
492
+ $order->loadByIncrementId($order_id);
493
+
494
+ // Note: Cancel only non-captured orders!
495
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
496
+ // Set Canceled State
497
+ $order->cancel();
498
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order canceled by user'), Mage_Sales_Model_Order::STATE_CANCELED);
499
+ $order->save();
500
+ }
501
+
502
+ // Set quote to active
503
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
504
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
505
+ if ($quote->getId()) {
506
+ $quote->setIsActive(true)->save();
507
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
508
+ }
509
+ }
510
+
511
+ Mage::getSingleton('checkout/session')->addError(Mage::helper('payex')->__('Order canceled by user'));
512
+ $this->_redirect('checkout/cart');
513
+ }
514
+
515
+ public function cancel_agreementAction()
516
+ {
517
+ Mage::helper('payex/tools')->addToDebug('Controller: cancel_agreement');
518
+
519
+ // Get CustomerId
520
+ $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
521
+ $agreement = Mage::getModel('payex/agreement')->load($customer_id, 'customer_id');
522
+
523
+ // Cancel Agreement
524
+ if ($agreement->getId()) {
525
+ // Call PxAgreement.DeleteAgreement
526
+ $params = array(
527
+ 'accountNumber' => '',
528
+ 'agreementRef' => $agreement->getAgreementRef(),
529
+ );
530
+
531
+ $result = Mage::helper('payex/api')->getPx()->DeleteAgreement($params);
532
+ Mage::helper('payex/tools')->debugApi($result, 'PxAgreement.DeleteAgreement');
533
+ }
534
+
535
+ // Remove Agreement
536
+ $agreement->delete();
537
+
538
+ // Redirect to back
539
+ if (!empty($_SERVER['HTTP_REFERER'])) {
540
+ header('Location: ' . $_SERVER['HTTP_REFERER']);
541
+ exit();
542
+ } else {
543
+ $this->_redirect('/', array('_secure' => true));
544
+ }
545
+ }
546
+ }
app/code/community/PayEx/Payments/controllers/BankdebitController.php ADDED
@@ -0,0 +1,315 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_BankdebitController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_bankdebit');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Additional Values
37
+ $additional = '';
38
+
39
+ // Responsive Skinning
40
+ if ($method->getConfigData('responsive') === '1') {
41
+ $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
42
+ $additional .= $separator . 'RESPONSIVE=1';
43
+ }
44
+
45
+ // Get Amount
46
+ //$amount = $order->getGrandTotal();
47
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
48
+
49
+ // Get Bank Id
50
+ $bank_id = Mage::getSingleton('checkout/session')->getBankId();
51
+
52
+ Mage::helper('payex/tools')->addToDebug('Selected bank: '.$bank_id);
53
+
54
+ // Call PxOrder.Initialize8
55
+ $params = array(
56
+ 'accountNumber' => '',
57
+ 'purchaseOperation' => 'SALE', // for BankDebit mode uses SALE method only
58
+ 'price' => 0,
59
+ 'priceArgList' => $bank_id . '=' . round($amount * 100),
60
+ 'currency' => $currency_code,
61
+ 'vat' => 0,
62
+ 'orderID' => $order_id,
63
+ 'productNumber' => $order_id,
64
+ 'description' => Mage::app()->getStore()->getName(),
65
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
66
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
67
+ 'additionalValues' => $additional,
68
+ 'externalID' => '',
69
+ 'returnUrl' => Mage::getUrl('payex/bankdebit/success', array('_secure' => true)),
70
+ 'view' => 'DIRECTDEBIT',
71
+ 'agreementRef' => '',
72
+ 'cancelUrl' => Mage::getUrl('payex/bankdebit/cancel', array('_secure' => true)),
73
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
74
+ );
75
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
76
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Initialize8');
77
+
78
+ // Check Errors
79
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
80
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
81
+
82
+ // Cancel order
83
+ $order->cancel();
84
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
85
+ $order->save();
86
+
87
+ // Set quote to active
88
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
89
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
90
+ if ($quote->getId()) {
91
+ $quote->setIsActive(true)->save();
92
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
93
+ }
94
+ }
95
+
96
+ Mage::getSingleton('checkout/session')->addError($message);
97
+ $this->_redirect('checkout/cart');
98
+ return;
99
+ }
100
+ Mage::helper('payex/tools')->addToDebug('Redirect URL: ' . $result['redirectUrl']);
101
+ $order_ref = $result['orderRef'];
102
+
103
+ // Add Order Lines and Orders Address
104
+ if ($method->getConfigData('checkoutinfo')) {
105
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
106
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
107
+ }
108
+
109
+ // Call PxOrder.PrepareSaleDD2
110
+ $params = array(
111
+ 'accountNumber' => '',
112
+ 'orderRef' => $order_ref,
113
+ 'userType' => 0, // Anonymous purchase
114
+ 'userRef' => '',
115
+ 'bankName' => $bank_id
116
+ );
117
+ $result = Mage::helper('payex/api')->getPx()->PrepareSaleDD2($params);
118
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.PrepareSaleDD2');
119
+
120
+ // Check Errors
121
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
122
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
123
+
124
+ // Cancel order
125
+ $order->cancel();
126
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
127
+ $order->save();
128
+
129
+ // Set quote to active
130
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
131
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
132
+ if ($quote->getId()) {
133
+ $quote->setIsActive(true)->save();
134
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
135
+ }
136
+ }
137
+
138
+ Mage::getSingleton('checkout/session')->addError($message);
139
+ $this->_redirect('checkout/cart');
140
+ return;
141
+ }
142
+
143
+ // Set Pending Payment status
144
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
145
+ $order->save();
146
+
147
+ // Redirect to Bank
148
+ header('Location: ' . $result['redirectUrl']);
149
+ exit();
150
+ }
151
+
152
+ public function successAction()
153
+ {
154
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
155
+
156
+ // Check OrderRef
157
+ if (empty($_GET['orderRef'])) {
158
+ $this->_redirect('checkout/cart');
159
+ }
160
+
161
+ // Load Order
162
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
163
+
164
+ /** @var Mage_Sales_Model_Order $order */
165
+ $order = Mage::getModel('sales/order');
166
+ $order->loadByIncrementId($order_id);
167
+ if (!$order->getId()) {
168
+ Mage::throwException('No order for processing found');
169
+ }
170
+
171
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
172
+ $method = $order->getPayment()->getMethodInstance();
173
+
174
+ // Call PxOrder.Complete
175
+ $params = array(
176
+ 'accountNumber' => '',
177
+ 'orderRef' => $_GET['orderRef']
178
+ );
179
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
180
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
181
+ if ($result['errorCodeSimple'] !== 'OK') {
182
+ // Cancel order
183
+ $order->cancel();
184
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
185
+ $order->save();
186
+
187
+ // Set quote to active
188
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
189
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
190
+ if ($quote->getId()) {
191
+ $quote->setIsActive(true)->save();
192
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
193
+ }
194
+ }
195
+
196
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
197
+ Mage::getSingleton('checkout/session')->addError($message);
198
+ $this->_redirect('checkout/cart');
199
+ return;
200
+ }
201
+
202
+ // Prevent Order cancellation when used TC
203
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
204
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
205
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
206
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
207
+ $order->save();
208
+
209
+ foreach ($order->getAllItems() as $item) {
210
+ $item->setQtyCanceled(0);
211
+ $item->save();
212
+ }
213
+ }
214
+
215
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
216
+ }
217
+
218
+ // Process Transaction
219
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
220
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
221
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
222
+
223
+ // Check Order and Transaction Result
224
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
225
+ switch ($transaction_status) {
226
+ case 0;
227
+ case 1;
228
+ case 3;
229
+ case 6:
230
+ // Select Order Status
231
+ $new_status = $method->getConfigData('order_status');
232
+ if (empty($new_status)) {
233
+ $new_status = $order->getStatus();
234
+ }
235
+
236
+ // Get Order Status
237
+ /** @var Mage_Sales_Model_Order_Status $status */
238
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
239
+
240
+ // Change order status
241
+ $order->setData('state', $status->getState());
242
+ $order->setStatus($status->getStatus());
243
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
244
+
245
+ // Create Invoice for Sale Transaction
246
+ if (in_array($transaction_status, array(0, 6))) {
247
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
248
+ $invoice->setTransactionId($result['transactionNumber']);
249
+ $invoice->save();
250
+
251
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
252
+ if ($transaction_status === 0) {
253
+ $order->setTotalPaid($order->getTotalDue());
254
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
255
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
256
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
257
+
258
+ // Update Order Totals because API V2 don't update order totals
259
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
260
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
261
+ ->setOrderFilter($order->getId())->getFirstItem();
262
+
263
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
264
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
265
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
266
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
267
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
268
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
269
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
270
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
271
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
272
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
273
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
274
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
275
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
276
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
277
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
278
+ }
279
+ }
280
+
281
+ $order->save();
282
+ $order->sendNewOrderEmail();
283
+
284
+ // Redirect to Success Page
285
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
286
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
287
+ break;
288
+ default:
289
+ // Cancel order
290
+ if ($transaction->getIsCancel()) {
291
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
292
+
293
+ $order->cancel();
294
+ $order->addStatusHistoryComment($transaction->getMessage());
295
+ $order->save();
296
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
297
+ }
298
+
299
+ // Set quote to active
300
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
301
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
302
+ if ($quote->getId()) {
303
+ $quote->setIsActive(true)->save();
304
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
305
+ }
306
+ }
307
+
308
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
309
+ $this->_redirect('checkout/cart');
310
+ }
311
+ }
312
+
313
+
314
+ }
315
+
app/code/community/PayEx/Payments/controllers/FinancingController.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_FinancingController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_financing');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Social Security Number from Session
34
+ $ssn = Mage::getSingleton('checkout/session')->getSocialSecurityNumber();
35
+
36
+ // Get Currency code
37
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
38
+
39
+ // Get Amount
40
+ //$amount = $order->getGrandTotal();
41
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
42
+
43
+ // @todo Implement "Sale" Purchase Operation
44
+
45
+ // Call PxOrder.Initialize8
46
+ $params = array(
47
+ 'accountNumber' => '',
48
+ 'purchaseOperation' => 'AUTHORIZATION',
49
+ 'price' => round($amount * 100),
50
+ 'priceArgList' => '',
51
+ 'currency' => $currency_code,
52
+ 'vat' => 0,
53
+ 'orderID' => $order_id,
54
+ 'productNumber' => $order_id,
55
+ 'description' => Mage::app()->getStore()->getName(),
56
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
57
+ 'clientIdentifier' => '',
58
+ 'additionalValues' => '',
59
+ 'externalID' => '',
60
+ 'returnUrl' => 'http://localhost.no/return',
61
+ 'view' => 'FINANCING',
62
+ 'agreementRef' => '',
63
+ 'cancelUrl' => 'http://localhost.no/cancel',
64
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
65
+ );
66
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
67
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
68
+
69
+ // Check Errors
70
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
71
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
72
+
73
+ // Cancel order
74
+ $order->cancel();
75
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
76
+ $order->save();
77
+
78
+ // Set quote to active
79
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
80
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
81
+ if ($quote->getId()) {
82
+ $quote->setIsActive(true)->save();
83
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
84
+ }
85
+ }
86
+
87
+ Mage::getSingleton('checkout/session')->addError($message);
88
+ $this->_redirect('checkout/cart');
89
+ return;
90
+ }
91
+ $order_ref = $result['orderRef'];
92
+
93
+ // Call PxOrder.PurchaseFinancingInvoice
94
+ $params = array(
95
+ 'accountNumber' => '',
96
+ 'orderRef' => $order_ref,
97
+ 'socialSecurityNumber' => $ssn,
98
+ 'legalName' => $order->getBillingAddress()->getName(),
99
+ 'streetAddress' => $order->getBillingAddress()->getStreet(-1),
100
+ 'coAddress' => '',
101
+ 'zipCode' => $order->getBillingAddress()->getPostcode(),
102
+ 'city' => $order->getBillingAddress()->getCity(),
103
+ 'countryCode' => $order->getBillingAddress()->getCountry(),
104
+ 'paymentMethod' => $order->getBillingAddress()->getCountry() === 'SE' ? 'PXFINANCINGINVOICESE' : 'PXFINANCINGINVOICENO',
105
+ 'email' => $order->getBillingAddress()->getEmail(),
106
+ 'msisdn' => (mb_substr($order->getBillingAddress()->getTelephone(), 0, 1) === '+') ? $order->getBillingAddress()->getTelephone() : '+' . $order->getBillingAddress()->getTelephone(),
107
+ 'ipAddress' => Mage::helper('core/http')->getRemoteAddr()
108
+ );
109
+ $result = Mage::helper('payex/api')->getPx()->PurchaseFinancingInvoice($params);
110
+ Mage::helper('payex/tools')->addToDebug('PxOrder.PurchaseFinancingInvoice:' . $result['description']);
111
+
112
+ // Check Errors
113
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
114
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
115
+
116
+ // Cancel order
117
+ $order->cancel();
118
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
119
+ $order->save();
120
+
121
+ // Set quote to active
122
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
123
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
124
+ if ($quote->getId()) {
125
+ $quote->setIsActive(true)->save();
126
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
127
+ }
128
+ }
129
+
130
+ Mage::getSingleton('checkout/session')->addError($message);
131
+ $this->_redirect('checkout/cart');
132
+ return;
133
+ }
134
+
135
+ // Validate transactionStatus value
136
+ if (!isset($result['transactionStatus']) || !is_numeric($result['transactionStatus'])) {
137
+ $message = Mage::helper('payex')->__('Error: No transactionsStatus in response.');
138
+ Mage::helper('payex/tools')->addToDebug('Error: No transactionsStatus in response.', $order->getIncrementId());
139
+
140
+ // Cancel order
141
+ $order->cancel();
142
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
143
+ $order->save();
144
+
145
+ // Set quote to active
146
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
147
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
148
+ if ($quote->getId()) {
149
+ $quote->setIsActive(true)->save();
150
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
151
+ }
152
+ }
153
+
154
+ Mage::getSingleton('checkout/session')->addError($message);
155
+ $this->_redirect('checkout/cart');
156
+ return;
157
+ }
158
+
159
+ // Prevent Order cancellation when used TC
160
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
161
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
162
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
163
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
164
+ $order->save();
165
+
166
+ foreach ($order->getAllItems() as $item) {
167
+ $item->setQtyCanceled(0);
168
+ $item->save();
169
+ }
170
+ }
171
+
172
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
173
+ }
174
+
175
+ // Process Transaction
176
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
177
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
178
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
179
+
180
+ // Check Order and Transaction Result
181
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
182
+ switch ($transaction_status) {
183
+ case 0;
184
+ case 1;
185
+ case 3;
186
+ case 6:
187
+ // Select Order Status
188
+ if (in_array($transaction_status, array(0, 6))) {
189
+ $new_status = $method->getConfigData('order_status_capture');
190
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
191
+ $new_status = $method->getConfigData('order_status_authorize');
192
+ } else {
193
+ $new_status = $order->getStatus();
194
+ }
195
+
196
+ // Get Order Status
197
+ /** @var Mage_Sales_Model_Order_Status $status */
198
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
199
+
200
+ // Change order status
201
+ $order->setData('state', $status->getState());
202
+ $order->setStatus($status->getStatus());
203
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
204
+
205
+ // Create Invoice for Sale Transaction
206
+ if (in_array($transaction_status, array(0, 6))) {
207
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
208
+ $invoice->setTransactionId($result['transactionNumber']);
209
+ $invoice->save();
210
+
211
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
212
+ if ($transaction_status === 0) {
213
+ $order->setTotalPaid($order->getTotalDue());
214
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
215
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
216
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
217
+
218
+ // Update Order Totals because API V2 don't update order totals
219
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
220
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
221
+ ->setOrderFilter($order->getId())->getFirstItem();
222
+
223
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
224
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
225
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
226
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
227
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
228
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
229
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
230
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
231
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
232
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
233
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
234
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
235
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
236
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
237
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
238
+ }
239
+ }
240
+
241
+ $order->save();
242
+ $order->sendNewOrderEmail();
243
+
244
+ // Redirect to Success Page
245
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
246
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
247
+ break;
248
+ default:
249
+ // Cancel order
250
+ if ($transaction->getIsCancel()) {
251
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
252
+
253
+ $order->cancel();
254
+ $order->addStatusHistoryComment($transaction->getMessage());
255
+ $order->save();
256
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
257
+ }
258
+
259
+ // Set quote to active
260
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
261
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
262
+ if ($quote->getId()) {
263
+ $quote->setIsActive(true)->save();
264
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
265
+ }
266
+ }
267
+
268
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
269
+ $this->_redirect('checkout/cart');
270
+ }
271
+ }
272
+ }
app/code/community/PayEx/Payments/controllers/GetaddrController.php ADDED
@@ -0,0 +1,118 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_GetaddrController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ const XML_PATH_MODULE_DEBUG = 'payex_ssn/payex_ssn/debug';
6
+ const XML_PATH_MODULE_ACCOUNTNUMBER = 'payex_ssn/payex_ssn/accountnumber';
7
+ const XML_PATH_MODULE_ENCRYPTIONKEY = 'payex_ssn/payex_ssn/encryptionkey';
8
+
9
+ public function indexAction()
10
+ {
11
+ // Get initial data from request
12
+ $ssn = trim($this->getRequest()->getParam('ssn'));
13
+ if (empty($ssn)) {
14
+ $data = array(
15
+ 'success' => false,
16
+ 'message' => Mage::helper('payex')->__('Social security number is empty')
17
+ );
18
+ $this->getResponse()->setHeader('Content-type', 'application/json');
19
+ $this->getResponse()->setBody(Zend_Json::encode($data));
20
+ return;
21
+ }
22
+
23
+ //$ssn = preg_replace('/[^0-9]/s', '', $ssn);
24
+
25
+ // Get Country Code
26
+ //$country_code = Mage::helper('payex/tools')->getCountryCodeBySSN($ssn);
27
+ //if (!$country_code) {
28
+ // $data = array(
29
+ // 'success' => false,
30
+ // 'message' => Mage::helper('payex')->__('Invalid Social Security Number')
31
+ // );
32
+ // $this->getResponse()->setHeader('Content-type', 'application/json');
33
+ // $this->getResponse()->setBody(Zend_Json::encode($data));
34
+ // return;
35
+ //}
36
+
37
+ $country_code = trim($this->getRequest()->getParam('country_code'));
38
+ if (empty($country_code)) {
39
+ $data = array(
40
+ 'success' => false,
41
+ 'message' => Mage::helper('payex')->__('Country is empty')
42
+ );
43
+ $this->getResponse()->setHeader('Content-type', 'application/json');
44
+ $this->getResponse()->setBody(Zend_Json::encode($data));
45
+ return;
46
+ }
47
+
48
+ if (!in_array($country_code, array('SE', 'NO'))) {
49
+ $data = array(
50
+ 'success' => false,
51
+ 'message' => Mage::helper('payex')->__('Your country don\'t supported')
52
+ );
53
+ $this->getResponse()->setHeader('Content-type', 'application/json');
54
+ $this->getResponse()->setBody(Zend_Json::encode($data));
55
+ return;
56
+ }
57
+
58
+ // strip whitespaces from postcode to pass validation
59
+ $postcode = preg_replace('/\s+/', '', $this->getRequest()->getParam('postcode'));
60
+ if (empty($postcode)) {
61
+ $data = array(
62
+ 'success' => false,
63
+ 'message' => Mage::helper('payex')->__('Postcode is empty')
64
+ );
65
+ $this->getResponse()->setHeader('Content-type', 'application/json');
66
+ $this->getResponse()->setBody(Zend_Json::encode($data));
67
+ return;
68
+ }
69
+
70
+ // Init PayEx
71
+ $px = Mage::helper('payex/api')->getPx();
72
+ $px->setEnvironment(Mage::getStoreConfig(self::XML_PATH_MODULE_ACCOUNTNUMBER), Mage::getStoreConfig(self::XML_PATH_MODULE_ENCRYPTIONKEY), (bool)Mage::getStoreConfig(self::XML_PATH_MODULE_DEBUG));
73
+
74
+ // Call PxOrder.GetAddressByPaymentMethod
75
+ $params = array(
76
+ 'accountNumber' => '',
77
+ 'paymentMethod' => 'PXFINANCINGINVOICE' . $country_code,
78
+ 'ssn' => $ssn,
79
+ 'zipcode' => $postcode,
80
+ 'countryCode' => $country_code,
81
+ 'ipAddress' => Mage::helper('core/http')->getRemoteAddr()
82
+ );
83
+ $result = $px->GetAddressByPaymentMethod($params);
84
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
85
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
86
+ $data = array(
87
+ 'success' => false,
88
+ 'message' => $message
89
+ );
90
+
91
+ $this->getResponse()->setHeader('Content-type', 'application/json');
92
+ $this->getResponse()->setBody(Zend_Json::encode($data));
93
+ return;
94
+ }
95
+
96
+ // Parse name field
97
+ $name = Mage::helper('payex/tools')->getNameParser()->parse_name($result['name']);
98
+
99
+ $data = array(
100
+ 'success' => true,
101
+ 'first_name' => $name['fname'],
102
+ 'last_name' => $name['lname'],
103
+ 'address_1' => $result['streetAddress'],
104
+ 'address_2' => !empty($result['coAddress']) ? 'c/o ' . $result['coAddress'] : '',
105
+ 'postcode' => $result['zipCode'],
106
+ 'city' => $result['city'],
107
+ 'country' => $result['countryCode']
108
+ );
109
+
110
+ // Save data in Session
111
+ Mage::getSingleton('checkout/session')->setPayexSSN($ssn);
112
+ Mage::getSingleton('checkout/session')->setPayexSSNData($data);
113
+
114
+ $this->getResponse()->setHeader('Content-type', 'application/json');
115
+ $this->getResponse()->setBody(Zend_Json::encode($data));
116
+ }
117
+
118
+ }
app/code/community/PayEx/Payments/controllers/InvoiceController.php ADDED
@@ -0,0 +1,326 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_InvoiceController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_invoice');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Operation Type (AUTHORIZATION / SALE)
37
+ $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
38
+
39
+ // Get CustomerId
40
+ $customer_id = (Mage::getSingleton('customer/session')->isLoggedIn() == true) ? Mage::getSingleton('customer/session')->getCustomer()->getId() : '0';
41
+
42
+ // Get Additional Values
43
+ $additional = $method->getConfigData('additionalValues') . '&INVOICE_MEDIADISTRIBUTION=11';
44
+
45
+ // Responsive Skinning
46
+ if ($method->getConfigData('responsive') === '1') {
47
+ $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
48
+ $additional .= $separator . 'USECSS=RESPONSIVEDESIGN';
49
+ }
50
+
51
+ // Get Amount
52
+ //$amount = $order->getGrandTotal();
53
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
54
+
55
+ $ssn = Mage::getSingleton('checkout/session')->getSocialSecurtyNumber();
56
+ $credit_data = Mage::getSingleton('checkout/session')->getCreditData();
57
+
58
+ // Call PxOrder.Initialize8
59
+ $params = array(
60
+ 'accountNumber' => '',
61
+ 'purchaseOperation' => $operation,
62
+ 'price' => round($amount * 100),
63
+ 'priceArgList' => '',
64
+ 'currency' => $currency_code,
65
+ 'vat' => 0,
66
+ 'orderID' => $order_id,
67
+ 'productNumber' => $order_id,
68
+ 'description' => Mage::app()->getStore()->getName(),
69
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
70
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
71
+ 'additionalValues' => $additional,
72
+ 'externalID' => '',
73
+ 'returnUrl' => Mage::getUrl('payex/invoice/success', array('_secure' => true)),
74
+ 'view' => 'INVOICE',
75
+ 'agreementRef' => '',
76
+ 'cancelUrl' => Mage::getUrl('payex/invoice/cancel', array('_secure' => true)),
77
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
78
+ );
79
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
80
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
81
+
82
+ // Check Errors
83
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
84
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
85
+
86
+ // Cancel order
87
+ $order->cancel();
88
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
89
+ $order->save();
90
+
91
+ // Set quote to active
92
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
93
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
94
+ if ($quote->getId()) {
95
+ $quote->setIsActive(true)->save();
96
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
97
+ }
98
+ }
99
+
100
+ Mage::getSingleton('checkout/session')->addError($message);
101
+ $this->_redirect('checkout/cart');
102
+ return;
103
+ }
104
+ $order_ref = $result['orderRef'];
105
+
106
+ // Add Order Lines and Orders Address
107
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
108
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
109
+
110
+ $credit_data['full_name'] = $credit_data['firstName'] . ' ' . $credit_data['lastName'];
111
+
112
+ // Limit strings
113
+ $limit_rules = array(
114
+ 'full_name' => 35,
115
+ 'address' => 35,
116
+ 'postCode' => 9,
117
+ 'city' > 27
118
+ );
119
+ foreach ($credit_data as $key => $value) {
120
+ if (isset($limit_rules[$key])) {
121
+ if (mb_strlen($credit_data[$key], 'UTF-8') > $limit_rules[$key]) {
122
+ $credit_data[$key] = mb_substr($credit_data[$key], 0, $limit_rules[$key], 'UTF-8');
123
+ }
124
+ }
125
+ }
126
+
127
+ // Call Invoice Purchase
128
+ $result = array();
129
+ $px_method = Mage::getSingleton('checkout/session')->getMethod();
130
+ switch ($px_method)
131
+ {
132
+ case 'private':
133
+ // Call PxOrder.PurchaseInvoicePrivate
134
+ $params = array(
135
+ 'accountNumber' => '',
136
+ 'orderRef' => $order_ref,
137
+ 'customerRef' => $customer_id,
138
+ 'customerName' => $credit_data['full_name'],
139
+ 'streetAddress' => $credit_data['address'],
140
+ 'coAddress' => '',
141
+ 'postalCode' => $credit_data['postCode'],
142
+ 'city' => $credit_data['city'],
143
+ 'country' => $order->getBillingAddress()->getCountry(),
144
+ 'socialSecurityNumber' => $ssn,
145
+ 'phoneNumber' => '',
146
+ 'email' => $order->getBillingAddress()->getEmail(),
147
+ 'productCode' => '0001',
148
+ 'creditcheckRef' => '',
149
+ 'mediaDistribution' => $method->getConfigData('distribution'),
150
+ 'invoiceText' => $method->getConfigData('invoicetext'),
151
+ 'invoiceDate' => date('Y-m-d'),
152
+ 'invoiceDueDays' => $method->getConfigData('invoiceduedays'),
153
+ 'invoiceNumber' => $order_id,
154
+ 'invoiceLayout' => ''
155
+ );
156
+ $result = Mage::helper('payex/api')->getPx()->PurchaseInvoicePrivate($params);
157
+ Mage::helper('payex/tools')->addToDebug('PxOrder.PurchaseInvoicePrivate:' . $result['description']);
158
+ break;
159
+ case 'corporate':
160
+ // Call PxOrder.PurchaseInvoiceCorporate
161
+ $params = array(
162
+ 'accountNumber' => '',
163
+ 'orderRef' => $order_ref,
164
+ 'companyRef' => 'C' . $customer_id,
165
+ 'companyName' => $credit_data['name'], // Firm name
166
+ 'streetAddress' => $credit_data['address'],
167
+ 'coAddress' => $credit_data['address'],
168
+ 'postalCode' => $credit_data['postCode'],
169
+ 'city' => $credit_data['city'],
170
+ 'country' => $order->getBillingAddress()->getCountry(),
171
+ 'organizationNumber' => $ssn,
172
+ 'phoneNumber' => '',
173
+ 'email' => $order->getBillingAddress()->getEmail(),
174
+ 'productCode' => '0001',
175
+ 'creditcheckRef' => $method->getConfigData('unapproved') ? '' : $credit_data['creditCheckRef'],
176
+ 'mediaDistribution' => $method->getConfigData('distribution'),
177
+ 'invoiceText' => $method->getConfigData('invoicetext'),
178
+ 'invoiceDate' => date('Y-m-d'),
179
+ 'invoiceDueDays' => $method->getConfigData('invoiceduedays'),
180
+ 'invoiceNumber' => $order_id,
181
+ 'invoiceLayout' => ''
182
+ );
183
+ $result = Mage::helper('payex/api')->getPx()->PurchaseInvoiceCorporate($params);
184
+ Mage::helper('payex/tools')->addToDebug('PxOrder.PurchaseInvoiceCorporate:' . $result['description']);
185
+ break;
186
+ default:
187
+ Mage::throwException('Unknown payment method for invoice');
188
+ }
189
+
190
+ // Check Errors
191
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
192
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
193
+
194
+ // Cancel order
195
+ $order->cancel();
196
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
197
+ $order->save();
198
+
199
+ // Set quote to active
200
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
201
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
202
+ if ($quote->getId()) {
203
+ $quote->setIsActive(true)->save();
204
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
205
+ }
206
+ }
207
+
208
+ Mage::getSingleton('checkout/session')->addError($message);
209
+ $this->_redirect('checkout/cart');
210
+ return;
211
+ }
212
+
213
+ // Prevent Order cancellation when used TC
214
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
215
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
216
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
217
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
218
+ $order->save();
219
+
220
+ foreach ($order->getAllItems() as $item) {
221
+ $item->setQtyCanceled(0);
222
+ $item->save();
223
+ }
224
+ }
225
+
226
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
227
+ }
228
+
229
+ // Process Transaction
230
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
231
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
232
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
233
+
234
+ // Check Order and Transaction Result
235
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
236
+ switch ($transaction_status) {
237
+ case 0;
238
+ case 1;
239
+ case 3;
240
+ case 6:
241
+ // Select Order Status
242
+ if (in_array($transaction_status, array(0, 6))) {
243
+ $new_status = $method->getConfigData('order_status_capture');
244
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
245
+ $new_status = $method->getConfigData('order_status_authorize');
246
+ } else {
247
+ $new_status = $order->getStatus();
248
+ }
249
+
250
+ // Get Order Status
251
+ /** @var Mage_Sales_Model_Order_Status $status */
252
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
253
+
254
+ // Change order status
255
+ $order->setData('state', $status->getState());
256
+ $order->setStatus($status->getStatus());
257
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
258
+
259
+ // Create Invoice for Sale Transaction
260
+ if (in_array($transaction_status, array(0, 6))) {
261
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
262
+ $invoice->setTransactionId($result['transactionNumber']);
263
+ $invoice->save();
264
+
265
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
266
+ if ($transaction_status === 0) {
267
+ $order->setTotalPaid($order->getTotalDue());
268
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
269
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
270
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
271
+
272
+ // Update Order Totals because API V2 don't update order totals
273
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
274
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
275
+ ->setOrderFilter($order->getId())->getFirstItem();
276
+
277
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
278
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
279
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
280
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
281
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
282
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
283
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
284
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
285
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
286
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
287
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
288
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
289
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
290
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
291
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
292
+ }
293
+ }
294
+
295
+ $order->save();
296
+ $order->sendNewOrderEmail();
297
+
298
+ // Redirect to Success Page
299
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
300
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
301
+ break;
302
+ default:
303
+ // Cancel order
304
+ if ($transaction->getIsCancel()) {
305
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
306
+
307
+ $order->cancel();
308
+ $order->addStatusHistoryComment($transaction->getMessage());
309
+ $order->save();
310
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
311
+ }
312
+
313
+ // Set quote to active
314
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
315
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
316
+ if ($quote->getId()) {
317
+ $quote->setIsActive(true)->save();
318
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
319
+ }
320
+ }
321
+
322
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
323
+ $this->_redirect('checkout/cart');
324
+ }
325
+ }
326
+ }
app/code/community/PayEx/Payments/controllers/MasterpassController.php ADDED
@@ -0,0 +1,678 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_MasterpassController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_MasterPass');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Operation Type (AUTHORIZATION / SALE)
37
+ $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
38
+
39
+ // Get Amount
40
+ //$amount = $order->getGrandTotal();
41
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
42
+
43
+ $additional = 'USEMASTERPASS=1&RESPONSIVE=1&SHOPPINGCARTXML=' . urlencode( Mage::helper('payex/order')->getShoppingCartXML( $order ) );
44
+
45
+ // Call PxOrder.Initialize8
46
+ $params = array(
47
+ 'accountNumber' => '',
48
+ 'purchaseOperation' => $operation,
49
+ 'price' => round($amount * 100),
50
+ 'priceArgList' => '',
51
+ 'currency' => $currency_code,
52
+ 'vat' => 0,
53
+ 'orderID' => $order_id,
54
+ 'productNumber' => $order_id,
55
+ 'description' => Mage::app()->getStore()->getName(),
56
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
57
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
58
+ 'additionalValues' => $additional,
59
+ 'externalID' => '',
60
+ 'returnUrl' => Mage::getUrl('payex/masterpass/success', array('_secure' => true)),
61
+ 'view' => 'CREDITCARD',
62
+ 'agreementRef' => '',
63
+ 'cancelUrl' => Mage::getUrl('payex/masterpass/cancel', array('_secure' => true)),
64
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
65
+ );
66
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
67
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
68
+
69
+ // Check Errors
70
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
71
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
72
+
73
+ // Cancel order
74
+ $order->cancel();
75
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
76
+ $order->save();
77
+
78
+ // Set quote to active
79
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
80
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
81
+ if ($quote->getId()) {
82
+ $quote->setIsActive(true)->save();
83
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
84
+ }
85
+ }
86
+
87
+ Mage::getSingleton('checkout/session')->addError($message);
88
+ $this->_redirect('checkout/cart');
89
+ return;
90
+ }
91
+ //$order_ref = $result['orderRef'];
92
+ $redirectUrl = $result['redirectUrl'];
93
+
94
+ // Set Pending Payment status
95
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
96
+ $order->save();
97
+
98
+ // Redirect to PayEx
99
+ header('Location: ' . $redirectUrl);
100
+ exit();
101
+ }
102
+
103
+ public function successAction()
104
+ {
105
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
106
+
107
+ // Check OrderRef
108
+ if (empty($_GET['orderRef'])) {
109
+ $this->_redirect('checkout/cart');
110
+ return;
111
+ }
112
+
113
+ // Load Order
114
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
115
+
116
+ /** @var Mage_Sales_Model_Order $order */
117
+ $order = Mage::getModel('sales/order');
118
+ $order->loadByIncrementId($order_id);
119
+ if (!$order->getId()) {
120
+ Mage::throwException('No order for processing found');
121
+ }
122
+
123
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
124
+ $method = $order->getPayment()->getMethodInstance();
125
+
126
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
127
+
128
+ // Call PxOrder.FinalizeTransaction
129
+ $params = array(
130
+ 'accountNumber' => '',
131
+ 'orderRef' => $_GET['orderRef'],
132
+ 'amount' => round( $amount * 100 ),
133
+ 'vatAmount' => 0,
134
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr()
135
+ );
136
+ $result = Mage::helper('payex/api')->getPx()->FinalizeTransaction( $params );
137
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.FinalizeTransaction');
138
+ if ( $result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK' ) {
139
+ // Check order has already been purchased
140
+ //if ( $result['code'] === 'Order_AlreadyPerformed' ) {
141
+ // @todo
142
+ //}
143
+
144
+ // Cancel order
145
+ $order->cancel();
146
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
147
+ $order->save();
148
+
149
+ // Set quote to active
150
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
151
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
152
+ if ($quote->getId()) {
153
+ $quote->setIsActive(true)->save();
154
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
155
+ }
156
+ }
157
+
158
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
159
+ Mage::getSingleton('checkout/session')->addError($message);
160
+ $this->_redirect('checkout/cart');
161
+ return;
162
+ }
163
+
164
+ // Check Transaction is already registered
165
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
166
+ ->addAttributeToFilter('txn_id', $result['transactionNumber']);
167
+
168
+ if (count($collection) > 0) {
169
+ $transaction = $collection->getFirstItem();
170
+ $raw_details_info = $transaction->getAdditionalInformation('raw_details_info');
171
+ if (is_array($raw_details_info) && in_array((int)$result['transactionStatus'], array(0, 3, 6))) {
172
+ // Redirect to Success Page
173
+ Mage::helper('payex/tools')->addToDebug('Redirected to success page because transaction is already paid.', $order_id);
174
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
175
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
176
+ return;
177
+ }
178
+ }
179
+
180
+ // Prevent Order cancellation when used TC
181
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
182
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
183
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
184
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
185
+ $order->save();
186
+
187
+ foreach ($order->getAllItems() as $item) {
188
+ $item->setQtyCanceled(0);
189
+ $item->save();
190
+ }
191
+ }
192
+
193
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
194
+ }
195
+
196
+ // Process Transaction
197
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
198
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
199
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
200
+
201
+ // Check Order and Transaction Result
202
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
203
+ switch ($transaction_status) {
204
+ case 0;
205
+ case 1;
206
+ case 3;
207
+ case 6:
208
+ // Select Order Status
209
+ if (in_array($transaction_status, array(0, 6))) {
210
+ $new_status = $method->getConfigData('order_status_capture');
211
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
212
+ $new_status = $method->getConfigData('order_status_authorize');
213
+ } else {
214
+ $new_status = $order->getStatus();
215
+ }
216
+
217
+ // Get Order Status
218
+ /** @var Mage_Sales_Model_Order_Status $status */
219
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
220
+
221
+ // Change order status
222
+ $order->setData('state', $status->getState());
223
+ $order->setStatus($status->getStatus());
224
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
225
+
226
+ // Create Invoice for Sale Transaction
227
+ if (in_array($transaction_status, array(0, 6))) {
228
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
229
+ $invoice->setTransactionId($result['transactionNumber']);
230
+ $invoice->save();
231
+
232
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
233
+ if ($transaction_status === 0) {
234
+ $order->setTotalPaid($order->getTotalDue());
235
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
236
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
237
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
238
+
239
+ // Update Order Totals because API V2 don't update order totals
240
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
241
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
242
+ ->setOrderFilter($order->getId())->getFirstItem();
243
+
244
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
245
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
246
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
247
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
248
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
249
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
250
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
251
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
252
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
253
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
254
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
255
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
256
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
257
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
258
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
259
+ }
260
+ }
261
+
262
+ $order->save();
263
+ $order->sendNewOrderEmail();
264
+
265
+ // Redirect to Success Page
266
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
267
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
268
+ break;
269
+ default:
270
+ // Cancel order
271
+ if ($transaction->getIsCancel()) {
272
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
273
+
274
+ $order->cancel();
275
+ $order->addStatusHistoryComment($transaction->getMessage());
276
+ $order->save();
277
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
278
+ }
279
+
280
+ // Set quote to active
281
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
282
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
283
+ if ($quote->getId()) {
284
+ $quote->setIsActive(true)->save();
285
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
286
+ }
287
+ }
288
+
289
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
290
+ $this->_redirect('checkout/cart');
291
+ }
292
+ }
293
+
294
+ public function cancelAction()
295
+ {
296
+ Mage::helper('payex/tools')->addToDebug('Controller: cancel');
297
+
298
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
299
+
300
+ /** @var Mage_Sales_Model_Order $order */
301
+ $order = Mage::getModel('sales/order');
302
+ $order->loadByIncrementId($order_id);
303
+
304
+ // Note: Cancel only non-captured orders!
305
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
306
+ // Set Canceled State
307
+ $order->cancel();
308
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order canceled by user'), Mage_Sales_Model_Order::STATE_CANCELED);
309
+ $order->save();
310
+ }
311
+
312
+ // Set quote to active
313
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
314
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
315
+ if ($quote->getId()) {
316
+ $quote->setIsActive(true)->save();
317
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
318
+ }
319
+ }
320
+
321
+ Mage::getSingleton('checkout/session')->addError(Mage::helper('payex')->__('Order canceled by user'));
322
+ $this->_redirect('checkout/cart');
323
+ }
324
+
325
+ /**
326
+ * MasterPass Checkout Button Action
327
+ */
328
+ public function checkoutAction()
329
+ {
330
+ /** @var $quote Mage_Sales_Model_Quote */
331
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
332
+
333
+ try {
334
+ if (!$quote->hasItems()) {
335
+ Mage::throwException(Mage::helper('payex')->__('You don\'t have any items in your cart'));
336
+ }
337
+ if (!$quote->getGrandTotal() && !$quote->hasNominalItems()) {
338
+ Mage::throwException(Mage::helper('payex')->__('Order total is too small'));
339
+ }
340
+
341
+ // Set Payment Method
342
+ $quote->setPaymentMethod('payex_masterpass');
343
+
344
+ // Update totals
345
+ $quote->collectTotals();
346
+
347
+ // Create an Order ID for the customer's quote
348
+ $quote->reserveOrderId()->save();
349
+ } catch (Mage_Core_Exception $e) {
350
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
351
+ return $this->_redirect('checkout/cart');
352
+ }
353
+
354
+ // Get Operation Type (AUTHORIZATION / SALE)
355
+ $operation = (Mage::getSingleton('payex/payment_MasterPass')->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
356
+
357
+ // Get Additional Values
358
+ $additional = 'USEMASTERPASS=1&RESPONSIVE=1&SHOPPINGCARTXML=' . urlencode( Mage::helper('payex/order')->getShoppingCartXML( $quote ) );
359
+
360
+ // Call PxOrder.Initialize8
361
+ $params = array(
362
+ 'accountNumber' => '',
363
+ 'purchaseOperation' => $operation,
364
+ 'price' => round($quote->getGrandTotal() * 100),
365
+ 'priceArgList' => '',
366
+ 'currency' => $quote->getQuoteCurrencyCode(),
367
+ 'vat' => 0,
368
+ 'orderID' => $quote->getReservedOrderId(),
369
+ 'productNumber' => $quote->getReservedOrderId(),
370
+ 'description' => Mage::app()->getStore()->getName(),
371
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
372
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
373
+ 'additionalValues' => $additional,
374
+ 'externalID' => '',
375
+ 'returnUrl' => Mage::getUrl('payex/masterpass/mp_success', array('_secure' => true)),
376
+ 'view' => 'CREDITCARD',
377
+ 'agreementRef' => '',
378
+ 'cancelUrl' => Mage::getUrl('payex/masterpass/cancel', array('_secure' => true)),
379
+ 'clientLanguage' => Mage::getSingleton('payex/payment_MasterPass')->getConfigData('clientlanguage')
380
+ );
381
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
382
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
383
+
384
+ // Check Errors
385
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
386
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
387
+ // Set quote to active
388
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
389
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
390
+ if ($quote->getId()) {
391
+ $quote->setIsActive(true)->save();
392
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
393
+ }
394
+ }
395
+
396
+ Mage::getSingleton('checkout/session')->addError($message);
397
+ $this->_redirect('checkout/cart');
398
+ return;
399
+ }
400
+
401
+ //$order_ref = $result['orderRef'];
402
+ $redirectUrl = $result['redirectUrl'];
403
+
404
+ // Set quote to inactive
405
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
406
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
407
+ Mage::getSingleton('checkout/session')->clear();
408
+
409
+ // Redirect to PayEx
410
+ header('Location: ' . $redirectUrl);
411
+ exit();
412
+ }
413
+
414
+ public function mp_successAction() {
415
+ // Check OrderRef
416
+ if (empty($_GET['orderRef'])) {
417
+ $this->_redirect('checkout/cart');
418
+ return;
419
+ }
420
+
421
+ $orderRef = $_GET['orderRef'];
422
+
423
+ // Set quote to active
424
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
425
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
426
+ if ($quote->getId()) {
427
+ $quote->setIsActive(true)->save();
428
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
429
+ }
430
+ }
431
+
432
+ /** @var $quote Mage_Sales_Model_Quote */
433
+ $quote = Mage::getSingleton('checkout/session')->getQuote();
434
+
435
+ // Call PxOrder.GetApprovedDeliveryAddress
436
+ $params = array(
437
+ 'accountNumber' => '',
438
+ 'orderRef' => $orderRef
439
+ );
440
+ $result = Mage::helper('payex/api')->getPx()->GetApprovedDeliveryAddress( $params );
441
+ if ( $result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK' ) {
442
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
443
+
444
+ Mage::getSingleton('checkout/session')->addError($message);
445
+ $this->_redirect('checkout/cart');
446
+ return;
447
+ }
448
+
449
+ // @todo "Please check shipping address information. Please enter the state/province."
450
+
451
+ // Billing Address
452
+ $billingAddress = array(
453
+ 'firstname' => $result['firstName'],
454
+ 'lastname' => $result['lastName'],
455
+ 'company' => '',
456
+ 'email' => $result['eMail'],
457
+ 'street' => array(
458
+ $result['address1'],
459
+ trim($result['address2'] . ' ' . $result['address3'])
460
+ ),
461
+ 'city' => ucfirst($result['city']),
462
+ 'region_id' => '',
463
+ 'region' => '',
464
+ 'postcode' => str_replace(' ', '', $result['postalCode']),
465
+ 'country_id' => $result['country'],
466
+ 'telephone' => $result['phone'],
467
+ 'fax' => '',
468
+ 'customer_password' => '',
469
+ 'confirm_password' => '',
470
+ 'save_in_address_book' => '0',
471
+ 'use_for_shipping' => '1',
472
+ );
473
+
474
+ // Set Billing Address
475
+ $quote->getBillingAddress()
476
+ ->addData($billingAddress);
477
+
478
+ // Set Shipping Address
479
+ $shipping = $quote->getShippingAddress()
480
+ ->addData($billingAddress);
481
+
482
+ // Set Shipping Method
483
+ if (!$quote->isVirtual()) {
484
+ $shipping_method = Mage::getSingleton('payex/payment_MasterPass')->getConfigData('shipping_method');
485
+ $shipping->setCollectShippingRates(true)->collectShippingRates()
486
+ ->setShippingMethod($shipping_method);
487
+
488
+ //$quote->getShippingAddress()->setShippingMethod($shipping_method);
489
+ }
490
+
491
+ // Use Check Money Payment Method
492
+ $quote->setPaymentMethod('payex_masterpass');
493
+
494
+ // Update totals
495
+ $quote->collectTotals();
496
+
497
+ // Set Checkout Method
498
+ if (!Mage::getSingleton('customer/session')->isLoggedIn()) {
499
+ // Use Guest Checkout
500
+ $quote->setCheckoutMethod('guest')
501
+ ->setCustomerId(null)
502
+ ->setCustomerEmail($quote->getBillingAddress()->getEmail())
503
+ ->setCustomerIsGuest(true)
504
+ ->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
505
+ } else {
506
+ $customer = Mage::getSingleton('customer/session')->getCustomer();
507
+ $quote
508
+ ->setCustomer($customer)
509
+ ->setCheckoutMethod($customer->getMode())
510
+ ->save();
511
+ }
512
+
513
+ $quote->getPayment()->importData(array('method' => 'payex_masterpass'));
514
+
515
+ // Save Order
516
+ try {
517
+ $quote->save();
518
+
519
+ /** @var Mage_Sales_Model_Service_Quote $service */
520
+ $service = Mage::getModel('sales/service_quote', $quote);
521
+ if (method_exists($service, 'submitAll')) {
522
+ $service->submitAll();
523
+ $order = $service->getOrder();
524
+ } else {
525
+ $order = $service->submit();
526
+ }
527
+ } catch (Exception $e) {
528
+ Mage::getSingleton('checkout/session')->addError($e->getMessage());
529
+ $this->_redirect('checkout/cart');
530
+ return;
531
+ }
532
+
533
+ // Get Order Id
534
+ $order_id = $order->getIncrementId();
535
+
536
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
537
+ $method = $order->getPayment()->getMethodInstance();
538
+
539
+ // Call PxOrder.FinalizeTransaction
540
+ $params = array(
541
+ 'accountNumber' => '',
542
+ 'orderRef' => $orderRef,
543
+ 'amount' => round( $order->getGrandTotal() * 100 ),
544
+ 'vatAmount' => 0,
545
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr()
546
+ );
547
+ $result = Mage::helper('payex/api')->getPx()->FinalizeTransaction( $params );
548
+ if ( $result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK' ) {
549
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
550
+
551
+ // Cancel order
552
+ $order->cancel();
553
+ $order->addStatusHistoryComment($message);
554
+ $order->save();
555
+
556
+ // Check order has already been purchased
557
+ //if ($result['code'] === 'Order_AlreadyPerformed') {
558
+ // @todo
559
+ //}
560
+
561
+ Mage::getSingleton('checkout/session')->addError($message);
562
+ $this->_redirect('checkout/cart');
563
+ return;
564
+ }
565
+
566
+ // Check Transaction is already registered
567
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
568
+ ->addAttributeToFilter('txn_id', $result['transactionNumber']);
569
+
570
+ if (count($collection) > 0) {
571
+ $transaction = $collection->getFirstItem();
572
+ $raw_details_info = $transaction->getAdditionalInformation('raw_details_info');
573
+ if (is_array($raw_details_info) && in_array((int)$result['transactionStatus'], array(0, 3, 6))) {
574
+ // Redirect to Success Page
575
+ Mage::helper('payex/tools')->addToDebug('Redirected to success page because transaction is already paid.', $order_id);
576
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
577
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
578
+ return;
579
+ }
580
+ }
581
+
582
+ // Process Transaction
583
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
584
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
585
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
586
+
587
+ // Check Order and Transaction Result
588
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
589
+ switch ($transaction_status) {
590
+ case 0;
591
+ case 1;
592
+ case 3;
593
+ case 6:
594
+ // Select Order Status
595
+ if (in_array($transaction_status, array(0, 6))) {
596
+ $new_status = $method->getConfigData('order_status_capture');
597
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
598
+ $new_status = $method->getConfigData('order_status_authorize');
599
+ } else {
600
+ $new_status = $order->getStatus();
601
+ }
602
+
603
+ // Get Order Status
604
+ /** @var Mage_Sales_Model_Order_Status $status */
605
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
606
+
607
+ // Change order status
608
+ $order->setData('state', $status->getState());
609
+ $order->setStatus($status->getStatus());
610
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
611
+
612
+ // Create Invoice for Sale Transaction
613
+ if (in_array($transaction_status, array(0, 6))) {
614
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
615
+ $invoice->setTransactionId($result['transactionNumber']);
616
+ $invoice->save();
617
+
618
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
619
+ if ($transaction_status === 0) {
620
+ $order->setTotalPaid($order->getTotalDue());
621
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
622
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
623
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
624
+
625
+ // Update Order Totals because API V2 don't update order totals
626
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
627
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
628
+ ->setOrderFilter($order->getId())->getFirstItem();
629
+
630
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
631
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
632
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
633
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
634
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
635
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
636
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
637
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
638
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
639
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
640
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
641
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
642
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
643
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
644
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
645
+ }
646
+ }
647
+
648
+ $order->save();
649
+ $order->sendNewOrderEmail();
650
+
651
+ // Empty Cart
652
+ //$quote->setIsActive(0)->save();
653
+ Mage::getSingleton('checkout/cart')->truncate()->save();
654
+
655
+ // Redirect to Success page
656
+ $session = Mage::getSingleton('checkout/type_onepage')->getCheckout();
657
+ $session->setLastSuccessQuoteId($quote->getId());
658
+ $session->setLastQuoteId($quote->getId());
659
+ $session->setLastOrderId($order->getId());
660
+
661
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
662
+ break;
663
+ default:
664
+ // Cancel order
665
+ if ($transaction->getIsCancel()) {
666
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
667
+
668
+ $order->cancel();
669
+ $order->addStatusHistoryComment($transaction->getMessage());
670
+ $order->save();
671
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
672
+ }
673
+
674
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
675
+ $this->_redirect('checkout/cart');
676
+ }
677
+ }
678
+ }
app/code/community/PayEx/Payments/controllers/PartpaymentController.php ADDED
@@ -0,0 +1,270 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_PartpaymentController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_PartPayment');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Social Security Number from Session
34
+ $ssn = Mage::getSingleton('checkout/session')->getSocialSecurityNumber();
35
+
36
+ // Get Currency code
37
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
38
+
39
+ // Get Amount
40
+ //$amount = $order->getGrandTotal();
41
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
42
+
43
+ // Call PxOrder.Initialize8
44
+ $params = array(
45
+ 'accountNumber' => '',
46
+ 'purchaseOperation' => 'AUTHORIZATION',
47
+ 'price' => round($amount * 100),
48
+ 'priceArgList' => '',
49
+ 'currency' => $currency_code,
50
+ 'vat' => 0,
51
+ 'orderID' => $order_id,
52
+ 'productNumber' => $order_id,
53
+ 'description' => Mage::app()->getStore()->getName(),
54
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
55
+ 'clientIdentifier' => '',
56
+ 'additionalValues' => '',
57
+ 'externalID' => '',
58
+ 'returnUrl' => 'http://localhost.no/return',
59
+ 'view' => 'FINANCING',
60
+ 'agreementRef' => '',
61
+ 'cancelUrl' => 'http://localhost.no/cancel',
62
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
63
+ );
64
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
65
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
66
+
67
+ // Check Errors
68
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
69
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
70
+
71
+ // Cancel order
72
+ $order->cancel();
73
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
74
+ $order->save();
75
+
76
+ // Set quote to active
77
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
78
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
79
+ if ($quote->getId()) {
80
+ $quote->setIsActive(true)->save();
81
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
82
+ }
83
+ }
84
+
85
+ Mage::getSingleton('checkout/session')->addError($message);
86
+ $this->_redirect('checkout/cart');
87
+ return;
88
+ }
89
+ $order_ref = $result['orderRef'];
90
+
91
+ // Call PxOrder.PurchaseCreditAccount
92
+ $params = array(
93
+ 'accountNumber' => '',
94
+ 'orderRef' => $order_ref,
95
+ 'socialSecurityNumber' => $ssn,
96
+ 'legalName' => $order->getBillingAddress()->getName(),
97
+ 'streetAddress' => $order->getBillingAddress()->getStreet(-1),
98
+ 'coAddress' => '',
99
+ 'zipCode' => $order->getBillingAddress()->getPostcode(),
100
+ 'city' => $order->getBillingAddress()->getCity(),
101
+ 'countryCode' => $order->getBillingAddress()->getCountry(),
102
+ 'paymentMethod' => $order->getBillingAddress()->getCountry() === 'SE' ? 'PXCREDITACCOUNTSE' : 'PXCREDITACCOUNTNO',
103
+ 'email' => $order->getBillingAddress()->getEmail(),
104
+ 'msisdn' => (mb_substr($order->getBillingAddress()->getTelephone(), 0, 1) === '+') ? $order->getBillingAddress()->getTelephone() : '+' . $order->getBillingAddress()->getTelephone(),
105
+ 'ipAddress' => Mage::helper('core/http')->getRemoteAddr()
106
+ );
107
+ $result = Mage::helper('payex/api')->getPx()->PurchaseCreditAccount($params);
108
+ Mage::helper('payex/tools')->addToDebug('PxOrder.PurchaseCreditAccount:' . $result['description']);
109
+
110
+ // Check Errors
111
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK') {
112
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
113
+
114
+ // Cancel order
115
+ $order->cancel();
116
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
117
+ $order->save();
118
+
119
+ // Set quote to active
120
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
121
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
122
+ if ($quote->getId()) {
123
+ $quote->setIsActive(true)->save();
124
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
125
+ }
126
+ }
127
+
128
+ Mage::getSingleton('checkout/session')->addError($message);
129
+ $this->_redirect('checkout/cart');
130
+ return;
131
+ }
132
+
133
+ // Validate transactionStatus value
134
+ if (empty($result['transactionStatus']) || !is_numeric($result['transactionStatus'])) {
135
+ $message = Mage::helper('payex')->__('Error: No transactionsStatus in response.');
136
+ Mage::helper('payex/tools')->addToDebug('Error: No transactionsStatus in response.', $order->getIncrementId());
137
+
138
+ // Cancel order
139
+ $order->cancel();
140
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
141
+ $order->save();
142
+
143
+ // Set quote to active
144
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
145
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
146
+ if ($quote->getId()) {
147
+ $quote->setIsActive(true)->save();
148
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
149
+ }
150
+ }
151
+
152
+ Mage::getSingleton('checkout/session')->addError($message);
153
+ $this->_redirect('checkout/cart');
154
+ return;
155
+ }
156
+
157
+ // Prevent Order cancellation when used TC
158
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
159
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
160
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
161
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
162
+ $order->save();
163
+
164
+ foreach ($order->getAllItems() as $item) {
165
+ $item->setQtyCanceled(0);
166
+ $item->save();
167
+ }
168
+ }
169
+
170
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
171
+ }
172
+
173
+ // Process Transaction
174
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
175
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
176
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
177
+
178
+ // Check Order and Transaction Result
179
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
180
+ switch ($transaction_status) {
181
+ case 0;
182
+ case 1;
183
+ case 3;
184
+ case 6:
185
+ // Select Order Status
186
+ if (in_array($transaction_status, array(0, 6))) {
187
+ $new_status = $method->getConfigData('order_status_capture');
188
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
189
+ $new_status = $method->getConfigData('order_status_authorize');
190
+ } else {
191
+ $new_status = $order->getStatus();
192
+ }
193
+
194
+ // Get Order Status
195
+ /** @var Mage_Sales_Model_Order_Status $status */
196
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
197
+
198
+ // Change order status
199
+ $order->setData('state', $status->getState());
200
+ $order->setStatus($status->getStatus());
201
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
202
+
203
+ // Create Invoice for Sale Transaction
204
+ if (in_array($transaction_status, array(0, 6))) {
205
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
206
+ $invoice->setTransactionId($result['transactionNumber']);
207
+ $invoice->save();
208
+
209
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
210
+ if ($transaction_status === 0) {
211
+ $order->setTotalPaid($order->getTotalDue());
212
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
213
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
214
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
215
+
216
+ // Update Order Totals because API V2 don't update order totals
217
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
218
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
219
+ ->setOrderFilter($order->getId())->getFirstItem();
220
+
221
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
222
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
223
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
224
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
225
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
226
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
227
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
228
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
229
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
230
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
231
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
232
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
233
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
234
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
235
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
236
+ }
237
+ }
238
+
239
+ $order->save();
240
+ $order->sendNewOrderEmail();
241
+
242
+ // Redirect to Success Page
243
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
244
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
245
+ break;
246
+ default:
247
+ // Cancel order
248
+ if ($transaction->getIsCancel()) {
249
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
250
+
251
+ $order->cancel();
252
+ $order->addStatusHistoryComment($transaction->getMessage());
253
+ $order->save();
254
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
255
+ }
256
+
257
+ // Set quote to active
258
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
259
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
260
+ if ($quote->getId()) {
261
+ $quote->setIsActive(true)->save();
262
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
263
+ }
264
+ }
265
+
266
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
267
+ $this->_redirect('checkout/cart');
268
+ }
269
+ }
270
+ }
app/code/community/PayEx/Payments/controllers/PaymentController.php ADDED
@@ -0,0 +1,351 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_PaymentController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_CC');
9
+ }
10
+
11
+ /**
12
+ * @throws Exception
13
+ * @throws Mage_Core_Exception
14
+ */
15
+ public function redirectAction()
16
+ {
17
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
18
+
19
+ // Load Order
20
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
21
+
22
+ /** @var Mage_Sales_Model_Order $order */
23
+ $order = Mage::getModel('sales/order');
24
+ $order->loadByIncrementId($order_id);
25
+ if (!$order->getId()) {
26
+ Mage::throwException('No order for processing found');
27
+ }
28
+
29
+ // Set quote to inactive
30
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
31
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
32
+ Mage::getSingleton('checkout/session')->clear();
33
+
34
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
35
+ $method = $order->getPayment()->getMethodInstance();
36
+
37
+ // Get Currency code
38
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
39
+
40
+ // Get Operation Type (AUTHORIZATION / SALE)
41
+ $operation = ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE';
42
+
43
+ // Get Payment Type (PX, CREDITCARD etc)
44
+ $paymentview = $method->getConfigData('paymentview');
45
+
46
+ // Get Additional Values
47
+ $additional = ($paymentview === 'PX' ? 'PAYMENTMENU=TRUE' : '');
48
+
49
+ // Direct Debit uses 'SALE' only
50
+ if ($paymentview === 'DIRECTDEBIT') {
51
+ $operation = 'SALE';
52
+ }
53
+
54
+ // Responsive Skinning
55
+ if ($method->getConfigData('responsive') === '1') {
56
+ $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
57
+
58
+ // PayEx Payment Page 2.0 works only for View 'Credit Card' and 'Direct Debit' at the moment
59
+ if (in_array($paymentview, array('CREDITCARD', 'DIRECTDEBIT'))) {
60
+ $additional .= $separator . 'RESPONSIVE=1';
61
+ } else {
62
+ $additional .= $separator . 'USECSS=RESPONSIVEDESIGN';
63
+ }
64
+ }
65
+
66
+ // Get Amount
67
+ //$amount = $order->getGrandTotal();
68
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
69
+
70
+ // Call PxOrder.Initialize8
71
+ $params = array(
72
+ 'accountNumber' => '',
73
+ 'purchaseOperation' => $operation,
74
+ 'price' => round($amount * 100),
75
+ 'priceArgList' => '',
76
+ 'currency' => $currency_code,
77
+ 'vat' => 0,
78
+ 'orderID' => $order_id,
79
+ 'productNumber' => $order_id,
80
+ 'description' => Mage::app()->getStore()->getName(),
81
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
82
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
83
+ 'additionalValues' => $additional,
84
+ 'externalID' => '',
85
+ 'returnUrl' => Mage::getUrl('payex/payment/success', array('_secure' => true)),
86
+ 'view' => $paymentview,
87
+ 'agreementRef' => '',
88
+ 'cancelUrl' => Mage::getUrl('payex/payment/cancel', array('_secure' => true)),
89
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
90
+ );
91
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
92
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
93
+
94
+ // Check Errors
95
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
96
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
97
+
98
+ // Cancel order
99
+ $order->cancel();
100
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
101
+ $order->save();
102
+
103
+ // Set quote to active
104
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
105
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
106
+ if ($quote->getId()) {
107
+ $quote->setIsActive(true)->save();
108
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
109
+ }
110
+ }
111
+
112
+ Mage::getSingleton('checkout/session')->addError($message);
113
+ $this->_redirect('checkout/cart');
114
+ return;
115
+ }
116
+ $order_ref = $result['orderRef'];
117
+ $redirectUrl = $result['redirectUrl'];
118
+
119
+ // Add Order Lines and Orders Address
120
+ if ($method->getConfigData('checkoutinfo')) {
121
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
122
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
123
+ }
124
+
125
+ // Set Pending Payment status
126
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
127
+ $order->save();
128
+
129
+ // Redirect to PayEx
130
+ header('Location: ' . $redirectUrl);
131
+ exit();
132
+ }
133
+
134
+ /**
135
+ * @throws Exception
136
+ * @throws Mage_Core_Exception
137
+ */
138
+ public function successAction()
139
+ {
140
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
141
+
142
+ // Check OrderRef
143
+ if (empty($_GET['orderRef'])) {
144
+ $this->_redirect('checkout/cart');
145
+ return;
146
+ }
147
+
148
+ // Load Order
149
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
150
+
151
+ /** @var Mage_Sales_Model_Order $order */
152
+ $order = Mage::getModel('sales/order');
153
+ $order->loadByIncrementId($order_id);
154
+ if (!$order->getId()) {
155
+ Mage::throwException('No order for processing found');
156
+ }
157
+
158
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
159
+ $method = $order->getPayment()->getMethodInstance();
160
+
161
+ // Call PxOrder.Complete
162
+ $params = array(
163
+ 'accountNumber' => '',
164
+ 'orderRef' => $_GET['orderRef']
165
+ );
166
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
167
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
168
+ if ($result['errorCodeSimple'] !== 'OK') {
169
+ // Cancel order
170
+ $order->cancel();
171
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
172
+ $order->save();
173
+
174
+ // Set quote to active
175
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
176
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
177
+ if ($quote->getId()) {
178
+ $quote->setIsActive(true)->save();
179
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
180
+ }
181
+ }
182
+
183
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
184
+ Mage::getSingleton('checkout/session')->addError($message);
185
+ $this->_redirect('checkout/cart');
186
+ return;
187
+ }
188
+
189
+ // Check Transaction is already registered
190
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
191
+ ->addAttributeToFilter('txn_id', $result['transactionNumber']);
192
+ if (count($collection) > 0) {
193
+ $transaction = $collection->getFirstItem();
194
+ $raw_details_info = $transaction->getAdditionalInformation('raw_details_info');
195
+ if (is_array($raw_details_info) && in_array((int)$result['transactionStatus'], array(0, 3, 6))) {
196
+ // Redirect to Success Page
197
+ Mage::helper('payex/tools')->addToDebug('Redirected to success page because transaction is already paid.', $order_id);
198
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
199
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
200
+ return;
201
+ }
202
+ }
203
+
204
+ // Prevent Order cancellation when used TC
205
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
206
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
207
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
208
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
209
+ $order->save();
210
+
211
+ foreach ($order->getAllItems() as $item) {
212
+ $item->setQtyCanceled(0);
213
+ $item->save();
214
+ }
215
+ }
216
+
217
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
218
+ }
219
+
220
+ // Process Transaction
221
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
222
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
223
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
224
+
225
+ // Check Order and Transaction Result
226
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
227
+ switch ($transaction_status) {
228
+ case 0;
229
+ case 1;
230
+ case 3;
231
+ case 6:
232
+ // Select Order Status
233
+ if (in_array($transaction_status, array(0, 6))) {
234
+ $new_status = $method->getConfigData('order_status_capture');
235
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
236
+ $new_status = $method->getConfigData('order_status_authorize');
237
+ } else {
238
+ $new_status = $order->getStatus();
239
+ }
240
+
241
+ // Get Order Status
242
+ /** @var Mage_Sales_Model_Order_Status $status */
243
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
244
+
245
+ // Change order status
246
+ $order->setData('state', $status->getState());
247
+ $order->setStatus($status->getStatus());
248
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
249
+
250
+ // Create Invoice for Sale Transaction
251
+ if (in_array($transaction_status, array(0, 6))) {
252
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
253
+ $invoice->setTransactionId($result['transactionNumber']);
254
+ $invoice->save();
255
+
256
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
257
+ if ($transaction_status === 0) {
258
+ $order->setTotalPaid($order->getTotalDue());
259
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
260
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
261
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
262
+
263
+ // Update Order Totals because API V2 don't update order totals
264
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
265
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
266
+ ->setOrderFilter($order->getId())->getFirstItem();
267
+
268
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
269
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
270
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
271
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
272
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
273
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
274
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
275
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
276
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
277
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
278
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
279
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
280
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
281
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
282
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
283
+ }
284
+ }
285
+
286
+ $order->save();
287
+ $order->sendNewOrderEmail();
288
+
289
+ // Redirect to Success Page
290
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
291
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
292
+ break;
293
+ default:
294
+ // Cancel order
295
+ if ($transaction->getIsCancel()) {
296
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
297
+
298
+ $order->cancel();
299
+ $order->addStatusHistoryComment($transaction->getMessage());
300
+ $order->save();
301
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
302
+ }
303
+
304
+ // Set quote to active
305
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
306
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
307
+ if ($quote->getId()) {
308
+ $quote->setIsActive(true)->save();
309
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
310
+ }
311
+ }
312
+
313
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
314
+ $this->_redirect('checkout/cart');
315
+ }
316
+ }
317
+
318
+ /**
319
+ * @throws Exception
320
+ */
321
+ public function cancelAction()
322
+ {
323
+ Mage::helper('payex/tools')->addToDebug('Controller: cancel');
324
+
325
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
326
+
327
+ /** @var Mage_Sales_Model_Order $order */
328
+ $order = Mage::getModel('sales/order');
329
+ $order->loadByIncrementId($order_id);
330
+
331
+ // Note: Cancel only non-captured orders!
332
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
333
+ // Set Canceled State
334
+ $order->cancel();
335
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order canceled by user'), Mage_Sales_Model_Order::STATE_CANCELED);
336
+ $order->save();
337
+ }
338
+
339
+ // Set quote to active
340
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
341
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
342
+ if ($quote->getId()) {
343
+ $quote->setIsActive(true)->save();
344
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
345
+ }
346
+ }
347
+
348
+ Mage::getSingleton('checkout/session')->addError(Mage::helper('payex')->__('Order canceled by user'));
349
+ $this->_redirect('checkout/cart');
350
+ }
351
+ }
app/code/community/PayEx/Payments/controllers/SwishController.php ADDED
@@ -0,0 +1,281 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_SwishController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_swish');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Additional Values
37
+ $additional = '';
38
+
39
+ // Responsive Skinning
40
+ if ($method->getConfigData('responsive') === '1') {
41
+ $separator = (!empty($additional) && mb_substr($additional, -1) !== '&') ? '&' : '';
42
+ $additional .= $separator . 'RESPONSIVE=1';
43
+ }
44
+
45
+ // Get Amount
46
+ //$amount = $order->getGrandTotal();
47
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
48
+
49
+ // Get Bank Id
50
+ $bank_id = Mage::getSingleton('checkout/session')->getBankId();
51
+
52
+ Mage::helper('payex/tools')->addToDebug('Selected bank: '.$bank_id);
53
+
54
+ // Call PxOrder.Initialize8
55
+ $params = array(
56
+ 'accountNumber' => '',
57
+ 'purchaseOperation' => 'SALE', // for Swish uses SALE method only
58
+ 'price' => round($amount * 100),
59
+ 'priceArgList' => '',
60
+ 'currency' => $currency_code,
61
+ 'vat' => 0,
62
+ 'orderID' => $order_id,
63
+ 'productNumber' => $order_id,
64
+ 'description' => Mage::app()->getStore()->getName(),
65
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
66
+ 'clientIdentifier' => 'USERAGENT=' . Mage::helper('core/http')->getHttpUserAgent(),
67
+ 'additionalValues' => $additional,
68
+ 'externalID' => '',
69
+ 'returnUrl' => Mage::getUrl('payex/swish/success', array('_secure' => true)),
70
+ 'view' => 'SWISH',
71
+ 'agreementRef' => '',
72
+ 'cancelUrl' => Mage::getUrl('payex/swish/cancel', array('_secure' => true)),
73
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
74
+ );
75
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
76
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Initialize8');
77
+
78
+ // Check Errors
79
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
80
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
81
+
82
+ // Cancel order
83
+ $order->cancel();
84
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
85
+ $order->save();
86
+
87
+ // Set quote to active
88
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
89
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
90
+ if ($quote->getId()) {
91
+ $quote->setIsActive(true)->save();
92
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
93
+ }
94
+ }
95
+
96
+ Mage::getSingleton('checkout/session')->addError($message);
97
+ $this->_redirect('checkout/cart');
98
+ return;
99
+ }
100
+ Mage::helper('payex/tools')->addToDebug('Redirect URL: ' . $result['redirectUrl']);
101
+ $order_ref = $result['orderRef'];
102
+
103
+ // Add Order Lines and Orders Address
104
+ if ($method->getConfigData('checkoutinfo')) {
105
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
106
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
107
+ }
108
+
109
+ // Set Pending Payment status
110
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
111
+ $order->save();
112
+
113
+ // Redirect to Bank
114
+ header('Location: ' . $result['redirectUrl']);
115
+ exit();
116
+ }
117
+
118
+ public function successAction()
119
+ {
120
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
121
+
122
+ // Check OrderRef
123
+ if (empty($_GET['orderRef'])) {
124
+ $this->_redirect('checkout/cart');
125
+ }
126
+
127
+ // Load Order
128
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
129
+
130
+ /** @var Mage_Sales_Model_Order $order */
131
+ $order = Mage::getModel('sales/order');
132
+ $order->loadByIncrementId($order_id);
133
+ if (!$order->getId()) {
134
+ Mage::throwException('No order for processing found');
135
+ }
136
+
137
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
138
+ $method = $order->getPayment()->getMethodInstance();
139
+
140
+ // Call PxOrder.Complete
141
+ $params = array(
142
+ 'accountNumber' => '',
143
+ 'orderRef' => $_GET['orderRef']
144
+ );
145
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
146
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
147
+ if ($result['errorCodeSimple'] !== 'OK') {
148
+ // Cancel order
149
+ $order->cancel();
150
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
151
+ $order->save();
152
+
153
+ // Set quote to active
154
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
155
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
156
+ if ($quote->getId()) {
157
+ $quote->setIsActive(true)->save();
158
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
159
+ }
160
+ }
161
+
162
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
163
+ Mage::getSingleton('checkout/session')->addError($message);
164
+ $this->_redirect('checkout/cart');
165
+ return;
166
+ }
167
+
168
+ // Prevent Order cancellation when used TC
169
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
170
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
171
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
172
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
173
+ $order->save();
174
+
175
+ foreach ($order->getAllItems() as $item) {
176
+ $item->setQtyCanceled(0);
177
+ $item->save();
178
+ }
179
+ }
180
+
181
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
182
+ }
183
+
184
+ // Process Transaction
185
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
186
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
187
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
188
+
189
+ // Check Order and Transaction Result
190
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
191
+ switch ($transaction_status) {
192
+ case 0;
193
+ case 1;
194
+ case 3;
195
+ case 6:
196
+ // Select Order Status
197
+ $new_status = $method->getConfigData('order_status');
198
+ if (empty($new_status)) {
199
+ $new_status = $order->getStatus();
200
+ }
201
+
202
+ // Get Order Status
203
+ /** @var Mage_Sales_Model_Order_Status $status */
204
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
205
+
206
+ // Change order status
207
+ $order->setData('state', $status->getState());
208
+ $order->setStatus($status->getStatus());
209
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
210
+
211
+ // Create Invoice for Sale Transaction
212
+ if (in_array($transaction_status, array(0, 6))) {
213
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
214
+ $invoice->setTransactionId($result['transactionNumber']);
215
+ $invoice->save();
216
+
217
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
218
+ if ($transaction_status === 0) {
219
+ $order->setTotalPaid($order->getTotalDue());
220
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
221
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
222
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
223
+
224
+ // Update Order Totals because API V2 don't update order totals
225
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
226
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
227
+ ->setOrderFilter($order->getId())->getFirstItem();
228
+
229
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
230
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
231
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
232
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
233
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
234
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
235
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
236
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
237
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
238
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
239
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
240
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
241
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
242
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
243
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
244
+ }
245
+ }
246
+
247
+ $order->save();
248
+ $order->sendNewOrderEmail();
249
+
250
+ // Redirect to Success Page
251
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
252
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
253
+ break;
254
+ default:
255
+ // Cancel order
256
+ if ($transaction->getIsCancel()) {
257
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
258
+
259
+ $order->cancel();
260
+ $order->addStatusHistoryComment($transaction->getMessage());
261
+ $order->save();
262
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
263
+ }
264
+
265
+ // Set quote to active
266
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
267
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
268
+ if ($quote->getId()) {
269
+ $quote->setIsActive(true)->save();
270
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
271
+ }
272
+ }
273
+
274
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
275
+ $this->_redirect('checkout/cart');
276
+ }
277
+ }
278
+
279
+
280
+ }
281
+
app/code/community/PayEx/Payments/controllers/TransactionController.php ADDED
@@ -0,0 +1,272 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_TransactionController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ /** @var array PayEx TC Spider IPs */
6
+ static protected $_allowed_ips = array(
7
+ '82.115.146.170', // Production
8
+ '82.115.146.10' // Test
9
+ );
10
+
11
+ /**
12
+ * PayEx Transaction Callback
13
+ * @see http://www.payexpim.com/quick-guide/9-transaction-callback/
14
+ * @return mixed
15
+ */
16
+ public function indexAction()
17
+ {
18
+ /**
19
+ * Test it using:
20
+ * curl --verbose http://www.xxxxx.xxx/index.php/payex/transaction -d "transactionRef=81596cd7410546c68c1f6046c&transactionNumber=40805420&orderRef=503e6fba843447bb892c70912bbffbde&zzzz=must be here to get http post to work" --location
21
+ */
22
+ $remote_addr = Mage::helper('core/http')->getRemoteAddr();
23
+ Mage::helper('payex/tools')->addToDebug('TC: Requested from: ' . $remote_addr);
24
+
25
+ // Check is PayEx Request
26
+ if (!in_array($remote_addr, self::$_allowed_ips)) {
27
+ Mage::helper('payex/tools')->addToDebug('TC: Access denied for this request. It\'s not PayEx Spider.');
28
+ header(sprintf('%s %s %s', 'HTTP/1.1', '403', 'Access denied. Accept PayEx Transaction Callback only.'), true, '403');
29
+ header(sprintf('Status: %s %s', '403', 'Access denied. Accept PayEx Transaction Callback only.'), true, '403');
30
+ exit('Error: Access denied. Accept PayEx Transaction Callback only. ');
31
+ }
32
+
33
+ // Check Post Fields
34
+ Mage::helper('payex/tools')->addToDebug('TC: Requested Params: ' . var_export($_POST, true));
35
+ if (count($_POST) == 0) {
36
+ Mage::helper('payex/tools')->addToDebug('TC: Error: Empty request received.');
37
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
38
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
39
+ exit('FAILURE');
40
+ }
41
+
42
+ // Detect Payment Method of Order
43
+ $order_id = $_POST['orderId'];
44
+
45
+ /**
46
+ * @var Mage_Sales_Model_Order @order
47
+ */
48
+ $order = Mage::getModel('sales/order');
49
+ $order->loadByIncrementId($order_id);
50
+ if (!$order->getId()) {
51
+ Mage::helper('payex/tools')->addToDebug('TC: Error: OrderID ' . $order_id . ' not found on store.');
52
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
53
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
54
+ exit('FAILURE');
55
+ }
56
+
57
+ // Check Payment Method
58
+ if (strpos($order->getPayment()->getMethodInstance()->getCode(), 'payex_') === false) {
59
+ Mage::helper('payex/tools')->addToDebug('TC: Unsupported payment method: ' . $order->getPayment()->getMethodInstance()->getCode());
60
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
61
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
62
+ exit('FAILURE');
63
+ }
64
+
65
+ // Get Payment Method instance
66
+ $payment_method = $order->getPayment()->getMethodInstance();
67
+
68
+ // Get Account Details
69
+ $accountNumber = $payment_method->getConfigData('accountnumber', $order->getStoreId());
70
+ $encryptionKey = $payment_method->getConfigData('encryptionkey', $order->getStoreId());
71
+ $debug = (bool)$payment_method->getConfigData('debug', $order->getStoreId());
72
+
73
+ // Check Requested Account Number
74
+ if ($_POST['accountNumber'] !== $accountNumber) {
75
+ Mage::helper('payex/tools')->addToDebug('TC: Error: Can\'t to get account details of : ' . $_POST['accountNumber']);
76
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
77
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
78
+ exit('FAILURE');
79
+ }
80
+
81
+ // Define PayEx Settings
82
+ Mage::helper('payex/api')->getPx()->setEnvironment($accountNumber, $encryptionKey, $debug);
83
+
84
+ // Get Transaction Details
85
+ $transactionId = $_POST['transactionNumber'];
86
+
87
+ // Lookup Transaction
88
+ $collection = Mage::getModel('sales/order_payment_transaction')->getCollection()
89
+ ->addAttributeToFilter('txn_id', $transactionId);
90
+ if (count($collection) > 0) {
91
+ Mage::helper('payex/tools')->addToDebug(sprintf('TC: Transaction %s already processed.', $transactionId));
92
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
93
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
94
+ exit('FAILURE');
95
+ }
96
+
97
+ // Call PxOrder.GetTransactionDetails2
98
+ $params = array(
99
+ 'accountNumber' => '',
100
+ 'transactionNumber' => $transactionId,
101
+ );
102
+
103
+ $details = Mage::helper('payex/api')->getPx()->GetTransactionDetails2($params);
104
+ Mage::helper('payex/tools')->debugApi($details, 'PxOrder.GetTransactionDetails2');
105
+ if ($details['code'] !== 'OK' || $details['errorCode'] !== 'OK') {
106
+ Mage::helper('payex/tools')->addToDebug('TC: Failed to Get Transaction Details.');
107
+ return;
108
+ }
109
+
110
+ $order_id = $details['orderId'];
111
+ $transaction_status = (int)$details['transactionStatus'];
112
+
113
+ Mage::helper('payex/tools')->addToDebug('TC: Incoming transaction: ' . $transactionId);
114
+ Mage::helper('payex/tools')->addToDebug('TC: Transaction Status: ' . $transaction_status);
115
+ Mage::helper('payex/tools')->addToDebug('TC: OrderId: ' . $order_id);
116
+
117
+ // Get Order Status from External Payment Module
118
+ switch ($payment_method->getCode()) {
119
+ case 'payex_bankdebit':
120
+ $order_status_authorize = $payment_method->getConfigData('order_status');
121
+ $order_status_capture = $payment_method->getConfigData('order_status');
122
+ break;
123
+ default:
124
+ $order_status_authorize = $payment_method->getConfigData('order_status_authorize');
125
+ $order_status_capture = $payment_method->getConfigData('order_status_capture');
126
+ break;
127
+ }
128
+
129
+ // Save Transaction
130
+ /** @var Mage_Sales_Model_Order_Payment_Transaction $transaction */
131
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $details);
132
+
133
+ // Check Order and Transaction Result
134
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
135
+ switch ($transaction_status) {
136
+ case 0;
137
+ case 1;
138
+ case 3;
139
+ case 6:
140
+ // Complete order
141
+ Mage::helper('payex/tools')->addToDebug('TC: Action: Complete order');
142
+
143
+ // Call PxOrder.Complete
144
+ $params = array(
145
+ 'accountNumber' => '',
146
+ 'orderRef' => $_POST['orderRef'],
147
+ );
148
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
149
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
150
+ if ($result['errorCodeSimple'] !== 'OK') {
151
+ Mage::helper('payex/tools')->addToDebug('TC: Failed to complete payment.');
152
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
153
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
154
+ exit('FAILURE');
155
+ }
156
+
157
+ // Verify transaction status
158
+ if ((int)$result['transactionStatus'] !== $transaction_status) {
159
+ Mage::helper('payex/tools')->addToDebug('TC: Failed to complete payment. Transaction status is different!');
160
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
161
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
162
+ exit('FAILURE');
163
+ }
164
+
165
+ // Select Order Status
166
+ if (in_array($transaction_status, array(0, 6))) {
167
+ $new_status = $order_status_capture;
168
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
169
+ $new_status = $order_status_authorize;
170
+ } else {
171
+ $new_status = $order->getStatus();
172
+ }
173
+
174
+ // Get Order Status
175
+ /** @var Mage_Sales_Model_Order_Status $status */
176
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
177
+
178
+ // Change order status
179
+ $order->setData('state', $status->getState());
180
+ $order->setStatus($status->getStatus());
181
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
182
+
183
+ // Create Invoice for Sale Transaction
184
+ if (in_array($transaction_status, array(0, 6))) {
185
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
186
+ $invoice->setTransactionId($transactionId);
187
+ $invoice->save();
188
+
189
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
190
+ if ($transaction_status === 0) {
191
+ $order->setTotalPaid($order->getTotalDue());
192
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
193
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
194
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
195
+
196
+ // Update Order Totals because API V2 don't update order totals
197
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
198
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
199
+ ->setOrderFilter($order->getId())->getFirstItem();
200
+
201
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
202
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
203
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
204
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
205
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
206
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
207
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
208
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
209
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
210
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
211
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
212
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
213
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
214
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
215
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
216
+ }
217
+ }
218
+
219
+ $order->save();
220
+ $order->sendNewOrderEmail();
221
+ break;
222
+ case 2:
223
+ // @todo Improve this method
224
+ // Create CreditMemo
225
+ Mage::helper('payex/tools')->addToDebug('TC: Action: Create CreditMemo');
226
+ if ($order->hasInvoices() && $order->canCreditmemo() && !$order->hasCreditmemos()) {
227
+ $credit_amount = (float)($details['creditAmount'] / 100);
228
+
229
+ // Get Order Invoices
230
+ $invoices = Mage::getResourceModel('sales/order_invoice_collection')
231
+ ->setOrderFilter($order->getId());
232
+
233
+ foreach ($invoices as $invoice) {
234
+ $invoice->setOrder($order);
235
+ $invoice_id = $invoice->getIncrementId();
236
+ // @todo Mage_Sales_Model_Order_Payment_Transaction::TYPE_REFUND
237
+ Mage::helper('payex/order')->makeCreditMemo($order, $invoice, $credit_amount, false, $transactionId);
238
+ Mage::helper('payex/tools')->addToDebug('TC: InvoiceId ' . $invoice_id . ' refunded', $order_id);
239
+ // @note: Create CreditMemo for first Invoice only
240
+ break;
241
+ }
242
+ }
243
+ break;
244
+ case 4;
245
+ case 5:
246
+ // Change Order Status to Canceled
247
+ Mage::helper('payex/tools')->addToDebug('TC: Action: Cancel order');
248
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
249
+ $message = Mage::helper('payex')->__('Order canceled by Transaction Callback');
250
+
251
+ $order->cancel();
252
+ $order->addStatusHistoryComment($message);
253
+ $order->save();
254
+ $order->sendOrderUpdateEmail(true, $message);
255
+
256
+ Mage::helper('payex/tools')->addToDebug('TC: OrderId ' . $order_id . ' canceled', $order_id);
257
+ }
258
+ break;
259
+ default:
260
+ Mage::helper('payex/tools')->addToDebug('TC: Unknown Transaction Status', $order_id);
261
+ header(sprintf('%s %s %s', 'HTTP/1.1', '500', 'FAILURE'), true, '500');
262
+ header(sprintf('Status: %s %s', '500', 'FAILURE'), true, '500');
263
+ exit('FAILURE');
264
+ }
265
+
266
+ // Show "OK"
267
+ Mage::helper('payex/tools')->addToDebug('TC: Done.');
268
+ header(sprintf('%s %s %s', 'HTTP/1.1', '200', 'OK'), true, '200');
269
+ header(sprintf('Status: %s %s', '200', 'OK'), true, '200');
270
+ exit('OK');
271
+ }
272
+ }
app/code/community/PayEx/Payments/controllers/WywalletController.php ADDED
@@ -0,0 +1,302 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class PayEx_Payments_WywalletController extends Mage_Core_Controller_Front_Action
4
+ {
5
+ public function _construct()
6
+ {
7
+ // Bootstrap PayEx Environment
8
+ Mage::getSingleton('payex/payment_wywallet');
9
+ }
10
+
11
+ public function redirectAction()
12
+ {
13
+ Mage::helper('payex/tools')->addToDebug('Controller: redirect');
14
+
15
+ // Load Order
16
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
17
+
18
+ /** @var Mage_Sales_Model_Order $order */
19
+ $order = Mage::getModel('sales/order');
20
+ $order->loadByIncrementId($order_id);
21
+ if (!$order->getId()) {
22
+ Mage::throwException('No order for processing found');
23
+ }
24
+
25
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
26
+ $method = $order->getPayment()->getMethodInstance();
27
+
28
+ // Set quote to inactive
29
+ Mage::getSingleton('checkout/session')->setPayexQuoteId(Mage::getSingleton('checkout/session')->getQuoteId());
30
+ Mage::getSingleton('checkout/session')->getQuote()->setIsActive(false)->save();
31
+ Mage::getSingleton('checkout/session')->clear();
32
+
33
+ // Get Currency code
34
+ $currency_code = $order->getOrderCurrency()->getCurrencyCode();
35
+
36
+ // Get Amount
37
+ //$amount = $order->getGrandTotal();
38
+ $amount = Mage::helper('payex/order')->getCalculatedOrderAmount($order)->getAmount();
39
+
40
+ // Call PxOrder.Initialize8
41
+ $params = array(
42
+ 'accountNumber' => '',
43
+ 'purchaseOperation' => ($method->getConfigData('transactiontype') == 0) ? 'AUTHORIZATION' : 'SALE',
44
+ 'price' => 0,
45
+ 'priceArgList' => 'WYWALLET=' . round($amount * 100),
46
+ 'currency' => $currency_code,
47
+ 'vat' => 0,
48
+ 'orderID' => $order_id,
49
+ 'productNumber' => $order_id,
50
+ 'description' => Mage::app()->getStore()->getName(),
51
+ 'clientIPAddress' => Mage::helper('core/http')->getRemoteAddr(),
52
+ 'clientIdentifier' => '',
53
+ 'additionalValues' => $method->getConfigData('responsive') === '1' ? 'USECSS=RESPONSIVEDESIGN' : '',
54
+ 'externalID' => '',
55
+ 'returnUrl' => Mage::getUrl('payex/wywallet/success', array('_secure' => true)),
56
+ 'view' => 'MICROACCOUNT',
57
+ 'agreementRef' => '',
58
+ 'cancelUrl' => Mage::getUrl('payex/wywallet/cancel', array('_secure' => true)),
59
+ 'clientLanguage' => $method->getConfigData('clientlanguage')
60
+ );
61
+ $result = Mage::helper('payex/api')->getPx()->Initialize8($params);
62
+ Mage::helper('payex/tools')->addToDebug('PxOrder.Initialize8:' . $result['description']);
63
+
64
+ // Check Errors
65
+ if ($result['code'] !== 'OK' || $result['description'] !== 'OK' || $result['errorCode'] !== 'OK') {
66
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
67
+
68
+ // Cancel order
69
+ $order->cancel();
70
+ $order->addStatusHistoryComment($message, Mage_Sales_Model_Order::STATE_CANCELED);
71
+ $order->save();
72
+
73
+ // Set quote to active
74
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
75
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
76
+ if ($quote->getId()) {
77
+ $quote->setIsActive(true)->save();
78
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
79
+ }
80
+ }
81
+
82
+ Mage::getSingleton('checkout/session')->addError($message);
83
+ $this->_redirect('checkout/cart');
84
+ return;
85
+ }
86
+ $order_ref = $result['orderRef'];
87
+ $redirectUrl = $result['redirectUrl'];
88
+
89
+ // Add Order Lines and Orders Address
90
+ if ($method->getConfigData('checkoutinfo')) {
91
+ Mage::helper('payex/order')->addOrderLine($order_ref, $order);
92
+ Mage::helper('payex/order')->addOrderAddress($order_ref, $order);
93
+ }
94
+
95
+ // Set Pending Payment status
96
+ $order->setState(Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('payex')->__('The customer was redirected to PayEx.'));
97
+ $order->save();
98
+
99
+ // Redirect to Bank
100
+ header('Location: ' . $redirectUrl);
101
+ exit();
102
+ }
103
+
104
+ public function successAction()
105
+ {
106
+ Mage::helper('payex/tools')->addToDebug('Controller: success');
107
+
108
+ // Check OrderRef
109
+ if (empty($_GET['orderRef'])) {
110
+ $this->_redirect('checkout/cart');
111
+ }
112
+
113
+ // Load Order
114
+ $order_id = Mage::getSingleton('checkout/session')->getLastRealOrderId();
115
+
116
+ /** @var Mage_Sales_Model_Order $order */
117
+ $order = Mage::getModel('sales/order');
118
+ $order->loadByIncrementId($order_id);
119
+ if (!$order->getId()) {
120
+ Mage::throwException('No order for processing found');
121
+ }
122
+
123
+ /** @var PayEx_Payments_Model_Payment_Abstract $method */
124
+ $method = $order->getPayment()->getMethodInstance();
125
+
126
+ // Call PxOrder.Complete
127
+ $params = array(
128
+ 'accountNumber' => '',
129
+ 'orderRef' => $_GET['orderRef']
130
+ );
131
+ $result = Mage::helper('payex/api')->getPx()->Complete($params);
132
+ Mage::helper('payex/tools')->debugApi($result, 'PxOrder.Complete');
133
+ if ($result['errorCodeSimple'] !== 'OK') {
134
+ // Cancel order
135
+ $order->cancel();
136
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order automatically canceled. Failed to complete payment.'));
137
+ $order->save();
138
+
139
+ // Set quote to active
140
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
141
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
142
+ if ($quote->getId()) {
143
+ $quote->setIsActive(true)->save();
144
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
145
+ }
146
+ }
147
+
148
+ $message = Mage::helper('payex/tools')->getVerboseErrorMessage($result);
149
+ Mage::getSingleton('checkout/session')->addError($message);
150
+ $this->_redirect('checkout/cart');
151
+ return;
152
+ }
153
+
154
+ // Prevent Order cancellation when used TC
155
+ if (in_array((int)$result['transactionStatus'], array(0, 3, 6)) && $order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
156
+ if ($order->getState() === Mage_Sales_Model_Order::STATE_CANCELED) {
157
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
158
+ $order->setStatus(Mage_Sales_Model_Order::STATE_PROCESSING);
159
+ $order->save();
160
+
161
+ foreach ($order->getAllItems() as $item) {
162
+ $item->setQtyCanceled(0);
163
+ $item->save();
164
+ }
165
+ }
166
+
167
+ Mage::helper('payex/tools')->addToDebug('Order has been uncanceled.', $order_id);
168
+ }
169
+
170
+ // Process Transaction
171
+ Mage::helper('payex/tools')->addToDebug('Process Payment Transaction...', $order_id);
172
+ $transaction = Mage::helper('payex/order')->processPaymentTransaction($order, $result);
173
+ $transaction_status = isset($result['transactionStatus']) ? (int)$result['transactionStatus'] : null;
174
+
175
+ // Check Order and Transaction Result
176
+ /* Transaction statuses: 0=Sale, 1=Initialize, 2=Credit, 3=Authorize, 4=Cancel, 5=Failure, 6=Capture */
177
+ switch ($transaction_status) {
178
+ case 0;
179
+ case 1;
180
+ case 3;
181
+ case 6:
182
+ // Select Order Status
183
+ if (in_array($transaction_status, array(0, 6))) {
184
+ $new_status = $method->getConfigData('order_status_capture');
185
+ } elseif ($transaction_status === 3 || (isset($result['pending']) && $result['pending'] === 'true')) {
186
+ $new_status = $method->getConfigData('order_status_authorize');
187
+ } else {
188
+ $new_status = $order->getStatus();
189
+ }
190
+
191
+ // Get Order Status
192
+ /** @var Mage_Sales_Model_Order_Status $status */
193
+ $status = Mage::helper('payex/order')->getAssignedStatus($new_status);
194
+
195
+ // Change order status
196
+ $order->setData('state', $status->getState());
197
+ $order->setStatus($status->getStatus());
198
+ $order->addStatusHistoryComment(Mage::helper('payex')->__('Order has been paid'), $new_status);
199
+
200
+ // Create Invoice for Sale Transaction
201
+ if (in_array($transaction_status, array(0, 6))) {
202
+ $invoice = Mage::helper('payex/order')->makeInvoice($order, false);
203
+ $invoice->setTransactionId($result['transactionNumber']);
204
+ $invoice->save();
205
+
206
+ // Update Order Totals: "Total Due" on Sale Transactions bugfix
207
+ if ($transaction_status === 0) {
208
+ $order->setTotalPaid($order->getTotalDue());
209
+ $order->setBaseTotalPaid($order->getBaseTotalDue());
210
+ $order->setTotalDue($order->getTotalDue() - $order->getTotalPaid());
211
+ $order->getBaseTotalDue($order->getBaseTotalDue() - $order->getBaseTotalPaid());
212
+
213
+ // Update Order Totals because API V2 don't update order totals
214
+ /** @var $invoice Mage_Sales_Model_Order_Invoice */
215
+ $invoice = Mage::getResourceModel('sales/order_invoice_collection')
216
+ ->setOrderFilter($order->getId())->getFirstItem();
217
+
218
+ $order->setTotalInvoiced($order->getTotalInvoiced() + $invoice->getGrandTotal());
219
+ $order->setBaseTotalInvoiced($order->getBaseTotalInvoiced() + $invoice->getBaseGrandTotal());
220
+ $order->setSubtotalInvoiced($order->getSubtotalInvoiced() + $invoice->getSubtotal());
221
+ $order->setBaseSubtotalInvoiced($order->getBaseSubtotalInvoiced() + $invoice->getBaseSubtotal());
222
+ $order->setTaxInvoiced($order->getTaxInvoiced() + $invoice->getTaxAmount());
223
+ $order->setBaseTaxInvoiced($order->getBaseTaxInvoiced() + $invoice->getBaseTaxAmount());
224
+ $order->setHiddenTaxInvoiced($order->getHiddenTaxInvoiced() + $invoice->getHiddenTaxAmount());
225
+ $order->setBaseHiddenTaxInvoiced($order->getBaseHiddenTaxInvoiced() + $invoice->getBaseHiddenTaxAmount());
226
+ $order->setShippingTaxInvoiced($order->getShippingTaxInvoiced() + $invoice->getShippingTaxAmount());
227
+ $order->setBaseShippingTaxInvoiced($order->getBaseShippingTaxInvoiced() + $invoice->getBaseShippingTaxAmount());
228
+ $order->setShippingInvoiced($order->getShippingInvoiced() + $invoice->getShippingAmount());
229
+ $order->setBaseShippingInvoiced($order->getBaseShippingInvoiced() + $invoice->getBaseShippingAmount());
230
+ $order->setDiscountInvoiced($order->getDiscountInvoiced() + $invoice->getDiscountAmount());
231
+ $order->setBaseDiscountInvoiced($order->getBaseDiscountInvoiced() + $invoice->getBaseDiscountAmount());
232
+ $order->setBaseTotalInvoicedCost($order->getBaseTotalInvoicedCost() + $invoice->getBaseCost());
233
+ }
234
+ }
235
+
236
+ $order->save();
237
+ $order->sendNewOrderEmail();
238
+
239
+ // Redirect to Success Page
240
+ Mage::getSingleton('checkout/session')->setLastSuccessQuoteId(Mage::getSingleton('checkout/session')->getPayexQuoteId());
241
+ $this->_redirect('checkout/onepage/success', array('_secure' => true));
242
+ break;
243
+ default:
244
+ // Cancel order
245
+ if ($transaction->getIsCancel()) {
246
+ Mage::helper('payex/tools')->addToDebug('Cancel: ' . $transaction->getMessage(), $order->getIncrementId());
247
+
248
+ $order->cancel();
249
+ $order->addStatusHistoryComment($transaction->getMessage());
250
+ $order->save();
251
+ $order->sendOrderUpdateEmail(true, $transaction->getMessage());
252
+ }
253
+
254
+ // Set quote to active
255
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
256
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
257
+ if ($quote->getId()) {
258
+ $quote->setIsActive(true)->save();
259
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
260
+ }
261
+ }
262
+
263
+ Mage::getSingleton('checkout/session')->addError($transaction->getMessage());
264
+ $this->_redirect('checkout/cart');
265
+ }
266
+ }
267
+
268
+ public function cancelAction()
269
+ {
270
+ Mage::helper('payex/tools')->addToDebug('Controller: cancel');
271
+
272
+ $session = Mage::getSingleton('checkout/session');
273
+ $order = Mage::getModel('sales/order');
274
+
275
+ $message = Mage::helper('payex')->__('Order canceled by user');
276
+
277
+ $order_id = $session->getLastRealOrderId();
278
+ $order->loadByIncrementId($order_id);
279
+
280
+ // Note: Cancel only non-captured orders!
281
+ if (!$order->isCanceled() && !$order->hasInvoices()) {
282
+ // Set Canceled State
283
+ $order->cancel();
284
+ $order->addStatusToHistory(Mage_Sales_Model_Order::STATE_CANCELED, $message);
285
+ $order->save();
286
+ }
287
+
288
+ // Set quote to active
289
+ if ($quoteId = Mage::getSingleton('checkout/session')->getPayexQuoteId()) {
290
+ $quote = Mage::getModel('sales/quote')->load($quoteId);
291
+ if ($quote->getId()) {
292
+ $quote->setIsActive(true)->save();
293
+ Mage::getSingleton('checkout/session')->setQuoteId($quoteId);
294
+ }
295
+ }
296
+
297
+ $session->addError($message);
298
+ $this->_redirect('checkout/cart');
299
+ }
300
+
301
+ }
302
+
app/code/community/PayEx/Payments/data/payex_setup/data-install-3.0.0.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $resource = Mage::getSingleton('core/resource');
3
+ $writeConnection = $resource->getConnection('core_write');
4
+ $readConnection = $resource->getConnection('core_read');
5
+
6
+ // Upgrade orders to new payment method names
7
+ $sales_flat_order_payment_table = $resource->getTableName('sales_flat_order_payment');
8
+ $sales_flat_quote_payment_table = $resource->getTableName('sales_flat_quote_payment');
9
+ $migrate = array(
10
+ 'payexautopay' => 'payex_autopay',
11
+ 'bankdebit' => 'payex_bankdebit',
12
+ 'payex2' => 'payex_cc',
13
+ 'factoring' => 'payex_financing',
14
+ 'payexinvoice' => 'payex_invoice',
15
+ 'payex_mp' => 'payex_masterpass',
16
+ 'partpayment' => 'payex_partpayment',
17
+ 'wywallet' => 'payex_wywallet',
18
+ );
19
+ foreach ($migrate as $old_name => $new_name) {
20
+ $writeConnection->query("UPDATE `{$sales_flat_order_payment_table}` SET method = '{$new_name}' WHERE method = '{$old_name}';");
21
+ $writeConnection->query("UPDATE `{$sales_flat_quote_payment_table}` SET method = '{$new_name}' WHERE method = '{$old_name}';");
22
+ }
23
+
24
+ // Update payment fee of orders
25
+ $orders = Mage::getModel('sales/order')->getCollection();
26
+ $orders->getSelect()->join(
27
+ array('p' => $orders->getResource()->getTable('sales/order_payment')),
28
+ 'p.parent_id = main_table.entity_id',
29
+ array()
30
+ );
31
+ $orders->addFieldToFilter('method', array('in' => array('payex_financing', 'payex_invoice', 'payex_partpayment')));
32
+ foreach ($orders as $order) {
33
+ try {
34
+ $method = $order->getPayment()->getMethodInstance()->getCode();
35
+ } catch (Exception $e) {
36
+ continue;
37
+ }
38
+
39
+ switch ($method) {
40
+ case 'payex_invoice':
41
+ $order->setBasePayexPaymentFee($order->getBasePayexinvoicePaymentFee());
42
+ $order->setPayexPaymentFee($order->getPayexinvoicePaymentFee());
43
+ $order->save();
44
+
45
+ $quote = Mage::getModel('sales/quote')->setStore($order->getStore())->load($order->getQuoteId());
46
+ if ($quote) {
47
+ $quote->setBasePayexPaymentFee($quote->getBasePayexinvoicePaymentFee());
48
+ $quote->setPayexPaymentFee($quote->getPayexinvoicePaymentFee());
49
+ $quote->save();
50
+ }
51
+ break;
52
+ case 'payex_financing':
53
+ $order->setBasePayexPaymentFee($order->getBaseFactoringPaymentFee());
54
+ $order->setPayexPaymentFee($order->getFactoringPaymentFee());
55
+ $order->save();
56
+
57
+ $quote = Mage::getModel('sales/quote')->setStore($order->getStore())->load($order->getQuoteId());
58
+ if ($quote) {
59
+ $quote->setBasePayexPaymentFee($quote->getBaseFactoringPaymentFee());
60
+ $quote->setPayexPaymentFee($quote->getFactoringPaymentFee());
61
+ $quote->save();
62
+ }
63
+ break;
64
+ case 'payex_partpayment':
65
+ $order->setBasePayexPaymentFee($order->getBasePartpaymentPaymentFee());
66
+ $order->setPayexPaymentFee($order->getPartpaymentPaymentFee());
67
+ $order->save();
68
+
69
+ $quote = Mage::getModel('sales/quote')->setStore($order->getStore())->load($order->getQuoteId());
70
+ if ($quote) {
71
+ $quote->setBasePayexPaymentFee($quote->getBasePartpaymentPaymentFee());
72
+ $quote->setPayexPaymentFee($quote->getPartpaymentPaymentFee());
73
+ $quote->save();
74
+ }
75
+ break;
76
+ }
77
+ }
78
+
79
+ // Migrate payment configuration
80
+ $migrate = array(
81
+ 'payment/payexautopay' => 'payment/payex_autopay',
82
+ 'payment/bankdebit' => 'payment/payex_bankdebit',
83
+ 'payment/payex2' => 'payment/payex_cc',
84
+ 'payment/factoring' => 'payment/payex_financing',
85
+ 'payment/payexinvoice' => 'payment/payex_invoice',
86
+ 'payment/payex_mp' => 'payment/payex_masterpass',
87
+ 'payment/partpayment' => 'payment/payex_partpayment',
88
+ 'payment/wywallet' => 'payment/payex_wywallet',
89
+ 'aait_ssn/aait_ssn' => 'payex_ssn/payex_ssn',
90
+ );
91
+
92
+ foreach ($migrate as $old_name => $new_name) {
93
+ $core_config_data_table = $resource->getTableName('core_config_data');
94
+ $results = $readConnection->fetchAll("SELECT scope, scope_id, path, value FROM `{$core_config_data_table}` WHERE path LIKE '{$old_name}/%';");
95
+ if (count($results) > 0) {
96
+ foreach($results as $id => $row) {
97
+ $scope = $row['scope'];
98
+ $scope_id = $row['scope_id'];
99
+ $value = $row['value'];
100
+ $path = str_replace($old_name, $new_name, $row['path']);
101
+ $writeConnection->query("INSERT IGNORE INTO `{$core_config_data_table}` (scope, scope_id, path, value) VALUES('{$scope}', '{$scope_id}', '{$path}', '{$value}');");
102
+ }
103
+ }
104
+ }
105
+
106
+ // Disable old modules
107
+ $modules_list = array(
108
+ 'AAIT_Bankdebit', 'AAIT_Factoring', 'AAIT_PartPayment', 'AAIT_Payex2', 'AAIT_Payexapi',
109
+ 'AAIT_Payexautopay', 'AAIT_Payexinvoice', 'AAIT_Wywallet', 'PayEx_MasterPass', 'PayEx_MasterPass', 'AAIT_SocialSecurityNumber'
110
+ );
111
+ $modules_dir = Mage::getModel('core/config')->getOptions()->getEtcDir() . DS . 'modules';
112
+ foreach ($modules_list as $id => $module_name) {
113
+ $module_file = $modules_dir . DS . $module_name . '.xml';
114
+ if (file_exists($module_file)) {
115
+ @rename($module_file, $module_file . '.bak');
116
+ }
117
+ }
app/code/community/PayEx/Payments/etc/config.xml ADDED
@@ -0,0 +1,419 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <PayEx_Payments>
5
+ <!-- declare module's version information for database updates -->
6
+ <version>3.0.1</version>
7
+ </PayEx_Payments>
8
+ </modules>
9
+
10
+ <global>
11
+ <!-- declare model group for new module -->
12
+ <models>
13
+ <!-- model group alias to be used in Mage::getModel('newmodule/...') -->
14
+ <payex>
15
+ <!-- base class name for the model group -->
16
+ <class>PayEx_Payments_Model</class>
17
+ <!-- base class name for the resource model group -->
18
+ <resourceModel>payex_mysql4</resourceModel>
19
+ </payex>
20
+
21
+ <payex_mysql4>
22
+ <class>PayEx_Payments_Model_Mysql4</class>
23
+ <entities>
24
+ <payex_agreement>
25
+ <table>payexautopay_agreement</table>
26
+ </payex_agreement>
27
+ </entities>
28
+ </payex_mysql4>
29
+ </models>
30
+
31
+ <!-- IMPORTANT: if you use your own namespace (i.e. CompanyName) you also have to declare blocks group for new module. See topic: http://www.magentocommerce.com/boards/viewthread/22416/#t102732 -->
32
+ <blocks>
33
+ <payex>
34
+ <class>PayEx_Payments_Block</class>
35
+ </payex>
36
+ </blocks>
37
+
38
+ <helpers>
39
+ <payex>
40
+ <class>PayEx_Payments_Helper</class>
41
+ </payex>
42
+ </helpers>
43
+
44
+ <!-- declare resource setup for new module -->
45
+ <resources>
46
+ <!-- resource identifier -->
47
+ <payex_setup>
48
+ <!-- specify that this resource is a setup resource and used for upgrades -->
49
+ <setup>
50
+ <!-- which module to look for install/upgrade files in -->
51
+ <module>PayEx_Payments</module>
52
+ </setup>
53
+ <!-- specify database connection for this resource -->
54
+ <connection>
55
+ <!-- do not create new connection, use predefined core setup connection -->
56
+ <use>core_setup</use>
57
+ </connection>
58
+ </payex_setup>
59
+ <payex_write>
60
+ <connection>
61
+ <use>core_write</use>
62
+ </connection>
63
+ </payex_write>
64
+ <payex_read>
65
+ <connection>
66
+ <use>core_read</use>
67
+ </connection>
68
+ </payex_read>
69
+ </resources>
70
+
71
+ <sales>
72
+ <quote>
73
+ <totals>
74
+ <payex_payment_fee>
75
+ <class>payex/quote_total</class>
76
+ <after>subtotal,discount,shipping</after>
77
+ <before>tax,grand_total</before>
78
+ <renderer>payex/checkout_fee</renderer>
79
+ <admin_renderer>payex/adminhtml_sales_order_create_totals_fee</admin_renderer>
80
+ </payex_payment_fee>
81
+ </totals>
82
+ </quote>
83
+ <order_invoice>
84
+ <totals>
85
+ <payex_payment_fee>
86
+ <class>payex/invoice_total</class>
87
+ </payex_payment_fee>
88
+ </totals>
89
+ </order_invoice>
90
+ </sales>
91
+
92
+ <events>
93
+ <sales_order_invoice_save_after>
94
+ <observers>
95
+ <payex>
96
+ <type>singleton</type>
97
+ <class>payex/observer</class>
98
+ <method>sales_order_invoice_save_after</method>
99
+ </payex>
100
+ </observers>
101
+ </sales_order_invoice_save_after>
102
+ <sales_quote_collect_totals_after>
103
+ <observers>
104
+ <payex>
105
+ <type>singleton</type>
106
+ <class>payex/observer</class>
107
+ <method>sales_quote_collect_totals_after</method>
108
+ </payex>
109
+ </observers>
110
+ </sales_quote_collect_totals_after>
111
+ <sales_order_payment_place_end>
112
+ <observers>
113
+ <payex>
114
+ <type>singleton</type>
115
+ <class>payex/observer</class>
116
+ <method>sales_order_payment_place_end</method>
117
+ </payex>
118
+ </observers>
119
+ </sales_order_payment_place_end>
120
+ </events>
121
+ </global>
122
+
123
+ <!-- declare default configuration values for this module -->
124
+ <default>
125
+ <!-- 'payment' configuration section (tab) -->
126
+ <payment>
127
+ <!-- 'newmodule' configuration group (fieldset) -->
128
+ <payex_cc>
129
+ <!-- by default this payment method is inactive -->
130
+ <active>1</active>
131
+ <!-- model to handle logic for this payment method -->
132
+ <model>payex/payment_CC</model>
133
+ <!-- default title for payment checkout page and order view page -->
134
+ <title>PayEx Payments</title>
135
+ <paymentview>PX</paymentview>
136
+ <allowspecific>0</allowspecific>
137
+ <debug>1</debug>
138
+ <accountnumber>payex account number</accountnumber>
139
+ <encryptionkey>payex encryption key</encryptionkey>
140
+ <transactiontype>1</transactiontype>
141
+ <order_status_authorize>processing</order_status_authorize>
142
+ <order_status_capture>complete</order_status_capture>
143
+ <clientlanguage>en-US</clientlanguage>
144
+ <cleantime>20</cleantime>
145
+ <responsive>0</responsive>
146
+ <checkoutinfo>1</checkoutinfo>
147
+ </payex_cc>
148
+
149
+ <!-- 'newmodule' configuration group (fieldset) -->
150
+ <payex_bankdebit>
151
+ <!-- by default this payment method is inactive -->
152
+ <active>1</active>
153
+ <!-- model to handle logic for this payment method -->
154
+ <model>payex/payment_bankdebit</model>
155
+ <!-- default title for payment checkout page and order view page -->
156
+ <title>PayEx Bank Debit</title>
157
+ <allowspecific>0</allowspecific>
158
+ <accountnumber>payex account number</accountnumber>
159
+ <encryptionkey>payex encryption key</encryptionkey>
160
+ <debug>1</debug>
161
+ <order_status>1</order_status>
162
+ <banks>NB,FSPA,SEB,SHB</banks>
163
+ <clientlanguage>en-US</clientlanguage>
164
+ <cleantime>20</cleantime>
165
+ <responsive>0</responsive>
166
+ <checkoutinfo>1</checkoutinfo>
167
+ </payex_bankdebit>
168
+
169
+ <!-- 'newmodule' configuration group (fieldset) -->
170
+ <payex_wywallet>
171
+ <!-- by default this payment method is inactive -->
172
+ <active>1</active>
173
+ <!-- model to handle logic for this payment method -->
174
+ <model>payex/payment_wywallet</model>
175
+ <!-- default title for payment checkout page and order view page -->
176
+ <title>PayEx WyWallet</title>
177
+ <allowspecific>0</allowspecific>
178
+ <debug>1</debug>
179
+ <accountnumber>payex account number</accountnumber>
180
+ <encryptionkey>payex encryption key</encryptionkey>
181
+ <transactiontype>1</transactiontype>
182
+ <order_status_authorize>processing</order_status_authorize>
183
+ <order_status_capture>complete</order_status_capture>
184
+ <clientlanguage>en-US</clientlanguage>
185
+ <cleantime>20</cleantime>
186
+ <responsive>0</responsive>
187
+ <checkoutinfo>1</checkoutinfo>
188
+ </payex_wywallet>
189
+
190
+ <!-- 'newmodule' configuration group (fieldset) -->
191
+ <payex_autopay>
192
+ <!-- by default this payment method is inactive -->
193
+ <active>1</active>
194
+ <!-- model to handle logic for this payment method -->
195
+ <model>payex/payment_autopay</model>
196
+ <!-- order status for new orders paid by this payment method -->
197
+ <order_status>1</order_status>
198
+ <!-- default title for payment checkout page and order view page -->
199
+ <title>PayEx Credit Card One-click Payments</title>
200
+ <allowspecific>0</allowspecific>
201
+ <accountnumber>payex account number</accountnumber>
202
+ <encryptionkey>payex encryption key</encryptionkey>
203
+ <transactiontype>1</transactiontype>
204
+ <debug>1</debug>
205
+ <order_status>1</order_status>
206
+ <clientlanguage>en-US</clientlanguage>
207
+ <agreementurl>http://example.com</agreementurl>
208
+ <maxamount>1000</maxamount>
209
+ <cleantime>20</cleantime>
210
+ <responsive>0</responsive>
211
+ <checkoutinfo>1</checkoutinfo>
212
+ </payex_autopay>
213
+
214
+ <!-- 'newmodule' configuration group (fieldset) -->
215
+ <payex_masterpass>
216
+ <!-- by default this payment method is inactive -->
217
+ <active>1</active>
218
+ <!-- model to handle logic for this payment method -->
219
+ <model>payex/payment_MasterPass</model>
220
+ <!-- default title for payment checkout page and order view page -->
221
+ <title>PayEx MasterPass</title>
222
+ <allowspecific>0</allowspecific>
223
+ <debug>1</debug>
224
+ <accountnumber>payex account number</accountnumber>
225
+ <encryptionkey>payex encryption key</encryptionkey>
226
+ <transactiontype>1</transactiontype>
227
+ <order_status_authorize>processing</order_status_authorize>
228
+ <order_status_capture>complete</order_status_capture>
229
+ <clientlanguage>en-US</clientlanguage>
230
+ <cleantime>20</cleantime>
231
+ </payex_masterpass>
232
+
233
+ <!-- 'newmodule' configuration group (fieldset) -->
234
+ <payex_financing>
235
+ <!-- by default this payment method is inactive -->
236
+ <active>1</active>
237
+ <!-- model to handle logic for this payment method -->
238
+ <model>payex/payment_financing</model>
239
+ <!-- default title for payment checkout page and order view page -->
240
+ <title>PayEx Financing Invoice</title>
241
+ <allowspecific>0</allowspecific>
242
+ <debug>1</debug>
243
+ <accountnumber>payex account number</accountnumber>
244
+ <encryptionkey>payex encryption key</encryptionkey>
245
+ <order_status_authorize>processing</order_status_authorize>
246
+ <order_status_capture>complete</order_status_capture>
247
+ <clientlanguage>en-US</clientlanguage>
248
+ <paymentfee>0</paymentfee>
249
+ <paymentfee_tax_class>0</paymentfee_tax_class>
250
+ <cleantime>20</cleantime>
251
+ <replace_illegal>1</replace_illegal>
252
+ <replacement_char>-</replacement_char>
253
+ </payex_financing>
254
+
255
+ <!-- 'newmodule' configuration group (fieldset) -->
256
+ <payex_partpayment>
257
+ <!-- by default this payment method is inactive -->
258
+ <active>1</active>
259
+ <!-- model to handle logic for this payment method -->
260
+ <model>payex/payment_PartPayment</model>
261
+ <!-- default title for payment checkout page and order view page -->
262
+ <title>PayEx Financing Credit Account</title>
263
+ <allowspecific>0</allowspecific>
264
+ <debug>1</debug>
265
+ <accountnumber>payex account number</accountnumber>
266
+ <encryptionkey>payex encryption key</encryptionkey>
267
+ <order_status_authorize>processing</order_status_authorize>
268
+ <order_status_capture>complete</order_status_capture>
269
+ <clientlanguage>en-US</clientlanguage>
270
+ <paymentfee>0</paymentfee>
271
+ <paymentfee_tax_class>0</paymentfee_tax_class>
272
+ <cleantime>20</cleantime>
273
+ <replace_illegal>1</replace_illegal>
274
+ <replacement_char>-</replacement_char>
275
+ </payex_partpayment>
276
+
277
+ <!-- 'newmodule' configuration group (fieldset) -->
278
+ <payex_invoice>
279
+ <!-- model to handle logic for this payment method -->
280
+ <model>payex/payment_invoice</model>
281
+ <active>1</active>
282
+ <!-- default title for payment checkout page and order view page -->
283
+ <title>PayEx Invoice Payments (Ledger Service)</title>
284
+ <allowspecific>0</allowspecific>
285
+ <debug>1</debug>
286
+ <transactiontype>1</transactiontype>
287
+ <order_status_authorize>processing</order_status_authorize>
288
+ <order_status_capture>complete</order_status_capture>
289
+ <accountnumber>payex account number</accountnumber>
290
+ <encryptionkey>payex encryption key</encryptionkey>
291
+ <additionalValues>INVOICE_COUNTRY=SE</additionalValues>
292
+ <clientlanguage>en-US</clientlanguage>
293
+ <distribution>11</distribution>
294
+ <paymentfee>0</paymentfee>
295
+ <paymentfee_tax_class>0</paymentfee_tax_class>
296
+ <invoicetext>Invoice text</invoicetext>
297
+ <invoiceduedays>15</invoiceduedays>
298
+ <unapproved>0</unapproved>
299
+ </payex_invoice>
300
+
301
+ <!-- 'newmodule' configuration group (fieldset) -->
302
+ <payex_swish>
303
+ <!-- by default this payment method is inactive -->
304
+ <active>1</active>
305
+ <!-- model to handle logic for this payment method -->
306
+ <model>payex/payment_swish</model>
307
+ <!-- default title for payment checkout page and order view page -->
308
+ <title>Swish Payments (via PayEx)</title>
309
+ <allowspecific>0</allowspecific>
310
+ <accountnumber>payex account number</accountnumber>
311
+ <encryptionkey>payex encryption key</encryptionkey>
312
+ <debug>1</debug>
313
+ <order_status>1</order_status>
314
+ <clientlanguage>en-US</clientlanguage>
315
+ <cleantime>20</cleantime>
316
+ <responsive>0</responsive>
317
+ <checkoutinfo>1</checkoutinfo>
318
+ </payex_swish>
319
+ </payment>
320
+ </default>
321
+
322
+ <adminhtml>
323
+ <!-- Updates layout... -->
324
+ <layout>
325
+ <updates>
326
+ <payex>
327
+ <file>payex/adminhtml.xml</file>
328
+ </payex>
329
+ <payment_fee>
330
+ <file>payex/payment_fee.xml</file>
331
+ </payment_fee>
332
+ </updates>
333
+ </layout>
334
+
335
+ <events>
336
+ <controller_action_predispatch>
337
+ <observers>
338
+ <payex_check_updates>
339
+ <type>singleton</type>
340
+ <class>payex/feed</class>
341
+ <method>check</method>
342
+ </payex_check_updates>
343
+ </observers>
344
+ </controller_action_predispatch>
345
+ </events>
346
+
347
+ <acl>
348
+ <resources>
349
+ <admin>
350
+ <children>
351
+ <system>
352
+ <children>
353
+ <config>
354
+ <children>
355
+ <payex_ssn>
356
+ <title>Social Security Number</title>
357
+ </payex_ssn>
358
+ </children>
359
+ </config>
360
+ </children>
361
+ </system>
362
+ </children>
363
+ </admin>
364
+ </resources>
365
+ </acl>
366
+ </adminhtml>
367
+
368
+ <frontend>
369
+ <!-- Routes... -->
370
+ <routers>
371
+ <payex>
372
+ <use>standard</use>
373
+ <args>
374
+ <module>PayEx_Payments</module>
375
+ <frontName>payex</frontName>
376
+ </args>
377
+ </payex>
378
+ </routers>
379
+
380
+ <!-- Translations... -->
381
+ <translate>
382
+ <modules>
383
+ <PayEx_Payments>
384
+ <files>
385
+ <default>PayEx_Payments.csv</default>
386
+ </files>
387
+ </PayEx_Payments>
388
+ </modules>
389
+ </translate>
390
+
391
+ <!-- Updates layout... -->
392
+ <layout>
393
+ <updates>
394
+ <payex_masterpass>
395
+ <file>payex/masterpass.xml</file>
396
+ </payex_masterpass>
397
+ <payment_fee>
398
+ <file>payex/payment_fee.xml</file>
399
+ </payment_fee>
400
+ <social_security_number>
401
+ <file>payex/social_security_number.xml</file>
402
+ </social_security_number>
403
+ </updates>
404
+ </layout>
405
+ </frontend>
406
+
407
+ <crontab>
408
+ <jobs>
409
+ <payex_clear_pending_orders>
410
+ <schedule>
411
+ <cron_expr>*/5 * * * *</cron_expr>
412
+ </schedule>
413
+ <run>
414
+ <model>payex/observer::clear_pending_orders</model>
415
+ </run>
416
+ </payex_clear_pending_orders>
417
+ </jobs>
418
+ </crontab>
419
+ </config>
app/code/community/PayEx/Payments/etc/system.xml ADDED
@@ -0,0 +1,1546 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <payex translate="label" module="payex">
5
+ <label>PayEx</label>
6
+ <sort_order>110</sort_order>
7
+ </payex>
8
+ </tabs>
9
+
10
+ <sections>
11
+ <!-- payment tab -->
12
+ <payment>
13
+ <groups>
14
+ <!-- Hint -->
15
+ <payex_hint translate="label" module="payex">
16
+ <frontend_model>payex/adminhtml_config_hint</frontend_model>
17
+ <sort_order>-60</sort_order>
18
+ <show_in_default>1</show_in_default>
19
+ <show_in_website>1</show_in_website>
20
+ <show_in_store>1</show_in_store>
21
+ </payex_hint>
22
+
23
+ <!-- newmodule fieldset -->
24
+ <payex_cc translate="label" module="payex">
25
+ <!-- will have title 'New Module' -->
26
+ <label>PayEx Payments</label>
27
+ <!-- position between other payment methods -->
28
+ <sort_order>610</sort_order>
29
+ <!-- do not show this configuration options in store scope -->
30
+ <show_in_default>1</show_in_default>
31
+ <show_in_website>1</show_in_website>
32
+ <show_in_store>1</show_in_store>
33
+ <comment><![CDATA[This payment module provide <a href="http://payex.com/" target="_blank">PayEx Payments</a>. You can set <a href="/index.php/payex/transaction" target="_blank">this URL</a> as a Transaction Callback URL.]]></comment>
34
+ <fields>
35
+ <!-- is this payment method active for the website? -->
36
+ <active translate="label">
37
+ <!-- label for the field -->
38
+ <label>Enabled</label>
39
+ <!-- input type for configuration value -->
40
+ <frontend_type>select</frontend_type>
41
+ <!-- model to take the option values from -->
42
+ <source_model>adminhtml/system_config_source_yesno</source_model>
43
+ <!-- field position -->
44
+ <sort_order>1</sort_order>
45
+ <!-- do not show this field in store scope -->
46
+ <show_in_default>1</show_in_default>
47
+ <show_in_website>1</show_in_website>
48
+ <show_in_store>1</show_in_store>
49
+ </active>
50
+
51
+ <title translate="label">
52
+ <label>Title</label>
53
+ <frontend_type>text</frontend_type>
54
+ <sort_order>2</sort_order>
55
+ <show_in_default>1</show_in_default>
56
+ <show_in_website>1</show_in_website>
57
+ <show_in_store>1</show_in_store>
58
+ </title>
59
+
60
+ <paymentview translate="label">
61
+ <label>Payment Type</label>
62
+ <frontend_type>select</frontend_type>
63
+ <source_model>payex/source_paymentView</source_model>
64
+ <sort_order>3</sort_order>
65
+ <show_in_default>1</show_in_default>
66
+ <show_in_website>1</show_in_website>
67
+ <show_in_store>1</show_in_store>
68
+ </paymentview>
69
+
70
+ <allowspecific translate="label">
71
+ <label>Payment to applicable countries</label>
72
+ <frontend_type>allowspecific</frontend_type>
73
+ <sort_order>4</sort_order>
74
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
75
+ <show_in_default>1</show_in_default>
76
+ <show_in_website>1</show_in_website>
77
+ <show_in_store>1</show_in_store>
78
+ </allowspecific>
79
+
80
+ <specificcountry translate="label">
81
+ <label>Payment to Specific countries</label>
82
+ <frontend_type>multiselect</frontend_type>
83
+ <sort_order>5</sort_order>
84
+ <source_model>adminhtml/system_config_source_country</source_model>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>1</show_in_website>
87
+ <show_in_store>1</show_in_store>
88
+ </specificcountry>
89
+
90
+ <debug translate="label">
91
+ <label>Enable test mode</label>
92
+ <frontend_type>select</frontend_type>
93
+ <source_model>adminhtml/system_config_source_yesno</source_model>
94
+ <sort_order>6</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>1</show_in_store>
98
+ </debug>
99
+
100
+ <accountnumber>
101
+ <label>Account Number</label>
102
+ <frontend_type>text</frontend_type>
103
+ <sort_order>7</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
+ </accountnumber>
108
+
109
+ <encryptionkey>
110
+ <label>Encryption Key</label>
111
+ <frontend_type>text</frontend_type>
112
+ <sort_order>8</sort_order>
113
+ <show_in_default>1</show_in_default>
114
+ <show_in_website>1</show_in_website>
115
+ <show_in_store>1</show_in_store>
116
+ </encryptionkey>
117
+
118
+ <transactiontype translate="label">
119
+ <label>Transaction Type</label>
120
+ <frontend_type>select</frontend_type>
121
+ <source_model>payex/source_paymentAction</source_model>
122
+ <sort_order>9</sort_order>
123
+ <show_in_default>1</show_in_default>
124
+ <show_in_website>1</show_in_website>
125
+ <show_in_store>1</show_in_store>
126
+ </transactiontype>
127
+
128
+ <order_status_authorize translate="label">
129
+ <label>Order status (for authorize)</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_order_status</source_model>
132
+ <sort_order>10</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </order_status_authorize>
137
+
138
+ <order_status_capture translate="label">
139
+ <label>Order status (for capture)</label>
140
+ <frontend_type>select</frontend_type>
141
+ <source_model>adminhtml/system_config_source_order_status</source_model>
142
+ <sort_order>11</sort_order>
143
+ <show_in_default>1</show_in_default>
144
+ <show_in_website>1</show_in_website>
145
+ <show_in_store>1</show_in_store>
146
+ </order_status_capture>
147
+
148
+ <clientlanguage translate="label">
149
+ <label>Client language</label>
150
+ <frontend_type>select</frontend_type>
151
+ <source_model>payex/source_clientLanguage</source_model>
152
+ <sort_order>12</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>1</show_in_store>
156
+ </clientlanguage>
157
+
158
+ <cleantime translate="label">
159
+ <label>Time to clean pending orders (0 - disabled)</label>
160
+ <frontend_type>text</frontend_type>
161
+ <sort_order>13</sort_order>
162
+ <show_in_default>1</show_in_default>
163
+ <show_in_website>1</show_in_website>
164
+ <show_in_store>1</show_in_store>
165
+ </cleantime>
166
+
167
+ <responsive translate="label">
168
+ <!-- label for the field -->
169
+ <label>Enable Responsive Skinning</label>
170
+ <!-- input type for configuration value -->
171
+ <frontend_type>select</frontend_type>
172
+ <!-- model to take the option values from -->
173
+ <source_model>adminhtml/system_config_source_yesno</source_model>
174
+ <!-- field position -->
175
+ <sort_order>14</sort_order>
176
+ <!-- do not show this field in store scope -->
177
+ <show_in_default>1</show_in_default>
178
+ <show_in_website>1</show_in_website>
179
+ <show_in_store>1</show_in_store>
180
+ </responsive>
181
+
182
+ <checkoutinfo translate="label">
183
+ <label>Send order lines and billing/delivery addresses to PayEx</label>
184
+ <frontend_type>select</frontend_type>
185
+ <source_model>adminhtml/system_config_source_yesno</source_model>
186
+ <sort_order>15</sort_order>
187
+ <show_in_default>1</show_in_default>
188
+ <show_in_website>1</show_in_website>
189
+ <show_in_store>1</show_in_store>
190
+ </checkoutinfo>
191
+ </fields>
192
+ </payex_cc>
193
+
194
+ <!-- newmodule fieldset -->
195
+ <payex_bankdebit translate="label" module="payex">
196
+ <!-- will have title 'New Module' -->
197
+ <label>PayEx Bank Debit</label>
198
+ <!-- position between other payment methods -->
199
+ <sort_order>611</sort_order>
200
+ <!-- do not show this configuration options in store scope -->
201
+ <show_in_default>1</show_in_default>
202
+ <show_in_website>1</show_in_website>
203
+ <show_in_store>0</show_in_store>
204
+ <fields>
205
+ <!-- is this payment method active for the website? -->
206
+ <active translate="label">
207
+ <!-- label for the field -->
208
+ <label>Enabled</label>
209
+ <!-- input type for configuration value -->
210
+ <frontend_type>select</frontend_type>
211
+ <!-- model to take the option values from -->
212
+ <source_model>adminhtml/system_config_source_yesno</source_model>
213
+ <!-- field position -->
214
+ <sort_order>1</sort_order>
215
+ <!-- do not show this field in store scope -->
216
+ <show_in_default>1</show_in_default>
217
+ <show_in_website>1</show_in_website>
218
+ <show_in_store>1</show_in_store>
219
+ </active>
220
+
221
+ <title translate="label">
222
+ <label>Title</label>
223
+ <frontend_type>text</frontend_type>
224
+ <sort_order>2</sort_order>
225
+ <show_in_default>1</show_in_default>
226
+ <show_in_website>1</show_in_website>
227
+ <show_in_store>1</show_in_store>
228
+ </title>
229
+
230
+ <allowspecific translate="label">
231
+ <label>Payment to applicable countries</label>
232
+ <frontend_type>allowspecific</frontend_type>
233
+ <sort_order>3</sort_order>
234
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
235
+ <show_in_default>1</show_in_default>
236
+ <show_in_website>1</show_in_website>
237
+ <show_in_store>1</show_in_store>
238
+ </allowspecific>
239
+
240
+ <specificcountry translate="label">
241
+ <label>Payment to Specific countries</label>
242
+ <frontend_type>multiselect</frontend_type>
243
+ <sort_order>4</sort_order>
244
+ <source_model>adminhtml/system_config_source_country</source_model>
245
+ <show_in_default>1</show_in_default>
246
+ <show_in_website>1</show_in_website>
247
+ <show_in_store>1</show_in_store>
248
+ </specificcountry>
249
+
250
+ <debug translate="label">
251
+ <label>Enable test mode</label>
252
+ <frontend_type>select</frontend_type>
253
+ <source_model>adminhtml/system_config_source_yesno</source_model>
254
+ <sort_order>5</sort_order>
255
+ <show_in_default>1</show_in_default>
256
+ <show_in_website>1</show_in_website>
257
+ <show_in_store>0</show_in_store>
258
+ </debug>
259
+
260
+ <accountnumber>
261
+ <label>Account Number</label>
262
+ <frontend_type>text</frontend_type>
263
+ <sort_order>6</sort_order>
264
+ <show_in_default>1</show_in_default>
265
+ <show_in_website>1</show_in_website>
266
+ <show_in_store>1</show_in_store>
267
+ </accountnumber>
268
+
269
+ <encryptionkey>
270
+ <label>Encryption Key</label>
271
+ <frontend_type>text</frontend_type>
272
+ <sort_order>7</sort_order>
273
+ <show_in_default>1</show_in_default>
274
+ <show_in_website>1</show_in_website>
275
+ <show_in_store>1</show_in_store>
276
+ </encryptionkey>
277
+
278
+ <order_status translate="label">
279
+ <label>New order status</label>
280
+ <frontend_type>select</frontend_type>
281
+ <source_model>adminhtml/system_config_source_order_status</source_model>
282
+ <sort_order>8</sort_order>
283
+ <show_in_default>1</show_in_default>
284
+ <show_in_website>1</show_in_website>
285
+ <show_in_store>1</show_in_store>
286
+ </order_status>
287
+
288
+ <banks translate="label">
289
+ <label>Available banks</label>
290
+ <frontend_type>multiselect</frontend_type>
291
+ <sort_order>9</sort_order>
292
+ <source_model>payex/source_banks</source_model>
293
+ <show_in_default>1</show_in_default>
294
+ <show_in_website>1</show_in_website>
295
+ <show_in_store>1</show_in_store>
296
+ </banks>
297
+
298
+ <clientlanguage translate="label">
299
+ <label>Client language</label>
300
+ <frontend_type>select</frontend_type>
301
+ <source_model>payex/source_clientLanguage</source_model>
302
+ <sort_order>10</sort_order>
303
+ <show_in_default>1</show_in_default>
304
+ <show_in_website>1</show_in_website>
305
+ <show_in_store>1</show_in_store>
306
+ </clientlanguage>
307
+
308
+ <cleantime translate="label">
309
+ <label>Time to clean pending orders (0 - disabled)</label>
310
+ <frontend_type>text</frontend_type>
311
+ <sort_order>11</sort_order>
312
+ <show_in_default>1</show_in_default>
313
+ <show_in_website>1</show_in_website>
314
+ <show_in_store>1</show_in_store>
315
+ </cleantime>
316
+
317
+ <responsive translate="label">
318
+ <!-- label for the field -->
319
+ <label>Enable Responsive Skinning</label>
320
+ <!-- input type for configuration value -->
321
+ <frontend_type>select</frontend_type>
322
+ <!-- model to take the option values from -->
323
+ <source_model>adminhtml/system_config_source_yesno</source_model>
324
+ <!-- field position -->
325
+ <sort_order>12</sort_order>
326
+ <!-- do not show this field in store scope -->
327
+ <show_in_default>1</show_in_default>
328
+ <show_in_website>1</show_in_website>
329
+ <show_in_store>1</show_in_store>
330
+ </responsive>
331
+
332
+ <checkoutinfo translate="label">
333
+ <label>Send order lines and billing/delivery addresses to PayEx</label>
334
+ <frontend_type>select</frontend_type>
335
+ <source_model>adminhtml/system_config_source_yesno</source_model>
336
+ <sort_order>13</sort_order>
337
+ <show_in_default>1</show_in_default>
338
+ <show_in_website>1</show_in_website>
339
+ <show_in_store>1</show_in_store>
340
+ </checkoutinfo>
341
+ </fields>
342
+ </payex_bankdebit>
343
+
344
+ <!-- newmodule fieldset -->
345
+ <payex_wywallet translate="label" module="payex">
346
+ <!-- will have title 'New Module' -->
347
+ <label>PayEx WyWallet</label>
348
+ <!-- position between other payment methods -->
349
+ <sort_order>612</sort_order>
350
+ <!-- do not show this configuration options in store scope -->
351
+ <show_in_default>1</show_in_default>
352
+ <show_in_website>1</show_in_website>
353
+ <show_in_store>1</show_in_store>
354
+ <fields>
355
+ <!-- is this payment method active for the website? -->
356
+ <active translate="label">
357
+ <!-- label for the field -->
358
+ <label>Enabled</label>
359
+ <!-- input type for configuration value -->
360
+ <frontend_type>select</frontend_type>
361
+ <!-- model to take the option values from -->
362
+ <source_model>adminhtml/system_config_source_yesno</source_model>
363
+ <!-- field position -->
364
+ <sort_order>1</sort_order>
365
+ <!-- do not show this field in store scope -->
366
+ <show_in_default>1</show_in_default>
367
+ <show_in_website>1</show_in_website>
368
+ <show_in_store>1</show_in_store>
369
+ </active>
370
+
371
+ <title translate="label">
372
+ <label>Title</label>
373
+ <frontend_type>text</frontend_type>
374
+ <sort_order>2</sort_order>
375
+ <show_in_default>1</show_in_default>
376
+ <show_in_website>1</show_in_website>
377
+ <show_in_store>1</show_in_store>
378
+ </title>
379
+
380
+ <allowspecific translate="label">
381
+ <label>Payment to applicable countries</label>
382
+ <frontend_type>allowspecific</frontend_type>
383
+ <sort_order>4</sort_order>
384
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
385
+ <show_in_default>1</show_in_default>
386
+ <show_in_website>1</show_in_website>
387
+ <show_in_store>1</show_in_store>
388
+ </allowspecific>
389
+
390
+ <specificcountry translate="label">
391
+ <label>Payment to Specific countries</label>
392
+ <frontend_type>multiselect</frontend_type>
393
+ <sort_order>5</sort_order>
394
+ <source_model>adminhtml/system_config_source_country</source_model>
395
+ <show_in_default>1</show_in_default>
396
+ <show_in_website>1</show_in_website>
397
+ <show_in_store>1</show_in_store>
398
+ </specificcountry>
399
+
400
+ <debug translate="label">
401
+ <label>Enable test mode</label>
402
+ <frontend_type>select</frontend_type>
403
+ <source_model>adminhtml/system_config_source_yesno</source_model>
404
+ <sort_order>6</sort_order>
405
+ <show_in_default>1</show_in_default>
406
+ <show_in_website>1</show_in_website>
407
+ <show_in_store>1</show_in_store>
408
+ </debug>
409
+
410
+ <accountnumber>
411
+ <label>Account Number</label>
412
+ <frontend_type>text</frontend_type>
413
+ <sort_order>7</sort_order>
414
+ <show_in_default>1</show_in_default>
415
+ <show_in_website>1</show_in_website>
416
+ <show_in_store>1</show_in_store>
417
+ </accountnumber>
418
+
419
+ <encryptionkey>
420
+ <label>Encryption Key</label>
421
+ <frontend_type>text</frontend_type>
422
+ <sort_order>8</sort_order>
423
+ <show_in_default>1</show_in_default>
424
+ <show_in_website>1</show_in_website>
425
+ <show_in_store>1</show_in_store>
426
+ </encryptionkey>
427
+
428
+ <transactiontype translate="label">
429
+ <label>Transaction Type</label>
430
+ <frontend_type>select</frontend_type>
431
+ <source_model>payex/source_paymentAction</source_model>
432
+ <sort_order>9</sort_order>
433
+ <show_in_default>1</show_in_default>
434
+ <show_in_website>1</show_in_website>
435
+ <show_in_store>1</show_in_store>
436
+ </transactiontype>
437
+
438
+ <order_status_authorize translate="label">
439
+ <label>Order status (for authorize)</label>
440
+ <frontend_type>select</frontend_type>
441
+ <source_model>adminhtml/system_config_source_order_status</source_model>
442
+ <sort_order>10</sort_order>
443
+ <show_in_default>1</show_in_default>
444
+ <show_in_website>1</show_in_website>
445
+ <show_in_store>1</show_in_store>
446
+ </order_status_authorize>
447
+
448
+ <order_status_capture translate="label">
449
+ <label>Order status (for capture)</label>
450
+ <frontend_type>select</frontend_type>
451
+ <source_model>adminhtml/system_config_source_order_status</source_model>
452
+ <sort_order>11</sort_order>
453
+ <show_in_default>1</show_in_default>
454
+ <show_in_website>1</show_in_website>
455
+ <show_in_store>1</show_in_store>
456
+ </order_status_capture>
457
+
458
+ <clientlanguage translate="label">
459
+ <label>Client language</label>
460
+ <frontend_type>select</frontend_type>
461
+ <source_model>payex/source_clientLanguage</source_model>
462
+ <sort_order>12</sort_order>
463
+ <show_in_default>1</show_in_default>
464
+ <show_in_website>1</show_in_website>
465
+ <show_in_store>1</show_in_store>
466
+ </clientlanguage>
467
+
468
+ <cleantime translate="label">
469
+ <label>Time to clean pending orders (0 - disabled)</label>
470
+ <frontend_type>text</frontend_type>
471
+ <sort_order>13</sort_order>
472
+ <show_in_default>1</show_in_default>
473
+ <show_in_website>1</show_in_website>
474
+ <show_in_store>1</show_in_store>
475
+ </cleantime>
476
+
477
+ <responsive translate="label">
478
+ <!-- label for the field -->
479
+ <label>Enable Responsive Skinning</label>
480
+ <!-- input type for configuration value -->
481
+ <frontend_type>select</frontend_type>
482
+ <!-- model to take the option values from -->
483
+ <source_model>adminhtml/system_config_source_yesno</source_model>
484
+ <!-- field position -->
485
+ <sort_order>14</sort_order>
486
+ <!-- do not show this field in store scope -->
487
+ <show_in_default>1</show_in_default>
488
+ <show_in_website>1</show_in_website>
489
+ <show_in_store>1</show_in_store>
490
+ </responsive>
491
+
492
+ <checkoutinfo translate="label">
493
+ <label>Send order lines and billing/delivery addresses to PayEx</label>
494
+ <frontend_type>select</frontend_type>
495
+ <source_model>adminhtml/system_config_source_yesno</source_model>
496
+ <sort_order>15</sort_order>
497
+ <show_in_default>1</show_in_default>
498
+ <show_in_website>1</show_in_website>
499
+ <show_in_store>1</show_in_store>
500
+ </checkoutinfo>
501
+ </fields>
502
+ </payex_wywallet>
503
+
504
+ <!-- newmodule fieldset -->
505
+ <payex_autopay translate="label" module="payex">
506
+ <!-- will have title 'New Module' -->
507
+ <label>PayEx Credit Card One-click Payments</label>
508
+ <!-- position between other payment methods -->
509
+ <sort_order>613</sort_order>
510
+ <!-- do not show this configuration options in store scope -->
511
+ <show_in_default>1</show_in_default>
512
+ <show_in_website>1</show_in_website>
513
+ <show_in_store>1</show_in_store>
514
+ <fields>
515
+ <!-- is this payment method active for the website? -->
516
+ <active translate="label">
517
+ <!-- label for the field -->
518
+ <label>Enabled</label>
519
+ <!-- input type for configuration value -->
520
+ <frontend_type>select</frontend_type>
521
+ <!-- model to take the option values from -->
522
+ <source_model>adminhtml/system_config_source_yesno</source_model>
523
+ <!-- field position -->
524
+ <sort_order>1</sort_order>
525
+ <!-- do not show this field in store scope -->
526
+ <show_in_default>1</show_in_default>
527
+ <show_in_website>1</show_in_website>
528
+ <show_in_store>1</show_in_store>
529
+ </active>
530
+
531
+ <title translate="label">
532
+ <label>Title</label>
533
+ <frontend_type>text</frontend_type>
534
+ <sort_order>2</sort_order>
535
+ <show_in_default>1</show_in_default>
536
+ <show_in_website>1</show_in_website>
537
+ <show_in_store>1</show_in_store>
538
+ </title>
539
+
540
+ <allowspecific translate="label">
541
+ <label>Payment to applicable countries</label>
542
+ <frontend_type>allowspecific</frontend_type>
543
+ <sort_order>3</sort_order>
544
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
545
+ <show_in_default>1</show_in_default>
546
+ <show_in_website>1</show_in_website>
547
+ <show_in_store>1</show_in_store>
548
+ </allowspecific>
549
+
550
+ <specificcountry translate="label">
551
+ <label>Payment to Specific countries</label>
552
+ <frontend_type>multiselect</frontend_type>
553
+ <sort_order>4</sort_order>
554
+ <source_model>adminhtml/system_config_source_country</source_model>
555
+ <show_in_default>1</show_in_default>
556
+ <show_in_website>1</show_in_website>
557
+ <show_in_store>1</show_in_store>
558
+ </specificcountry>
559
+
560
+ <debug translate="label">
561
+ <label>Enable test mode</label>
562
+ <frontend_type>select</frontend_type>
563
+ <source_model>adminhtml/system_config_source_yesno</source_model>
564
+ <sort_order>5</sort_order>
565
+ <show_in_default>1</show_in_default>
566
+ <show_in_website>1</show_in_website>
567
+ <show_in_store>1</show_in_store>
568
+ </debug>
569
+
570
+ <accountnumber>
571
+ <label>Account Number</label>
572
+ <frontend_type>text</frontend_type>
573
+ <sort_order>6</sort_order>
574
+ <show_in_default>1</show_in_default>
575
+ <show_in_website>1</show_in_website>
576
+ <show_in_store>1</show_in_store>
577
+ </accountnumber>
578
+
579
+ <encryptionkey>
580
+ <label>Encryption Key</label>
581
+ <frontend_type>text</frontend_type>
582
+ <sort_order>7</sort_order>
583
+ <show_in_default>1</show_in_default>
584
+ <show_in_website>1</show_in_website>
585
+ <show_in_store>1</show_in_store>
586
+ </encryptionkey>
587
+
588
+ <transactiontype translate="label">
589
+ <label>Transaction Type</label>
590
+ <frontend_type>select</frontend_type>
591
+ <source_model>payex/source_paymentAction</source_model>
592
+ <sort_order>8</sort_order>
593
+ <show_in_default>1</show_in_default>
594
+ <show_in_website>1</show_in_website>
595
+ <show_in_store>1</show_in_store>
596
+ </transactiontype>
597
+
598
+ <order_status_authorize translate="label">
599
+ <label>Order status (for authorize)</label>
600
+ <frontend_type>select</frontend_type>
601
+ <source_model>adminhtml/system_config_source_order_status</source_model>
602
+ <sort_order>9</sort_order>
603
+ <show_in_default>1</show_in_default>
604
+ <show_in_website>1</show_in_website>
605
+ <show_in_store>1</show_in_store>
606
+ </order_status_authorize>
607
+
608
+ <order_status_capture translate="label">
609
+ <label>Order status (for capture)</label>
610
+ <frontend_type>select</frontend_type>
611
+ <source_model>adminhtml/system_config_source_order_status</source_model>
612
+ <sort_order>10</sort_order>
613
+ <show_in_default>1</show_in_default>
614
+ <show_in_website>1</show_in_website>
615
+ <show_in_store>1</show_in_store>
616
+ </order_status_capture>
617
+
618
+ <clientlanguage translate="label">
619
+ <label>Client language</label>
620
+ <frontend_type>select</frontend_type>
621
+ <source_model>payex/source_clientLanguage</source_model>
622
+ <sort_order>11</sort_order>
623
+ <show_in_default>1</show_in_default>
624
+ <show_in_website>1</show_in_website>
625
+ <show_in_store>1</show_in_store>
626
+ </clientlanguage>
627
+
628
+ <agreementurl translate="label">
629
+ <label>Agreement url</label>
630
+ <frontend_type>text</frontend_type>
631
+ <sort_order>12</sort_order>
632
+ <show_in_default>1</show_in_default>
633
+ <show_in_website>1</show_in_website>
634
+ <show_in_store>1</show_in_store>
635
+ </agreementurl>
636
+
637
+ <maxamount translate="label">
638
+ <label>Max amount of single transaction</label>
639
+ <frontend_type>text</frontend_type>
640
+ <sort_order>13</sort_order>
641
+ <show_in_default>1</show_in_default>
642
+ <show_in_website>1</show_in_website>
643
+ <show_in_store>1</show_in_store>
644
+ </maxamount>
645
+
646
+ <cleantime translate="label">
647
+ <label>Time to clean pending orders (0 - disabled)</label>
648
+ <frontend_type>text</frontend_type>
649
+ <sort_order>14</sort_order>
650
+ <show_in_default>1</show_in_default>
651
+ <show_in_website>1</show_in_website>
652
+ <show_in_store>1</show_in_store>
653
+ </cleantime>
654
+
655
+ <responsive translate="label">
656
+ <!-- label for the field -->
657
+ <label>Enable Responsive Skinning</label>
658
+ <!-- input type for configuration value -->
659
+ <frontend_type>select</frontend_type>
660
+ <!-- model to take the option values from -->
661
+ <source_model>adminhtml/system_config_source_yesno</source_model>
662
+ <!-- field position -->
663
+ <sort_order>15</sort_order>
664
+ <!-- do not show this field in store scope -->
665
+ <show_in_default>1</show_in_default>
666
+ <show_in_website>1</show_in_website>
667
+ <show_in_store>1</show_in_store>
668
+ </responsive>
669
+
670
+ <checkoutinfo translate="label">
671
+ <label>Send order lines and billing/delivery addresses to PayEx</label>
672
+ <frontend_type>select</frontend_type>
673
+ <source_model>adminhtml/system_config_source_yesno</source_model>
674
+ <sort_order>16</sort_order>
675
+ <show_in_default>1</show_in_default>
676
+ <show_in_website>1</show_in_website>
677
+ <show_in_store>1</show_in_store>
678
+ </checkoutinfo>
679
+ </fields>
680
+ </payex_autopay>
681
+
682
+ <!-- newmodule fieldset -->
683
+ <payex_masterpass translate="label" module="payex">
684
+ <!-- will have title 'New Module' -->
685
+ <label>PayEx MasterPass</label>
686
+ <!-- position between other payment methods -->
687
+ <sort_order>614</sort_order>
688
+ <!-- do not show this configuration options in store scope -->
689
+ <show_in_default>1</show_in_default>
690
+ <show_in_website>1</show_in_website>
691
+ <show_in_store>1</show_in_store>
692
+ <fields>
693
+ <!-- is this payment method active for the website? -->
694
+ <active translate="label">
695
+ <!-- label for the field -->
696
+ <label>Enabled</label>
697
+ <!-- input type for configuration value -->
698
+ <frontend_type>select</frontend_type>
699
+ <!-- model to take the option values from -->
700
+ <source_model>adminhtml/system_config_source_yesno</source_model>
701
+ <!-- field position -->
702
+ <sort_order>1</sort_order>
703
+ <!-- do not show this field in store scope -->
704
+ <show_in_default>1</show_in_default>
705
+ <show_in_website>1</show_in_website>
706
+ <show_in_store>1</show_in_store>
707
+ </active>
708
+
709
+ <title translate="label">
710
+ <label>Title</label>
711
+ <frontend_type>text</frontend_type>
712
+ <sort_order>2</sort_order>
713
+ <show_in_default>1</show_in_default>
714
+ <show_in_website>1</show_in_website>
715
+ <show_in_store>1</show_in_store>
716
+ </title>
717
+
718
+ <allowspecific translate="label">
719
+ <label>Payment to applicable countries</label>
720
+ <frontend_type>allowspecific</frontend_type>
721
+ <sort_order>4</sort_order>
722
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
723
+ <show_in_default>1</show_in_default>
724
+ <show_in_website>1</show_in_website>
725
+ <show_in_store>1</show_in_store>
726
+ </allowspecific>
727
+
728
+ <specificcountry translate="label">
729
+ <label>Payment to Specific countries</label>
730
+ <frontend_type>multiselect</frontend_type>
731
+ <sort_order>5</sort_order>
732
+ <source_model>adminhtml/system_config_source_country</source_model>
733
+ <show_in_default>1</show_in_default>
734
+ <show_in_website>1</show_in_website>
735
+ <show_in_store>1</show_in_store>
736
+ </specificcountry>
737
+
738
+ <debug translate="label">
739
+ <label>Enable test mode</label>
740
+ <frontend_type>select</frontend_type>
741
+ <source_model>adminhtml/system_config_source_yesno</source_model>
742
+ <sort_order>6</sort_order>
743
+ <show_in_default>1</show_in_default>
744
+ <show_in_website>1</show_in_website>
745
+ <show_in_store>1</show_in_store>
746
+ </debug>
747
+
748
+ <accountnumber>
749
+ <label>Account Number</label>
750
+ <frontend_type>text</frontend_type>
751
+ <sort_order>7</sort_order>
752
+ <show_in_default>1</show_in_default>
753
+ <show_in_website>1</show_in_website>
754
+ <show_in_store>1</show_in_store>
755
+ </accountnumber>
756
+
757
+ <encryptionkey>
758
+ <label>Encryption Key</label>
759
+ <frontend_type>text</frontend_type>
760
+ <sort_order>8</sort_order>
761
+ <show_in_default>1</show_in_default>
762
+ <show_in_website>1</show_in_website>
763
+ <show_in_store>1</show_in_store>
764
+ </encryptionkey>
765
+
766
+ <transactiontype translate="label">
767
+ <label>Transaction Type</label>
768
+ <frontend_type>select</frontend_type>
769
+ <source_model>payex/source_paymentAction</source_model>
770
+ <sort_order>9</sort_order>
771
+ <show_in_default>1</show_in_default>
772
+ <show_in_website>1</show_in_website>
773
+ <show_in_store>1</show_in_store>
774
+ </transactiontype>
775
+
776
+ <order_status_authorize translate="label">
777
+ <label>Order status (for authorize)</label>
778
+ <frontend_type>select</frontend_type>
779
+ <source_model>adminhtml/system_config_source_order_status</source_model>
780
+ <sort_order>10</sort_order>
781
+ <show_in_default>1</show_in_default>
782
+ <show_in_website>1</show_in_website>
783
+ <show_in_store>1</show_in_store>
784
+ </order_status_authorize>
785
+
786
+ <order_status_capture translate="label">
787
+ <label>Order status (for capture)</label>
788
+ <frontend_type>select</frontend_type>
789
+ <source_model>adminhtml/system_config_source_order_status</source_model>
790
+ <sort_order>11</sort_order>
791
+ <show_in_default>1</show_in_default>
792
+ <show_in_website>1</show_in_website>
793
+ <show_in_store>1</show_in_store>
794
+ </order_status_capture>
795
+
796
+ <clientlanguage translate="label">
797
+ <label>Client language</label>
798
+ <frontend_type>select</frontend_type>
799
+ <source_model>payex/source_clientLanguage</source_model>
800
+ <sort_order>12</sort_order>
801
+ <show_in_default>1</show_in_default>
802
+ <show_in_website>1</show_in_website>
803
+ <show_in_store>1</show_in_store>
804
+ </clientlanguage>
805
+
806
+ <cleantime translate="label">
807
+ <label>Time to clean pending orders (0 - disabled)</label>
808
+ <frontend_type>text</frontend_type>
809
+ <sort_order>13</sort_order>
810
+ <show_in_default>1</show_in_default>
811
+ <show_in_website>1</show_in_website>
812
+ <show_in_store>1</show_in_store>
813
+ </cleantime>
814
+
815
+ <shipping_method translate="label">
816
+ <label>Default shipping method for MasterPass orders</label>
817
+ <frontend_type>select</frontend_type>
818
+ <source_model>payex/source_shippingMethod</source_model>
819
+ <sort_order>14</sort_order>
820
+ <show_in_default>1</show_in_default>
821
+ <show_in_website>1</show_in_website>
822
+ <show_in_store>1</show_in_store>
823
+ </shipping_method>
824
+ </fields>
825
+ </payex_masterpass>
826
+
827
+ <!-- newmodule fieldset -->
828
+ <payex_financing translate="label" module="payex">
829
+ <!-- will have title 'New Module' -->
830
+ <label>PayEx Financing Invoice</label>
831
+ <!-- position between other payment methods -->
832
+ <sort_order>615</sort_order>
833
+ <!-- do not show this configuration options in store scope -->
834
+ <show_in_default>1</show_in_default>
835
+ <show_in_website>1</show_in_website>
836
+ <show_in_store>1</show_in_store>
837
+ <fields>
838
+ <!-- is this payment method active for the website? -->
839
+ <active translate="label">
840
+ <!-- label for the field -->
841
+ <label>Enabled</label>
842
+ <!-- input type for configuration value -->
843
+ <frontend_type>select</frontend_type>
844
+ <!-- model to take the option values from -->
845
+ <source_model>adminhtml/system_config_source_yesno</source_model>
846
+ <!-- field position -->
847
+ <sort_order>1</sort_order>
848
+ <!-- do not show this field in store scope -->
849
+ <show_in_default>1</show_in_default>
850
+ <show_in_website>1</show_in_website>
851
+ <show_in_store>1</show_in_store>
852
+ </active>
853
+
854
+ <title translate="label">
855
+ <label>Title</label>
856
+ <frontend_type>text</frontend_type>
857
+ <sort_order>2</sort_order>
858
+ <show_in_default>1</show_in_default>
859
+ <show_in_website>1</show_in_website>
860
+ <show_in_store>1</show_in_store>
861
+ </title>
862
+
863
+ <allowspecific translate="label">
864
+ <label>Payment to applicable countries</label>
865
+ <frontend_type>allowspecific</frontend_type>
866
+ <sort_order>3</sort_order>
867
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
868
+ <show_in_default>1</show_in_default>
869
+ <show_in_website>1</show_in_website>
870
+ <show_in_store>1</show_in_store>
871
+ </allowspecific>
872
+
873
+ <specificcountry translate="label">
874
+ <label>Payment to Specific countries</label>
875
+ <frontend_type>multiselect</frontend_type>
876
+ <sort_order>4</sort_order>
877
+ <source_model>adminhtml/system_config_source_country</source_model>
878
+ <show_in_default>1</show_in_default>
879
+ <show_in_website>1</show_in_website>
880
+ <show_in_store>1</show_in_store>
881
+ </specificcountry>
882
+
883
+ <debug translate="label">
884
+ <label>Enable test mode</label>
885
+ <frontend_type>select</frontend_type>
886
+ <source_model>adminhtml/system_config_source_yesno</source_model>
887
+ <sort_order>5</sort_order>
888
+ <show_in_default>1</show_in_default>
889
+ <show_in_website>1</show_in_website>
890
+ <show_in_store>1</show_in_store>
891
+ </debug>
892
+
893
+ <accountnumber>
894
+ <label>Account Number</label>
895
+ <frontend_type>text</frontend_type>
896
+ <sort_order>6</sort_order>
897
+ <show_in_default>1</show_in_default>
898
+ <show_in_website>1</show_in_website>
899
+ <show_in_store>1</show_in_store>
900
+ </accountnumber>
901
+
902
+ <encryptionkey>
903
+ <label>Encryption Key</label>
904
+ <frontend_type>text</frontend_type>
905
+ <sort_order>7</sort_order>
906
+ <show_in_default>1</show_in_default>
907
+ <show_in_website>1</show_in_website>
908
+ <show_in_store>1</show_in_store>
909
+ </encryptionkey>
910
+
911
+ <order_status_authorize translate="label">
912
+ <label>Order status (for authorize)</label>
913
+ <frontend_type>select</frontend_type>
914
+ <source_model>adminhtml/system_config_source_order_status</source_model>
915
+ <sort_order>8</sort_order>
916
+ <show_in_default>1</show_in_default>
917
+ <show_in_website>1</show_in_website>
918
+ <show_in_store>1</show_in_store>
919
+ </order_status_authorize>
920
+
921
+ <order_status_capture translate="label">
922
+ <label>Order status (for capture)</label>
923
+ <frontend_type>select</frontend_type>
924
+ <source_model>adminhtml/system_config_source_order_status</source_model>
925
+ <sort_order>9</sort_order>
926
+ <show_in_default>1</show_in_default>
927
+ <show_in_website>1</show_in_website>
928
+ <show_in_store>1</show_in_store>
929
+ </order_status_capture>
930
+
931
+ <clientlanguage translate="label">
932
+ <label>Client language</label>
933
+ <frontend_type>select</frontend_type>
934
+ <source_model>payex/source_clientLanguage</source_model>
935
+ <sort_order>10</sort_order>
936
+ <show_in_default>1</show_in_default>
937
+ <show_in_website>1</show_in_website>
938
+ <show_in_store>1</show_in_store>
939
+ </clientlanguage>
940
+
941
+ <paymentfee>
942
+ <label>Payment fee</label>
943
+ <frontend_type>text</frontend_type>
944
+ <sort_order>11</sort_order>
945
+ <show_in_default>1</show_in_default>
946
+ <show_in_website>1</show_in_website>
947
+ <show_in_store>1</show_in_store>
948
+ </paymentfee>
949
+
950
+ <paymentfee_tax_class>
951
+ <label>Tax Class for Payment fee</label>
952
+ <frontend_type>select</frontend_type>
953
+ <source_model>payex/source_taxClasses</source_model>
954
+ <sort_order>12</sort_order>
955
+ <show_in_default>1</show_in_default>
956
+ <show_in_website>1</show_in_website>
957
+ <show_in_store>1</show_in_store>
958
+ </paymentfee_tax_class>
959
+
960
+ <cleantime translate="label">
961
+ <label>Time to clean pending orders (0 - disabled)</label>
962
+ <frontend_type>text</frontend_type>
963
+ <sort_order>13</sort_order>
964
+ <show_in_default>1</show_in_default>
965
+ <show_in_website>1</show_in_website>
966
+ <show_in_store>1</show_in_store>
967
+ </cleantime>
968
+
969
+ <replace_illegal translate="label">
970
+ <label>Replace illegal characters</label>
971
+ <frontend_type>select</frontend_type>
972
+ <source_model>adminhtml/system_config_source_yesno</source_model>
973
+ <sort_order>14</sort_order>
974
+ <show_in_default>1</show_in_default>
975
+ <show_in_website>1</show_in_website>
976
+ <show_in_store>1</show_in_store>
977
+ </replace_illegal>
978
+
979
+ <replacement_char>
980
+ <label>Enter replacement char</label>
981
+ <frontend_type>text</frontend_type>
982
+ <sort_order>15</sort_order>
983
+ <show_in_default>1</show_in_default>
984
+ <show_in_website>1</show_in_website>
985
+ <show_in_store>1</show_in_store>
986
+ </replacement_char>
987
+ </fields>
988
+ </payex_financing>
989
+
990
+ <!-- newmodule fieldset -->
991
+ <payex_partpayment translate="label" module="payex">
992
+ <!-- will have title 'New Module' -->
993
+ <label>PayEx Financing Credit Account</label>
994
+ <!-- position between other payment methods -->
995
+ <sort_order>616</sort_order>
996
+ <!-- do not show this configuration options in store scope -->
997
+ <show_in_default>1</show_in_default>
998
+ <show_in_website>1</show_in_website>
999
+ <show_in_store>1</show_in_store>
1000
+ <fields>
1001
+ <!-- is this payment method active for the website? -->
1002
+ <active translate="label">
1003
+ <!-- label for the field -->
1004
+ <label>Enabled</label>
1005
+ <!-- input type for configuration value -->
1006
+ <frontend_type>select</frontend_type>
1007
+ <!-- model to take the option values from -->
1008
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1009
+ <!-- field position -->
1010
+ <sort_order>1</sort_order>
1011
+ <!-- do not show this field in store scope -->
1012
+ <show_in_default>1</show_in_default>
1013
+ <show_in_website>1</show_in_website>
1014
+ <show_in_store>1</show_in_store>
1015
+ </active>
1016
+
1017
+ <title translate="label">
1018
+ <label>Title</label>
1019
+ <frontend_type>text</frontend_type>
1020
+ <sort_order>2</sort_order>
1021
+ <show_in_default>1</show_in_default>
1022
+ <show_in_website>1</show_in_website>
1023
+ <show_in_store>1</show_in_store>
1024
+ </title>
1025
+
1026
+ <allowspecific translate="label">
1027
+ <label>Payment to applicable countries</label>
1028
+ <frontend_type>allowspecific</frontend_type>
1029
+ <sort_order>4</sort_order>
1030
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
1031
+ <show_in_default>1</show_in_default>
1032
+ <show_in_website>1</show_in_website>
1033
+ <show_in_store>1</show_in_store>
1034
+ </allowspecific>
1035
+
1036
+ <specificcountry translate="label">
1037
+ <label>Payment to Specific countries</label>
1038
+ <frontend_type>multiselect</frontend_type>
1039
+ <sort_order>5</sort_order>
1040
+ <source_model>adminhtml/system_config_source_country</source_model>
1041
+ <show_in_default>1</show_in_default>
1042
+ <show_in_website>1</show_in_website>
1043
+ <show_in_store>1</show_in_store>
1044
+ </specificcountry>
1045
+
1046
+ <debug translate="label">
1047
+ <label>Enable test mode</label>
1048
+ <frontend_type>select</frontend_type>
1049
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1050
+ <sort_order>6</sort_order>
1051
+ <show_in_default>1</show_in_default>
1052
+ <show_in_website>1</show_in_website>
1053
+ <show_in_store>1</show_in_store>
1054
+ </debug>
1055
+
1056
+ <accountnumber>
1057
+ <label>Account Number</label>
1058
+ <frontend_type>text</frontend_type>
1059
+ <sort_order>7</sort_order>
1060
+ <show_in_default>1</show_in_default>
1061
+ <show_in_website>1</show_in_website>
1062
+ <show_in_store>1</show_in_store>
1063
+ </accountnumber>
1064
+
1065
+ <encryptionkey>
1066
+ <label>Encryption Key</label>
1067
+ <frontend_type>text</frontend_type>
1068
+ <sort_order>8</sort_order>
1069
+ <show_in_default>1</show_in_default>
1070
+ <show_in_website>1</show_in_website>
1071
+ <show_in_store>1</show_in_store>
1072
+ </encryptionkey>
1073
+
1074
+ <order_status_authorize translate="label">
1075
+ <label>Order status (for authorize)</label>
1076
+ <frontend_type>select</frontend_type>
1077
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1078
+ <sort_order>10</sort_order>
1079
+ <show_in_default>1</show_in_default>
1080
+ <show_in_website>1</show_in_website>
1081
+ <show_in_store>1</show_in_store>
1082
+ </order_status_authorize>
1083
+
1084
+ <order_status_capture translate="label">
1085
+ <label>Order status (for capture)</label>
1086
+ <frontend_type>select</frontend_type>
1087
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1088
+ <sort_order>11</sort_order>
1089
+ <show_in_default>1</show_in_default>
1090
+ <show_in_website>1</show_in_website>
1091
+ <show_in_store>1</show_in_store>
1092
+ </order_status_capture>
1093
+
1094
+ <clientlanguage translate="label">
1095
+ <label>Client language</label>
1096
+ <frontend_type>select</frontend_type>
1097
+ <source_model>payex/source_clientLanguage</source_model>
1098
+ <sort_order>12</sort_order>
1099
+ <show_in_default>1</show_in_default>
1100
+ <show_in_website>1</show_in_website>
1101
+ <show_in_store>1</show_in_store>
1102
+ </clientlanguage>
1103
+
1104
+ <paymentfee>
1105
+ <label>Payment fee</label>
1106
+ <frontend_type>text</frontend_type>
1107
+ <sort_order>13</sort_order>
1108
+ <show_in_default>1</show_in_default>
1109
+ <show_in_website>1</show_in_website>
1110
+ <show_in_store>1</show_in_store>
1111
+ </paymentfee>
1112
+
1113
+ <paymentfee_tax_class>
1114
+ <label>Tax Class for Payment fee</label>
1115
+ <frontend_type>select</frontend_type>
1116
+ <source_model>payex/source_taxClasses</source_model>
1117
+ <sort_order>14</sort_order>
1118
+ <show_in_default>1</show_in_default>
1119
+ <show_in_website>1</show_in_website>
1120
+ <show_in_store>1</show_in_store>
1121
+ </paymentfee_tax_class>
1122
+
1123
+ <cleantime translate="label">
1124
+ <label>Time to clean pending orders (0 - disabled)</label>
1125
+ <frontend_type>text</frontend_type>
1126
+ <sort_order>15</sort_order>
1127
+ <show_in_default>1</show_in_default>
1128
+ <show_in_website>1</show_in_website>
1129
+ <show_in_store>1</show_in_store>
1130
+ </cleantime>
1131
+
1132
+ <replace_illegal translate="label">
1133
+ <label>Replace illegal characters</label>
1134
+ <frontend_type>select</frontend_type>
1135
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1136
+ <sort_order>16</sort_order>
1137
+ <show_in_default>1</show_in_default>
1138
+ <show_in_website>1</show_in_website>
1139
+ <show_in_store>1</show_in_store>
1140
+ </replace_illegal>
1141
+
1142
+ <replacement_char>
1143
+ <label>Enter replacement char</label>
1144
+ <frontend_type>text</frontend_type>
1145
+ <sort_order>17</sort_order>
1146
+ <show_in_default>1</show_in_default>
1147
+ <show_in_website>1</show_in_website>
1148
+ <show_in_store>1</show_in_store>
1149
+ </replacement_char>
1150
+ </fields>
1151
+ </payex_partpayment>
1152
+
1153
+ <!-- newmodule fieldset -->
1154
+ <payex_invoice translate="label" module="paygate">
1155
+ <!-- will have title 'New Module' -->
1156
+ <label>PayEx Invoice Payments (Ledger Service)</label>
1157
+ <!-- position between other payment methods -->
1158
+ <sort_order>617</sort_order>
1159
+ <!-- do not show this configuration options in store scope -->
1160
+ <show_in_default>1</show_in_default>
1161
+ <show_in_website>1</show_in_website>
1162
+ <show_in_store>1</show_in_store>
1163
+ <fields>
1164
+ <!-- is this payment method active for the website? -->
1165
+ <active translate="label">
1166
+ <!-- label for the field -->
1167
+ <label>Enabled</label>
1168
+ <!-- input type for configuration value -->
1169
+ <frontend_type>select</frontend_type>
1170
+ <!-- model to take the option values from -->
1171
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1172
+ <!-- field position -->
1173
+ <sort_order>1</sort_order>
1174
+ <!-- do not show this field in store scope -->
1175
+ <show_in_default>1</show_in_default>
1176
+ <show_in_website>1</show_in_website>
1177
+ <show_in_store>1</show_in_store>
1178
+ </active>
1179
+
1180
+ <title translate="label">
1181
+ <label>Title</label>
1182
+ <frontend_type>text</frontend_type>
1183
+ <sort_order>2</sort_order>
1184
+ <show_in_default>1</show_in_default>
1185
+ <show_in_website>1</show_in_website>
1186
+ <show_in_store>1</show_in_store>
1187
+ </title>
1188
+
1189
+ <allowspecific translate="label">
1190
+ <label>Payment to applicable countries</label>
1191
+ <frontend_type>allowspecific</frontend_type>
1192
+ <sort_order>3</sort_order>
1193
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
1194
+ <show_in_default>1</show_in_default>
1195
+ <show_in_website>1</show_in_website>
1196
+ <show_in_store>1</show_in_store>
1197
+ </allowspecific>
1198
+
1199
+ <specificcountry translate="label">
1200
+ <label>Payment to Specific countries</label>
1201
+ <frontend_type>multiselect</frontend_type>
1202
+ <sort_order>4</sort_order>
1203
+ <source_model>adminhtml/system_config_source_country</source_model>
1204
+ <show_in_default>1</show_in_default>
1205
+ <show_in_website>1</show_in_website>
1206
+ <show_in_store>1</show_in_store>
1207
+ </specificcountry>
1208
+
1209
+ <debug translate="label">
1210
+ <label>Enable test mode</label>
1211
+ <frontend_type>select</frontend_type>
1212
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1213
+ <sort_order>5</sort_order>
1214
+ <show_in_default>1</show_in_default>
1215
+ <show_in_website>1</show_in_website>
1216
+ <show_in_store>1</show_in_store>
1217
+ </debug>
1218
+
1219
+ <transactiontype translate="label">
1220
+ <label>Transaction Type</label>
1221
+ <frontend_type>select</frontend_type>
1222
+ <source_model>payex/source_paymentAction</source_model>
1223
+ <sort_order>6</sort_order>
1224
+ <show_in_default>1</show_in_default>
1225
+ <show_in_website>1</show_in_website>
1226
+ <show_in_store>1</show_in_store>
1227
+ </transactiontype>
1228
+
1229
+ <order_status_authorize translate="label">
1230
+ <label>Order status (for authorize)</label>
1231
+ <frontend_type>select</frontend_type>
1232
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1233
+ <sort_order>7</sort_order>
1234
+ <show_in_default>1</show_in_default>
1235
+ <show_in_website>1</show_in_website>
1236
+ <show_in_store>1</show_in_store>
1237
+ </order_status_authorize>
1238
+
1239
+ <order_status_capture translate="label">
1240
+ <label>Order status (for capture)</label>
1241
+ <frontend_type>select</frontend_type>
1242
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1243
+ <sort_order>8</sort_order>
1244
+ <show_in_default>1</show_in_default>
1245
+ <show_in_website>1</show_in_website>
1246
+ <show_in_store>1</show_in_store>
1247
+ </order_status_capture>
1248
+
1249
+ <accountnumber>
1250
+ <label>Account Number</label>
1251
+ <frontend_type>text</frontend_type>
1252
+ <sort_order>9</sort_order>
1253
+ <show_in_default>1</show_in_default>
1254
+ <show_in_website>1</show_in_website>
1255
+ <show_in_store>1</show_in_store>
1256
+ </accountnumber>
1257
+
1258
+ <encryptionkey>
1259
+ <label>Encryption Key</label>
1260
+ <frontend_type>text</frontend_type>
1261
+ <sort_order>10</sort_order>
1262
+ <show_in_default>1</show_in_default>
1263
+ <show_in_website>1</show_in_website>
1264
+ <show_in_store>1</show_in_store>
1265
+ </encryptionkey>
1266
+
1267
+ <additionalValues>
1268
+ <label>Additional values to send</label>
1269
+ <frontend_type>text</frontend_type>
1270
+ <sort_order>11</sort_order>
1271
+ <show_in_default>1</show_in_default>
1272
+ <show_in_website>1</show_in_website>
1273
+ <show_in_store>1</show_in_store>
1274
+ </additionalValues>
1275
+
1276
+ <clientlanguage translate="label">
1277
+ <label>Client language</label>
1278
+ <frontend_type>select</frontend_type>
1279
+ <source_model>payex/source_clientLanguage</source_model>
1280
+ <sort_order>12</sort_order>
1281
+ <show_in_default>1</show_in_default>
1282
+ <show_in_website>1</show_in_website>
1283
+ <show_in_store>1</show_in_store>
1284
+ </clientlanguage>
1285
+
1286
+ <distribution translate="label">
1287
+ <label>Invoice distribution</label>
1288
+ <frontend_type>select</frontend_type>
1289
+ <source_model>payex/source_mediaDistribution</source_model>
1290
+ <sort_order>13</sort_order>
1291
+ <show_in_default>1</show_in_default>
1292
+ <show_in_website>1</show_in_website>
1293
+ <show_in_store>1</show_in_store>
1294
+ </distribution>
1295
+
1296
+ <paymentfee>
1297
+ <label>Invoice fee</label>
1298
+ <frontend_type>text</frontend_type>
1299
+ <sort_order>14</sort_order>
1300
+ <show_in_default>1</show_in_default>
1301
+ <show_in_website>1</show_in_website>
1302
+ <show_in_store>1</show_in_store>
1303
+ </paymentfee>
1304
+
1305
+ <paymentfee_tax_class>
1306
+ <label>Tax Class for Payment fee</label>
1307
+ <frontend_type>select</frontend_type>
1308
+ <source_model>payex/source_taxClasses</source_model>
1309
+ <sort_order>16</sort_order>
1310
+ <show_in_default>1</show_in_default>
1311
+ <show_in_website>1</show_in_website>
1312
+ <show_in_store>1</show_in_store>
1313
+ </paymentfee_tax_class>
1314
+
1315
+ <invoicetext>
1316
+ <label>Invoice text</label>
1317
+ <frontend_type>text</frontend_type>
1318
+ <sort_order>17</sort_order>
1319
+ <show_in_default>1</show_in_default>
1320
+ <show_in_website>1</show_in_website>
1321
+ <show_in_store>1</show_in_store>
1322
+ </invoicetext>
1323
+
1324
+ <invoiceduedays>
1325
+ <label>Invoice due days</label>
1326
+ <frontend_type>text</frontend_type>
1327
+ <sort_order>18</sort_order>
1328
+ <show_in_default>1</show_in_default>
1329
+ <show_in_website>1</show_in_website>
1330
+ <show_in_store>1</show_in_store>
1331
+ </invoiceduedays>
1332
+
1333
+ <unapproved translate="label">
1334
+ <label>Allow unapproved by CreditCheck</label>
1335
+ <frontend_type>select</frontend_type>
1336
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1337
+ <sort_order>19</sort_order>
1338
+ <show_in_default>1</show_in_default>
1339
+ <show_in_website>1</show_in_website>
1340
+ <show_in_store>1</show_in_store>
1341
+ </unapproved>
1342
+ </fields>
1343
+ </payex_invoice>
1344
+
1345
+ <!-- newmodule fieldset -->
1346
+ <payex_swish translate="label" module="payex">
1347
+ <!-- will have title 'New Module' -->
1348
+ <label>PayEx Swish</label>
1349
+ <!-- position between other payment methods -->
1350
+ <sort_order>618</sort_order>
1351
+ <!-- do not show this configuration options in store scope -->
1352
+ <show_in_default>1</show_in_default>
1353
+ <show_in_website>1</show_in_website>
1354
+ <show_in_store>0</show_in_store>
1355
+ <fields>
1356
+ <!-- is this payment method active for the website? -->
1357
+ <active translate="label">
1358
+ <!-- label for the field -->
1359
+ <label>Enabled</label>
1360
+ <!-- input type for configuration value -->
1361
+ <frontend_type>select</frontend_type>
1362
+ <!-- model to take the option values from -->
1363
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1364
+ <!-- field position -->
1365
+ <sort_order>1</sort_order>
1366
+ <!-- do not show this field in store scope -->
1367
+ <show_in_default>1</show_in_default>
1368
+ <show_in_website>1</show_in_website>
1369
+ <show_in_store>1</show_in_store>
1370
+ </active>
1371
+
1372
+ <title translate="label">
1373
+ <label>Title</label>
1374
+ <frontend_type>text</frontend_type>
1375
+ <sort_order>2</sort_order>
1376
+ <show_in_default>1</show_in_default>
1377
+ <show_in_website>1</show_in_website>
1378
+ <show_in_store>1</show_in_store>
1379
+ </title>
1380
+
1381
+ <allowspecific translate="label">
1382
+ <label>Payment to applicable countries</label>
1383
+ <frontend_type>allowspecific</frontend_type>
1384
+ <sort_order>3</sort_order>
1385
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
1386
+ <show_in_default>1</show_in_default>
1387
+ <show_in_website>1</show_in_website>
1388
+ <show_in_store>1</show_in_store>
1389
+ </allowspecific>
1390
+
1391
+ <specificcountry translate="label">
1392
+ <label>Payment to Specific countries</label>
1393
+ <frontend_type>multiselect</frontend_type>
1394
+ <sort_order>4</sort_order>
1395
+ <source_model>adminhtml/system_config_source_country</source_model>
1396
+ <show_in_default>1</show_in_default>
1397
+ <show_in_website>1</show_in_website>
1398
+ <show_in_store>1</show_in_store>
1399
+ </specificcountry>
1400
+
1401
+ <debug translate="label">
1402
+ <label>Enable test mode</label>
1403
+ <frontend_type>select</frontend_type>
1404
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1405
+ <sort_order>5</sort_order>
1406
+ <show_in_default>1</show_in_default>
1407
+ <show_in_website>1</show_in_website>
1408
+ <show_in_store>0</show_in_store>
1409
+ </debug>
1410
+
1411
+ <accountnumber>
1412
+ <label>Account Number</label>
1413
+ <frontend_type>text</frontend_type>
1414
+ <sort_order>6</sort_order>
1415
+ <show_in_default>1</show_in_default>
1416
+ <show_in_website>1</show_in_website>
1417
+ <show_in_store>1</show_in_store>
1418
+ </accountnumber>
1419
+
1420
+ <encryptionkey>
1421
+ <label>Encryption Key</label>
1422
+ <frontend_type>text</frontend_type>
1423
+ <sort_order>7</sort_order>
1424
+ <show_in_default>1</show_in_default>
1425
+ <show_in_website>1</show_in_website>
1426
+ <show_in_store>1</show_in_store>
1427
+ </encryptionkey>
1428
+
1429
+ <order_status translate="label">
1430
+ <label>New order status</label>
1431
+ <frontend_type>select</frontend_type>
1432
+ <source_model>adminhtml/system_config_source_order_status</source_model>
1433
+ <sort_order>8</sort_order>
1434
+ <show_in_default>1</show_in_default>
1435
+ <show_in_website>1</show_in_website>
1436
+ <show_in_store>1</show_in_store>
1437
+ </order_status>
1438
+
1439
+ <clientlanguage translate="label">
1440
+ <label>Client language</label>
1441
+ <frontend_type>select</frontend_type>
1442
+ <source_model>payex/source_clientLanguage</source_model>
1443
+ <sort_order>10</sort_order>
1444
+ <show_in_default>1</show_in_default>
1445
+ <show_in_website>1</show_in_website>
1446
+ <show_in_store>1</show_in_store>
1447
+ </clientlanguage>
1448
+
1449
+ <cleantime translate="label">
1450
+ <label>Time to clean pending orders (0 - disabled)</label>
1451
+ <frontend_type>text</frontend_type>
1452
+ <sort_order>11</sort_order>
1453
+ <show_in_default>1</show_in_default>
1454
+ <show_in_website>1</show_in_website>
1455
+ <show_in_store>1</show_in_store>
1456
+ </cleantime>
1457
+
1458
+ <responsive translate="label">
1459
+ <!-- label for the field -->
1460
+ <label>Enable Responsive Skinning</label>
1461
+ <!-- input type for configuration value -->
1462
+ <frontend_type>select</frontend_type>
1463
+ <!-- model to take the option values from -->
1464
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1465
+ <!-- field position -->
1466
+ <sort_order>12</sort_order>
1467
+ <!-- do not show this field in store scope -->
1468
+ <show_in_default>1</show_in_default>
1469
+ <show_in_website>1</show_in_website>
1470
+ <show_in_store>1</show_in_store>
1471
+ </responsive>
1472
+
1473
+ <checkoutinfo translate="label">
1474
+ <label>Send order lines and billing/delivery addresses to PayEx</label>
1475
+ <frontend_type>select</frontend_type>
1476
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1477
+ <sort_order>15</sort_order>
1478
+ <show_in_default>1</show_in_default>
1479
+ <show_in_website>1</show_in_website>
1480
+ <show_in_store>1</show_in_store>
1481
+ </checkoutinfo>
1482
+ </fields>
1483
+ </payex_swish>
1484
+ </groups>
1485
+ </payment>
1486
+
1487
+ <!-- Social Security Number -->
1488
+ <payex_ssn translate="label" module="payex">
1489
+ <label>Social Security Number</label>
1490
+ <tab>payex</tab>
1491
+ <show_in_default>1</show_in_default>
1492
+ <show_in_website>1</show_in_website>
1493
+ <show_in_store>1</show_in_store>
1494
+ <sort_order>100</sort_order>
1495
+ <groups>
1496
+ <payex_ssn translate="label">
1497
+ <label>PayEx Settings</label>
1498
+ <sort_order>1</sort_order>
1499
+ <frontend_type>text</frontend_type>
1500
+ <show_in_default>1</show_in_default>
1501
+ <show_in_website>1</show_in_website>
1502
+ <show_in_store>1</show_in_store>
1503
+ <expanded>1</expanded>
1504
+ <fields>
1505
+ <active translate="label">
1506
+ <label>Enabled</label>
1507
+ <frontend_type>select</frontend_type>
1508
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1509
+ <sort_order>1</sort_order>
1510
+ <show_in_default>1</show_in_default>
1511
+ <show_in_website>1</show_in_website>
1512
+ <show_in_store>1</show_in_store>
1513
+ </active>
1514
+ <debug translate="label">
1515
+ <label>Enable test mode</label>
1516
+ <frontend_type>select</frontend_type>
1517
+ <source_model>adminhtml/system_config_source_yesno</source_model>
1518
+ <sort_order>2</sort_order>
1519
+ <show_in_default>1</show_in_default>
1520
+ <show_in_website>1</show_in_website>
1521
+ <show_in_store>1</show_in_store>
1522
+ </debug>
1523
+
1524
+ <accountnumber>
1525
+ <label>Account Number</label>
1526
+ <frontend_type>text</frontend_type>
1527
+ <sort_order>3</sort_order>
1528
+ <show_in_default>1</show_in_default>
1529
+ <show_in_website>1</show_in_website>
1530
+ <show_in_store>1</show_in_store>
1531
+ </accountnumber>
1532
+
1533
+ <encryptionkey>
1534
+ <label>Encryption Key</label>
1535
+ <frontend_type>text</frontend_type>
1536
+ <sort_order>4</sort_order>
1537
+ <show_in_default>1</show_in_default>
1538
+ <show_in_website>1</show_in_website>
1539
+ <show_in_store>1</show_in_store>
1540
+ </encryptionkey>
1541
+ </fields>
1542
+ </payex_ssn>
1543
+ </groups>
1544
+ </payex_ssn>
1545
+ </sections>
1546
+ </config>
app/code/community/PayEx/Payments/sql/payex_setup/install-3.0.0.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $installer = $this;
3
+ $this->startSetup();
4
+
5
+ // Install fee
6
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'payex_payment_fee', 'decimal(12,4)');
7
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'payex_payment_fee_tax', 'decimal(12,4)');
8
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_payex_payment_fee', 'decimal(12,4)');
9
+ $this->_conn->addColumn($this->getTable('sales_flat_quote'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
10
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee', 'decimal(12,4)');
11
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'payex_payment_fee_tax', 'decimal(12,4)');
12
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee', 'decimal(12,4)');
13
+ $this->_conn->addColumn($this->getTable('sales_flat_order'), 'base_payex_payment_fee_tax', 'decimal(12,4)');
14
+
15
+ $eav = new Mage_Sales_Model_Resource_Setup('sales_setup');
16
+ $eav->addAttribute('quote', 'payex_payment_fee', array('type' => 'decimal'));
17
+ $eav->addAttribute('quote', 'payex_payment_fee_tax', array('type' => 'decimal'));
18
+ $eav->addAttribute('quote', 'base_payex_payment_fee', array('type' => 'decimal'));
19
+ $eav->addAttribute('quote', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
20
+ $eav->addAttribute('order', 'payex_payment_fee', array('type' => 'decimal'));
21
+ $eav->addAttribute('order', 'payex_payment_fee_tax', array('type' => 'decimal'));
22
+ $eav->addAttribute('order', 'base_payex_payment_fee', array('type' => 'decimal'));
23
+ $eav->addAttribute('order', 'base_payex_payment_fee_tax', array('type' => 'decimal'));
24
+
25
+ // Install Agreement table
26
+ $installer->run("
27
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('payexautopay_agreement')}` (
28
+ `agreement_id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'Agreement Reference',
29
+ `customer_id` int(10) NOT NULL COMMENT 'Customer Id',
30
+ `agreement_ref` varchar(255) NOT NULL COMMENT 'Agreement Reference',
31
+ `created_at` datetime NOT NULL COMMENT 'Date',
32
+ PRIMARY KEY (`agreement_id`),
33
+ UNIQUE KEY `agreement_ref` (`agreement_ref`),
34
+ UNIQUE KEY `customer_id` (`customer_id`)
35
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Payex Autopay: Agreements';
36
+ ");
37
+
38
+ $this->endSetup();
app/design/adminhtml/default/default/layout/payex/adminhtml.xml ADDED
@@ -0,0 +1,8 @@
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_system_config_edit>
4
+ <reference name="head">
5
+ <action method="addCss"><name>payex/payex_admin.css</name></action>
6
+ </reference>
7
+ </adminhtml_system_config_edit>
8
+ </layout>
app/design/adminhtml/default/default/layout/payex/payment_fee.xml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <adminhtml_sales_order_view>
4
+ <reference name="order_totals">
5
+ <block name="payex_payment_fee" type="payex/order_totals_fee" before="tax"/>
6
+ </reference>
7
+ </adminhtml_sales_order_view>
8
+
9
+ <adminhtml_sales_order_invoice_view>
10
+ <reference name="invoice_totals">
11
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
12
+ </reference>
13
+ </adminhtml_sales_order_invoice_view>
14
+
15
+ <adminhtml_sales_order_invoice_new>
16
+ <reference name="invoice_totals">
17
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
18
+ </reference>
19
+ </adminhtml_sales_order_invoice_new>
20
+ </layout>
app/design/adminhtml/default/default/template/payex/adminhtml/hint.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="payex-settings-hint">
2
+ <p>
3
+ <?php echo Mage::helper('payex')->__('Thank you for using the official PayEx Payments module for Magento!'); ?>
4
+ <br/>
5
+ <?php echo Mage::helper('payex')->__('Check out the code on %s', '<a href="https://github.com/PayEx/Magento-modules" target="_blank">Github</a>'); ?>
6
+ </p>
7
+ <p>
8
+ <?php echo Mage::helper('payex')->__('Version: %s', $current_version); ?>
9
+ <?php if (version_compare($current_version, $last_version, '<')): ?>
10
+ <br />
11
+ <span class="last-version"><?php echo Mage::helper('payex')->__('Update Available: %s', $last_version); ?></span>
12
+ <?php endif; ?>
13
+ </p>
14
+ </div>
app/design/adminhtml/default/default/template/payex/autopay/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Autopay */
3
+
4
+ // Get Agreement Data
5
+ $agreement_id = Mage::helper('payex/agreement')->getCustomerAgreement();
6
+ $agreement_url = Mage::getSingleton('payex/payment_autopay')->getConfigData('agreementurl');
7
+ $agreement_link = Mage::helper('payex')->__('<a target="_blank" href="%s">agreement</a>', $agreement_url);
8
+ $agreement_status = Mage::helper('payex/agreement')->getPxAgreementStatus($agreement_id);
9
+ ?>
10
+ <style type="text/css">
11
+ #payment_form_payex_autopay ul.cards-logo li {
12
+ float: left;
13
+ }
14
+ </style>
15
+ <fieldset class="form-list">
16
+ <?php $_code = $this->getMethodCode() ?>
17
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
18
+ <li>
19
+ <div style="float:left">
20
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-small.gif'); ?>" />
21
+ </div>
22
+ <div style="float:left">
23
+ <!-- Start PayEx Autopay block -->
24
+ <form action="<?php echo $this->getFormAction(); ?>" id="payexAutopayForm" method="post">
25
+ <div class="input-box">
26
+ <?php if ($agreement_status === PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS): ?>
27
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
28
+ <?php echo Mage::helper('payex')->__('Sign a %s to streamline further purchases with PayEx.', $agreement_link); ?>
29
+ <br/>
30
+ <label
31
+ for="payex_agreement"><?php echo Mage::helper('payex')->__('I accept the agreement'); ?>
32
+ <span class="required">*</span>
33
+ <input name="payex_agreement" id="payex_agreement" title="I accept the agreement" value="1"
34
+ class="required-entry checkbox" type="checkbox"/>
35
+ </label>
36
+ <?php else: ?>
37
+ <?php echo Mage::helper('payex')->__('You already %s the agreement.', $agreement_link); ?>
38
+ <br/>
39
+ <?php echo Mage::helper('payex')->__('Payment will be made automatically by credit card.'); ?>
40
+ <br/>
41
+ <?php
42
+ $cancel_agreement_url = Mage::getUrl('payex/autopay/cancel_agreement', array('_secure' => true));
43
+ $cancel_agreement_url = "javascript:if(window.confirm('" . Mage::helper('payex')->__('Cancel agreement?') . "')) { self.location.href = '" . $cancel_agreement_url . "' };";
44
+ echo Mage::helper('payex')->__('<a href="%s">Cancel agreement</a>', $cancel_agreement_url);
45
+ ?>
46
+ <?php endif ?>
47
+ </div>
48
+ </form>
49
+ <!-- End PayEx Autopay block -->
50
+ </div>
51
+ <div class="clearfix">&nbsp;</div>
52
+ <ul class="cards-logo">
53
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/visa_64.png'); ?>" /></li>
54
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/mastercard_64.png'); ?>" /></li>
55
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/diners_club_64.png'); ?>" /></li>
56
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/jcb_64.png'); ?>" /></li>
57
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
58
+ </ul>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/adminhtml/default/default/template/payex/autopay/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Autopay */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/autopay/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/bankdebit/form.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Bankdebit */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code = $this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex.gif'); ?>" />
11
+ </div>
12
+ <div style="float:left">
13
+ <!-- Start PayEx Bank Debit block -->
14
+ <p><?php echo Mage::helper('payex')->__('Select your bank:'); ?></p>
15
+ <?php
16
+ $banks = $this->getLayout()->createBlock('payex/bankdebit_banks');
17
+ $banks->setBlockId('bank_select');
18
+ echo $banks->toHtml();
19
+ ?>
20
+ <!-- End PayEx Bank Debit block -->
21
+ </div>
22
+ <div style="float:right"></div>
23
+ </li>
24
+ </ul>
25
+ </fieldset>
26
+
app/design/adminhtml/default/default/template/payex/bankdebit/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Bankdebit */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()); ?></p>
app/design/adminhtml/default/default/template/payex/cc/form.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_CC */
3
+ ?>
4
+
5
+ <style type="text/css">
6
+ #payment_form_payex_cc ul.cards-logo li {
7
+ float: left;
8
+ }
9
+ </style>
10
+ <fieldset class="form-list">
11
+ <?php $_code=$this->getMethodCode() ?>
12
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
13
+ <li>
14
+ <div style="float:left">
15
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-small.gif'); ?>" alt="PayEx" /><br />
16
+ </div>
17
+ <div style="float:left">
18
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
19
+ </div>
20
+ <div class="clearfix">&nbsp;</div>
21
+ <ul class="cards-logo">
22
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/visa_64.png'); ?>" /></li>
23
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/mastercard_64.png'); ?>" /></li>
24
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/diners_club_64.png'); ?>" /></li>
25
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/jcb_64.png'); ?>" /></li>
26
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
27
+ </ul>
28
+ </li>
29
+ </ul>
30
+ </fieldset>
app/design/adminhtml/default/default/template/payex/cc/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_CC */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/adminhtml/default/default/template/payex/cc/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/financing/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Financing */
3
+
4
+ // Get saved SSN from SSN extension
5
+ $socal_security_number = $this->getPayexSSN();
6
+
7
+ // Get fee
8
+ $fee = $this->getPayexPaymentFee();
9
+ ?>
10
+
11
+ <fieldset class="form-list">
12
+ <?php $_code = $this->getMethodCode() ?>
13
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
14
+ <li>
15
+ <div style="float:right">
16
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/financing-logo.gif'); ?>"/>
17
+ </div>
18
+ <div style="float:left">
19
+ <!-- Start PayEx Financing block -->
20
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
21
+ <?php if (empty($socal_security_number)): ?>
22
+ <label
23
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
24
+ <span class="required">*</span></label><br/>
25
+ <input name="social-security-number" id="social-security-number"
26
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>"
27
+ class="required-entry input-text" type="text"/><br/>
28
+ <?php else: ?>
29
+ <label
30
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
31
+ <span class="required">*</span></label><br/>
32
+ <input name="social-security-number" id="social-security-number"
33
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo $socal_security_number; ?>"
34
+ class="required-entry input-text" type="text" readonly/><br/>
35
+ <?php endif; ?>
36
+ </form>
37
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
+ <div>
39
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
+ <br />
42
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
+ <br />
45
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
+ <?php else: ?>
51
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
+ <?php endif; ?>
54
+ </div>
55
+ <?php endif; ?>
56
+ <!-- End PayEx Financing block -->
57
+ </div>
58
+ <div style="float:right"></div>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/adminhtml/default/default/template/payex/financing/info.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Financing */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach ($specific as $key => $value): ?>
11
+ <?php if ($key === 'Invoice'): ?>
12
+ <a href="<?php echo $this->htmlEscape($value); ?>" target="_blank">
13
+ <?php echo Mage::helper('payex')->__('View Invoice'); ?>
14
+ </a>
15
+ <br/>
16
+ <?php else: ?>
17
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
18
+ <?php endif; ?>
19
+ <?php endforeach; ?>
20
+ <?php endif; ?>
21
+ <?php else: ?>
22
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
23
+ <?php endif; ?>
app/design/adminhtml/default/default/template/payex/financing/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/invoice/form.phtml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Invoice */
3
+
4
+ // Get fee
5
+ $fee = $this->getPayexPaymentFee();
6
+ ?>
7
+ <script type="text/javascript">
8
+ var pxInvoiceForm = Class.create();
9
+ pxInvoiceForm.prototype = {
10
+ switchMethod: function (method) {
11
+ // Get current method
12
+ if (method == 'private') {
13
+ var method_to_disable = 'corporate';
14
+ } else {
15
+ var method_to_disable = 'private';
16
+ }
17
+
18
+ // Disable sections
19
+ var form = $('pxinvoice_' + method_to_disable);
20
+ form.hide();
21
+ var elements = form.getElementsByTagName('input');
22
+ for (var i = 0; i < elements.length; i++) {
23
+ $(elements[i]).removeClassName('required-entry');
24
+ }
25
+
26
+ // Enable sections
27
+ var form = $('pxinvoice_' + method);
28
+ form.show();
29
+ var elements = form.getElementsByTagName('input');
30
+ for (var i = 0; i < elements.length; i++) {
31
+ $(elements[i]).addClassName('required-entry');
32
+ }
33
+ }
34
+ }
35
+
36
+ Varien.pxInvoiceForm_switchMethod = function (method) {
37
+ return pxInvoiceForm.prototype.switchMethod(method);
38
+ }
39
+ </script>
40
+ <fieldset class="form-list">
41
+ <?php $_code = $this->getMethodCode() ?>
42
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
43
+ <li>
44
+ <div style="float:left">
45
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-invoice.png'); ?>"/>
46
+ </div>
47
+ <div style="float:left">
48
+ <!-- Start PayEx Invoice block -->
49
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
50
+ <p><?php echo Mage::helper('payex')->__('Select Invoice Type:'); ?></p>
51
+ <ul class="form-list">
52
+ <li class="control">
53
+ <input type="radio" name="pxinvoice_method" id="pxinvoice_method:private" value="private"
54
+ class="radio" onclick="Varien.pxInvoiceForm_switchMethod('private');" checked/>
55
+ <label
56
+ for="pxinvoice_method:private"><?php echo Mage::helper('payex')->__('Private'); ?></label>
57
+ <br/>
58
+
59
+ <div id="pxinvoice_private" class="input-box">
60
+ <label
61
+ for="socialSecurityNumber"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
62
+ <span class="required">*</span></label><br/>
63
+ <input name="socialSecurityNumber" id="socialSecurityNumber"
64
+ title="Social Security Number" value="Social Security Number"
65
+ class="required-entry input-text" type="text"/><br/>
66
+ <label for="firstName"><?php echo Mage::helper('payex')->__('First name'); ?>
67
+ <span class="required">*</span></label><br/>
68
+ <input name="firstName" id="firstName" title="First name" value="First name"
69
+ class="required-entry input-text" type="text"/><br/>
70
+ <label for="lastName"><?php echo Mage::helper('payex')->__('Last name'); ?><span
71
+ class="required">*</span></label><br/>
72
+ <input name="lastName" id="lastName" title="Last name" value="Last name"
73
+ class="required-entry input-text" type="text"/><br/>
74
+ </div>
75
+ </li>
76
+ <li class="control">
77
+ <input type="radio" name="pxinvoice_method" id="pxinvoice_method:corporate"
78
+ value="corporate" class="radio"
79
+ onclick="Varien.pxInvoiceForm_switchMethod('corporate');"/>
80
+ <label
81
+ for="pxinvoice_method:corporate"><?php echo Mage::helper('payex')->__('Corporate'); ?></label>
82
+ <br/>
83
+
84
+ <div id="pxinvoice_corporate" class="input-box" style="display: none;">
85
+ <label
86
+ for="organizationNumber"><?php echo Mage::helper('payex')->__('Organization Number'); ?>
87
+ <span class="required">*</span></label><br/>
88
+ <input name="organizationNumber" id="organizationNumber"
89
+ title="Social Security Number" value="Organization Number"
90
+ class="input-text" type="text"/><br/>
91
+ </div>
92
+ </li>
93
+ </ul>
94
+ </form>
95
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
96
+ <div>
97
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
98
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
99
+ <br />
100
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
101
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
102
+ <br />
103
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
104
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
105
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
106
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
107
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
108
+ <?php else: ?>
109
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
110
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
111
+ <?php endif; ?>
112
+ </div>
113
+ <?php endif; ?>
114
+ <!-- End PayEx Invoice block -->
115
+ </div>
116
+ <div style="float:right"></div>
117
+ </li>
118
+ </ul>
119
+ </fieldset>
app/design/adminhtml/default/default/template/payex/invoice/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Invoice */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()); ?></p>
app/design/adminhtml/default/default/template/payex/masterpass/button.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php /** @var $this PayEx_Payments_Block_MasterPass_Button */ ?>
2
+ <a href="<?php echo $this->getCheckoutUrl(); ?>" class="payex-masterpass-button">
3
+ <img src="<?php echo $this->getImageUrl(); ?>" title="<?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>" alt="<?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>" />
4
+ </a>
app/design/adminhtml/default/default/template/payex/masterpass/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_MasterPass */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/masterpass-140.png'); ?>" alt="Buy with MasterPass" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/adminhtml/default/default/template/payex/masterpass/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_MasterPass */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/adminhtml/default/default/template/payex/masterpass/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/partpayment/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_PartPayment */
3
+
4
+ // Get saved SSN from SSN extension
5
+ $socal_security_number = $this->getPayexSSN();
6
+
7
+ // Get fee
8
+ $fee = $this->getPayexPaymentFee();
9
+ ?>
10
+
11
+ <fieldset class="form-list">
12
+ <?php $_code = $this->getMethodCode() ?>
13
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
14
+ <li>
15
+ <div style="float:right">
16
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/partpayment-logo.gif'); ?>"/>
17
+ </div>
18
+ <div style="float:left">
19
+ <!-- Start PayEx PartPayment block -->
20
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
21
+ <?php if (empty($socal_security_number)): ?>
22
+ <label
23
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
24
+ <span class="required">*</span></label><br/>
25
+ <input name="social-security-number" id="social-security-number"
26
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>"
27
+ class="required-entry input-text" type="text"/><br/>
28
+ <?php else: ?>
29
+ <label
30
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
31
+ <span class="required">*</span></label><br/>
32
+ <input name="social-security-number" id="social-security-number"
33
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo $socal_security_number; ?>"
34
+ class="required-entry input-text" type="text" readonly/><br/>
35
+ <?php endif; ?>
36
+ </form>
37
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
+ <div>
39
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
+ <br />
42
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
+ <br />
45
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
+ <?php else: ?>
51
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
+ <?php endif; ?>
54
+ </div>
55
+ <?php endif; ?>
56
+ <!-- End PayEx PartPayment block -->
57
+ </div>
58
+ <div style="float:right"></div>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/adminhtml/default/default/template/payex/partpayment/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_PartPayment */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach ($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/adminhtml/default/default/template/payex/partpayment/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/swish/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Swish */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/swish.png'); ?>" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/adminhtml/default/default/template/payex/swish/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Swish */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/adminhtml/default/default/template/payex/swish/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/adminhtml/default/default/template/payex/wywallet/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_WyWallet */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/ww_logo.png'); ?>" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/adminhtml/default/default/template/payex/wywallet/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_WyWallet */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/layout/payex/masterpass.xml ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <!--CSS and JS Files-->
5
+ <reference name="head">
6
+ <action method="addItem"><type>skin_css</type><name>css/payex/masterpass.css</name></action>
7
+ </reference>
8
+ </default>
9
+
10
+ <checkout_cart_index>
11
+ <block type="payex/MasterPass_button" name="payex_mp_button" template="payex/masterpass/button.phtml" />
12
+
13
+ <reference name="checkout.cart.top_methods">
14
+ <action method="append" ifconfig="payment/payex_masterpass/active"><block>payex_mp_button</block></action>
15
+ </reference>
16
+
17
+ <reference name="checkout.cart.methods">
18
+ <action method="append" ifconfig="payment/payex_masterpass/active"><block>payex_mp_button</block></action>
19
+ </reference>
20
+ </checkout_cart_index>
21
+
22
+ <checkout_onepage_index>
23
+ <block type="payex/MasterPass_button" name="payex_mp_button" template="payex/masterpass/button.phtml" />
24
+
25
+ <reference name="checkout.onepage.login.before">
26
+ <action method="append" ifconfig="payment/payex_masterpass/active"><block>payex_mp_button</block></action>
27
+ </reference>
28
+ </checkout_onepage_index>
29
+ </layout>
app/design/frontend/base/default/layout/payex/payment_fee.xml ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <sales_order_print>
4
+ <reference name="order_totals">
5
+ <block name="payex_payment_fee" type="payex/order_totals_fee" before="tax"/>
6
+ </reference>
7
+ </sales_order_print>
8
+
9
+ <sales_order_view>
10
+ <reference name="order_totals">
11
+ <block name="payex_payment_fee" type="payex/order_totals_fee" before="tax"/>
12
+ </reference>
13
+ </sales_order_view>
14
+
15
+ <sales_order_invoice>
16
+ <reference name="invoice_totals">
17
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
18
+ </reference>
19
+ </sales_order_invoice>
20
+
21
+ <sales_order_printinvoice>
22
+ <reference name="invoice_totals">
23
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
24
+ </reference>
25
+ </sales_order_printinvoice>
26
+
27
+ <sales_email_order_items>
28
+ <reference name="order_totals">
29
+ <block name="payex_payment_fee" type="payex/order_totals_fee" before="tax"/>
30
+ </reference>
31
+ </sales_email_order_items>
32
+
33
+ <sales_email_order_invoice_items>
34
+ <reference name="invoice_totals">
35
+ <block name="payex_payment_fee" type="payex/invoice_totals_fee" before="tax"/>
36
+ </reference>
37
+ </sales_email_order_invoice_items>
38
+ </layout>
app/design/frontend/base/default/layout/payex/social_security_number.xml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <layout version="0.1.0">
2
+ <checkout_onepage_index>
3
+ <reference name='checkout.onepage.billing'>
4
+ <action method='setTemplate' ifconfig="payex_ssn/payex_ssn/active">
5
+ <template>payex/checkout/onepage/billing_with_ssn.phtml</template>
6
+ </action>
7
+ </reference>
8
+ <reference name="head">
9
+ <action method="addJs" ifconfig="payex_ssn/payex_ssn/active">
10
+ <script>payex/social_security_number.js</script>
11
+ </action>
12
+ </reference>
13
+ </checkout_onepage_index>
14
+
15
+ <opc_index_index>
16
+ <reference name="head">
17
+ <action method="addJs" ifconfig="payex_ssn/payex_ssn/active">
18
+ <script>payex/iwd_opc/social_security_number.js</script>
19
+ </action>
20
+ </reference>
21
+
22
+ <reference name='checkout.onepage.billing'>
23
+ <action method="setTemplate" ifconfig="payex_ssn/payex_ssn/active">
24
+ <template>payex/iwd_opc/billing_with_ssn.phtml</template>
25
+ </action>
26
+ </reference>
27
+ </opc_index_index>
28
+ </layout>
app/design/frontend/base/default/template/payex/autopay/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Autopay */
3
+
4
+ // Get Agreement Data
5
+ $agreement_id = Mage::helper('payex/agreement')->getCustomerAgreement();
6
+ $agreement_url = Mage::getSingleton('payex/payment_autopay')->getConfigData('agreementurl');
7
+ $agreement_link = Mage::helper('payex')->__('<a target="_blank" href="%s">agreement</a>', $agreement_url);
8
+ $agreement_status = Mage::helper('payex/agreement')->getPxAgreementStatus($agreement_id);
9
+ ?>
10
+ <style type="text/css">
11
+ #payment_form_payex_autopay ul.cards-logo li {
12
+ float: left;
13
+ }
14
+ </style>
15
+ <fieldset class="form-list">
16
+ <?php $_code = $this->getMethodCode() ?>
17
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
18
+ <li>
19
+ <div style="float:left">
20
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-small.gif'); ?>" />
21
+ </div>
22
+ <div style="float:left">
23
+ <!-- Start PayEx Autopay block -->
24
+ <form action="<?php echo $this->getFormAction(); ?>" id="payexAutopayForm" method="post">
25
+ <div class="input-box">
26
+ <?php if ($agreement_status === PayEx_Payments_Model_Payment_Autopay::AGREEMENT_NOTEXISTS): ?>
27
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
28
+ <?php echo Mage::helper('payex')->__('Sign a %s to streamline further purchases with PayEx.', $agreement_link); ?>
29
+ <br/>
30
+ <label
31
+ for="payex_agreement"><?php echo Mage::helper('payex')->__('I accept the agreement'); ?>
32
+ <span class="required">*</span>
33
+ <input name="payex_agreement" id="payex_agreement" title="I accept the agreement" value="1"
34
+ class="required-entry checkbox" type="checkbox"/>
35
+ </label>
36
+ <?php else: ?>
37
+ <?php echo Mage::helper('payex')->__('You already %s the agreement.', $agreement_link); ?>
38
+ <br/>
39
+ <?php echo Mage::helper('payex')->__('Payment will be made automatically by credit card.'); ?>
40
+ <br/>
41
+ <?php
42
+ $cancel_agreement_url = Mage::getUrl('payex/autopay/cancel_agreement', array('_secure' => true));
43
+ $cancel_agreement_url = "javascript:if(window.confirm('" . Mage::helper('payex')->__('Cancel agreement?') . "')) { self.location.href = '" . $cancel_agreement_url . "' };";
44
+ echo Mage::helper('payex')->__('<a href="%s">Cancel agreement</a>', $cancel_agreement_url);
45
+ ?>
46
+ <?php endif ?>
47
+ </div>
48
+ </form>
49
+ <!-- End PayEx Autopay block -->
50
+ </div>
51
+ <div class="clearfix">&nbsp;</div>
52
+ <ul class="cards-logo">
53
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/visa_64.png'); ?>" /></li>
54
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/mastercard_64.png'); ?>" /></li>
55
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/diners_club_64.png'); ?>" /></li>
56
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/jcb_64.png'); ?>" /></li>
57
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
58
+ </ul>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/frontend/base/default/template/payex/autopay/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Autopay */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/autopay/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $specific = $this->getSpecificInformation();
3
+ ?>
4
+
5
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
6
+ {{pdf_row_separator}}
7
+ <?php if (count($specific) > 0): ?>
8
+ <?php foreach($specific as $key => $value): ?>
9
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?>
10
+ {{pdf_row_separator}}
11
+ <?php endforeach; ?>
12
+ <?php endif; ?>
13
+ {{pdf_row_separator}}
app/design/frontend/base/default/template/payex/autopay/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/bankdebit/form.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Bankdebit */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code = $this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex.gif'); ?>" />
11
+ </div>
12
+ <div style="float:left">
13
+ <!-- Start PayEx Bank Debit block -->
14
+ <p><?php echo Mage::helper('payex')->__('Select your bank:'); ?></p>
15
+ <?php
16
+ $banks = $this->getLayout()->createBlock('payex/bankdebit_banks');
17
+ $banks->setBlockId('bank_select');
18
+ echo $banks->toHtml();
19
+ ?>
20
+ <!-- End PayEx Bank Debit block -->
21
+ </div>
22
+ <div style="float:right"></div>
23
+ </li>
24
+ </ul>
25
+ </fieldset>
26
+
app/design/frontend/base/default/template/payex/bankdebit/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Bankdebit */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()); ?></p>
app/design/frontend/base/default/template/payex/cc/form.phtml ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_CC */
3
+ ?>
4
+
5
+ <style type="text/css">
6
+ #payment_form_payex_cc ul.cards-logo li {
7
+ float: left;
8
+ }
9
+ </style>
10
+ <fieldset class="form-list">
11
+ <?php $_code=$this->getMethodCode() ?>
12
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
13
+ <li>
14
+ <div style="float:left">
15
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-small.gif'); ?>" alt="PayEx" /><br />
16
+ </div>
17
+ <div style="float:left">
18
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
19
+ </div>
20
+ <div class="clearfix">&nbsp;</div>
21
+ <ul class="cards-logo">
22
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/visa_64.png'); ?>" /></li>
23
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/mastercard_64.png'); ?>" /></li>
24
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/diners_club_64.png'); ?>" /></li>
25
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/jcb_64.png'); ?>" /></li>
26
+ <li><img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/american_express_64.png'); ?>" /></li>
27
+ </ul>
28
+ </li>
29
+ </ul>
30
+ </fieldset>
app/design/frontend/base/default/template/payex/cc/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_CC */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/cc/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
2
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
3
+ <?php if (!empty($trans_id)): ?>
4
+ <?php $specific = $this->getSpecificInformation(); ?>
5
+ <?php if (count($specific) > 0): ?>
6
+ <?php foreach($specific as $key => $value): ?>
7
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
+ {{pdf_row_separator}}
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
11
+ <?php else: ?>
12
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/cc/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/checkout/fee.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @var $this PayEx_Payments_Block_Checkout_Fee
4
+ */
5
+
6
+ $fee = $this->getPaymentFee();
7
+ ?>
8
+ <!-- Start PayEx Payment Fee -->
9
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
10
+ <tr>
11
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
12
+ <?php echo $this->helper('payex')->__('Payment fee'); ?>
13
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
14
+ </td>
15
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
16
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
17
+ </td>
18
+ </tr>
19
+ <tr>
20
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
21
+ <?php echo $this->helper('payex')->__('Payment fee'); ?>
22
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
23
+ </td>
24
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
25
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
26
+ </td>
27
+ </tr>
28
+ <?php else: ?>
29
+ <?php if ($this->helper('tax')->displayPriceIncludingTax()): ?>
30
+ <tr>
31
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
32
+ <?php echo $this->helper('payex')->__('Payment fee'); ?>
33
+ </td>
34
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
35
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
36
+ </td>
37
+ </tr>
38
+ <?php else: ?>
39
+ <tr>
40
+ <td style="<?php echo $this->getStyle() ?>" class="a-right" colspan="<?php echo $this->getColspan(); ?>">
41
+ <?php echo $this->helper('payex')->__('Payment fee'); ?>
42
+ </td>
43
+ <td style="<?php echo $this->getStyle() ?>" class="a-right">
44
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
45
+ </td>
46
+ </tr>
47
+ <?php endif; ?>
48
+ <?php endif; ?>
49
+ <!-- End PayEx Payment Fee -->
app/design/frontend/base/default/template/payex/checkout/onepage/billing_with_ssn.phtml ADDED
@@ -0,0 +1,257 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ <!-- Start Social Security Number Block -->
28
+ <form id="social_security_number_form">
29
+ <div class="form-list">
30
+ <div class="field">
31
+ <label for="socialSecurityNumber" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Social Security Number'); ?></label>
32
+ <div class="input-box">
33
+ <input type="text" title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" name="socialSecurityNumber" id="socialSecurityNumber" class="input-text required-entry" />
34
+ </div>
35
+ </div>
36
+ <div class="field">
37
+ <button style="margin-top: 17px;" type="button" title="<?php echo Mage::helper('payex')->__('Get Address'); ?>" class="button" id="ssn_click"><span><span><?php echo Mage::helper('payex')->__('Get Address'); ?></span></span></button>
38
+ </div>
39
+ <div class="clearer">&nbsp;</div>
40
+ <div class="field">
41
+ <label for="check_country" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Country'); ?></label>
42
+ <div class="input-box">
43
+ <select name="check_country" id="check_country" class="validate-select required-entry" title="Country">
44
+ <option value="SE" selected="selected"><?php echo Mage::helper('payex')->__('Sweden'); ?></option>
45
+ <option value="NO"><?php echo Mage::helper('payex')->__('Norway'); ?></option>
46
+ </select>
47
+ </div>
48
+ </div>
49
+ <div class="clearer">&nbsp;</div>
50
+ <div class="field">
51
+ <label for="check_postcode" class="required"><em>*</em><?php echo Mage::helper('payex')->__('Postal Code'); ?></label>
52
+ <div class="input-box">
53
+ <input type="text" title="<?php echo Mage::helper('payex')->__('Postal Code'); ?>" name="check_postcode" id="check_postcode" class="input-text validate-zip required-entry" />
54
+ </div>
55
+ </div>
56
+ </div>
57
+ </form>
58
+ <div class="clearer">&nbsp;</div>
59
+
60
+ <script type="application/javascript">
61
+ //<![CDATA[
62
+ var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(); ?>';
63
+ window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
64
+ //]]>
65
+ </script>
66
+ <!-- End Social Security Number Block -->
67
+
68
+ <form id="co-billing-form" action="">
69
+ <fieldset>
70
+ <ul class="form-list">
71
+ <?php if ($this->customerHasAddresses()): ?>
72
+ <li class="wide">
73
+ <label for="billing-address-select"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
74
+ <div class="input-box">
75
+ <?php echo $this->getAddressesHtmlSelect('billing') ?>
76
+ </div>
77
+ </li>
78
+ <?php endif; ?>
79
+ <li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
80
+ <fieldset>
81
+ <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
82
+ <ul>
83
+ <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
84
+ <li class="fields">
85
+ <div class="field">
86
+ <label for="billing:company"><?php echo $this->__('Company') ?></label>
87
+ <div class="input-box">
88
+ <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('company') ?>" />
89
+ </div>
90
+ </div>
91
+ <?php if(!$this->isCustomerLoggedIn()): ?>
92
+ <div class="field">
93
+ <label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
94
+ <div class="input-box">
95
+ <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
96
+ </div>
97
+ </div>
98
+ <?php endif; ?>
99
+ </li>
100
+ <?php $_streetValidationClass = $this->helper('customer/address')->getAttributeValidationClass('street'); ?>
101
+ <li class="wide">
102
+ <label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
103
+ <div class="input-box">
104
+ <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
105
+ </div>
106
+ </li>
107
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
108
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
109
+ <li class="wide">
110
+ <div class="input-box">
111
+ <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="billing[street][]" id="billing:street<?php echo $_i ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
112
+ </div>
113
+ </li>
114
+ <?php endfor; ?>
115
+ <?php if ($this->helper('customer/address')->isVatAttributeVisible()) : ?>
116
+ <li class="wide">
117
+ <label for="billing:vat_id"><?php echo $this->__('VAT Number') ?></label>
118
+ <div class="input-box">
119
+ <input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('vat_id') ?>" />
120
+ </div>
121
+ </li>
122
+ <?php endif; ?>
123
+ <li class="fields">
124
+ <div class="field">
125
+ <label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
126
+ <div class="input-box">
127
+ <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('city') ?>" id="billing:city" />
128
+ </div>
129
+ </div>
130
+ <div class="field">
131
+ <label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State/Province') ?></label>
132
+ <div class="input-box">
133
+ <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State/Province') ?>" class="validate-select" style="display:none;">
134
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
135
+ </select>
136
+ <script type="text/javascript">
137
+ //<![CDATA[
138
+ $('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
139
+ //]]>
140
+ </script>
141
+ <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State/Province') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('region') ?>" style="display:none;" />
142
+ </div>
143
+ </div>
144
+ </li>
145
+ <li class="fields">
146
+ <div class="field">
147
+ <label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip/Postal Code') ?></label>
148
+ <div class="input-box">
149
+ <input type="text" title="<?php echo $this->__('Zip/Postal Code') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('customer/address')->getAttributeValidationClass('postcode') ?>" />
150
+ </div>
151
+ </div>
152
+ <div class="field">
153
+ <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
154
+ <div class="input-box">
155
+ <?php echo $this->getCountryHtmlSelect('billing') ?>
156
+ </div>
157
+ </div>
158
+ </li>
159
+ <li class="fields">
160
+ <div class="field">
161
+ <label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
162
+ <div class="input-box">
163
+ <input type="text" name="billing[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('telephone') ?>" id="billing:telephone" />
164
+ </div>
165
+ </div>
166
+ <div class="field">
167
+ <label for="billing:fax"><?php echo $this->__('Fax') ?></label>
168
+ <div class="input-box">
169
+ <input type="text" name="billing[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('customer/address')->getAttributeValidationClass('fax') ?>" id="billing:fax" />
170
+ </div>
171
+ </div>
172
+ </li>
173
+ <?php if(!$this->isCustomerLoggedIn()): ?>
174
+
175
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
176
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
177
+ <?php if ($_dob->isEnabled() || $_gender->isEnabled()): ?>
178
+ <li class="fields">
179
+ <?php if ($_dob->isEnabled()): ?>
180
+ <div class="field">
181
+ <?php echo $_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
182
+ </div>
183
+ <?php endif; ?>
184
+ <?php if ($_gender->isEnabled()): ?>
185
+ <div class="field">
186
+ <?php echo $_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
187
+ </div>
188
+ <?php endif ?>
189
+ </li>
190
+ <?php endif ?>
191
+
192
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
193
+ <?php if ($_taxvat->isEnabled()): ?>
194
+ <li>
195
+ <?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
196
+ </li>
197
+ <?php endif ?>
198
+
199
+ <li class="fields" id="register-customer-password">
200
+ <div class="field">
201
+ <label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
202
+ <div class="input-box">
203
+ <input type="password" name="billing[customer_password]" id="billing:customer_password" title="<?php echo $this->__('Password') ?>" class="input-text required-entry validate-password" />
204
+ </div>
205
+ </div>
206
+ <div class="field">
207
+ <label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
208
+ <div class="input-box">
209
+ <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="input-text required-entry validate-cpassword" />
210
+ </div>
211
+ </div>
212
+ </li>
213
+ <?php endif; ?>
214
+ <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
215
+ <li class="control">
216
+ <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="billing:save_in_address_book"><?php echo $this->__('Save in address book') ?></label>
217
+ </li>
218
+ <?php else:?>
219
+ <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>
220
+ <?php endif; ?>
221
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
222
+ </ul>
223
+ </fieldset>
224
+ </li>
225
+ <?php /* Extensions placeholder */ ?>
226
+ <?php echo $this->getChildHtml('checkout.onepage.billing.extra')?>
227
+ <?php if ($this->canShip()): ?>
228
+ <li class="control">
229
+ <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to this address') ?>" onclick="$('shipping:same_as_billing').checked = true;" class="radio" /><label for="billing:use_for_shipping_yes"><?php echo $this->__('Ship to this address') ?></label></li>
230
+ <li class="control">
231
+ <input type="radio" name="billing[use_for_shipping]" id="billing:use_for_shipping_no" value="0"<?php if (!$this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to different address') ?>" onclick="$('shipping:same_as_billing').checked = false;" class="radio" /><label for="billing:use_for_shipping_no"><?php echo $this->__('Ship to different address') ?></label>
232
+ </li>
233
+ <?php endif; ?>
234
+ </ul>
235
+ <?php if (!$this->canShip()): ?>
236
+ <input type="hidden" name="billing[use_for_shipping]" value="1" />
237
+ <?php endif; ?>
238
+ <div class="buttons-set" id="billing-buttons-container">
239
+ <p class="required"><?php echo $this->__('* Required Fields') ?></p>
240
+ <button type="button" title="<?php echo $this->__('Continue') ?>" class="button" onclick="billing.save()"><span><span><?php echo $this->__('Continue') ?></span></span></button>
241
+ <span class="please-wait" id="billing-please-wait" style="display:none;">
242
+ <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...') ?>
243
+ </span>
244
+ </div>
245
+ </fieldset>
246
+ </form>
247
+ <script type="text/javascript">
248
+ //<![CDATA[
249
+ var billing = new Billing('co-billing-form', '<?php echo $this->getUrl('checkout/onepage/getAddress') ?>address/', '<?php echo $this->getUrl('checkout/onepage/saveBilling') ?>');
250
+ var billingForm = new VarienForm('co-billing-form');
251
+
252
+ //billingForm.setElementsRelation('billing:country_id', 'billing:region', '<?php echo $this->getUrl('directory/json/childRegion') ?>', '<?php echo $this->__('Select State/Province...') ?>');
253
+ $('billing-address-select') && billing.newAddress(!$('billing-address-select').value);
254
+
255
+ var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
256
+ //]]>
257
+ </script>
app/design/frontend/base/default/template/payex/financing/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Financing */
3
+
4
+ // Get saved SSN from SSN extension
5
+ $socal_security_number = $this->getPayexSSN();
6
+
7
+ // Get fee
8
+ $fee = $this->getPayexPaymentFee();
9
+ ?>
10
+
11
+ <fieldset class="form-list">
12
+ <?php $_code = $this->getMethodCode() ?>
13
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
14
+ <li>
15
+ <div style="float:right">
16
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/financing-logo.gif'); ?>"/>
17
+ </div>
18
+ <div style="float:left">
19
+ <!-- Start PayEx Financing block -->
20
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
21
+ <?php if (empty($socal_security_number)): ?>
22
+ <label
23
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
24
+ <span class="required">*</span></label><br/>
25
+ <input name="social-security-number" id="social-security-number"
26
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>"
27
+ class="required-entry input-text" type="text"/><br/>
28
+ <?php else: ?>
29
+ <label
30
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
31
+ <span class="required">*</span></label><br/>
32
+ <input name="social-security-number" id="social-security-number"
33
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo $socal_security_number; ?>"
34
+ class="required-entry input-text" type="text" readonly/><br/>
35
+ <?php endif; ?>
36
+ </form>
37
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
+ <div>
39
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
+ <br />
42
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
+ <br />
45
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
+ <?php else: ?>
51
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
+ <?php endif; ?>
54
+ </div>
55
+ <?php endif; ?>
56
+ <!-- End PayEx Financing block -->
57
+ </div>
58
+ <div style="float:right"></div>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/frontend/base/default/template/payex/financing/info.phtml ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Financing */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach ($specific as $key => $value): ?>
11
+ <?php if ($key === 'Invoice'): ?>
12
+ <a href="<?php echo $this->htmlEscape($value); ?>" target="_blank">
13
+ <?php echo Mage::helper('payex')->__('View Invoice'); ?>
14
+ </a>
15
+ <br/>
16
+ <?php else: ?>
17
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
18
+ <?php endif; ?>
19
+ <?php endforeach; ?>
20
+ <?php endif; ?>
21
+ <?php else: ?>
22
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
23
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/financing/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
2
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
3
+ <?php if (!empty($trans_id)): ?>
4
+ <?php $specific = $this->getSpecificInformation(); ?>
5
+ <?php if (count($specific) > 0): ?>
6
+ <?php foreach($specific as $key => $value): ?>
7
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
+ {{pdf_row_separator}}
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
11
+ <?php else: ?>
12
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/financing/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/invoice/form.phtml ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Invoice */
3
+
4
+ // Get fee
5
+ $fee = $this->getPayexPaymentFee();
6
+ ?>
7
+ <script type="text/javascript">
8
+ var pxInvoiceForm = Class.create();
9
+ pxInvoiceForm.prototype = {
10
+ switchMethod: function (method) {
11
+ // Get current method
12
+ if (method == 'private') {
13
+ var method_to_disable = 'corporate';
14
+ } else {
15
+ var method_to_disable = 'private';
16
+ }
17
+
18
+ // Disable sections
19
+ var form = $('pxinvoice_' + method_to_disable);
20
+ form.hide();
21
+ var elements = form.getElementsByTagName('input');
22
+ for (var i = 0; i < elements.length; i++) {
23
+ $(elements[i]).removeClassName('required-entry');
24
+ }
25
+
26
+ // Enable sections
27
+ var form = $('pxinvoice_' + method);
28
+ form.show();
29
+ var elements = form.getElementsByTagName('input');
30
+ for (var i = 0; i < elements.length; i++) {
31
+ $(elements[i]).addClassName('required-entry');
32
+ }
33
+ }
34
+ }
35
+
36
+ Varien.pxInvoiceForm_switchMethod = function (method) {
37
+ return pxInvoiceForm.prototype.switchMethod(method);
38
+ }
39
+ </script>
40
+ <fieldset class="form-list">
41
+ <?php $_code = $this->getMethodCode() ?>
42
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
43
+ <li>
44
+ <div style="float:left">
45
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/payex-invoice.png'); ?>"/>
46
+ </div>
47
+ <div style="float:left">
48
+ <!-- Start PayEx Invoice block -->
49
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
50
+ <p><?php echo Mage::helper('payex')->__('Select Invoice Type:'); ?></p>
51
+ <ul class="form-list">
52
+ <li class="control">
53
+ <input type="radio" name="pxinvoice_method" id="pxinvoice_method:private" value="private"
54
+ class="radio" onclick="Varien.pxInvoiceForm_switchMethod('private');" checked/>
55
+ <label
56
+ for="pxinvoice_method:private"><?php echo Mage::helper('payex')->__('Private'); ?></label>
57
+ <br/>
58
+
59
+ <div id="pxinvoice_private" class="input-box">
60
+ <label
61
+ for="socialSecurityNumber"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
62
+ <span class="required">*</span></label><br/>
63
+ <input name="socialSecurityNumber" id="socialSecurityNumber"
64
+ title="Social Security Number" value="Social Security Number"
65
+ class="required-entry input-text" type="text"/><br/>
66
+ <label for="firstName"><?php echo Mage::helper('payex')->__('First name'); ?>
67
+ <span class="required">*</span></label><br/>
68
+ <input name="firstName" id="firstName" title="First name" value="First name"
69
+ class="required-entry input-text" type="text"/><br/>
70
+ <label for="lastName"><?php echo Mage::helper('payex')->__('Last name'); ?><span
71
+ class="required">*</span></label><br/>
72
+ <input name="lastName" id="lastName" title="Last name" value="Last name"
73
+ class="required-entry input-text" type="text"/><br/>
74
+ </div>
75
+ </li>
76
+ <li class="control">
77
+ <input type="radio" name="pxinvoice_method" id="pxinvoice_method:corporate"
78
+ value="corporate" class="radio"
79
+ onclick="Varien.pxInvoiceForm_switchMethod('corporate');"/>
80
+ <label
81
+ for="pxinvoice_method:corporate"><?php echo Mage::helper('payex')->__('Corporate'); ?></label>
82
+ <br/>
83
+
84
+ <div id="pxinvoice_corporate" class="input-box" style="display: none;">
85
+ <label
86
+ for="organizationNumber"><?php echo Mage::helper('payex')->__('Organization Number'); ?>
87
+ <span class="required">*</span></label><br/>
88
+ <input name="organizationNumber" id="organizationNumber"
89
+ title="Social Security Number" value="Organization Number"
90
+ class="input-text" type="text"/><br/>
91
+ </div>
92
+ </li>
93
+ </ul>
94
+ </form>
95
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
96
+ <div>
97
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
98
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
99
+ <br />
100
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
101
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
102
+ <br />
103
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
104
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
105
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
106
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
107
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
108
+ <?php else: ?>
109
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
110
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
111
+ <?php endif; ?>
112
+ </div>
113
+ <?php endif; ?>
114
+ <!-- End PayEx Invoice block -->
115
+ </div>
116
+ <div style="float:right"></div>
117
+ </li>
118
+ </ul>
119
+ </fieldset>
app/design/frontend/base/default/template/payex/invoice/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Invoice */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()); ?></p>
app/design/frontend/base/default/template/payex/iwd_opc/billing_with_ssn.phtml ADDED
@@ -0,0 +1,225 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="co-billing-form">
2
+ <h3><?php echo $this->__('Name & Address')?></h3>
3
+ <ul class="form-list">
4
+ <?php if ($this->customerHasAddresses()): ?>
5
+ <li class="wide">
6
+ <label for="billing-address-select" class="notice"><?php echo $this->__('Select a billing address from your address book or enter a new address.') ?></label>
7
+ <div class="input-box">
8
+ <?php echo $this->getAddressesHtmlSelect('billing') ?>
9
+ </div>
10
+ </li>
11
+ <?php endif; ?>
12
+ <li id="billing-new-address-form"<?php if ($this->customerHasAddresses()): ?> style="display:none;"<?php endif; ?>>
13
+ <fieldset>
14
+ <input type="hidden" name="billing[address_id]" value="<?php echo $this->getAddress()->getId() ?>" id="billing:address_id" />
15
+ <ul>
16
+ <!-- Start Social Security Number Block -->
17
+ <li class="fields">
18
+ <div class="field">
19
+ <label for="socialSecurityNumber"><?php echo Mage::helper('payex')->__('Social Security Number'); ?></label>
20
+ <div class="input-box">
21
+ <input type="text" title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" name="socialSecurityNumber" id="socialSecurityNumber" class="input-text" />
22
+ </div>
23
+ </div>
24
+ <div class="field">
25
+ <button type="button" title="<?php echo Mage::helper('payex')->__('Get Address'); ?>" class="button" id="ssn_click"><span><span><?php echo Mage::helper('payex')->__('Get Address'); ?></span></span></button>
26
+ </div>
27
+ <script type="application/javascript">
28
+ //<![CDATA[
29
+ var MAGENTO_BASE_URL = '<?php echo Mage::getBaseUrl(); ?>';
30
+ window.PAYEX_SSN_FORM = new VarienForm('social_security_number_form', false);
31
+ //]]>
32
+ </script>
33
+ </li>
34
+ <!-- End Social Security Number Block -->
35
+
36
+ <li class="fields"><?php echo $this->getLayout()->createBlock('customer/widget_name')->setObject($this->getAddress()->getFirstname() ? $this->getAddress() : $this->getQuote()->getCustomer())->setForceUseCustomerRequiredAttributes(!$this->isCustomerLoggedIn())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?></li>
37
+ <div class="clear"></div>
38
+ <li class="fields">
39
+ <div class="field">
40
+ <label for="billing:company"><?php echo $this->__('Company') ?></label>
41
+ <div class="input-box">
42
+ <input type="text" id="billing:company" name="billing[company]" value="<?php echo $this->escapeHtml($this->getAddress()->getCompany()) ?>" title="<?php echo $this->__('Company') ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('company') ?>" />
43
+ </div>
44
+ </div>
45
+ <?php if(!$this->isCustomerLoggedIn()): ?>
46
+ <div class="field">
47
+ <label for="billing:email" class="required"><em>*</em><?php echo $this->__('Email Address') ?></label>
48
+ <div class="input-box">
49
+ <input type="text" name="billing[email]" id="billing:email" value="<?php echo $this->escapeHtml($this->getAddress()->getEmail()) ?>" title="<?php echo $this->__('Email Address') ?>" class="input-text validate-email required-entry" />
50
+ </div>
51
+ </div>
52
+ <?php endif; ?>
53
+ </li>
54
+ <div class="clear"></div>
55
+ <?php $_streetValidationClass = $this->helper('opc')->getAttributeValidationClass('street'); ?>
56
+ <li class="wide">
57
+ <label for="billing:street1" class="required"><em>*</em><?php echo $this->__('Address') ?></label>
58
+ <div class="input-box">
59
+ <input type="text" title="<?php echo $this->__('Street Address') ?>" name="billing[street][]" id="billing:street1" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet(1)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
60
+ </div>
61
+ </li>
62
+ <?php $_streetValidationClass = trim(str_replace('required-entry', '', $_streetValidationClass)); ?>
63
+ <?php for ($_i = 2, $_n = $this->helper('customer/address')->getStreetLines(); $_i <= $_n; $_i++): ?>
64
+ <li class="wide">
65
+ <div class="input-box">
66
+ <input type="text" title="<?php echo $this->__('Street Address %s', $_i) ?>" name="billing[street][]" id="billing:street<?php echo $_i ?>" value="<?php echo $this->escapeHtml($this->getAddress()->getStreet($_i)) ?>" class="input-text <?php echo $_streetValidationClass ?>" />
67
+ </div>
68
+ </li>
69
+ <?php endfor; ?>
70
+ <?php if ($this->helper('opc')->isVatAttributeVisible()) : ?>
71
+ <li class="wide">
72
+ <label for="billing:vat_id"><?php echo $this->__('VAT Number') ?></label>
73
+ <div class="input-box">
74
+ <input type="text" id="billing:vat_id" name="billing[vat_id]" value="<?php echo $this->escapeHtml($this->getAddress()->getVatId()) ?>" title="<?php echo $this->__('VAT Number') ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('vat_id') ?>" />
75
+ </div>
76
+ </li>
77
+ <?php endif; ?>
78
+ <li class="address-additional-separator"></li>
79
+ <li class="fields">
80
+ <div class="field">
81
+ <label for="billing:city" class="required"><em>*</em><?php echo $this->__('City') ?></label>
82
+ <div class="input-box">
83
+ <input type="text" title="<?php echo $this->__('City') ?>" name="billing[city]" value="<?php echo $this->escapeHtml($this->getAddress()->getCity()) ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('city') ?>" id="billing:city" />
84
+ </div>
85
+ </div>
86
+ <div class="field">
87
+ <label for="billing:region_id" class="required"><em>*</em><?php echo $this->__('State / Province') ?></label>
88
+ <div class="input-box">
89
+ <select id="billing:region_id" name="billing[region_id]" title="<?php echo $this->__('State / Province') ?>" class="validate-select" style="display:none;">
90
+ <option value=""><?php echo $this->__('Please select region, state or province') ?></option>
91
+ </select>
92
+ <script type="text/javascript">
93
+ //<![CDATA[
94
+ $('billing:region_id').setAttribute('defaultValue', "<?php echo $this->getAddress()->getRegionId() ?>");
95
+ //]]>
96
+ </script>
97
+ <input type="text" id="billing:region" name="billing[region]" value="<?php echo $this->escapeHtml($this->getAddress()->getRegion()) ?>" title="<?php echo $this->__('State / Province') ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('region') ?>" style="display:none;" />
98
+ </div>
99
+ </div>
100
+ </li>
101
+ <li class="fields">
102
+ <div class="field">
103
+ <label for="billing:postcode" class="required"><em>*</em><?php echo $this->__('Zip') ?></label>
104
+ <div class="input-box">
105
+ <input type="text" title="<?php echo $this->__('Zip') ?>" name="billing[postcode]" id="billing:postcode" value="<?php echo $this->escapeHtml($this->getAddress()->getPostcode()) ?>" class="input-text validate-zip-international <?php echo $this->helper('opc')->getAttributeValidationClass('postcode') ?>" />
106
+ </div>
107
+ </div>
108
+ <div class="field">
109
+ <label for="billing:country_id" class="required"><em>*</em><?php echo $this->__('Country') ?></label>
110
+ <div class="input-box">
111
+ <?php echo $this->getCountryHtmlSelect('billing') ?>
112
+ </div>
113
+ </div>
114
+ </li>
115
+ <li class="fields">
116
+ <div class="field">
117
+ <label for="billing:telephone" class="required"><em>*</em><?php echo $this->__('Telephone') ?></label>
118
+ <div class="input-box">
119
+ <input type="text" name="billing[telephone]" value="<?php echo $this->escapeHtml($this->getAddress()->getTelephone()) ?>" title="<?php echo $this->__('Telephone') ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('telephone') ?>" id="billing:telephone" />
120
+ </div>
121
+ </div>
122
+ <div class="field">
123
+ <label for="billing:fax"><?php echo $this->__('Fax') ?></label>
124
+ <div class="input-box">
125
+ <input type="text" name="billing[fax]" value="<?php echo $this->escapeHtml($this->getAddress()->getFax()) ?>" title="<?php echo $this->__('Fax') ?>" class="input-text <?php echo $this->helper('opc')->getAttributeValidationClass('fax') ?>" id="billing:fax" />
126
+ </div>
127
+ </div>
128
+ </li>
129
+ <?php if(!$this->isCustomerLoggedIn()): ?>
130
+
131
+ <?php $_dob = $this->getLayout()->createBlock('customer/widget_dob') ?>
132
+ <?php $_gender = $this->getLayout()->createBlock('customer/widget_gender') ?>
133
+ <?php if ($_dob->isEnabled() || $_gender->isEnabled()): ?>
134
+ <li class="fields">
135
+ <?php if ($_dob->isEnabled()): ?>
136
+ <div class="field">
137
+ <?php echo $_dob->setDate($this->getQuote()->getCustomerDob())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
138
+ </div>
139
+ <?php endif; ?>
140
+ <?php if ($_gender->isEnabled()): ?>
141
+ <div class="field">
142
+ <?php echo $_gender->setGender($this->getQuote()->getCustomerGender())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
143
+ </div>
144
+ <?php endif ?>
145
+ </li>
146
+ <div class="clear"></div>
147
+ <?php endif ?>
148
+
149
+ <?php $_taxvat = $this->getLayout()->createBlock('customer/widget_taxvat') ?>
150
+ <?php if ($_taxvat->isEnabled()): ?>
151
+ <li>
152
+ <?php echo $_taxvat->setTaxvat($this->getQuote()->getCustomerTaxvat())->setFieldIdFormat('billing:%s')->setFieldNameFormat('billing[%s]')->toHtml() ?>
153
+ </li>
154
+ <?php endif ?>
155
+
156
+
157
+ <?php endif; ?>
158
+ <?php if ($this->isCustomerLoggedIn() && $this->customerHasAddresses()):?>
159
+ <div class="clear"></div>
160
+ <li class="control">
161
+ <input type="checkbox" name="billing[save_in_address_book]" value="1" title="<?php echo $this->__('Save in address book') ?>" id="billing:save_in_address_book" onchange="if(window.shipping) shipping.setSameAsBilling(false);"<?php if ($this->getAddress()->getSaveInAddressBook()):?> checked="checked"<?php endif;?> class="checkbox" /><label for="billing:save_in_address_book"><?php echo $this->__('Save in address book') ?></label>
162
+ </li>
163
+ <?php else:?>
164
+ <li class="no-display"><input type="hidden" name="billing[save_in_address_book]" value="1" /></li>
165
+ <?php endif; ?>
166
+ <?php echo $this->getChildHtml('form.additional.info'); ?>
167
+ </ul>
168
+ </fieldset>
169
+ </li>
170
+ <?php /* Extensions placeholder */ ?>
171
+ <?php echo $this->getChildHtml('checkout.onepage.billing.extra')?>
172
+
173
+ <!-- fix browser autocomplete -->
174
+ <div style="display:none !important">
175
+ <input type="text" autocomplete="off" value="" />
176
+ <input type="password" autocomplete="off" value=""/>
177
+ </div>
178
+ <!-- end fix browser autocomplete -->
179
+
180
+ <?php if(!$this->isCustomerLoggedIn()): ?>
181
+
182
+ <?php
183
+ $guest_allowed = $this->getQuote()->isAllowedGuestCheckout();
184
+ if($guest_allowed): ?>
185
+ <li class="control">
186
+ <input type="checkbox" name="billing[create_account]" id="billing:create_account" value="1" title="<?php echo $this->__('Create an account for later use') ?>" class="checkbox" /><label for="billing:create_account"><?php echo $this->__('Create an account for later use') ?></label>
187
+ </li>
188
+ <?php else:?>
189
+ <input type="hidden" name="billing[create_account]" id="billing:create_account" value="1" />
190
+ <?php endif;?>
191
+
192
+ <li class="fields <?php if($guest_allowed):?>hidden<?php endif;?>" id="register-customer-password">
193
+ <div class="field">
194
+ <label for="billing:customer_password" class="required"><em>*</em><?php echo $this->__('Password') ?></label>
195
+ <div class="input-box">
196
+ <input type="password" name="billing[customer_password]" title="<?php echo $this->__('Password') ?>" id="billing:customer_password" class="input-text validate-password <?php if(!$guest_allowed):?>required-entry<?php endif;?>" autocomplete="off" value=""/>
197
+ </div>
198
+ </div>
199
+ <div class="field">
200
+ <label for="billing:confirm_password" class="required"><em>*</em><?php echo $this->__('Confirm Password') ?></label>
201
+ <div class="input-box">
202
+ <input type="password" name="billing[confirm_password]" title="<?php echo $this->__('Confirm Password') ?>" id="billing:confirm_password" class="input-text validate-cpassword <?php if(!$guest_allowed):?>required-entry<?php endif;?>" autocomplete="off" value=""/>
203
+ </div>
204
+ </div>
205
+ </li>
206
+ <div class="clear"></div>
207
+
208
+ <?php endif;?>
209
+
210
+ <?php if ($this->canShip()): ?>
211
+ <li class="control <?php if (!Mage::helper('opc')->isShowShippingForm()):?>hidden<?php endif;?>">
212
+ <input type="checkbox" name="billing[use_for_shipping]" id="billing:use_for_shipping_yes" value="1"<?php if ($this->isUseBillingAddressForShipping()) {?> checked="checked"<?php }?> title="<?php echo $this->__('Ship to this address') ?>" class="checkbox " /><label for="billing:use_for_shipping_yes"><?php echo $this->__('Ship to this address') ?></label>
213
+ </li>
214
+ <?php endif; ?>
215
+ </ul>
216
+ <?php if (!$this->canShip()): ?>
217
+ <input type="hidden" name="billing[use_for_shipping]" value="1" />
218
+ <?php endif; ?>
219
+
220
+ </div>
221
+ <script type="text/javascript">
222
+ //<![CDATA[
223
+ var billingRegionUpdater = new RegionUpdater('billing:country_id', 'billing:region', 'billing:region_id', <?php echo $this->helper('directory')->getRegionJson() ?>, undefined, 'billing:postcode');
224
+ //]]>
225
+ </script>
app/design/frontend/base/default/template/payex/masterpass/button.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php /** @var $this PayEx_Payments_Block_MasterPass_Button */ ?>
2
+ <a href="<?php echo $this->getCheckoutUrl(); ?>" class="payex-masterpass-button">
3
+ <img src="<?php echo $this->getImageUrl(); ?>" title="<?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>" alt="<?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>" />
4
+ </a>
app/design/frontend/base/default/template/payex/masterpass/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_MasterPass */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/masterpass-140.png'); ?>" alt="Buy with MasterPass" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('Buy with MasterPass'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/frontend/base/default/template/payex/masterpass/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_MasterPass */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/masterpass/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
2
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
3
+ <?php if (!empty($trans_id)): ?>
4
+ <?php $specific = $this->getSpecificInformation(); ?>
5
+ <?php if (count($specific) > 0): ?>
6
+ <?php foreach($specific as $key => $value): ?>
7
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
+ {{pdf_row_separator}}
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
11
+ <?php else: ?>
12
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/masterpass/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/partpayment/form.phtml ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_PartPayment */
3
+
4
+ // Get saved SSN from SSN extension
5
+ $socal_security_number = $this->getPayexSSN();
6
+
7
+ // Get fee
8
+ $fee = $this->getPayexPaymentFee();
9
+ ?>
10
+
11
+ <fieldset class="form-list">
12
+ <?php $_code = $this->getMethodCode() ?>
13
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
14
+ <li>
15
+ <div style="float:right">
16
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/partpayment-logo.gif'); ?>"/>
17
+ </div>
18
+ <div style="float:left">
19
+ <!-- Start PayEx PartPayment block -->
20
+ <form action="<?php echo $this->getFormAction(); ?>" method="post">
21
+ <?php if (empty($socal_security_number)): ?>
22
+ <label
23
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
24
+ <span class="required">*</span></label><br/>
25
+ <input name="social-security-number" id="social-security-number"
26
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>"
27
+ class="required-entry input-text" type="text"/><br/>
28
+ <?php else: ?>
29
+ <label
30
+ for="social-security-number"><?php echo Mage::helper('payex')->__('Social Security Number'); ?>
31
+ <span class="required">*</span></label><br/>
32
+ <input name="social-security-number" id="social-security-number"
33
+ title="<?php echo Mage::helper('payex')->__('Social Security Number'); ?>" value="<?php echo $socal_security_number; ?>"
34
+ class="required-entry input-text" type="text" readonly/><br/>
35
+ <?php endif; ?>
36
+ </form>
37
+ <?php if ($fee->getPaymentFeePrice() > 0): ?>
38
+ <div>
39
+ <?php if ($this->helper('tax')->displayBothPrices()): ?>
40
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
41
+ <br />
42
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
43
+ <?php echo $this->helper('checkout')->__('(Excl. Tax)'); ?>
44
+ <br />
45
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
46
+ <?php echo $this->helper('checkout')->__('(Incl. Tax)'); ?>
47
+ <?php elseif ($this->helper('tax')->displayPriceIncludingTax()): ?>
48
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
49
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice() + $fee->getPaymentFeeTax()); ?>
50
+ <?php else: ?>
51
+ <strong><?php echo Mage::helper('payex')->__('Payment fee'); ?>:</strong>
52
+ <?php echo $this->helper('checkout')->formatPrice($fee->getPaymentFeePrice()); ?>
53
+ <?php endif; ?>
54
+ </div>
55
+ <?php endif; ?>
56
+ <!-- End PayEx PartPayment block -->
57
+ </div>
58
+ <div style="float:right"></div>
59
+ </li>
60
+ </ul>
61
+ </fieldset>
app/design/frontend/base/default/template/payex/partpayment/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_PartPayment */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach ($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br/>
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/partpayment/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
2
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
3
+ <?php if (!empty($trans_id)): ?>
4
+ <?php $specific = $this->getSpecificInformation(); ?>
5
+ <?php if (count($specific) > 0): ?>
6
+ <?php foreach($specific as $key => $value): ?>
7
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
+ {{pdf_row_separator}}
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
11
+ <?php else: ?>
12
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/partpayment/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/swish/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_Swish */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/swish.png'); ?>" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/frontend/base/default/template/payex/swish/info.phtml ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_Swish */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()); ?></p>
app/design/frontend/base/default/template/payex/swish/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php echo $this->escapeHtml($this->getMethod()->getTitle()) ?>{{pdf_row_separator}}
2
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
3
+ <?php if (!empty($trans_id)): ?>
4
+ <?php $specific = $this->getSpecificInformation(); ?>
5
+ <?php if (count($specific) > 0): ?>
6
+ <?php foreach($specific as $key => $value): ?>
7
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $value; ?>
8
+ {{pdf_row_separator}}
9
+ <?php endforeach; ?>
10
+ <?php endif; ?>
11
+ <?php else: ?>
12
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
13
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/swish/title.phtml ADDED
@@ -0,0 +1 @@
 
1
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
app/design/frontend/base/default/template/payex/wywallet/form.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Form_WyWallet */
3
+ ?>
4
+
5
+ <fieldset class="form-list">
6
+ <?php $_code=$this->getMethodCode() ?>
7
+ <ul id="payment_form_<?php echo $_code ?>" style="display:none">
8
+ <li>
9
+ <div style="float:left">
10
+ <img src="<?php echo Mage::getDesign()->getSkinUrl('images/payex/ww_logo.png'); ?>" /><br />
11
+ </div>
12
+ <div style="float:left">
13
+ <?php echo Mage::helper('payex')->__('You will be redirected to <a target="_blank" href="http://www.payex.com">PayEx</a> website when you place an order.'); ?>
14
+ </div>
15
+ </li>
16
+ </ul>
17
+ </fieldset>
app/design/frontend/base/default/template/payex/wywallet/info.phtml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /** @var $this PayEx_Payments_Block_Info_WyWallet */
3
+ ?>
4
+
5
+ <p><?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?></p>
6
+ <?php $trans_id = $this->getInfo()->getLastTransId(); ?>
7
+ <?php if (!empty($trans_id)): ?>
8
+ <?php $specific = $this->getSpecificInformation(); ?>
9
+ <?php if (count($specific) > 0): ?>
10
+ <?php foreach($specific as $key => $value): ?>
11
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?><br />
12
+ <?php endforeach; ?>
13
+ <?php endif; ?>
14
+ <?php else: ?>
15
+ <?php echo Mage::helper('paygate')->__('Payment has not been processed yet.'); ?>
16
+ <?php endif; ?>
app/design/frontend/base/default/template/payex/wywallet/pdf/info.phtml ADDED
@@ -0,0 +1,13 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ $specific = $this->getSpecificInformation();
3
+ ?>
4
+
5
+ <?php echo $this->htmlEscape($this->getMethod()->getTitle()) ?>
6
+ {{pdf_row_separator}}
7
+ <?php if (count($specific) > 0): ?>
8
+ <?php foreach($specific as $key => $value): ?>
9
+ <?php echo Mage::helper('payex')->__($key) . ': ' . $this->htmlEscape($value); ?>
10
+ {{pdf_row_separator}}
11
+ <?php endforeach; ?>
12
+ <?php endif; ?>
13
+ {{pdf_row_separator}}
app/etc/modules/PayEx_Payments.xml ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <PayEx_Payments>
5
+ <active>true</active>
6
+ <!-- this module will be located in app/code/community code pool -->
7
+ <codePool>community</codePool>
8
+ <!-- specify dependencies for correct module loading order -->
9
+ <depends>
10
+ <Mage_Payment />
11
+ </depends>
12
+ <!-- declare module's version information for database updates -->
13
+ <version>3.0.1</version>
14
+ </PayEx_Payments>
15
+ </modules>
16
+ </config>
app/locale/en_US/PayEx_Payments.csv ADDED
File without changes
app/locale/sv_SE/PayEx_Payments.csv ADDED
@@ -0,0 +1,180 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ "Selected currency code (%s) is not compatible with PayEx","Vald valutakod (% s) är inte kompatibel med PayEx"
2
+ "Can't load last transaction.","Kan inte ladda sista transaktionen."
3
+ "This payment has not yet captured.","Denna betalning har ännu inte fångats."
4
+ "Unknown error","Okänt fel"
5
+ "Discount","Rabatt"
6
+ "Shipping","Frakt"
7
+ "English","English"
8
+ "Swedish","Svenska"
9
+ "Norway","Norge"
10
+ "Danish","Danska"
11
+ "Spanish","Spanska"
12
+ "German","Tyska"
13
+ "Finnish","Finska"
14
+ "French","Franska"
15
+ "Polish","Polska"
16
+ "Czech","Tjeckien"
17
+ "Hungarian","Ungerska"
18
+ "Detected an abnormal payment process. Order is canceled.","Upptäckte en onormal betalningsprocess. Ordern avbryts."
19
+ "The customer was redirected to PayEx.","Kunden skickades till PayEx."
20
+ "Order automatically canceled. Failed to complete payment.","Ordern blev automatiskt avbruten. Misslyckades att genomföra betalningen."
21
+ "Order automatically canceled. Payment refused.","Ordern blev automatiskt avbruten. Betalningen nekades."
22
+ "Order automatically canceled. Transaction is canceled.","Ordern blev automatiskt avbruten. Transaktionen är avbruten."
23
+ "Order has been paid","Order har betalats"
24
+ "Payment is accepted","Payment is accepted"
25
+ "You will be redirected to <a target=""_blank"" href=""http://www.payex.com"">PayEx</a> website when you place an order.","Du skickas vidare till <a target=""_blank"" href=""http://www.payex.com"">PayEx</a> webbplats för att betala."
26
+ "Time to clean pending orders (0 - disabled)","Tid innan väntande ordrar rensas - (0 = inaktiverad)"
27
+ "<a target=""_blank"" href=""%s"">agreement</a>","<a target=""_blank"" href=""%s"">överenskommelse</a>"
28
+ "Sign a %s to streamline further purchases with PayEx.","Gör en %s för att underlätta vidare köp."
29
+ "I accept the agreement","Jag godkänner överenskommelsen"
30
+ "You already %s the agreement.","Du har redan %s överenskommelsen."
31
+ "Payment will be made automatically by credit card.","Betalningen görs automatiskt med kort."
32
+ "Cancel agreement?","Upphäv överenskommelsen?"
33
+ "Cancel agreement","Upphäv överenskommelsen"
34
+ "Selected currency code (%s) is not compatible with PayEx","Vald valuta (%s) är inte godkänd av PayEx"
35
+ "Can't load last transaction.","Kan inte ladda senaste transaktion."
36
+ "Unable to execute capture. Accept only Authorize transactions.","Kan inte fånga ordern. Bara order med Authorize accepteras."
37
+ "This payment has not yet captured.","Den här transaktionen har inte fångats."
38
+ "The customer was redirected to PayEx.","Kunden har omdirigerats till PayEx."
39
+ "Order canceled by user","Order avbruten av kund"
40
+ "Detected an abnormal payment process. Order is canceled.","Upptäckta en onormal betalningsprocessen. Beställ avbryts."
41
+ "Payment Menu","Payment Meny"
42
+ "Credit Card","Kreditkort"
43
+ "Invoice","Faktura"
44
+ "Direct Debit","Direct Debit"
45
+ "Clean older pending orders","Clean äldre pågående order"
46
+ "Agreement url","Avtal url"
47
+ "Max amount of single transaction","Max mängd enda transaktion"
48
+ "Payment is accepted","Betalning accepterad"
49
+ "Can't capture captured order.","Kan inte fånga redan fångad order."
50
+ "Unable to execute cancel.","Gick inte att avbryta."
51
+ "Payment fee","Betalningsavgift"
52
+ "Failed to complete action: Bad Session Data","Misslyckades med att genomföra åtgärden: Bad Session Data"
53
+ "Paper by mail","Papper via post"
54
+ "PDF by e-mail","PDF via e-post"
55
+ "Authorize","Authorize"
56
+ "Sale","Sale"
57
+ "PayEx Payment Method","PayEx Betalningsmetod"
58
+ "Masked Number","Maskerade Number"
59
+ "Bank Hash","Bank Hash"
60
+ "Bank Reference","Bankreferens"
61
+ "Authenticated Status","Autentiserad Status"
62
+ "Authenticated With","Autentiserad med"
63
+ "PayEx Transaction Number","PayEx Transaktions Nummer"
64
+ "Transaction Error Code","Transaktionens felkod"
65
+ "Transaction Error Description","Transaktionens felbeskrivning"
66
+ "Transaction ThirdParty Error","Transaktionen misslykades pga tredje part"
67
+ "Select Invoice Type:","Välj Faktura Typ:"
68
+ "Private","Privat"
69
+ "Corporate","Företag"
70
+ "Social Security Number","Personnummer"
71
+ "First name","Förnamn"
72
+ "Last name","Efternamn"
73
+ "Organization Number","Organisationsnummer"
74
+ "Selected currency code (%s) is not compatible with PayEx","Vald valutakod (%s) är inte kompatibel med PayEx"
75
+ "Order has been paid","Ordern har betalats"
76
+ "Select your bank:","Välj din bank:"
77
+ "Nordea Bank","Nordea Bank"
78
+ "Swedbank","Swedbank"
79
+ "Svenska Enskilda Bank","Svenska Enskilda Bank"
80
+ "Handelsbanken","Handelsbanken"
81
+ "Nordea Bank DK","Nordea Bank DK"
82
+ "Den Danske Bank","Den Danske Bank"
83
+ "BankAxess","BankAxess"
84
+ "Sampo","Sampo"
85
+ "Aktia, Säästöpankki","Aktia, Säästöpankki"
86
+ "Osuuspanki, Pohjola, Oko","Osuuspanki, Pohjola, Oko"
87
+ "Nordea Bank Finland","Nordea Bank Finland"
88
+ "SHB:FI","SHB:FI"
89
+ "SPANKKI","SPANKKI"
90
+ "TAPIOLA","TAPIOLA"
91
+ "Ålandsbanken","Ålandsbanken"
92
+ "Failed to process order","Failed to process order"
93
+ "The customer was redirected to PayEx.","The customer was redirected to PayEx."
94
+ "Order automatically canceled. Failed to complete payment.","Order automatically canceled. Failed to complete payment."
95
+ "Order has been paid","Order has been paid"
96
+ "Order canceled by user","Order canceled by user"
97
+ "Error: No transactionsStatus in response.","Error: No transactionsStatus in response."
98
+ "You don't have any items in your cart","You don't have any items in your cart"
99
+ "Order total is too small","Order total is too small"
100
+ "Payment is accepted by Transaction Callback","Payment is accepted by Transaction Callback"
101
+ "Order canceled by Transaction Callback","Order canceled by Transaction Callback"
102
+ "Order captured by Transaction Callback","Order captured by Transaction Callback"
103
+ "Transaction Status: %s.","Transaction Status: %s."
104
+ "Detected an abnormal payment process (Transaction Status: %s).","Detected an abnormal payment process (Transaction Status: %s)."
105
+ "Order automatically canceled. Transaction is canceled.","Order automatically canceled. Transaction is canceled."
106
+ "Order automatically canceled. Transaction is failed.","Order automatically canceled. Transaction is failed."
107
+ "Invalid transaction status.","Invalid transaction status."
108
+ "Reward points","Reward points"
109
+ "Your customers bank declined the transaction, your customer can contact their bank for more information","Your customers bank declined the transaction, your customer can contact their bank for more information"
110
+ "An unhandled exception occurred","An unhandled exception occurred"
111
+ "A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification","A problem with Visa or MasterCards directory server, that communicates transactions for 3D-Secure verification"
112
+ "Communication error with the acquiring bank","Communication error with the acquiring bank"
113
+ "The sum of your order lines is not equal to the price set in initialize","The sum of your order lines is not equal to the price set in initialize"
114
+ "Your customers card is not eligible for this kind of purchase, your customer can contact their bank for more information","Your customers card is not eligible for this kind of purchase, your customer can contact their bank for more information"
115
+ "Some problem occurred with the credit card, your customer can contact their bank for more information","Some problem occurred with the credit card, your customer can contact their bank for more information"
116
+ "Your customers bank declined the transaction, your customer can contact their bank for more information","Your customers bank declined the transaction, your customer can contact their bank for more information"
117
+ "The merchant account number sent in on request is invalid","The merchant account number sent in on request is invalid"
118
+ "The IP address the request comes from is not registered in PayEx, you can set it up in PayEx Admin under Merchant profile","The IP address the request comes from is not registered in PayEx, you can set it up in PayEx Admin under Merchant profile"
119
+ "The merchant does not have access to requested functionality","The merchant does not have access to requested functionality"
120
+ "Your customers bank declined the transaction, your customer can contact their bank for more information","Your customers bank declined the transaction, your customer can contact their bank for more information"
121
+ "The merchant account is not active","The merchant account is not active"
122
+ "The merchant account is locked out","The merchant account is locked out"
123
+ "Generic validation error","Generic validation error"
124
+ "The hash on request is not valid, this might be due to the encryption key being incorrect","The hash on request is not valid, this might be due to the encryption key being incorrect"
125
+ "One of the input parameters has invalid data. See paramName and description for more information","One of the input parameters has invalid data. See paramName and description for more information"
126
+ "The operation was cancelled by the client","The operation was cancelled by the client"
127
+ "Unexpecter error at 3rd party","Unexpecter error at 3rd party"
128
+ "The amount is not valid for this operation","The amount is not valid for this operation"
129
+ "No data found","No data found"
130
+ "The operation is not allowed, transaction is in invalid state","The operation is not allowed, transaction is in invalid state"
131
+ "Could not get in touch with the card issuer","Could not get in touch with the card issuer"
132
+ "The card could not be verified","The card could not be verified"
133
+ "There is a problem with this card","There is a problem with this card"
134
+ "The card expired","The card expired"
135
+ "Insufficient funds","Insufficient funds"
136
+ "Incorrect amount","Incorrect amount"
137
+ "Payment cancelled","Payment cancelled"
138
+ "Your Credit Card not accepted for this purchase","Your Credit Card not accepted for this purchase"
139
+ "PayEx error: %s","PayEx error: %s"
140
+ "Can't load last transaction.","Can't load last transaction."
141
+ "Can't capture captured order.","Can't capture captured order."
142
+ "Unable to execute cancel.","Unable to execute cancel."
143
+ "This payment has not yet captured.","This payment has not yet captured."
144
+ "Product name ""%s"" contains invalid characters.","Product name ""%s"" contains invalid characters."
145
+ "Please select country.","Please select country."
146
+ "Please enter postcode.","Please enter postcode."
147
+ "Credit Card","Credit Card"
148
+ "Invoice","Invoice"
149
+ "Invoice (Ledger Service)","Invoice (Ledger Service)"
150
+ "PayPal","PayPal"
151
+ "Thank you for using the official PayEx Payments module for Magento!","Thank you for using the official PayEx Payments module for Magento!"
152
+ "Check out the code on %s","Check out the code on %s"
153
+ "Version: %s","Version: %s"
154
+ "Update Available: %s","Update Available: %s"
155
+ "Buy with MasterPass","Buy with MasterPass"
156
+ "Payment Type","Payment Type"
157
+ "Payment to applicable countries","Payment to applicable countries"
158
+ "Payment to Specific countries","Payment to Specific countries"
159
+ "Enable test mode","Enable test mode"
160
+ "Account Number","Account Number"
161
+ "Encryption Key","Encryption Key"
162
+ "Transaction Type","Transaction Type"
163
+ "Order status (for authorize)","Order status (for authorize)"
164
+ "Order status (for capture)","Order status (for capture)"
165
+ "New order status","New order status"
166
+ "Client language","Client language"
167
+ "Enable Responsive Skinning","Enable Responsive Skinning"
168
+ "Available banks","Available banks"
169
+ "Default shipping method for MasterPass orders","Default shipping method for MasterPass orders"
170
+ "Additional values to send","Additional values to send"
171
+ "Invoice distribution","Invoice distribution"
172
+ "Invoice fee","Invoice fee"
173
+ "Invoice text","Invoice text"
174
+ "Invoice due days","Invoice due days"
175
+ "Allow unapproved by CreditCheck","Allow unapproved by CreditCheck"
176
+ "Social security number is empty","Social security number is empty"
177
+ "Invalid Social Security Number","Invalid Social Security Number"
178
+ "Country is empty","Country is empty"
179
+ "Your country don't supported","Your country don't supported"
180
+ "Postcode is empty","Postcode is empty"
js/payex/iwd_opc/social_security_number.js ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ jQuery(document).ready(function($) {
2
+ $(document).on('click', '#ssn_click', function(e) {
3
+ if ($(this).hasClass('disabled')) {
4
+ return false;
5
+ }
6
+
7
+ var url = MAGENTO_BASE_URL + 'payex/getaddr';
8
+ var ssn = $('[name="socialSecurityNumber"]').first().val();
9
+ var country_code = $('#billing\\:country_id').val();
10
+ var postcode = $('#billing\\:postcode').val();
11
+
12
+ // Validate
13
+ if (ssn.length === 0) {
14
+ alert('Please enter Social security number.');
15
+ return;
16
+ }
17
+
18
+ $(this).addClass('disabled');
19
+
20
+ var self = this;
21
+ $.ajax({
22
+ url: url,
23
+ type: 'POST',
24
+ data: {ssn: ssn, country_code: country_code, postcode: postcode},
25
+ dataType: 'json',
26
+ success: function(json) {
27
+ $(self).removeClass('disabled');
28
+ if (!json.success) {
29
+ alert(json.message);
30
+ return;
31
+ }
32
+
33
+ // Set Form Fields
34
+ if ($('#billing\\:firstname').length) $('#billing\\:firstname').val(json.first_name);
35
+ if ($('#billing\\:lastname').length) $('#billing\\:lastname').val(json.last_name);
36
+ if ($('#billing\\:company').length) $('#billing\\:company').val('');
37
+ if ($('#billing\\:street1').length) $('#billing\\:street1').val(json.address_1);
38
+ if ($('#billing\\:street2').length) $('#billing\\:street2').val($.trim(json.address_2));
39
+ if ($('#billing\\:city').length) $('#billing\\:city').val(json.city);
40
+ if ($('#billing\\:region').length) $('#billing\\:region').val('');
41
+ if ($('#billing\\:postcode').length) $('#billing\\:postcode').val(json.postcode);
42
+ if ($('#billing\\:country_id').length) $('#billing\\:country_id').val(json.country);
43
+ }
44
+ });
45
+ });
46
+ });
js/payex/social_security_number.js ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ function fireEvent(element, event) {
2
+ if (document.createEventObject) {
3
+ // dispatch for IE
4
+ var evt = document.createEventObject();
5
+ return element.fireEvent('on' + event, evt)
6
+ }
7
+ else {
8
+ // dispatch for firefox + others
9
+ var evt = document.createEvent("HTMLEvents");
10
+ evt.initEvent(event, true, true); // event type,bubbling,cancelable
11
+ return !element.dispatchEvent(evt);
12
+ }
13
+ }
14
+
15
+ Event.observe(document, 'dom:loaded', function () {
16
+ if ($('billing-address-select')) {
17
+ document.getElementById('billing-address-select').value = '';
18
+ fireEvent(document.getElementById('billing-address-select'), 'change');
19
+ }
20
+
21
+ $('ssn_click').observe('click', function (event) {
22
+ // Check button is disabled
23
+ if ($(this).hasClassName('disabled')) {
24
+ return;
25
+ }
26
+
27
+ var url = MAGENTO_BASE_URL + 'payex/getaddr';
28
+ var ssn = $$('[name="socialSecurityNumber"]')[0].value;
29
+ var country_code = $$('[name="check_country"]')[0].value;
30
+ var postcode = $$('[name="check_postcode"]')[0].value;
31
+
32
+ // Check PayEx SSN Form is exists
33
+ if (typeof window.PAYEX_SSN_FORM === 'undefined') {
34
+ return false;
35
+ }
36
+
37
+ if (window.PAYEX_SSN_FORM.validator.validate()) {
38
+ $(this).addClassName('disabled');
39
+ var self = this;
40
+ var request = new Ajax.Request(
41
+ url, {
42
+ method: 'post',
43
+ parameters: {ssn: ssn, country_code: country_code, postcode: postcode},
44
+ onSuccess: function (response) {
45
+ $(self).removeClassName('disabled');
46
+ var json = response.responseText.evalJSON();
47
+ if (!json.success) {
48
+ alert(json.message);
49
+ return;
50
+ }
51
+ // Set Form Fields
52
+ if ($('billing:firstname')) $('billing:firstname').setValue(json.first_name);
53
+ if ($('billing:lastname')) $('billing:lastname').setValue(json.last_name);
54
+ if ($('billing:company')) $('billing:company').setValue('');
55
+ if ($('billing:street1')) $('billing:street1').setValue(json.address_1);
56
+ if ($('billing:street2')) {
57
+ //WHEN payex gives us a space -> validation will crash. So sanitize json input
58
+ // replace(/^\s+/,"") === ltrim()
59
+ $('billing:street2').setValue(json.address_2.replace(/^\s+/,""));
60
+ }
61
+ if ($('billing:city')) $('billing:city').setValue(json.city);
62
+ if ($('billing:region')) $('billing:region').setValue('');
63
+ if ($('billing:postcode')) $('billing:postcode').setValue(json.postcode);
64
+ if ($('billing:country_id')) $('billing:country_id').setValue(json.country);
65
+ }
66
+ }
67
+ );
68
+ }
69
+ });
70
+ });
lib/Px/Px.php ADDED
@@ -0,0 +1,253 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * PayEx API
4
+ * @see http://www.payexpim.com/technical-reference/
5
+ * Created by AAIT Team.
6
+ */
7
+
8
+ class Px
9
+ {
10
+ /** @var array SOAP Options */
11
+ protected $_options = array();
12
+
13
+ /** @var bool PayEx Debug mode */
14
+ protected $_debug_mode = true;
15
+
16
+ /** @var string PayEx Account Number */
17
+ protected $_account_number = '';
18
+
19
+ /** @var string Encryption Key */
20
+ protected $_encryption_key = '';
21
+
22
+ /** @see http://www.payexpim.com/technical-reference/wsdl/wsdl-files/ */
23
+ /** @var array WSDL Files */
24
+ protected static $_wsdl = array(
25
+ 'PxOrderWSDL' => '',
26
+ 'PxVerificationWSDL' => '',
27
+ 'PxAgreementWSDL' => '',
28
+ 'PxRecurringWSDL' => '',
29
+ 'PxConfinedWSDL' => ''
30
+ );
31
+
32
+ /** @var array PayEx SOAP API List */
33
+ protected static $_rules = array(
34
+ /** @see http://www.payexpim.com/category/pxorder/ */
35
+ 'PxOrderWSDL' => array(
36
+ 'AddOrderAddress2', 'AddSingleOrderLine2', 'AuthorizeEVC', 'AuthorizeGC', 'AuthorizeInvoice',
37
+ 'AuthorizeInvoiceLedger', 'Cancel2', 'Capture5', 'Check2', 'Complete', 'Credit5', 'CreditOrderLine3',
38
+ 'FinalizeTransaction', 'GetAddressByPaymentMethod', 'GetApprovedDeliveryAddress', 'GetLowestMonthlyInvoiceSaleAmount',
39
+ 'GetTransactionDetails2', 'Initialize8', 'InvoiceLinkGet', 'PrepareAuthorizeDD', 'PrepareSaleDD2', 'PurchaseActivate',
40
+ 'PurchaseFinancingInvoice', 'PurchaseInvoiceCorporate', 'PurchaseInvoicePrivate', 'PurchaseInvoiceSale',
41
+ 'PurchasePartPaymentSale', 'PurchaseOTT', 'PurchaseInvoicePartPaymentSale', 'PurchasePX', 'SaleEVC',
42
+ 'SaleInvoiceLedger', 'SaleGC', 'PurchaseWyWallet', 'PreparePurchaseWyWallet', 'PurchaseCreditAccount'
43
+ ),
44
+ /** @see http://www.payexpim.com/category/pxverification/ */
45
+ 'PxVerificationWSDL' => array(
46
+ 'CreditCheckCorporate2', 'CreditCheckPrivate2', 'GetConsumerLegalAddress', 'NameCheckPrivate'
47
+ ),
48
+ /** @see http://www.payexpim.com/category/pxagreement/ */
49
+ 'PxAgreementWSDL' => array(
50
+ 'ActivatePxAgreement', 'AutoPay3', 'AgreementCheck', 'CreateAgreement3', 'DeleteAgreement'
51
+ ),
52
+ /** @see http://www.payexpim.com/category/pxagreement/ */
53
+ 'PxRecurringWSDL' => array(
54
+ 'Check', 'Start', 'Stop'
55
+ ),
56
+ /** @see http://www.payexpim.com/category/pxconfined/ */
57
+ 'PxConfinedWSDL' => array(
58
+ 'PreparePurchaseCC', 'PurchaseCC'
59
+ )
60
+ );
61
+
62
+ /**
63
+ * Constructor
64
+ * @param array $options
65
+ */
66
+ public function __construct($options = array())
67
+ {
68
+ // SSL Verification option
69
+ if (isset($options['ssl_verify'])) {
70
+ if (!$options['ssl_verify']) {
71
+ $context = stream_context_create(array(
72
+ 'ssl' => array(
73
+ 'verify_peer' => false,
74
+ 'allow_self_signed' => true
75
+ )
76
+ ));
77
+ $options['stream_context'] = $context;
78
+ }
79
+
80
+ unset($options['ssl_verify']);
81
+ }
82
+
83
+ $this->_options = $options;
84
+ }
85
+
86
+ /**
87
+ * Get Library Version
88
+ * @return string
89
+ */
90
+ public function getVersion()
91
+ {
92
+ return '2.0.3';
93
+ }
94
+
95
+ /**
96
+ * Set PayEx Environment
97
+ * @param string $account
98
+ * @param string $key
99
+ * @param bool $debug
100
+ */
101
+ public function setEnvironment($account, $key, $debug = true)
102
+ {
103
+ $this->_account_number = $account;
104
+ $this->_encryption_key = $key;
105
+ $this->_debug_mode = $debug;
106
+
107
+ // Init WSDL
108
+ $this->initWSDL($this->_debug_mode);
109
+ }
110
+
111
+ /**
112
+ * Init WSDL Values
113
+ * @param bool $debug_mode
114
+ */
115
+ protected function initWSDL($debug_mode)
116
+ {
117
+ self::$_wsdl['PxOrderWSDL'] = 'https://test-external.payex.com/pxorder/pxorder.asmx?WSDL';
118
+ self::$_wsdl['PxConfinedWSDL'] = 'https://test-confined.payex.com/PxConfined/pxorder.asmx?WSDL';
119
+ self::$_wsdl['PxVerificationWSDL'] = 'https://test-external.payex.com/PxVerification/pxverification.asmx?WSDL';
120
+ self::$_wsdl['PxAgreementWSDL'] = 'https://test-external.payex.com/pxagreement/pxagreement.asmx?WSDL';
121
+ self::$_wsdl['PxRecurringWSDL'] = 'https://test-external.payex.com/pxagreement/pxrecurring.asmx?WSDL';
122
+
123
+ // Set Live environment
124
+ if (!$debug_mode ) {
125
+ self::$_wsdl['PxOrderWSDL'] = 'https://external.payex.com/pxorder/pxorder.asmx?WSDL';
126
+ self::$_wsdl['PxConfinedWSDL'] = 'https://confined.payex.com/PxConfined/pxorder.asmx?WSDL';
127
+ self::$_wsdl['PxVerificationWSDL'] = 'https://external.payex.com/pxverification/pxverification.asmx?WSDL';
128
+ self::$_wsdl['PxAgreementWSDL'] = 'https://external.payex.com/pxagreement/pxagreement.asmx?WSDL';
129
+ self::$_wsdl['PxRecurringWSDL'] = 'https://external.payex.com/pxagreement/pxrecurring.asmx?WSDL';
130
+ }
131
+ }
132
+
133
+ /**
134
+ * Get WSDL File
135
+ * @param $px_function
136
+ * @return bool
137
+ */
138
+ protected function getWSDL($px_function)
139
+ {
140
+ foreach (self::$_rules as $wsdl_type => $function_list) {
141
+ if (in_array($px_function, $function_list)) {
142
+ return self::$_wsdl[$wsdl_type];
143
+ }
144
+ }
145
+ return false;
146
+ }
147
+
148
+ /**
149
+ * Parse PayEx XML Response
150
+ * @param $xml_body
151
+ * @return array|bool
152
+ */
153
+ protected function parseFields($xml_body)
154
+ {
155
+ // Load XML
156
+ libxml_use_internal_errors(true);
157
+ $doc = new DOMDocument();
158
+ $status = @$doc->loadXML($xml_body);
159
+ if ($status === false) {
160
+ return false;
161
+ }
162
+
163
+ $result = array();
164
+ $blacklisted = array('header', 'id', 'status');
165
+ $items = $doc->getElementsByTagName('payex')->item(0)->getElementsByTagName('*');
166
+ foreach ($items as $item) {
167
+ $key = $item->nodeName;
168
+ $value = $item->nodeValue;
169
+ if (!in_array($key, $blacklisted)) {
170
+ $result[$key] = $value;
171
+ }
172
+ }
173
+
174
+ // Get Status codes for corrected result.
175
+ $items = $doc->getElementsByTagName('payex')->item(0)->getElementsByTagName('status')->item(0)->getElementsByTagName('*');
176
+ foreach ($items as $item) {
177
+ $key = $item->nodeName;
178
+ $value = $item->nodeValue;
179
+ $result[$key] = $value;
180
+ }
181
+ return $result;
182
+ }
183
+
184
+ /**
185
+ * Magic Method: Call PayEx Function
186
+ * @param $px_function
187
+ * @param $arguments
188
+ * @return array|bool
189
+ * @throws Exception
190
+ */
191
+ public function __call($px_function, $arguments)
192
+ {
193
+ if (empty($this->_account_number) || empty($this->_encryption_key)) {
194
+ throw new Exception('Account number or Encryption key not defined. Use setEnvironment().');
195
+ }
196
+
197
+ $wsdl = $this->getWSDL($px_function);
198
+ if (!$wsdl || empty($wsdl)) {
199
+ throw new Exception('Unknown PayEx Method.');
200
+ }
201
+
202
+ if (!isset($arguments[0]) || !is_array($arguments[0])) {
203
+ throw new Exception('Invalid PayEx Method params.');
204
+ }
205
+
206
+ // Set Account Number param automatically
207
+ if (isset($arguments[0]['accountNumber']) && empty($arguments[0]['accountNumber'])) {
208
+ $arguments[0]['accountNumber'] = $this->_account_number;
209
+ }
210
+
211
+ // AgreementCheck used as "Check"
212
+ if ($px_function === 'AgreementCheck') {
213
+ $px_function = 'Check';
214
+ }
215
+
216
+ // Add Hash to Params
217
+ $arguments[0]['hash'] = $this->getHash($arguments[0]);
218
+
219
+ // Call PayEx Method
220
+ $client = new SoapClient($wsdl, $this->_options);
221
+ $result = $client->__soapCall($px_function, $arguments);
222
+ if (!property_exists($result, $px_function . 'Result')) {
223
+ throw new Exception('Invalid PayEx Response.');
224
+ }
225
+ $result = $result->{$px_function . 'Result'};
226
+ $result = $this->parseFields($result);
227
+ if (!$result) {
228
+ throw new Exception('Failed to parse PayEx Response.');
229
+ }
230
+
231
+ return $result;
232
+ }
233
+
234
+ /**
235
+ * Get Hash Params
236
+ *
237
+ * Hexadecimal md5 hash built up by the value of the following parameters (for Initialize7):
238
+ * accountNumber + purchaseOperation + price + priceArgList + currency + vat + orderID +
239
+ * productNumber + description + clientIPAddress + clientIdentifier + additionalValues +
240
+ * externalID + returnUrl + view + agreementRef + cancelUrl + clientLanguage
241
+ *
242
+ * All parameters are added together – the ‘plus’ character is not included.
243
+ * In addition the encryption key must be included at the end of the string before performing the md5-hash.
244
+ * @param array $params
245
+ * @return string
246
+ */
247
+ protected function getHash($params)
248
+ {
249
+ $params = trim(implode('', $params));
250
+ return strtoupper(md5($params . $this->_encryption_key));
251
+ }
252
+
253
+ }
lib/Px/parser.php ADDED
@@ -0,0 +1,388 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+
5
+ /**
6
+ * Split a full name into its constituent parts
7
+ * - prefix/salutation (Mr. Mrs. Dr. etc)
8
+ * - given/first name
9
+ * - middle name/initial(s)
10
+ * - surname (last name)
11
+ * - suffix (II, PhD, Jr. etc)
12
+ */
13
+ class FullNameParser {
14
+
15
+
16
+
17
+ /**
18
+ * Create the dictionary of terms for use later
19
+ *
20
+ * - Common honorific prefixes (english)
21
+ * - Common compound surname identifiers
22
+ * - Common suffixes (lineage and professional)
23
+ */
24
+ protected $dict = array(
25
+ 'prefix' => array(
26
+ 'Mr.' => array('mr', 'mister', 'master'),
27
+ 'Mrs.' => array('mrs', 'missus', 'missis'),
28
+ 'Ms.' => array('ms', 'miss'),
29
+ 'Dr.' => array('dr'),
30
+ 'Rev.' => array("rev", "rev'd", "reverend"),
31
+ 'Fr.' => array('fr', 'father'),
32
+ 'Sr.' => array('sr', 'sister'),
33
+ 'Prof.' => array('prof', 'professor'),
34
+ 'Sir' => array('sir'),
35
+ ' ' => array('the')
36
+ ),
37
+ 'compound' => array('da','de','del','della','der','di','du','la','pietro','st.','st','ter','van','vanden','vere','von'),
38
+ 'suffixes' => array(
39
+ 'line' => array('I','II','III','IV','V','1st','2nd','3rd','4th','5th','Senior','Junior','Jr','Sr'),
40
+ 'prof' => array('PhD','APR','RPh','PE','MD','MA','DMD','CME')
41
+ ),
42
+ 'vowels' => array('a','e','i','o','u')
43
+ );
44
+
45
+
46
+
47
+ /**
48
+ * This is the primary method which calls all other methods
49
+ *
50
+ * @param string $name the full name you wish to parse
51
+ * @return array returns associative array of name parts
52
+ */
53
+ public function parse_name($full_name) {
54
+
55
+ # Remove leading/trailing whitespace
56
+ $full_name = trim($full_name);
57
+
58
+ # Setup default vars
59
+ extract(array('salutation' => '', 'fname' => '', 'initials' => '', 'lname' => '', 'suffix' => ''));
60
+
61
+ # If name contains professional suffix, assign and remove it
62
+ $professional_suffix = $this->get_pro_suffix($full_name);
63
+ if ($professional_suffix) {
64
+ # Remove the suffix from full name
65
+ $full_name = str_replace($professional_suffix, '', $full_name);
66
+ # Remove the preceeding comma and space(s) from suffix
67
+ $professional_suffix = preg_replace("/, */", '', $professional_suffix);
68
+ # Normalize the case of suffix if found in dictionary
69
+ foreach ($this->dict['suffixes']['prof'] as $prosuffix) {
70
+ if (strtolower($prosuffix) === strtolower($professional_suffix)) {
71
+ $professional_suffix = $prosuffix;
72
+ }
73
+ }
74
+ }
75
+
76
+ # Deal with nickname, push to array
77
+ $has_nick = $this->get_nickname($full_name);
78
+ if ($has_nick) {
79
+ # Remove wrapper chars from around nickname
80
+ $name['nickname'] = substr($has_nick, 1, (strlen($has_nick) - 2));
81
+ # Remove the nickname from the full name
82
+ $full_name = str_replace($has_nick, '', $full_name);
83
+ # Get rid of consecutive spaces left by the removal
84
+ $full_name = str_replace(' ', ' ', $full_name);
85
+ }
86
+
87
+ # Grab a list of words from name
88
+ $unfiltered_name_parts = $this->break_words($full_name);
89
+
90
+ # Is first word a title or multiple titles consecutively?
91
+ while ($s = $this->is_salutation($unfiltered_name_parts[0])) {
92
+ $salutation .= "$s ";
93
+ array_shift($unfiltered_name_parts);
94
+ }
95
+ $salutation = trim($salutation);
96
+
97
+ # Is last word a suffix or multiple suffixes consecutively?
98
+ while ($s = $this->is_suffix($unfiltered_name_parts[count($unfiltered_name_parts)-1], $full_name)) {
99
+ $suffix .= "$s ";
100
+ array_pop($unfiltered_name_parts);
101
+ }
102
+ $suffix = trim($suffix);
103
+
104
+ # If suffix and professional suffix not empty, add comma
105
+ if (!empty($professional_suffix) && !empty($suffix)) {
106
+ $suffix .= ', ';
107
+ }
108
+
109
+ # Concat professional suffix to suffix
110
+ $suffix .= $professional_suffix;
111
+
112
+ # set the ending range after prefix/suffix trim
113
+ $end = count($unfiltered_name_parts);
114
+
115
+ # concat the first name
116
+ for ($i=0; $i<$end-1; $i++) {
117
+ $word = $unfiltered_name_parts[$i];
118
+ # move on to parsing the last name if we find an indicator of a compound last name (Von, Van, etc)
119
+ # we use $i != 0 to allow for rare cases where an indicator is actually the first name (like "Von Fabella")
120
+ if ($this->is_compound($word) && $i != 0) {
121
+ break;
122
+ }
123
+ # is it a middle initial or part of their first name?
124
+ # if we start off with an initial, we'll call it the first name
125
+ if ($this->is_initial($word)) {
126
+ # is the initial the first word?
127
+ if ($i == 0) {
128
+ # if so, do a look-ahead to see if they go by their middle name
129
+ # for ex: "R. Jason Smith" => "Jason Smith" & "R." is stored as an initial
130
+ # but "R. J. Smith" => "R. Smith" and "J." is stored as an initial
131
+ if ($this->is_initial($unfiltered_name_parts[$i+1])) {
132
+ $fname .= " ".strtoupper($word);
133
+ }
134
+ else {
135
+ $initials .= " ".strtoupper($word);
136
+ }
137
+ }
138
+ # otherwise, just go ahead and save the initial
139
+ else {
140
+ $initials .= " ".strtoupper($word);
141
+ }
142
+ }
143
+ else {
144
+ $fname .= " ".$this->fix_case($word);
145
+ }
146
+ }
147
+
148
+ # check that we have more than 1 word in our string
149
+ if ($end-0 > 1) {
150
+ # concat the last name
151
+ for ($i; $i < $end; $i++) {
152
+ $lname .= " ".$this->fix_case($unfiltered_name_parts[$i]);
153
+ }
154
+ }
155
+ else {
156
+ # otherwise, single word strings are assumed to be first names
157
+ $fname = $this->fix_case($unfiltered_name_parts[$i]);
158
+ }
159
+
160
+ # return the various parts in an array
161
+ $name['salutation'] = $salutation;
162
+ $name['fname'] = trim($fname);
163
+ $name['initials'] = trim($initials);
164
+ $name['lname'] = trim($lname);
165
+ $name['suffix'] = $suffix;
166
+ return $name;
167
+ }
168
+
169
+
170
+
171
+ /**
172
+ * Breaks name into individual words
173
+ *
174
+ * @param string $name the full name you wish to parse
175
+ * @return array full list of words broken down by spaces
176
+ */
177
+ public function break_words($name) {
178
+ return explode(' ', $name);
179
+ }
180
+
181
+
182
+
183
+ /**
184
+ * Checks for the existence of, and returns professional suffix
185
+ *
186
+ * @param string $name the name you wish to test
187
+ * @return mixed returns the suffix if exists, false otherwise
188
+ */
189
+ protected function get_pro_suffix($name) {
190
+ foreach ($this->dict['suffixes']['prof'] as $suffix) {
191
+ if (preg_match("/,[\s]*$suffix\b/i", $name, $matches)) {
192
+ return $matches[0];
193
+ }
194
+ }
195
+ return false;
196
+ }
197
+
198
+
199
+
200
+ /**
201
+ * Function to check name for existence of nickname based on these stipulations
202
+ * - String wrapped in parentheses (string)
203
+ * - String wrapped in double quotes "string"
204
+ * x String wrapped in single quotes 'string'
205
+ *
206
+ * I removed the check for strings in single quotes 'string' due to possible
207
+ * conflicts with names that may include apostrophes. Arabic transliterations, for example
208
+ *
209
+ * @param string $name the name you wish to test against
210
+ * @return mixed returns nickname if exists, false otherwise
211
+ */
212
+ protected function get_nickname($name) {
213
+ if (preg_match("/[\(|\"].*?[\)|\"]/", $name, $matches)) {
214
+ return $matches[0];
215
+ }
216
+ return false;
217
+ }
218
+
219
+
220
+
221
+ /**
222
+ * Checks word against array of common suffixes
223
+ *
224
+ * @param string $word the single word you wish to test
225
+ * @param string $name full name for context in determining edge-cases
226
+ * @return mixed boolean if false, string if true (returns suffix)
227
+ */
228
+ protected function is_suffix($word, $name) {
229
+
230
+ # Ignore periods, normalize case
231
+ $word = str_replace('.', '', strtolower($word));
232
+
233
+ # Search the array for our word
234
+ $line_match = array_search($word, array_map('strtolower', $this->dict['suffixes']['line']));
235
+ $prof_match = array_search($word, array_map('strtolower', $this->dict['suffixes']['prof']));
236
+
237
+ # Break out for professional suffix matches first
238
+ if ($prof_match !== false) {
239
+ return $this->dict['suffixes']['prof'][$prof_match];
240
+ }
241
+
242
+ # Now test our edge cases based on lineage
243
+ if ($line_match !== false) {
244
+
245
+ # Store our match
246
+ $matched_case = $this->dict['suffixes']['line'][$line_match];
247
+
248
+ # Remove it from the array
249
+ $temp_array = $this->dict['suffixes']['line'];
250
+ unset($temp_array[$line_match]);
251
+
252
+ # Make sure we're dealing with the suffix and not a surname
253
+ if ($word == 'senior' || $word == 'junior') {
254
+
255
+ # If name is Joshua Senior, it's pretty likely that Senior is the surname
256
+ # However, if the name is Joshua Jones Senior, then it's likely a suffix
257
+ if (str_word_count($name) < 3) {
258
+ return false;
259
+ }
260
+
261
+ # If the word Junior or Senior is contained, but so is some other
262
+ # lineage suffix, then the word is likely a surname and not a suffix
263
+ foreach ($temp_array as $suffix) {
264
+ if (preg_match("/\b".$suffix."\b/i", $name)) {
265
+ return false;
266
+ }
267
+ }
268
+ }
269
+ return $matched_case;
270
+ }
271
+ return false;
272
+ }
273
+
274
+
275
+
276
+ /**
277
+ * Checks word against list of common honorific prefixes
278
+ *
279
+ * @param string $word the single word you wish to test
280
+ * @return boolean
281
+ */
282
+ protected function is_salutation($word) {
283
+ $word = str_replace('.', '', strtolower($word));
284
+ foreach ($this->dict['prefix'] as $replace => $originals) {
285
+ if (in_array($word, $originals)) {
286
+ return $replace;
287
+ }
288
+ }
289
+ return false;
290
+ }
291
+
292
+
293
+
294
+ /**
295
+ * Checks our dictionary of compound indicators to see if last name is compound
296
+ *
297
+ * @param string $word the single word you wish to test
298
+ * @return boolean
299
+ */
300
+ protected function is_compound($word) {
301
+ return array_search(strtolower($word), $this->dict['compound']);
302
+ }
303
+
304
+
305
+
306
+ /**
307
+ * Test string to see if it's a single letter/initial (period optional)
308
+ *
309
+ * @param string $word the single word you wish to test
310
+ * @return boolean
311
+ */
312
+ protected function is_initial($word) {
313
+ return ((strlen($word) == 1) || (strlen($word) == 2 && $word{1} == "."));
314
+ }
315
+
316
+
317
+
318
+ /**
319
+ * Checks for camelCase words such as McDonald and MacElroy
320
+ *
321
+ * @param string $word the single word you wish to test
322
+ * @return boolean
323
+ */
324
+ protected function is_camel_case($word) {
325
+ if (preg_match("/[A-Za-z]([A-Z]*[a-z][a-z]*[A-Z]|[a-z]*[A-Z][A-Z]*[a-z])[A-Za-z]*/", $word)) {
326
+ return true;
327
+ }
328
+ return false;
329
+ }
330
+
331
+ # ucfirst words split by dashes or periods
332
+ # ucfirst all upper/lower strings, but leave camelcase words alone
333
+ public function fix_case($word) {
334
+
335
+ # Fix case for words split by periods (J.P.)
336
+ if (strpos($word, '.') !== false) {
337
+ $word = $this->safe_ucfirst(".", $word);;
338
+ }
339
+
340
+ # Fix case for words split by hyphens (Kimura-Fay)
341
+ if (strpos($word, '-') !== false) {
342
+ $word = $this->safe_ucfirst("-", $word);
343
+ }
344
+
345
+ # Special case for single letters
346
+ if (strlen($word) == 1) {
347
+ $word = strtoupper($word);
348
+ }
349
+
350
+ # Special case for 2-letter words
351
+ if (strlen($word) == 2) {
352
+ # Both letters vowels (uppercase both)
353
+ if (in_array(strtolower($word{0}), $this->dict['vowels']) && in_array(strtolower($word{1}), $this->dict['vowels'])) {
354
+ $word = strtoupper($word);
355
+ }
356
+ # Both letters consonants (uppercase both)
357
+ if (!in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
358
+ $word = strtoupper($word);
359
+ }
360
+ # First letter is vowel, second letter consonant (uppercase first)
361
+ if (in_array(strtolower($word{0}), $this->dict['vowels']) && !in_array(strtolower($word{1}), $this->dict['vowels'])) {
362
+ $word = ucfirst(strtolower($word));
363
+ }
364
+ # First letter consonant, second letter vowel or "y" (uppercase first)
365
+ if (!in_array(strtolower($word{0}), $this->dict['vowels']) && (in_array(strtolower($word{1}), $this->dict['vowels']) || strtolower($word{1}) == 'y')) {
366
+ $word = ucfirst(strtolower($word));
367
+ }
368
+ }
369
+
370
+ # Fix case for words which aren't initials, but are all upercase or lowercase
371
+ if ( (strlen($word) >= 3) && (ctype_upper($word) || ctype_lower($word)) ) {
372
+ $word = ucfirst(strtolower($word));
373
+ }
374
+
375
+ return $word;
376
+ }
377
+
378
+ # helper public function for fix_case
379
+ public function safe_ucfirst($seperator, $word) {
380
+ # uppercase words split by the seperator (ex. dashes or periods)
381
+ $parts = explode($seperator, $word);
382
+ foreach ($parts as $word) {
383
+ $words[] = ($this->is_camel_case($word)) ? $word : ucfirst(strtolower($word));
384
+ }
385
+ return implode($seperator, $words);
386
+ }
387
+
388
+ }
package.xml ADDED
@@ -0,0 +1,182 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>PayEx_Payments</name>
4
+ <version>3.0.1</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL 3.0)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>PayEx Payments for Magento</summary>
10
+ <description>Official PayEx Payments Extension for Magento</description>
11
+ <notes>Version 3.0.1&#xD;
12
+ * Implemented Swish Payment Method&#xD;
13
+ * Financing Invoice: Invoice link&#xD;
14
+ * Fixed payex account problem for multiple stores&#xD;
15
+ &#xD;
16
+ Version 3.0.0&#xD;
17
+ * Init release of PayEx Payments module&#xD;
18
+ * Payment modules have been assembled in a single module&#xD;
19
+ * Integrated "Social Security Number" module&#xD;
20
+ * Implemented PayEx Faktura (Financing Invoice)&#xD;
21
+ * Implemented PayEx Delbetala (PartPayment)&#xD;
22
+ * Implemented PayEx Invoice (Ledger Service)&#xD;
23
+ * Implemented MasterPass Payments&#xD;
24
+ * Social Security Number: IWD_Opc support&#xD;
25
+ * Taxable discounts&#xD;
26
+ * Taxable fees&#xD;
27
+ * Option: Send order lines and billing/delivery addresses to PayEx&#xD;
28
+ * Option: Replace illegal characters of product names&#xD;
29
+ * Tune: Use order_id instead customer_id for productNumber&#xD;
30
+ * Improved Transaction Callback&#xD;
31
+ * Install using modman&#xD;
32
+ * Many various code changes and fixes&#xD;
33
+ * Removed deprecated code&#xD;
34
+ &#xD;
35
+ Version 2.0.31&#xD;
36
+ * Fixed bug with wrong order state when capture via backend&#xD;
37
+ &#xD;
38
+ Version 2.0.30&#xD;
39
+ * Improved update checker&#xD;
40
+ &#xD;
41
+ Version 2.0.29&#xD;
42
+ * PayEx Payment Page 2.0 for 'Credit Card' and 'Direct Debit' views&#xD;
43
+ &#xD;
44
+ Version 2.0.28&#xD;
45
+ * Improved rounding issue workaround&#xD;
46
+ &#xD;
47
+ Version 2.0.27&#xD;
48
+ * Added Reward points support&#xD;
49
+ &#xD;
50
+ Version 2.0.26&#xD;
51
+ * Improved transaction processing&#xD;
52
+ * Set correct order state&#xD;
53
+ * Sending mail when failed payments&#xD;
54
+ &#xD;
55
+ Version 2.0.25&#xD;
56
+ * Fixed problem with handling of canceled transactions&#xD;
57
+ &#xD;
58
+ Version 2.0.24&#xD;
59
+ * Fixed problem "The transaction "xxx" (capture) is already closed"&#xD;
60
+ * Removed unused functions&#xD;
61
+ * Minor changes&#xD;
62
+ &#xD;
63
+ Version 2.0.23&#xD;
64
+ * Fixed problems with order state&#xD;
65
+ * Small bugfixes&#xD;
66
+ &#xD;
67
+ Version 2.0.22&#xD;
68
+ * Fixed bug with empty invoice totals&#xD;
69
+ * Updated Px library to 2.0.1&#xD;
70
+ &#xD;
71
+ Version 2.0.21&#xD;
72
+ * Fixed problem with empty TotalPaid value&#xD;
73
+ * Fixed problem with empty tax for bundled product&#xD;
74
+ * Small bugfixes&#xD;
75
+ * Added version hint&#xD;
76
+ &#xD;
77
+ Version 2.0.20&#xD;
78
+ * Fixed problem with downloadable products&#xD;
79
+ &#xD;
80
+ Version 2.0.19&#xD;
81
+ * Fixed bug with multiple currencies setup&#xD;
82
+ * Use Initialize8, Capture5, Credit5&#xD;
83
+ * Updated Px library (moved to lib directory)&#xD;
84
+ * Removed deprecated code&#xD;
85
+ * Various bugfixes&#xD;
86
+ &#xD;
87
+ Version 2.0.18&#xD;
88
+ * Responsive Skinning&#xD;
89
+ &#xD;
90
+ Version 2.0.17&#xD;
91
+ * Fixed rounding issue&#xD;
92
+ &#xD;
93
+ Version 2.0.16&#xD;
94
+ * Added PayPal Payment View&#xD;
95
+ * Saving the refunded/canceled/failed transactions.&#xD;
96
+ * Verbose error messages&#xD;
97
+ * Save cart when fails&#xD;
98
+ * Updated translations&#xD;
99
+ * Bugfixes&#xD;
100
+ &#xD;
101
+ Version 2.0.15&#xD;
102
+ * Fixed multi store support&#xD;
103
+ &#xD;
104
+ Version 2.0.14&#xD;
105
+ * Updated Payex Library&#xD;
106
+ &#xD;
107
+ Version 2.0.13&#xD;
108
+ * Enabled Partial Refund in Invoice&#xD;
109
+ &#xD;
110
+ Version 2.0.12&#xD;
111
+ * Fixed rounding error bug&#xD;
112
+ &#xD;
113
+ Version 2.0.11&#xD;
114
+ * Fixed CodeOrder_AmountNotEqualOrderLinesTotal&#xD;
115
+ &#xD;
116
+ Version 2.0.10&#xD;
117
+ * Fix amount bug in AddOrderLine function&#xD;
118
+ * Fixed some bugs in order statuses&#xD;
119
+ &#xD;
120
+ Version 2.0.9&#xD;
121
+ * Fixed Tax Calc bug&#xD;
122
+ * Fixed CodeOrder_AmountNotEqualOrderLinesTotal&#xD;
123
+ &#xD;
124
+ Version 2.0.8&#xD;
125
+ * Improved Order Info&#xD;
126
+ * Added Order Info in PDF Invoice&#xD;
127
+ &#xD;
128
+ Version 2.0.7&#xD;
129
+ * Fixed bug with order (in sale mode the order is not finalized)&#xD;
130
+ * Fixed bug with refund&#xD;
131
+ * Moved design templates in base directory&#xD;
132
+ &#xD;
133
+ Version 2.0.6&#xD;
134
+ * Fixed bug with wrong capture/refund amount&#xD;
135
+ &#xD;
136
+ Version 2.0.5&#xD;
137
+ * Added options for cleaning time in Payment Config&#xD;
138
+ &#xD;
139
+ Version 2.0.4&#xD;
140
+ * Fixed Pending Order Cleaner bug&#xD;
141
+ &#xD;
142
+ Version 2.0.3&#xD;
143
+ * Many bugfixes&#xD;
144
+ &#xD;
145
+ Version 2.0.2&#xD;
146
+ * Division by zero fix (When Shipping is 0)&#xD;
147
+ &#xD;
148
+ Version 2.0.1&#xD;
149
+ * Rewrited API Helper&#xD;
150
+ &#xD;
151
+ Version 2.0.0&#xD;
152
+ * Changend namespace&#xD;
153
+ * Rewrited payment engine&#xD;
154
+ * Added Translations&#xD;
155
+ * Bugfixes&#xD;
156
+ &#xD;
157
+ Version 1.2.3-r20120329&#xD;
158
+ * Added compatibility with AAIT PayEx Core&#xD;
159
+ &#xD;
160
+ Version 1.2.3&#xD;
161
+ * Small bugfixes&#xD;
162
+ &#xD;
163
+ Version 1.2.2&#xD;
164
+ * Fixed DirectDebit bug (Payment Cancel)&#xD;
165
+ * Added option "Payment Type" in the settings panel.&#xD;
166
+ * Small bugfixes&#xD;
167
+ &#xD;
168
+ Version 1.2.1&#xD;
169
+ * Small bugfixes&#xD;
170
+ &#xD;
171
+ Version 1.2.0&#xD;
172
+ * Required PayEx Core module v1.0.1&#xD;
173
+ * Transaction fetching&#xD;
174
+ * Bugfixes&#xD;
175
+ </notes>
176
+ <authors><author><name>AAIT</name><user>aaight</user><email>info@aait.se</email></author></authors>
177
+ <date>2016-05-04</date>
178
+ <time>11:59:32</time>
179
+ <contents><target name="magecommunity"><dir name="PayEx"><dir name="Payments"><dir name="Block"><dir name="Adminhtml"><dir name="Config"><file name="Hint.php" hash="eb183968bc78ad610698149c2e43eee8"/></dir><dir name="Sales"><dir name="Order"><dir name="Create"><dir name="Totals"><file name="Fee.php" hash="8a2e94e150260233793bc234175860ca"/></dir></dir></dir></dir></dir><dir name="Bankdebit"><file name="Banks.php" hash="513151012cfc3b50ba664a4dd5ae0506"/></dir><dir name="Checkout"><file name="Fee.php" hash="19e183ebcca0fd0124e16e8a5ee12a27"/></dir><dir name="Form"><file name="Autopay.php" hash="fe9b0f2c290929b65cffc0d9d82c8134"/><file name="Bankdebit.php" hash="7ac259e42c1750b039333bdf8e251120"/><file name="CC.php" hash="3a1e2c04277ad1112f6c02e1a69feb6b"/><file name="Financing.php" hash="407259a988ac5184d26530b196ef5fd6"/><file name="Invoice.php" hash="da5b1a05319df937787fccb383d10603"/><file name="MasterPass.php" hash="c498e2a8348e69c38363bbfb4637a9db"/><file name="PartPayment.php" hash="5109b405a3bf50af8abef09382f9832d"/><file name="Swish.php" hash="3bafe7744b0d7b6d7cf58b801368da6c"/><file name="Wywallet.php" hash="6d93149b4708369cf9b162b28acf93ae"/></dir><dir name="Info"><file name="Autopay.php" hash="87efd7d5e0c013c50698e951806e61a4"/><file name="Bankdebit.php" hash="0adc20468181f262f96a85d0cc660294"/><file name="CC.php" hash="5e5719393bf435ad43262d8cff99ff7d"/><file name="Financing.php" hash="3f00c97d360931ab26e43cf7fc51c802"/><file name="Invoice.php" hash="b5279f695dd4a3b2f03359d31024d715"/><file name="MasterPass.php" hash="e89dfab07bc90dbbde17add8ec86edd4"/><file name="PartPayment.php" hash="8af5c7d10d46f198835823a2246411e4"/><file name="Swish.php" hash="ced50c4956bbf1b47d75bf6e17add7a2"/><file name="Wywallet.php" hash="cf2ab25ee18ce1864d54295bce9c5413"/></dir><dir name="MasterPass"><file name="Button.php" hash="a21664578bd2e64dd0da17c78d86acd4"/></dir><dir name="Order"><dir name="Totals"><file name="Fee.php" hash="5c17b48ff4af838118d2f3a79f8196de"/></dir></dir></dir><dir name="Helper"><file name="Agreement.php" hash="669e23be0609b8b2b6e8ef69828237bb"/><file name="Api.php" hash="efcbba9c2b74bf2856e70c975e7441cc"/><file name="Data.php" hash="222c131eaa7ec9b9a63f5d04d1396cdf"/><file name="Discount.php" hash="a9e14a27371bfa658d145fa4c1645528"/><file name="Fee.php" hash="3704dd59b91e450824b14d7ce815fcd2"/><file name="Order.php" hash="2cdd01cdd85fce52003c2cdb2352cb5c"/><file name="Tools.php" hash="44532d39b11fc0d8bc100a70de695ca1"/></dir><dir name="Model"><file name="Agreement.php" hash="424c46027050c8414c43acb16da6eb62"/><file name="Feed.php" hash="f5da40677cf63bc951ef79b76cc5511d"/><dir name="Invoice"><file name="Total.php" hash="8882f98404b07353eee6acbe1958c6dd"/></dir><dir name="Mysql4"><dir name="Agreement"><file name="Collection.php" hash="b3e90711a42b1809a19ea020229af8bf"/></dir><file name="Agreement.php" hash="08a61c11053577ac16c63e3d205bfb24"/></dir><file name="Observer.php" hash="70f737166e3db85715ac87b5f7dcf0af"/><dir name="Payment"><file name="Abstract.php" hash="ca596169a9f999e9cf2e41df37502c17"/><file name="Autopay.php" hash="c884987d4bf87dc3ae354443ab21c2a4"/><file name="Bankdebit.php" hash="a26006557a1e61deead2fc5c86f264db"/><file name="CC.php" hash="5d76e80dfea312753b5b73c4d69306c1"/><file name="Financing.php" hash="8748a14ac071767b615c9cb330c69a76"/><file name="Invoice.php" hash="6a7fd1e01d5d10aac1238e2730446fd1"/><file name="MasterPass.php" hash="bd42b6804285d1d38bce2da87ede0b7d"/><file name="PartPayment.php" hash="db870218eb9d13cccf894a0088d90f1b"/><file name="Swish.php" hash="79421605835b4d959749a9dad3538a36"/><file name="Wywallet.php" hash="723a11740b07ace3a29cd07e2090a273"/></dir><dir name="Quote"><file name="Total.php" hash="f8afbb402a17d429a55a238d1c09df04"/></dir><file name="Session.php" hash="1fecbc5cfae2895af571ec4f6bd94b77"/><dir name="Source"><file name="Banks.php" hash="0ef09b35734564738624c49124288429"/><file name="ClientLanguage.php" hash="6a62ed649614a3fdb8544d6a028518a1"/><file name="MediaDistribution.php" hash="f01d02d087d8d006b91ef542ad9bd3e7"/><file name="PaymentAction.php" hash="9dcb319d3987c285b297d40f0318f079"/><file name="PaymentView.php" hash="a1ed5ba1386ca6a294c53125fafe80fa"/><file name="ShippingMethod.php" hash="6c05068faae319ebb27319733ed5e95a"/><file name="TaxClasses.php" hash="b6ceeb12e575d6c1296cbc3850165a12"/></dir></dir><dir name="controllers"><file name="AutopayController.php" hash="3fab1a3c8c477a3bb4877e0820efed8d"/><file name="BankdebitController.php" hash="70ffcc53b5fd45f57153c29e0d6269b1"/><file name="FinancingController.php" hash="9777fd538daf0ad5a70386b04a23a4c2"/><file name="GetaddrController.php" hash="c119f5771b6b9f35b17bad472d0b1165"/><file name="InvoiceController.php" hash="058265b8390894c9c2b9f3cf4c7caee1"/><file name="MasterpassController.php" hash="078f8f71b7f1c28ef404f7023c41ccf3"/><file name="PartpaymentController.php" hash="5adccde9244fd6da6a667383f726bec4"/><file name="PaymentController.php" hash="36108a68423d34f606b0c658f6fa7e24"/><file name="SwishController.php" hash="040f8394796e59dc49f52b507d45afec"/><file name="TransactionController.php" hash="2b9b42ebd63e1f0202fb05881651269a"/><file name="WywalletController.php" hash="b41ca2f84d9304c21cbe97ea2e2e8bc8"/></dir><dir name="data"><dir name="payex_setup"><file name="data-install-3.0.0.php" hash="3a93c2049db69949fc615fddee97c818"/></dir></dir><dir name="etc"><file name="config.xml" hash="1c8b2830b6ce5fa3a0dbef33ff0ab555"/><file name="system.xml" hash="e7cd1bacbc84087d998c47e064397e3d"/></dir><dir name="sql"><dir name="payex_setup"><file name="install-3.0.0.php" hash="3182c5ce1647a38e805f86abef05bc8a"/></dir></dir></dir></dir></target><target name="magelocale"><dir name="en_US"><file name="PayEx_Payments.csv" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="sv_SE"><file name="PayEx_Payments.csv" hash="07b5a1df1d4ed49bc803b1d505f9d2f5"/></dir></target><target name="magedesign"><dir name="frontend"><dir name="base"><dir name="default"><dir name="template"><dir name="payex"><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><dir name="pdf"><file name="info.phtml" hash="1a7bb5d58cabb8a4a66234ffd3d6c230"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="cc"><file name="form.phtml" hash="8286f66533534c36b1a8284dc55f543b"/><file name="info.phtml" hash="01f5da45f5a3668f3228a72bbd0b6aae"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="checkout"><file name="fee.phtml" hash="78f6f419e4324fb76a5b25d5d9dbbe29"/><dir name="onepage"><file name="billing_with_ssn.phtml" hash="b0a7f7aafc449eb05488ee31c72fc5ae"/></dir></dir><dir name="financing"><file name="form.phtml" hash="08e98c6954d14276f57eb8339567bfb7"/><file name="info.phtml" hash="15700ce473736a214fc1aa41daf7f1e6"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="fba1c82b52d3204f9db93e55f0501f1d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="iwd_opc"><file name="billing_with_ssn.phtml" hash="fa37263b495924da540607989c845b51"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="e321b2421e706f328c531595dcaf1316"/><file name="info.phtml" hash="e8d0ef852c3b899bf305a9b486a253a7"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="b2c51aa0a4383c5465cebdc50cda5ec4"/><dir name="pdf"><file name="info.phtml" hash="fbbe9f65f9e36ddb630ab9a9b019ed49"/></dir><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="600d2c36c2691f1cddd3f05e4aafbc70"/><dir name="pdf"><file name="info.phtml" hash="1a7bb5d58cabb8a4a66234ffd3d6c230"/></dir></dir></dir></dir><dir name="layout"><dir name="payex"><file name="masterpass.xml" hash="d98963f85886570e21246f34d798ffa7"/><file name="payment_fee.xml" hash="d79c4ac5c4a9fddbadf8e156f67643bc"/><file name="social_security_number.xml" hash="67bcd100a20f68a45b52eb063ecc23c6"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="payex"><dir name="adminhtml"><file name="hint.phtml" hash="e50c7fd0c9ea1fd315ea713a88e1b3e2"/></dir><dir name="autopay"><file name="form.phtml" hash="eeff0becc642b3f2f468e80d96144dbc"/><file name="info.phtml" hash="d9b8f551ac4d53b1fe2e9b82d365e4c3"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="bankdebit"><file name="form.phtml" hash="9840095a4d2f87dd955579cb053d6327"/><file name="info.phtml" hash="8b43e84bae9c4ffc96e57537c042bc42"/></dir><dir name="cc"><file name="form.phtml" hash="8286f66533534c36b1a8284dc55f543b"/><file name="info.phtml" hash="01f5da45f5a3668f3228a72bbd0b6aae"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="financing"><file name="form.phtml" hash="ef3303f50ce4a7d27b2fe2eb89f5b532"/><file name="info.phtml" hash="15700ce473736a214fc1aa41daf7f1e6"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="invoice"><file name="form.phtml" hash="fba1c82b52d3204f9db93e55f0501f1d"/><file name="info.phtml" hash="a90f8aa90e56265c9e4533551bd3f1d2"/></dir><dir name="masterpass"><file name="button.phtml" hash="a845fe3f3965b4c151a87132a2560502"/><file name="form.phtml" hash="d7b01403fb3c58c2de79fdfa4ee38bc9"/><file name="info.phtml" hash="a3fe264db69fc49b65f05a7d2fc64590"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="partpayment"><file name="form.phtml" hash="e321b2421e706f328c531595dcaf1316"/><file name="info.phtml" hash="e8d0ef852c3b899bf305a9b486a253a7"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="swish"><file name="form.phtml" hash="44a68dc45b8db91bfb715ca9467ab827"/><file name="info.phtml" hash="8cab37ca1d161bc1751d26d6b647dd75"/><file name="title.phtml" hash="de64ade21290cd394a0dc7f0b356a131"/></dir><dir name="wywallet"><file name="form.phtml" hash="6e1bd3fb7bc50bfc3cf4e6808ebfb7b7"/><file name="info.phtml" hash="600d2c36c2691f1cddd3f05e4aafbc70"/></dir></dir></dir><dir name="layout"><dir name="payex"><file name="adminhtml.xml" hash="09843499521cc0d049e598af3bc93577"/><file name="payment_fee.xml" hash="8901262fe753925034024f90519a00b6"/></dir></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="PayEx_Payments.xml" hash="17ebbe7078c7a64531d9bccab1c04dd9"/></dir></dir></dir><dir name="."><file name="Changelog_payex.txt" hash="d8bba54533b8b245a48e33630107bf05"/></dir><dir name="js"><dir name="payex"><dir name="iwd_opc"><file name="social_security_number.js" hash="8be665ea511415c9a955db3454fc0110"/></dir><file name="social_security_number.js" hash="58e057aabbf97ae0506fd5c4522a36d2"/></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="american_express_64.png" hash="0e4379f8c5963b4eb550b1941b89821e"/><file name="diners_club_64.png" hash="76ad504729a6a86ed3be9a496a5def73"/><file name="financing-logo.gif" hash="601ac8ee1101dc6e83393c15b92f3761"/><file name="jcb_64.png" hash="79fd2798aa7c8695da293c25fa6e18a5"/><file name="mastercard_64.png" hash="a656e3028f69c593b4261555c75351d6"/><file name="masterpass-140.png" hash="b74662352d7a83ce5586ab26c3dafe91"/><file name="masterpass.png" hash="681673dd599a743a512a3697fc6576cc"/><file name="partpayment-logo.gif" hash="db8f8f8bcfb4decd106ff49dbe9a955e"/><file name="payex-invoice.png" hash="568683eca82952bf847e0b08d88274d7"/><file name="payex-small.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="payex.gif" hash="b760e19d0024a994a0d07058038201db"/><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/><file name="visa_64.png" hash="2f263bca4b195b6b18eac60c5e889891"/><file name="ww_logo.png" hash="77f03db05e5c2c557fc7a69f778f94e1"/></dir></dir><dir name="css"><dir name="payex"><file name="masterpass.css" hash="9aabd17cdc8a0f58662d86581c418294"/></dir></dir></dir></dir></dir><dir name="adminhtml"><dir name="base"><dir name="default"><dir name="images"><dir name="payex"><file name="swish.png" hash="a21c66a591a13823a9b546a13f22c843"/></dir></dir><dir name="payex"><file name="payex-logo.png" hash="5b493d130ef51483a3190d1285380242"/><file name="payex_admin.css" hash="bd5d31f628944b6b2e338b2bfcbf64ac"/></dir></dir></dir></dir></target><target name="magelib"><dir name="Px"><file name="Px.php" hash="2324304980e6252284da2eab7def26b2"/><file name="parser.php" hash="cfa3dfa8be36ebbf5ca50c512b370f0f"/></dir></target></contents>
180
+ <compatible/>
181
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php><extension><name>soap</name><min/><max/></extension></required></dependencies>
182
+ </package>
skin/adminhtml/base/default/images/payex/swish.png ADDED
Binary file
skin/adminhtml/base/default/payex/payex-logo.png ADDED
Binary file
skin/adminhtml/base/default/payex/payex_admin.css ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #payex-settings-hint {
2
+ background: url("payex-logo.png") no-repeat scroll 5px center #2DA944;
3
+ border: 1px solid #00AF64;
4
+ margin-bottom: 10px;
5
+ padding: 10px 10px 10px 200px;
6
+ font-family: Helvetica, sans-serif;
7
+ font-size: 15px;
8
+ color: #fff;
9
+ -webkit-font-smoothing: antialiased;
10
+ }
11
+
12
+ #payex-settings-hint a {
13
+ color: #fff;
14
+ }
15
+
16
+ #payex-settings-hint h4, #payex-settings-hint p {
17
+ margin: 0;
18
+ }
19
+
20
+ #payex-settings-hint .last-version {
21
+ color: #D54E06;
22
+ font-weight: bold;
23
+ }
skin/frontend/base/default/css/payex/masterpass.css ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ .payex-masterpass-button img {
2
+ height: 46px;
3
+ }
skin/frontend/base/default/images/payex/american_express_64.png ADDED
Binary file
skin/frontend/base/default/images/payex/diners_club_64.png ADDED
Binary file
skin/frontend/base/default/images/payex/financing-logo.gif ADDED
Binary file
skin/frontend/base/default/images/payex/jcb_64.png ADDED
Binary file
skin/frontend/base/default/images/payex/mastercard_64.png ADDED
Binary file
skin/frontend/base/default/images/payex/masterpass-140.png ADDED
Binary file
skin/frontend/base/default/images/payex/masterpass.png ADDED
Binary file
skin/frontend/base/default/images/payex/partpayment-logo.gif ADDED
Binary file
skin/frontend/base/default/images/payex/payex-invoice.png ADDED
Binary file
skin/frontend/base/default/images/payex/payex-small.gif ADDED
Binary file
skin/frontend/base/default/images/payex/payex.gif ADDED
Binary file
skin/frontend/base/default/images/payex/swish.png ADDED
Binary file
skin/frontend/base/default/images/payex/visa_64.png ADDED
Binary file
skin/frontend/base/default/images/payex/ww_logo.png ADDED
Binary file