Yoma_Realex - Version 1.1.0

Version Notes

Stable Version

Download this release

Release Info

Developer Steve Cantlay
Extension Yoma_Realex
Version 1.1.0
Comparing to
See all releases


Version 1.1.0

Files changed (239) hide show
  1. app/code/community/Yoma/.DS_Store +0 -0
  2. app/code/community/Yoma/Realex/.DS_Store +0 -0
  3. app/code/community/Yoma/Realex/Block/.DS_Store +0 -0
  4. app/code/community/Yoma/Realex/Block/Adminhtml/Customer/Tab.php +115 -0
  5. app/code/community/Yoma/Realex/Block/Adminhtml/Form/Edit/Renderer/Expiry.php +81 -0
  6. app/code/community/Yoma/Realex/Block/Adminhtml/Notifications.php +32 -0
  7. app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Order/Creditmemo/Rebate.php +57 -0
  8. app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Order/Invoice/Settle.php +62 -0
  9. app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Realex/Logs.php +86 -0
  10. app/code/community/Yoma/Realex/Block/Adminhtml/System/Config/Renderer/SubAccount/Abstract.php +95 -0
  11. app/code/community/Yoma/Realex/Block/Adminhtml/System/Config/Renderer/SubAccount/Direct.php +24 -0
  12. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard.php +32 -0
  13. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit.php +55 -0
  14. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Form.php +35 -0
  15. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Tab/Form.php +49 -0
  16. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Tabs.php +39 -0
  17. app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Grid.php +150 -0
  18. app/code/community/Yoma/Realex/Block/Adminhtml/Transaction.php +32 -0
  19. app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Detail.php +83 -0
  20. app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Detail/Grid.php +85 -0
  21. app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Grid.php +113 -0
  22. app/code/community/Yoma/Realex/Block/Config.php +79 -0
  23. app/code/community/Yoma/Realex/Block/Customer/Account/Cards.php +50 -0
  24. app/code/community/Yoma/Realex/Block/Customer/Account/Cards/Edit.php +71 -0
  25. app/code/community/Yoma/Realex/Block/Direct/Form.php +85 -0
  26. app/code/community/Yoma/Realex/Block/Direct/Frame.php +70 -0
  27. app/code/community/Yoma/Realex/Block/Form/Direct.php +54 -0
  28. app/code/community/Yoma/Realex/Block/Form/Redirect.php +129 -0
  29. app/code/community/Yoma/Realex/Block/Form/Token.php +77 -0
  30. app/code/community/Yoma/Realex/Block/Info/Direct.php +64 -0
  31. app/code/community/Yoma/Realex/Block/Info/Redirect.php +40 -0
  32. app/code/community/Yoma/Realex/Block/Info/Token.php +77 -0
  33. app/code/community/Yoma/Realex/Block/Onepage/Success.php +64 -0
  34. app/code/community/Yoma/Realex/Block/Redirect/Form.php +113 -0
  35. app/code/community/Yoma/Realex/Block/Redirect/Frame.php +89 -0
  36. app/code/community/Yoma/Realex/Block/Redirect/Result.php +34 -0
  37. app/code/community/Yoma/Realex/Helper/Data.php +920 -0
  38. app/code/community/Yoma/Realex/Helper/Direct.php +93 -0
  39. app/code/community/Yoma/Realex/Helper/Redirect.php +115 -0
  40. app/code/community/Yoma/Realex/Model/.DS_Store +0 -0
  41. app/code/community/Yoma/Realex/Model/Api/Payment.php +474 -0
  42. app/code/community/Yoma/Realex/Model/Direct.php +296 -0
  43. app/code/community/Yoma/Realex/Model/Exception/DenyPayment.php +23 -0
  44. app/code/community/Yoma/Realex/Model/Exception/NoLiabilityShift.php +23 -0
  45. app/code/community/Yoma/Realex/Model/Exception/NoneParticipatingCard.php +23 -0
  46. app/code/community/Yoma/Realex/Model/Exception/NotAuthenticated.php +23 -0
  47. app/code/community/Yoma/Realex/Model/Exception/NotEnrolled.php +23 -0
  48. app/code/community/Yoma/Realex/Model/Exception/NotVerified.php +23 -0
  49. app/code/community/Yoma/Realex/Model/Exception/PayerNew.php +23 -0
  50. app/code/community/Yoma/Realex/Model/Exception/Payment.php +23 -0
  51. app/code/community/Yoma/Realex/Model/Exception/ThreedSecure.php +23 -0
  52. app/code/community/Yoma/Realex/Model/Log.php +157 -0
  53. app/code/community/Yoma/Realex/Model/Message/Abstract.php +120 -0
  54. app/code/community/Yoma/Realex/Model/Message/Direct/Authorize.php +22 -0
  55. app/code/community/Yoma/Realex/Model/Message/Direct/Capture.php +22 -0
  56. app/code/community/Yoma/Realex/Model/Message/Direct/Partial.php +22 -0
  57. app/code/community/Yoma/Realex/Model/Message/Direct/Refund.php +22 -0
  58. app/code/community/Yoma/Realex/Model/Message/Direct/ThreedSecure.php +40 -0
  59. app/code/community/Yoma/Realex/Model/Message/Direct/ThreedSecureVerify.php +38 -0
  60. app/code/community/Yoma/Realex/Model/Message/Direct/Void.php +22 -0
  61. app/code/community/Yoma/Realex/Model/Message/Redirect/Authorize.php +22 -0
  62. app/code/community/Yoma/Realex/Model/Message/Redirect/Capture.php +22 -0
  63. app/code/community/Yoma/Realex/Model/Message/Redirect/EditPayer.php +22 -0
  64. app/code/community/Yoma/Realex/Model/Message/Redirect/Partial.php +22 -0
  65. app/code/community/Yoma/Realex/Model/Message/Redirect/Refund.php +22 -0
  66. app/code/community/Yoma/Realex/Model/Message/Redirect/Void.php +22 -0
  67. app/code/community/Yoma/Realex/Model/Message/Token/Authorize.php +22 -0
  68. app/code/community/Yoma/Realex/Model/Message/Token/Capture.php +22 -0
  69. app/code/community/Yoma/Realex/Model/Message/Token/Delete.php +22 -0
  70. app/code/community/Yoma/Realex/Model/Message/Token/EditPayer.php +22 -0
  71. app/code/community/Yoma/Realex/Model/Message/Token/EditToken.php +22 -0
  72. app/code/community/Yoma/Realex/Model/Message/Token/Partial.php +22 -0
  73. app/code/community/Yoma/Realex/Model/Message/Token/PayerNew.php +22 -0
  74. app/code/community/Yoma/Realex/Model/Message/Token/Refund.php +22 -0
  75. app/code/community/Yoma/Realex/Model/Message/Token/RegisterToken.php +38 -0
  76. app/code/community/Yoma/Realex/Model/Message/Token/ThreedSecure.php +38 -0
  77. app/code/community/Yoma/Realex/Model/Message/Token/ThreedSecureVerify.php +38 -0
  78. app/code/community/Yoma/Realex/Model/Message/Token/Void.php +22 -0
  79. app/code/community/Yoma/Realex/Model/Observer.php +165 -0
  80. app/code/community/Yoma/Realex/Model/Observer/Cron.php +78 -0
  81. app/code/community/Yoma/Realex/Model/Observer/Tokencard.php +197 -0
  82. app/code/community/Yoma/Realex/Model/Order/Creditmemo/Total/Rebate.php +33 -0
  83. app/code/community/Yoma/Realex/Model/Order/Invoice/Total/SettleAmount.php +33 -0
  84. app/code/community/Yoma/Realex/Model/Payment/Abstract.php +534 -0
  85. app/code/community/Yoma/Realex/Model/Payment/Direct.php +499 -0
  86. app/code/community/Yoma/Realex/Model/Payment/Direct/Authorize.php +27 -0
  87. app/code/community/Yoma/Realex/Model/Payment/Direct/Capture.php +366 -0
  88. app/code/community/Yoma/Realex/Model/Payment/Direct/Partial.php +115 -0
  89. app/code/community/Yoma/Realex/Model/Payment/Direct/Refund.php +137 -0
  90. app/code/community/Yoma/Realex/Model/Payment/Direct/RegisterToken.php +258 -0
  91. app/code/community/Yoma/Realex/Model/Payment/Direct/Void.php +117 -0
  92. app/code/community/Yoma/Realex/Model/Payment/Redirect.php +205 -0
  93. app/code/community/Yoma/Realex/Model/Payment/Redirect/Authorize.php +28 -0
  94. app/code/community/Yoma/Realex/Model/Payment/Redirect/Capture.php +136 -0
  95. app/code/community/Yoma/Realex/Model/Payment/Redirect/EditPayer.php +131 -0
  96. app/code/community/Yoma/Realex/Model/Payment/Redirect/Partial.php +42 -0
  97. app/code/community/Yoma/Realex/Model/Payment/Redirect/Refund.php +95 -0
  98. app/code/community/Yoma/Realex/Model/Payment/Redirect/Void.php +76 -0
  99. app/code/community/Yoma/Realex/Model/Payment/Token.php +415 -0
  100. app/code/community/Yoma/Realex/Model/Payment/Token/Authorize.php +26 -0
  101. app/code/community/Yoma/Realex/Model/Payment/Token/Capture.php +333 -0
  102. app/code/community/Yoma/Realex/Model/Payment/Token/Delete.php +136 -0
  103. app/code/community/Yoma/Realex/Model/Payment/Token/EditPayer.php +132 -0
  104. app/code/community/Yoma/Realex/Model/Payment/Token/EditToken.php +133 -0
  105. app/code/community/Yoma/Realex/Model/Payment/Token/Partial.php +32 -0
  106. app/code/community/Yoma/Realex/Model/Payment/Token/Refund.php +27 -0
  107. app/code/community/Yoma/Realex/Model/Payment/Token/Void.php +28 -0
  108. app/code/community/Yoma/Realex/Model/PaymentInfo.php +92 -0
  109. app/code/community/Yoma/Realex/Model/Realex/Source/Cards.php +147 -0
  110. app/code/community/Yoma/Realex/Model/Realex/Source/IframeSize.php +70 -0
  111. app/code/community/Yoma/Realex/Model/Realex/Source/PaymentAction.php +92 -0
  112. app/code/community/Yoma/Realex/Model/Realex/Source/PaymentMode.php +56 -0
  113. app/code/community/Yoma/Realex/Model/Realex/Source/Status.php +48 -0
  114. app/code/community/Yoma/Realex/Model/Redirect.php +226 -0
  115. app/code/community/Yoma/Realex/Model/Redirect.php.orig +201 -0
  116. app/code/community/Yoma/Realex/Model/Resource/PaymentInfo.php +39 -0
  117. app/code/community/Yoma/Realex/Model/Resource/PaymentInfo/Collection.php +28 -0
  118. app/code/community/Yoma/Realex/Model/Resource/Tokencard.php +27 -0
  119. app/code/community/Yoma/Realex/Model/Resource/Tokencard/Collection.php +97 -0
  120. app/code/community/Yoma/Realex/Model/Resource/Transaction.php +39 -0
  121. app/code/community/Yoma/Realex/Model/Resource/Transaction/Collection.php +51 -0
  122. app/code/community/Yoma/Realex/Model/Response/Abstract.php +136 -0
  123. app/code/community/Yoma/Realex/Model/Response/Direct.php +195 -0
  124. app/code/community/Yoma/Realex/Model/Response/Direct/Authorize.php +22 -0
  125. app/code/community/Yoma/Realex/Model/Response/Direct/Capture.php +48 -0
  126. app/code/community/Yoma/Realex/Model/Response/Direct/Partial.php +46 -0
  127. app/code/community/Yoma/Realex/Model/Response/Direct/Refund.php +39 -0
  128. app/code/community/Yoma/Realex/Model/Response/Direct/ThreedSecure.php +82 -0
  129. app/code/community/Yoma/Realex/Model/Response/Direct/ThreedSecureVerify.php +153 -0
  130. app/code/community/Yoma/Realex/Model/Response/Direct/Void.php +39 -0
  131. app/code/community/Yoma/Realex/Model/Response/Redirect.php +102 -0
  132. app/code/community/Yoma/Realex/Model/Response/Redirect/Abstract.php +27 -0
  133. app/code/community/Yoma/Realex/Model/Response/Redirect/Authorize.php +23 -0
  134. app/code/community/Yoma/Realex/Model/Response/Redirect/Capture.php +47 -0
  135. app/code/community/Yoma/Realex/Model/Response/Redirect/EditPayer.php +72 -0
  136. app/code/community/Yoma/Realex/Model/Response/Redirect/Partial.php +23 -0
  137. app/code/community/Yoma/Realex/Model/Response/Redirect/Refund.php +23 -0
  138. app/code/community/Yoma/Realex/Model/Response/Redirect/Void.php +23 -0
  139. app/code/community/Yoma/Realex/Model/Response/Token.php +30 -0
  140. app/code/community/Yoma/Realex/Model/Response/Token/Authorize.php +22 -0
  141. app/code/community/Yoma/Realex/Model/Response/Token/Capture.php +43 -0
  142. app/code/community/Yoma/Realex/Model/Response/Token/Delete.php +61 -0
  143. app/code/community/Yoma/Realex/Model/Response/Token/EditPayer.php +61 -0
  144. app/code/community/Yoma/Realex/Model/Response/Token/EditToken.php +61 -0
  145. app/code/community/Yoma/Realex/Model/Response/Token/Partial.php +23 -0
  146. app/code/community/Yoma/Realex/Model/Response/Token/PayerNew.php +63 -0
  147. app/code/community/Yoma/Realex/Model/Response/Token/Refund.php +22 -0
  148. app/code/community/Yoma/Realex/Model/Response/Token/RegisterToken.php +65 -0
  149. app/code/community/Yoma/Realex/Model/Response/Token/ThreedSecure.php +68 -0
  150. app/code/community/Yoma/Realex/Model/Response/Token/ThreedSecureVerify.php +135 -0
  151. app/code/community/Yoma/Realex/Model/Response/Token/Void.php +22 -0
  152. app/code/community/Yoma/Realex/Model/Service/Abstract.php +1147 -0
  153. app/code/community/Yoma/Realex/Model/Service/Direct.php +50 -0
  154. app/code/community/Yoma/Realex/Model/Service/Redirect.php +84 -0
  155. app/code/community/Yoma/Realex/Model/Service/Token.php +147 -0
  156. app/code/community/Yoma/Realex/Model/Session.php +27 -0
  157. app/code/community/Yoma/Realex/Model/SubAccountProcessor.php +102 -0
  158. app/code/community/Yoma/Realex/Model/System/Config/Source/Storecard.php +35 -0
  159. app/code/community/Yoma/Realex/Model/Token.php +164 -0
  160. app/code/community/Yoma/Realex/Model/Tokencard.php +148 -0
  161. app/code/community/Yoma/Realex/Model/Total/Creditmemo/Rebate.php +71 -0
  162. app/code/community/Yoma/Realex/Model/Total/Invoice/Settle.php +84 -0
  163. app/code/community/Yoma/Realex/Model/Transaction.php +245 -0
  164. app/code/community/Yoma/Realex/controllers/.DS_Store +0 -0
  165. app/code/community/Yoma/Realex/controllers/Adminhtml/LogController.php +110 -0
  166. app/code/community/Yoma/Realex/controllers/Adminhtml/TokencardController.php +154 -0
  167. app/code/community/Yoma/Realex/controllers/Adminhtml/TransactionController.php +106 -0
  168. app/code/community/Yoma/Realex/controllers/CardsController.php +195 -0
  169. app/code/community/Yoma/Realex/controllers/Checkout/OnepageController.php +48 -0
  170. app/code/community/Yoma/Realex/controllers/DirectController.php +98 -0
  171. app/code/community/Yoma/Realex/controllers/PaymentController.php +22 -0
  172. app/code/community/Yoma/Realex/controllers/RedirectController.php +125 -0
  173. app/code/community/Yoma/Realex/controllers/TokenController.php +83 -0
  174. app/code/community/Yoma/Realex/etc/adminhtml.xml +84 -0
  175. app/code/community/Yoma/Realex/etc/config.xml +585 -0
  176. app/code/community/Yoma/Realex/etc/system.xml +718 -0
  177. app/code/community/Yoma/Realex/sql/.DS_Store +0 -0
  178. app/code/community/Yoma/Realex/sql/realex_setup/mysql4-install-0.0.1.php +158 -0
  179. app/code/local/Yoma/RealexRewrite/Helper/Data.php +4 -0
  180. app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Creditmemo.php +79 -0
  181. app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Payment.php +35 -0
  182. app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Payment/Transaction.php +41 -0
  183. app/code/local/Yoma/RealexRewrite/etc/config.xml +34 -0
  184. app/design/adminhtml/default/default/layout/realex/realex.xml +77 -0
  185. app/design/adminhtml/default/default/template/realex/customer/tab.phtml +9 -0
  186. app/design/adminhtml/default/default/template/realex/notifications.phtml +3 -0
  187. app/design/adminhtml/default/default/template/realex/payment/info/payment-info.phtml +24 -0
  188. app/design/adminhtml/default/default/template/realex/sales/order/creditmemo/totals/rebate.phtml +4 -0
  189. app/design/adminhtml/default/default/template/realex/sales/order/invoice/totals/settle.phtml +4 -0
  190. app/design/adminhtml/default/default/template/realex/sales/order/invoice/totals/settled.phtml +4 -0
  191. app/design/adminhtml/default/default/template/realex/sales/realex/logs.phtml +7 -0
  192. app/design/adminhtml/default/default/template/realex/sales/transaction/detail.phtml +56 -0
  193. app/design/frontend/base/default/layout/realex/realex.xml +211 -0
  194. app/design/frontend/base/default/template/realex/customer/cards.phtml +66 -0
  195. app/design/frontend/base/default/template/realex/customer/cards/edit.phtml +69 -0
  196. app/design/frontend/base/default/template/realex/onepage/success.phtml +62 -0
  197. app/design/frontend/base/default/template/realex/payment/config.phtml +3 -0
  198. app/design/frontend/base/default/template/realex/payment/direct/form.phtml +55 -0
  199. app/design/frontend/base/default/template/realex/payment/direct/frame.phtml +33 -0
  200. app/design/frontend/base/default/template/realex/payment/form/direct.phtml +179 -0
  201. app/design/frontend/base/default/template/realex/payment/form/redirect.phtml +49 -0
  202. app/design/frontend/base/default/template/realex/payment/form/token.phtml +55 -0
  203. app/design/frontend/base/default/template/realex/payment/info/redirect.phtml +0 -0
  204. app/design/frontend/base/default/template/realex/payment/redirect/form.phtml +56 -0
  205. app/design/frontend/base/default/template/realex/payment/redirect/frame.phtml +31 -0
  206. app/design/frontend/base/default/template/realex/payment/redirect/result.phtml +28 -0
  207. app/etc/modules/Yoma_Realex.xml +9 -0
  208. app/etc/modules/Yoma_RealexRewrite.xml +12 -0
  209. app/locale/en_GB/realex/Yoma_Realex.csv +4 -0
  210. app/locale/en_GB/realex/Yoma_Realex_Adminhtml.csv +2 -0
  211. js/realex/invoice.js +43 -0
  212. js/realex/livepipe/contextmenu.js +185 -0
  213. js/realex/livepipe/cookie.js +41 -0
  214. js/realex/livepipe/event_behavior.js +298 -0
  215. js/realex/livepipe/hotkey.js +74 -0
  216. js/realex/livepipe/livepipe.js +181 -0
  217. js/realex/livepipe/progressbar.js +102 -0
  218. js/realex/livepipe/rating.js +156 -0
  219. js/realex/livepipe/resizable.js +233 -0
  220. js/realex/livepipe/scrollbar.js +227 -0
  221. js/realex/livepipe/selection.js +459 -0
  222. js/realex/livepipe/selectmultiple.js +155 -0
  223. js/realex/livepipe/tabs.js +233 -0
  224. js/realex/livepipe/textarea.js +122 -0
  225. js/realex/livepipe/window.js +947 -0
  226. js/realex/validation.js +20 -0
  227. lib/Realex/Log.php +15 -0
  228. lib/Realex/check.xsl +16 -0
  229. package.xml +18 -0
  230. skin/adminhtml/default/default/realex/css/realex.css +2 -0
  231. skin/adminhtml/default/default/realex/js/realex.js +14 -0
  232. skin/frontend/base/default/realex/css/realex.css +98 -0
  233. skin/frontend/base/default/realex/images/icons.png +0 -0
  234. skin/frontend/base/default/realex/js/checkout.js +122 -0
  235. skin/frontend/base/default/realex/js/customer.js +109 -0
  236. skin/frontend/base/default/realex/js/iframe.js +114 -0
  237. skin/frontend/base/default/realex/js/iframe.js.orig +62 -0
  238. skin/frontend/base/default/realex/js/realex.js +157 -0
  239. skin/frontend/base/default/realex/js/realexosc.js +132 -0
app/code/community/Yoma/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/Block/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/Block/Adminhtml/Customer/Tab.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Customer_Tab extends Yoma_Realex_Block_Adminhtml_Tokencard_Grid
21
+ implements Mage_Adminhtml_Block_Widget_Tab_Interface {
22
+
23
+ /**
24
+ * Set the template for the block
25
+ *
26
+ */
27
+ public function _construct()
28
+ {
29
+ parent::_construct();
30
+ //$this->setTemplate('realex/customer/tab.phtml');
31
+ //parent::__construct();
32
+ $this->setFilterVisibility(FALSE);
33
+ $this->setSaveParametersInSession(FALSE);
34
+ }
35
+ /**
36
+ * Retrieve the label used for the tab relating to this block
37
+ *
38
+ * @return string
39
+ */
40
+ public function getTabLabel()
41
+ {
42
+ return $this->__('Saved Cards');
43
+ }
44
+ /**
45
+ * Retrieve the title used by this tab
46
+ *
47
+ * @return string
48
+ */
49
+ public function getTabTitle()
50
+ {
51
+ return $this->__('View Saved Cards');
52
+ }
53
+ /**
54
+ * Determines whether to display the tab
55
+ * Add logic here to decide whether you want the tab to display
56
+ *
57
+ * @return bool
58
+ */
59
+ public function canShowTab()
60
+ {
61
+ $customer = Mage::registry('current_customer');
62
+ return (bool)$customer->getId();
63
+ }
64
+ /**
65
+ * Stops the tab being hidden
66
+ *
67
+ * @return bool
68
+ */
69
+ public function isHidden()
70
+ {
71
+ $hidden = false;
72
+
73
+ $config = (string) Mage::getStoreConfig('payment/realvault/active');
74
+ if($config == 'false') {
75
+ $hidden = true;
76
+ }
77
+
78
+ return $hidden;
79
+ }
80
+
81
+ /**
82
+ * Defines after which tab, this tab should be rendered
83
+ *
84
+ * @return string
85
+ */
86
+ public function getAfter() {
87
+
88
+ return 'orders';
89
+ }
90
+
91
+ protected function _prepareCollection()
92
+ {
93
+ $collection = Mage::getModel('realex/tokencard')
94
+ ->getCollection()
95
+ ->addCustomerFilter(Mage::registry('current_customer'));
96
+ $this->setCollection($collection);
97
+ return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
98
+ }
99
+
100
+ public function getRowUrl($row)
101
+ {
102
+ return $this->getUrl('realexAdmin/adminhtml_tokencard/edit', array('id' => $row->getId()));
103
+ }
104
+
105
+
106
+ public function getGridUrl()
107
+ {
108
+ return $this->getUrl('*/*/tab', array('_current' => true));
109
+ }
110
+
111
+
112
+ public function getExportTypes(){
113
+ return false;
114
+ }
115
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Form/Edit/Renderer/Expiry.php ADDED
@@ -0,0 +1,81 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Form_Edit_Renderer_Expiry extends Varien_Data_Form_Element_Abstract {
21
+
22
+ /**
23
+ * Retrieve Element HTML fragment
24
+ *
25
+ * @return string
26
+ */
27
+ public function getElementHtml() {
28
+ $html = '';
29
+ if($this->getValue()) {
30
+ $html .= '<select onchange="updateExpire(this)" name="expiry_month" id="expiry_month" style="width:138px;margin-right:2px;">';
31
+ $html .= $this->_getMonthOptions();
32
+ $html .= '</select>';
33
+ $html .= '<select onchange="updateExpire(this)" name="expiry_year" id="expiry_year" style="width:138px;margin-left:2px;">';
34
+ $html .= $this->_getYearOptions();
35
+ $html .= '</select>';
36
+
37
+ $html .= '<input type="hidden" name="expiry_date" id="expiry_date" value="'.$this->getValue().'"/>';
38
+ $html .= $this->_scriptBlock();
39
+ }
40
+ return $html;
41
+ }
42
+
43
+ private function _getMonthOptions() {
44
+ $current_month = substr($this->getValue(), 0, 2);
45
+ $html = '';
46
+ for ($i=1; $i <= 12; $i++) {
47
+ $month = $this->_formatMonth($i, 2);
48
+ $html.= '<option value="'.$month.'" '.($month == $current_month ? 'selected="selected"' : '').'>'.date('M', mktime(0,0,0,$i,10)).'</option>';
49
+ }
50
+ return $html;
51
+ }
52
+
53
+ private function _getYearOptions() {
54
+ $present_year = date('Y');
55
+ $current_year = substr($this->getValue(), -2);
56
+ $html = '';
57
+ for ($i=0; $i <= 15; $i++) {
58
+ $present_year += 1;
59
+ $short_year = substr($present_year, -2);
60
+ $html .= '<option value="'.$short_year.'" '.($current_year == $short_year ? 'selected="selected"' : '').'>'.$present_year.'</option>';
61
+ }
62
+ return $html;
63
+ }
64
+
65
+ private function _formatMonth($num,$numDigits) {
66
+ return sprintf("%0".$numDigits."d",$num);
67
+ }
68
+
69
+ private function _scriptBlock() {
70
+ return '
71
+ <script type="text/javascript">
72
+ updateExpire = function (dropdown) {
73
+ var month = $("expiry_month").getValue();
74
+ var year = $("expiry_year").getValue();
75
+ var date = month+year;
76
+ $("expiry_date").value = date;
77
+ }
78
+ </script>';
79
+ }
80
+
81
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Notifications.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Notifications extends Mage_Adminhtml_Block_Template {
21
+
22
+ public function getMessage() {
23
+ if($count = $this->_cardsExpiring()) {
24
+ return '<strong>Realex Payments:</strong> You have <strong class="label">'.$count.'</strong> that are about to expire.';
25
+ }
26
+ }
27
+
28
+ private function _cardsExpiring() {
29
+ return Mage::getModel("realex/tokencard")->getCardsExpiring();
30
+ }
31
+
32
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Order/Creditmemo/Rebate.php ADDED
@@ -0,0 +1,57 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Sales_Order_Creditmemo_Rebate extends Mage_Core_Block_Template
21
+ {
22
+ protected $_source;
23
+
24
+ /**
25
+ * Initialize options
26
+ *
27
+ * @return $this
28
+ */
29
+ public function initTotals()
30
+ {
31
+ $parent = $this->getParentBlock();
32
+ $this->_source = $parent->getSource();
33
+ $total = new Varien_Object(array(
34
+ 'code' => 'rebate_positive',
35
+ 'block_name'=> $this->getNameInLayout()
36
+ ));
37
+
38
+ if($this->_canShow($parent->getOrder()->getPayment())) {
39
+ $parent->removeTotal('adjustment_negative');
40
+ $parent->addTotal($total);
41
+ }
42
+ return $this;
43
+ }
44
+
45
+ public function getSource()
46
+ {
47
+ return $this->_source;
48
+ }
49
+
50
+ protected function _canShow($payment){
51
+
52
+ if(in_array($payment->getMethod(),array('realexdirect','realexredirect','realvault'))){
53
+ return true;
54
+ }
55
+ return false;
56
+ }
57
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Order/Invoice/Settle.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Sales_Order_Invoice_Settle extends Mage_Core_Block_Template
21
+ {
22
+
23
+ protected $_source;
24
+
25
+ /**
26
+ * Initialize totals
27
+ *
28
+ * @return $this
29
+ */
30
+ public function initTotals()
31
+ {
32
+ $parent = $this->getParentBlock();
33
+ $this->_source = $parent->getSource();
34
+ $total = new Varien_Object(array(
35
+ 'code' => 'settle_positive',
36
+ 'block_name'=> $this->getNameInLayout()
37
+ ));
38
+
39
+ if($this->_canShow($parent->getOrder()->getPayment())) {
40
+ $parent->addTotal($total);
41
+ }
42
+ return $this;
43
+ }
44
+
45
+ public function getSource()
46
+ {
47
+ return $this->_source;
48
+ }
49
+
50
+ public function getSettleAmount(){
51
+
52
+ return $this->_source->getSettlePositive();
53
+ }
54
+
55
+ protected function _canShow($payment){
56
+
57
+ if(in_array($payment->getMethod(),array('realexdirect','realexredirect','realvault'))){
58
+ return true;
59
+ }
60
+ return false;
61
+ }
62
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Sales/Realex/Logs.php ADDED
@@ -0,0 +1,86 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Sales_Realex_Logs extends Mage_Core_Block_Template
21
+ {
22
+
23
+ /**
24
+ * Get tail url
25
+ *
26
+ * @param array $params
27
+ * @return string
28
+ */
29
+ public function getTailUrl(array $params = array())
30
+ {
31
+ $params ['_secure'] = true;
32
+
33
+ return $this->helper('adminhtml')->getUrl('realexAdmin/adminhtml_log/tail', $params);
34
+ }
35
+
36
+ /**
37
+ * Get log path
38
+ *
39
+ * @return mixed
40
+ */
41
+ protected function _getLogPath()
42
+ {
43
+ return $this->helper('realex')->getRealexLogDir();
44
+ }
45
+
46
+ /**
47
+ * Generate log select
48
+ *
49
+ * @return string
50
+ */
51
+ public function getLogFilesSelect()
52
+ {
53
+
54
+ $logPath = $this->_getLogPath();
55
+ $logFiles = array();
56
+
57
+ if( file_exists($logPath) ){
58
+ foreach (new DirectoryIterator($logPath) as $fileInfo) {
59
+ if($fileInfo->isDot()){
60
+ continue;
61
+ }
62
+
63
+ if(preg_match('/[(.log)(.logs)]$/', $fileInfo->getFilename())){
64
+ $logFiles [] = array('file' => $fileInfo->getPathname(), 'filename'=>$fileInfo->getFilename());
65
+ }
66
+ }
67
+ }
68
+
69
+ if(empty($logFiles)){
70
+ return $this->__('No log files found');
71
+ }
72
+
73
+ $html = '<label for="rl-log-switcher">' . $this->__('Please, choose a file:') . '</label><select id="rl-log-switcher" name="rl-log-switcher"><option value=""></option>';
74
+
75
+ foreach($logFiles as $l){
76
+ $html .= '<option value="' . $this->getTailUrl(array('file'=>$l['filename'])) . '">' . $l['filename'] . '</option>';
77
+ }
78
+
79
+ $html .= '</select>';
80
+
81
+ return $html;
82
+
83
+
84
+ }
85
+
86
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/System/Config/Renderer/SubAccount/Abstract.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_System_Config_Renderer_SubAccount_Abstract extends Mage_Adminhtml_Block_System_Config_Form_Field_Array_Abstract
21
+ {
22
+
23
+ /**
24
+ * Card field renderer
25
+ *
26
+ */
27
+ protected $_cardRenderer;
28
+
29
+ public function __construct()
30
+ {
31
+ parent::__construct();
32
+ }
33
+
34
+ /**
35
+ * Get select block for search field
36
+ *
37
+ */
38
+ protected function _getCardRenderer()
39
+ {
40
+ if (!$this->_cardRenderer) {
41
+
42
+ $this->_cardRenderer = $this->getLayout()
43
+ ->createBlock('core/html_select')
44
+ ->setIsRenderToJsTemplate(true);
45
+ }
46
+ return $this->_cardRenderer;
47
+ }
48
+
49
+ protected function _prepareToRender()
50
+ {
51
+ $this->_cardRenderer = null;
52
+
53
+ $this->addColumn('sub_account', array(
54
+ 'label' => Mage::helper('realex')->__('Sub Account'),
55
+ 'style' => 'width:120px;',
56
+ 'renderer' => false
57
+ ));
58
+
59
+ $this->addColumn('card_type', array(
60
+ 'label' => Mage::helper('realex')->__('Card Type'),
61
+ 'renderer' => NULL
62
+ ));
63
+
64
+ // Disables "Add after" button
65
+ $this->_addAfter = false;
66
+ $this->_addButtonLabel = Mage::helper('realex')->__('Add Sub Account');
67
+ }
68
+
69
+ protected function _renderCellTemplate($columnName)
70
+ {
71
+
72
+ $inputName = $this->getElement()->getName() . '[#{_id}][' . $columnName . ']';
73
+
74
+ if ($columnName=="card_type") {
75
+ return $this->_getCardRenderer()
76
+ ->setName($inputName)
77
+ ->setTitle($columnName)
78
+ ->setExtraParams('style="width:150px"')
79
+ ->setOptions(
80
+ Mage::getSingleton('realex/realex_source_cards')->toOptionArray())
81
+ ->toHtml();
82
+ }
83
+
84
+ return parent::_renderCellTemplate($columnName);
85
+ }
86
+
87
+ protected function _prepareArrayRow(Varien_Object $row)
88
+ {
89
+ $row->setData(
90
+ 'option_extra_attr_' . $this->_getCardRenderer()->calcOptionHash(
91
+ $row->getData('card_type')),
92
+ 'selected="selected"'
93
+ );
94
+ }
95
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/System/Config/Renderer/SubAccount/Direct.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_System_Config_Renderer_SubAccount_Direct
21
+ extends Yoma_Realex_Block_Adminhtml_System_Config_Renderer_SubAccount_Abstract
22
+ {
23
+
24
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard extends Mage_Adminhtml_Block_Widget_Grid_Container{
21
+
22
+ public function __construct()
23
+ {
24
+ $this->_controller = "adminhtml_tokencard";
25
+ $this->_blockGroup = "realex";
26
+ $this->_headerText = Mage::helper("realex")->__("Token Card Manager");
27
+ parent::__construct();
28
+ $this->_removeButton('add');
29
+
30
+ }
31
+
32
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard_Edit extends Mage_Adminhtml_Block_Widget_Form_Container
21
+ {
22
+ public function __construct()
23
+ {
24
+
25
+ parent::__construct();
26
+ $this->_objectId = "id";
27
+ $this->_blockGroup = "realex";
28
+ $this->_controller = "adminhtml_tokencard";
29
+ $this->_updateButton("save", "label", Mage::helper("realex")->__("Save Item"));
30
+ $this->_updateButton("delete", "label", Mage::helper("realex")->__("Delete Item"));
31
+
32
+ $this->_addButton("saveandcontinue", array(
33
+ "label" => Mage::helper("realex")->__("Save And Continue Edit"),
34
+ "onclick" => "saveAndContinueEdit()",
35
+ "class" => "save",
36
+ ), -100);
37
+
38
+
39
+ $this->_formScripts[] = "
40
+ function saveAndContinueEdit(){
41
+ editForm.submit($('edit_form').action+'back/edit/');
42
+ }
43
+ ";
44
+ }
45
+
46
+ public function getHeaderText()
47
+ {
48
+ if( Mage::registry("tokencard_data") && Mage::registry("tokencard_data")->getId() ){
49
+
50
+ return Mage::helper("realex")->__("Edit Item '%s'", $this->htmlEscape(Mage::registry("tokencard_data")->getId()));
51
+ }else{
52
+ return Mage::helper("realex")->__("Add Item");
53
+ }
54
+ }
55
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Form.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
21
+ {
22
+ protected function _prepareForm()
23
+ {
24
+ $form = new Varien_Data_Form(array(
25
+ "id" => "edit_form",
26
+ "action" => $this->getUrl("*/*/save", array("id" => $this->getRequest()->getParam("id"))),
27
+ "method" => "post",
28
+ "enctype" =>"multipart/form-data",
29
+ )
30
+ );
31
+ $form->setUseContainer(true);
32
+ $this->setForm($form);
33
+ return parent::_prepareForm();
34
+ }
35
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Tab/Form.php ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard_Edit_Tab_Form extends Mage_Adminhtml_Block_Widget_Form
21
+ {
22
+ protected function _prepareForm()
23
+ {
24
+
25
+ $form = new Varien_Data_Form();
26
+ $this->setForm($form);
27
+ $fieldset = $form->addFieldset("realex_form", array("legend"=>Mage::helper("realex")->__("Item information")));
28
+
29
+ $fieldset->addField("ch_name", "text", array(
30
+ "label" => Mage::helper("realex")->__("Card Holder Name"),
31
+ "name" => "ch_name",
32
+ ));
33
+
34
+ $fieldset->addType('expiry', Mage::getConfig()->getBlockClassName('realex/adminhtml_form_edit_renderer_expiry'));
35
+ $fieldset->addField('expiry_date', 'expiry', array(
36
+ 'label' => Mage::helper("realex")->__("Card Expiry Date"),
37
+ ));
38
+
39
+ if (Mage::getSingleton("adminhtml/session")->getTokencardData())
40
+ {
41
+ $form->setValues(Mage::getSingleton("adminhtml/session")->getTokencardData());
42
+ Mage::getSingleton("adminhtml/session")->setTokencardData(null);
43
+ }
44
+ elseif(Mage::registry("tokencard_data")) {
45
+ $form->setValues(Mage::registry("tokencard_data")->getData());
46
+ }
47
+ return parent::_prepareForm();
48
+ }
49
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Edit/Tabs.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard_Edit_Tabs extends Mage_Adminhtml_Block_Widget_Tabs
21
+ {
22
+ public function __construct()
23
+ {
24
+ parent::__construct();
25
+ $this->setId("tokencard_tabs");
26
+ $this->setDestElementId("edit_form");
27
+ $this->setTitle(Mage::helper("realex")->__("Item Information"));
28
+ }
29
+ protected function _beforeToHtml()
30
+ {
31
+ $this->addTab("form_section", array(
32
+ "label" => Mage::helper("realex")->__("Item Information"),
33
+ "title" => Mage::helper("realex")->__("Item Information"),
34
+ "content" => $this->getLayout()->createBlock("realex/adminhtml_tokencard_edit_tab_form")->toHtml(),
35
+ ));
36
+ return parent::_beforeToHtml();
37
+ }
38
+
39
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Tokencard/Grid.php ADDED
@@ -0,0 +1,150 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Tokencard_Grid extends Mage_Adminhtml_Block_Widget_Grid
21
+ {
22
+
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId("tokencardGrid");
27
+ $this->setDefaultSort("id");
28
+ $this->setDefaultDir("DESC");
29
+ $this->setSaveParametersInSession(true);
30
+ }
31
+
32
+ public function getRowUrl($row)
33
+ {
34
+ return $this->getUrl("*/*/edit", array("id" => $row->getId()));
35
+ }
36
+
37
+ protected function _prepareCollection()
38
+ {
39
+ $collection = Mage::getModel("realex/tokencard")->getCollection();
40
+ $fn = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'firstname');
41
+ $ln = Mage::getModel('eav/entity_attribute')->loadByCode('1', 'lastname');
42
+
43
+ $collection->getSelect()
44
+ ->join(array('ce1' => 'customer_entity_varchar'), 'ce1.entity_id=main_table.customer_id', array('firstname' => 'value'))
45
+ ->where('ce1.attribute_id='.$fn->getAttributeId())
46
+ ->join(array('ce2' => 'customer_entity_varchar'), 'ce2.entity_id=main_table.customer_id', array('lastname' => 'value'))
47
+ ->where('ce2.attribute_id='.$ln->getAttributeId())
48
+ ->columns(new Zend_Db_Expr("CONCAT(`ce1`.`value`, ' ',`ce2`.`value`) AS fullname"))
49
+ ->columns(new Zend_Db_Expr("LEFT(`main_table`.`expiry_date`,2) as month"))
50
+ ->columns(new Zend_Db_Expr("RIGHT(`main_table`.`expiry_date`,2) as year"))
51
+ ;
52
+
53
+ $this->setCollection($collection);
54
+ return parent::_prepareCollection();
55
+ }
56
+
57
+ protected function _prepareColumns()
58
+ {
59
+ $this->addColumn("id", array(
60
+ "header" => Mage::helper("realex")->__("ID"),
61
+ "align" =>"right",
62
+ "width" => "50px",
63
+ "type" => "number",
64
+ "index" => "id",
65
+ ));
66
+
67
+ $this->addColumn("customer_id", array(
68
+ "header" => Mage::helper("realex")->__("Customer ID"),
69
+ "align" =>"right",
70
+ "width" => "50px",
71
+ "type" => "number",
72
+ "index" => "customer_id",
73
+ ));
74
+
75
+ $this->addColumn("fullname", array(
76
+ "header" => Mage::helper("realex")->__("Customer Name"),
77
+ 'filter' => false,
78
+ "index" => "fullname",
79
+ ));
80
+
81
+ $this->addColumn("token", array(
82
+ "header" => Mage::helper("realex")->__("Token Ref"),
83
+ "index" => "token",
84
+ ));
85
+
86
+ $this->addColumn("payer_ref", array(
87
+ "header" => Mage::helper("realex")->__("Payer Ref"),
88
+ "index" => "payer_ref",
89
+ ));
90
+
91
+ $this->addColumn("ch_name", array(
92
+ "header" => Mage::helper("realex")->__("Card Holder Name"),
93
+ "index" => "ch_name",
94
+ ));
95
+
96
+ $this->addColumn("card_type", array(
97
+ "header" => Mage::helper("realex")->__("Card Type"),
98
+ "index" => "card_type",
99
+ ));
100
+
101
+ $this->addColumn("last_four", array(
102
+ "header" => Mage::helper("realex")->__("Last Four Digits"),
103
+ "index" => "last_four",
104
+ ));
105
+
106
+ $this->addColumn("expiry_date", array(
107
+ "header" => Mage::helper("realex")->__("Expiry Date"),
108
+ "index" => "expiry_date",
109
+ ));
110
+
111
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
112
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
113
+
114
+ return parent::_prepareColumns();
115
+ }
116
+
117
+ protected function _prepareMassaction()
118
+ {
119
+ $this->setMassactionIdField('id');
120
+
121
+ $this->getMassactionBlock()->setFormFieldName('ids');
122
+
123
+ $this->getMassactionBlock()->setUseSelectAll(true);
124
+
125
+ $this->getMassactionBlock()->addItem('remove_tokencard', array(
126
+ 'label'=> Mage::helper('realex')->__('Delete Token Card'),
127
+ 'url' => $this->getUrl('realexAdmin/adminhtml_tokencard/massRemove'),
128
+ 'confirm' => Mage::helper('realex')->__('Are you sure?')
129
+ ));
130
+ return $this;
131
+ }
132
+
133
+ protected function _setCollectionOrder($column)
134
+ {
135
+ $collection = $this->getCollection();
136
+ if ($collection) {
137
+ $columnIndex = $column->getFilterIndex() ?
138
+ $column->getFilterIndex() : $column->getIndex();
139
+ if($columnIndex == 'expiry_date'){
140
+ $collection
141
+ ->setOrder('year', strtoupper($column->getDir()))
142
+ ->setOrder('month', strtoupper($column->getDir()));
143
+ }else {
144
+ $collection->setOrder($columnIndex, strtoupper($column->getDir()));
145
+ }
146
+ }
147
+ return $this;
148
+ }
149
+
150
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Transaction.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Transaction extends Mage_Adminhtml_Block_Widget_Grid_Container{
21
+
22
+ public function __construct()
23
+ {
24
+ $this->_controller = "adminhtml_transaction";
25
+ $this->_blockGroup = "realex";
26
+ $this->_headerText = Mage::helper("realex")->__("Transactions");
27
+ parent::__construct();
28
+ $this->_removeButton('add');
29
+
30
+ }
31
+
32
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Detail.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Transaction_Detail extends Mage_Adminhtml_Block_Widget_Container
21
+ {
22
+ /**
23
+ * Transaction model
24
+ *
25
+ * @var Mage_Sales_Model_Order_Payment_Transaction
26
+ */
27
+ protected $_txn;
28
+
29
+ /**
30
+ * Add control buttons
31
+ *
32
+ */
33
+ public function __construct()
34
+ {
35
+ parent::__construct();
36
+
37
+ $this->_txn = Mage::registry('transaction_data');
38
+
39
+ $backUrl = ($this->_txn->getOrderUrl()) ? $this->_txn->getOrderUrl() : $this->getUrl('*/*/');
40
+ $this->_addButton('back', array(
41
+ 'label' => Mage::helper('sales')->__('Back'),
42
+ 'onclick' => "setLocation('{$backUrl}')",
43
+ 'class' => 'back'
44
+ ));
45
+
46
+ }
47
+
48
+ /**
49
+ * Retrieve header text
50
+ *
51
+ * @return string
52
+ */
53
+ public function getHeaderText()
54
+ {
55
+ return Mage::helper('realex')->__("Transaction # %s | %s", $this->_txn->getEntityId(), $this->formatDate($this->_txn->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true));
56
+ }
57
+
58
+ protected function _toHtml()
59
+ {
60
+ $this->setTxnIdHtml($this->escapeHtml($this->_txn->getTransactionReference()));
61
+
62
+
63
+ if($this->_txn->getOrder()) {
64
+ $this->setOrderIncrementIdHtml($this->escapeHtml($this->_txn->getOrder()->getIncrementId()));
65
+ }else{
66
+ $this->setOrderIncrementIdHtml('');
67
+ }
68
+
69
+ $this->setTxnTypeHtml($this->escapeHtml($this->_txn->getTransactionType()));
70
+
71
+ $this->setOrderIdUrlHtml(
72
+ $this->escapeHtml($this->getUrl('adminhtml/sales_order/view', array('order_id' => $this->_txn->getOrderId())))
73
+ );
74
+
75
+
76
+ $createdAt = (strtotime($this->_txn->getCreatedAt()))
77
+ ? $this->formatDate($this->_txn->getCreatedAt(), Mage_Core_Model_Locale::FORMAT_TYPE_MEDIUM, true)
78
+ : $this->__('N/A');
79
+ $this->setCreatedAtHtml($this->escapeHtml($createdAt));
80
+
81
+ return parent::_toHtml();
82
+ }
83
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Detail/Grid.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Transaction_Detail_Grid extends Mage_Adminhtml_Block_Widget_Grid
21
+ {
22
+ /**
23
+ * Initialize default sorting and html ID
24
+ */
25
+ protected function _construct()
26
+ {
27
+ $this->setId('transactionDetailsGrid');
28
+ $this->setPagerVisibility(false);
29
+ $this->setFilterVisibility(false);
30
+ }
31
+
32
+ /**
33
+ * Prepare collection for grid
34
+ *
35
+ * @return Mage_Adminhtml_Block_Widget_Grid
36
+ */
37
+ protected function _prepareCollection()
38
+ {
39
+ $collection = new Varien_Data_Collection();
40
+ foreach ($this->getTransactionAdditionalInfo() as $key => $value) {
41
+ $data = new Varien_Object(array('key' => $key, 'value' => $value));
42
+ $collection->addItem($data);
43
+ }
44
+
45
+ $this->setCollection($collection);
46
+ return parent::_prepareCollection();
47
+ }
48
+
49
+ /**
50
+ * Add columns to grid
51
+ *
52
+ * @return Mage_Adminhtml_Block_Widget_Grid
53
+ */
54
+ protected function _prepareColumns()
55
+ {
56
+ $this->addColumn('key', array(
57
+ 'header' => Mage::helper('realex')->__('Key'),
58
+ 'index' => 'key',
59
+ 'sortable' => false,
60
+ 'type' => 'text',
61
+ 'width' => '50%'
62
+ ));
63
+
64
+ $this->addColumn('value', array(
65
+ 'header' => Mage::helper('realex')->__('Value'),
66
+ 'index' => 'value',
67
+ 'sortable' => false,
68
+ 'type' => 'text',
69
+ 'escape' => true
70
+ ));
71
+
72
+ return parent::_prepareColumns();
73
+ }
74
+
75
+ /**
76
+ * Retrieve Transaction addtitional info
77
+ *
78
+ * @return array
79
+ */
80
+ public function getTransactionAdditionalInfo()
81
+ {
82
+ $info = Mage::registry('transaction_data')->getAdditionalInformation();
83
+ return (is_array($info)) ? $info : array();
84
+ }
85
+ }
app/code/community/Yoma/Realex/Block/Adminhtml/Transaction/Grid.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Adminhtml_Transaction_Grid extends Mage_Adminhtml_Block_Widget_Grid
21
+ {
22
+
23
+ public function __construct()
24
+ {
25
+ parent::__construct();
26
+ $this->setId("transactionGrid");
27
+ $this->setDefaultSort("created_at");
28
+ $this->setDefaultDir("DESC");
29
+ $this->setSaveParametersInSession(true);
30
+ $this->setUseAjax(true);
31
+ }
32
+
33
+ protected function _prepareCollection()
34
+ {
35
+ $collection = Mage::getModel("realex/transaction")->getCollection()->addErrorFilter();
36
+
37
+ $this->setCollection($collection);
38
+ return parent::_prepareCollection();
39
+ }
40
+
41
+ protected function _prepareColumns()
42
+ {
43
+ $this->addColumn("entity_id", array(
44
+ "header" => Mage::helper("realex")->__("ID"),
45
+ "align" =>"right",
46
+ "width" => "50px",
47
+ "type" => "number",
48
+ "index" => "id",
49
+ ));
50
+
51
+ $this->addColumn("created_at", array(
52
+ "header" => Mage::helper("realex")->__("Date"),
53
+ "type" => "datetime",
54
+ "index" => "created_at",
55
+ ));
56
+
57
+ $this->addColumn("service_code", array(
58
+ "header" => Mage::helper("realex")->__("Method"),
59
+ "index" => "service_code",
60
+ ));
61
+
62
+ $this->addColumn("transaction_reference", array(
63
+ "header" => Mage::helper("realex")->__("Transaction Reference"),
64
+ "index" => "transaction_reference",
65
+ ));
66
+
67
+ $this->addColumn("payment_id", array(
68
+ "header" => Mage::helper("realex")->__("Payment"),
69
+ "index" => "payment_id",
70
+ ));
71
+
72
+ $this->addColumn("order_id", array(
73
+ "header" => Mage::helper("realex")->__("Order Increment Id"),
74
+ "index" => "order_id",
75
+ ));
76
+
77
+ $this->addColumn("transaction_type", array(
78
+ "header" => Mage::helper("realex")->__("Type"),
79
+ "index" => "transaction_type",
80
+ ));
81
+
82
+ $this->addColumn("payment_amount", array(
83
+ "header" => Mage::helper("realex")->__("Amount"),
84
+ "index" => "payment_amount",
85
+ ));
86
+
87
+ $this->addColumn("error_message", array(
88
+ "header" => Mage::helper("realex")->__("Error"),
89
+ "index" => "error_message",
90
+ ));
91
+
92
+ $this->addExportType('*/*/exportCsv', Mage::helper('sales')->__('CSV'));
93
+ $this->addExportType('*/*/exportExcel', Mage::helper('sales')->__('Excel'));
94
+
95
+ return parent::_prepareColumns();
96
+ }
97
+
98
+ public function getGridUrl()
99
+ {
100
+ return $this->getUrl('*/*/grid', array('_current' => true));
101
+ }
102
+
103
+ /**
104
+ * Retrieve row url
105
+ *
106
+ * @return string
107
+ */
108
+ public function getRowUrl($row)
109
+ {
110
+ return $this->getUrl('*/*/view', array('txn_id' => $row->getEntityId()));
111
+ }
112
+
113
+ }
app/code/community/Yoma/Realex/Block/Config.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Yoma_Realex_Block_Config extends Mage_Core_Block_Template
3
+ {
4
+ protected function _construct()
5
+ {
6
+ parent::_construct();
7
+
8
+ $this->setTemplate('realex/payment/config.phtml');
9
+ }
10
+
11
+ /**
12
+ * Get config values
13
+ *
14
+ * @return array
15
+ */
16
+ public function getConfig(){
17
+
18
+ $config = array();
19
+ $config['realexdirect']['iframe'] = Mage::getStoreConfig('payment/realexdirect/iframe');
20
+ $config['realexredirect']['iframe'] = Mage::getStoreConfig('payment/realexredirect/iframe');
21
+ $config['realvault']['iframe'] = Mage::getStoreConfig('payment/realvault/iframe');
22
+ $config['realexdirect']['display'] = Mage::getStoreConfig('payment/realexdirect/iframe_display');
23
+ $config['realexredirect']['display'] = Mage::getStoreConfig('payment/realexredirect/iframe_display');
24
+ $config['realexredirect']['inline'] = Mage::getStoreConfig('payment/realexredirect/iframe_inline');
25
+ $config['realvault']['display'] = Mage::getStoreConfig('payment/realvault/iframe_display');
26
+ $config['realexdirect']['secure'] = Mage::getStoreConfig('payment/realexdirect/use_threed_secure');
27
+ $config['realexredirect']['secure'] = '1';
28
+ $config['realvault']['secure'] = Mage::getStoreConfig('payment/realvault/use_threed_secure');
29
+ $config['realexdirect']['deny'] = $this->_denyUrl('direct');
30
+ $config['realexredirect']['deny'] = $this->_denyUrl('redirect');
31
+ $config['realvault']['deny'] = $this->_denyUrl('token');
32
+ $config['iframeSize'] = $this->_getIframeSize();
33
+ $config['failUrl'] = mage::getUrl('checkout/onepage/failure');
34
+
35
+ return $config;
36
+ }
37
+
38
+ /**
39
+ * Get deny url
40
+ *
41
+ * @param string $code
42
+ * @return string
43
+ */
44
+ protected function _denyUrl($code){
45
+ return Mage::getUrl(
46
+ 'realex/' . $code . '/onepageFailureOrder',
47
+ array(
48
+ '_forced_secure' => true
49
+ )
50
+ );
51
+ }
52
+
53
+ protected function _toHtml()
54
+ {
55
+ return parent::_toHtml();
56
+
57
+ }
58
+
59
+ /**
60
+ * Get iframe size
61
+ *
62
+ * @return mixed
63
+ */
64
+ protected function _getIframeSize(){
65
+
66
+ $size = $this->_getHelper()->getConfigData('realexredirect','iframe_size');
67
+
68
+ return mage::getModel('realex/realex_source_iframeSize')->getDimensions($size);
69
+
70
+ }
71
+
72
+ /**
73
+ * @return Mage_Core_Helper_Abstract
74
+ */
75
+ protected function _getHelper(){
76
+ return mage::helper('realex/redirect');
77
+ }
78
+
79
+ }
app/code/community/Yoma/Realex/Block/Customer/Account/Cards.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Customer_Account_Cards extends Mage_Core_Block_Template {
21
+ protected $_cards = null;
22
+
23
+
24
+ public function getCustomerCards() {
25
+
26
+ if($customer = Mage::getSingleton('customer/session')->getCustomer()) {
27
+ $cards = Mage::getModel("realex/tokencard")->getCollection()->addCustomerFilter($customer);
28
+ return $cards;
29
+ }
30
+ return;
31
+ }
32
+
33
+ public function canDeleteCards(){
34
+ return mage::helper('realex')->getConfigData('realvault','allow_delete');
35
+ }
36
+
37
+ public function getCcTypeName($ccType,$method = false)
38
+ {
39
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
40
+ if (isset($types[$ccType])) {
41
+ if($method == 'redirect' && $ccType == 'MC'){
42
+ return "MasterCard / Maestro";
43
+ }
44
+ return $types[$ccType];
45
+ }
46
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
47
+ }
48
+
49
+
50
+ }
app/code/community/Yoma/Realex/Block/Customer/Account/Cards/Edit.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Customer_Account_Cards_Edit extends Mage_Core_Block_Template {
21
+
22
+ protected $card;
23
+
24
+ /*
25
+ * Get customer card
26
+ */
27
+ public function getCustomerCard() {
28
+ if($card_id = (int) $this->getRequest()->getParam('card')) {
29
+ if($this->card = Mage::getModel("realex/tokencard")->getCardById($card_id)) {
30
+ return $this->card;
31
+ }
32
+ }
33
+ }
34
+
35
+ /**
36
+ * Get month options
37
+ *
38
+ * @return string
39
+ */
40
+ public function getMonthOptions() {
41
+ $current_month = substr($this->card->getExpiryDate(), 0, 2);
42
+ $html = '';
43
+ for ($i=1; $i <= 12; $i++) {
44
+ $month = $this->_formatMonth($i, 2);
45
+ $html.= '<option value="'.$month.'" '.($month == $current_month ? 'selected="selected"' : '').'>'.$month.'</option>';
46
+ }
47
+ return $html;
48
+ }
49
+
50
+ /**
51
+ * Get year options
52
+ *
53
+ * @return string
54
+ */
55
+ public function getYearOptions() {
56
+ $present_year = date('Y')-1;
57
+ $current_year = substr($this->card->getExpiryDate(), -2);
58
+ $html = '';
59
+ for ($i=0; $i <= 15; $i++) {
60
+ $present_year += 1;
61
+ $short_year = substr($present_year, -2);
62
+ $html .= '<option value="'.$short_year.'" '.($current_year == $short_year ? 'selected="selected"' : '').'>'.$present_year.'</option>';
63
+ }
64
+ return $html;
65
+ }
66
+
67
+ public function _formatMonth($num,$numDigits) {
68
+ return sprintf("%0".$numDigits."d",$num);
69
+ }
70
+
71
+ }
app/code/community/Yoma/Realex/Block/Direct/Form.php ADDED
@@ -0,0 +1,85 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Direct_Form extends Mage_Core_Block_Template
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+
27
+ $this->setTemplate('realex/payment/direct/form.phtml');
28
+ }
29
+
30
+ public function getTermUrl(){
31
+ $transaction = $this->_getTransaction();
32
+ if (!$transaction) {
33
+ throw new Exception($this->_getHelper()
34
+ ->__("Unable to load transaction'"));
35
+ }
36
+ return $transaction['action'];
37
+
38
+ }
39
+
40
+ public function getNoRedirectUrlMessage()
41
+ {
42
+
43
+ return 'Unable to redirect.';
44
+ }
45
+
46
+ public function getTitle()
47
+ {
48
+
49
+ return 'Please wait while you are redirected...';
50
+ }
51
+
52
+ public function getMessageData(){
53
+
54
+ $transaction = $this->_getTransaction();
55
+ if (!$transaction) {
56
+ throw new Exception($this->_getHelper()
57
+ ->__("Unable to load transaction'"));
58
+ }
59
+ return $transaction['post'];
60
+
61
+ }
62
+
63
+ protected function _toHtml()
64
+ {
65
+ return parent::_toHtml();
66
+
67
+ }
68
+
69
+ protected function _getTransaction(){
70
+ return mage::getSingleton('realex/session')->getTransactionData();
71
+
72
+ }
73
+
74
+ protected function _getPayment($id){
75
+ return Mage::getModel('sales/order_payment')->load($id);
76
+ }
77
+
78
+ protected function _getOrder($id){
79
+ return Mage::getModel('sales/order')->load($id);
80
+ }
81
+
82
+ protected function _getHelper(){
83
+ return mage::helper('realex/redirect');
84
+ }
85
+ }
app/code/community/Yoma/Realex/Block/Direct/Frame.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Direct_Frame extends Mage_Core_Block_Template {
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+
26
+ $this->setTemplate('realex/payment/direct/frame.phtml');
27
+ }
28
+
29
+ protected function _toHtml()
30
+ {
31
+ return parent::_toHtml();
32
+
33
+ }
34
+
35
+ public function getRedirectUrl(){
36
+
37
+ return mage::getUrl('realex/direct/form');
38
+ }
39
+
40
+ public function getFailUrl(){
41
+
42
+ return mage::getUrl('checkout/onepage/failure');
43
+ }
44
+
45
+ public function getTerminalUrl(){
46
+
47
+ $transaction = $this->_getTransaction();
48
+ if (!$transaction) {
49
+ throw new Exception($this->_getHelper()
50
+ ->__("Unable to load transaction'"));
51
+ }
52
+ return $transaction['action'];
53
+ }
54
+
55
+ protected function _getHelper(){
56
+ return mage::helper('realex/direct');
57
+ }
58
+
59
+ public function getIframeSize(){
60
+
61
+ return mage::getModel('realex/realex_source_iframeSize')->getDimensions(false);
62
+
63
+ }
64
+
65
+ protected function _getTransaction(){
66
+ return mage::getSingleton('realex/session')->getTransactionData();
67
+
68
+ }
69
+
70
+ }
app/code/community/Yoma/Realex/Block/Form/Direct.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Form_Direct extends Mage_Payment_Block_Form_Cc {
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('realex/payment/form/direct.phtml');
26
+ }
27
+
28
+ public function getTokenCards($methodCode = null) {
29
+
30
+ $cards = Mage::getModel("realex/tokencard")->getCollection()
31
+ ->addActiveCardsByCustomerFilter(Mage::getSingleton('customer/session')->getCustomer())
32
+ ->load();
33
+ return $cards;
34
+ }
35
+
36
+ public function canUseToken() {
37
+ $ret = Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore());
38
+ $ret = $ret && (Mage::getModel('checkout/type_onepage')->getCheckoutMethod() != 'guest');
39
+
40
+ return $ret;
41
+ }
42
+
43
+ public function alwaysSave(){
44
+
45
+ return !Mage::getStoreConfig('payment/realvault/store_card', Mage::app()->getStore());
46
+
47
+ }
48
+
49
+ public function canAddToken($tokens) {
50
+
51
+ return mage::helper('realex')->canAddCard($tokens->getSize());
52
+ }
53
+
54
+ }
app/code/community/Yoma/Realex/Block/Form/Redirect.php ADDED
@@ -0,0 +1,129 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Form_Redirect extends Mage_Payment_Block_Form_Cc {
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('realex/payment/form/redirect.phtml');
26
+ }
27
+
28
+ public function getQuote()
29
+ {
30
+ return Mage::getSingleton('checkout/session')->getQuote();
31
+ }
32
+
33
+ public function isCcTypeRequired()
34
+ {
35
+ return $this->getMethod()->getIsCcTypeRequired();
36
+ }
37
+
38
+ public function getCcAvailableTypes()
39
+ {
40
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
41
+ if ($method = $this->getMethod()) {
42
+ $path = 'realex/' . $method->getCode() . '/cctypes';
43
+ $availableTypes = Mage::getStoreConfig($path,Mage::app()->getStore());
44
+ if ($availableTypes) {
45
+ $availableTypes = explode(',', $availableTypes);
46
+ foreach ($types as $code => $name) {
47
+ if (!in_array($code, $availableTypes)) {
48
+ unset($types[$code]);
49
+ }
50
+ }
51
+ }
52
+ }
53
+ return $types;
54
+ }
55
+
56
+ protected function _toHtml()
57
+ {
58
+ Mage::dispatchEvent('payment_form_block_to_html_before', array(
59
+ 'block' => $this
60
+ ));
61
+
62
+ return parent::_toHtml();
63
+ }
64
+
65
+ /**
66
+ * Return save card status
67
+ * @return int
68
+ */
69
+ public function storeCardOption(){
70
+ $value = Mage::getStoreConfig('payment/realvault/store_card', Mage::app()->getStore());
71
+ if($value) {
72
+ return '1';
73
+ }
74
+
75
+ return '0';
76
+ }
77
+
78
+
79
+ public function useRealVault(){
80
+ if($desc = Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore())) {
81
+ return $desc;
82
+ }
83
+ }
84
+
85
+ /**
86
+ * Return always store label
87
+ * @return string
88
+ */
89
+ public function storeLabel() {
90
+ return Mage::getStoreConfig('payment/realvault/store_label', Mage::app()->getStore());
91
+ }
92
+
93
+ /**
94
+ * Return description for realex payment method
95
+ * @return string
96
+ */
97
+ public function payOptionDesc() {
98
+ if($desc = Mage::getStoreConfig('payment/realvault/option_description', Mage::app()->getStore())) {
99
+ return $desc;
100
+ }
101
+ }
102
+
103
+
104
+ public function canUseToken() {
105
+ $ret = Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore());
106
+ $ret = $ret && (Mage::getModel('checkout/type_onepage')->getCheckoutMethod() != 'guest');
107
+ return $ret;
108
+ }
109
+
110
+ public function alwaysSave(){
111
+ return !Mage::getStoreConfig('payment/realvault/store_card', Mage::app()->getStore());
112
+ }
113
+
114
+ public function getTokenCards($methodCode = null) {
115
+
116
+ $cards = Mage::getModel("realex/tokencard")->getCollection()
117
+ ->addActiveCardsByCustomerFilter(Mage::getSingleton('customer/session')->getCustomer())
118
+ ->load();
119
+ return $cards;
120
+ }
121
+
122
+ public function canAddToken($tokens){
123
+
124
+ return mage::helper('realex')->canAddCard($tokens->getSize());
125
+ }
126
+
127
+
128
+
129
+ }
app/code/community/Yoma/Realex/Block/Form/Token.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Form_Token extends Mage_Payment_Block_Form_Cc {
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+ $this->setTemplate('realex/payment/form/token.phtml');
26
+ }
27
+
28
+ public function getPaymentMethodCode(){
29
+ return 'realvault';
30
+ }
31
+
32
+ public function getAvailableTokenCards($methodCode = null)
33
+ {
34
+ $cards = Mage::getModel("realex/tokencard")->getCollection()
35
+ ->addActiveCardsByCustomerFilter(Mage::getSingleton('customer/session')->getCustomer())
36
+ ->load();
37
+ return $cards;
38
+ }
39
+
40
+ public function canUseToken() {
41
+ $ret = Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore());
42
+ $ret = $ret && (Mage::getModel('checkout/type_onepage')->getCheckoutMethod() != 'guest');
43
+
44
+ return $ret;
45
+ }
46
+
47
+ public function canUseTokens(){
48
+ if (!Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore())) {
49
+ return false;
50
+ }
51
+
52
+ return true;
53
+ }
54
+
55
+ public function alwaysSave(){
56
+
57
+ return !Mage::getStoreConfig('payment/realvault/store_card', Mage::app()->getStore());
58
+
59
+ }
60
+
61
+ public function canAddToken($tokens) {
62
+
63
+ return mage::helper('realex')->canAddCard($tokens->getSize());
64
+ }
65
+
66
+ public function requireTokenCvv(){
67
+ return Mage::getStoreConfig('payment/realvault/require_cvv', Mage::app()->getStore());
68
+ }
69
+
70
+ public function getMagentoCardType($token){
71
+
72
+ $cards = mage::getModel('realex/realex_source_cards');
73
+
74
+ return $cards->getMagentoCardType($token->getCardType());
75
+ }
76
+
77
+ }
app/code/community/Yoma/Realex/Block/Info/Direct.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Info_Direct extends Mage_Payment_Block_Info_Cc {
21
+
22
+
23
+ public function isTokenInfo() {
24
+
25
+ if($this->getInfo()->getRealexTokenCcId()){
26
+ return $this->getInfo()->getRealexTokenCcId();
27
+ }
28
+
29
+ return false;
30
+ }
31
+
32
+ /**
33
+ * Prepare payment information
34
+ *
35
+ * @param Varien_Object $transport
36
+ * @return Varien_Object
37
+ */
38
+ protected function _prepareSpecificInformation($transport = null)
39
+ {
40
+ if (null !== $this->_paymentSpecificInformation) {
41
+ return $this->_paymentSpecificInformation;
42
+ }
43
+ $transport = parent::_prepareSpecificInformation($transport);
44
+ $data = array();
45
+ if ($ccType = $this->getCcTypeName()) {
46
+ $data[Mage::helper('payment')->__('Credit Card Type')] = $ccType;
47
+ }
48
+ if ($this->getInfo()->getCcLast4()) {
49
+ $data[Mage::helper('payment')->__('Credit Card Number')] = sprintf('xxxx-%s', $this->getInfo()->getCcLast4());
50
+ }
51
+ if (!$this->getIsSecureMode()) {
52
+ if ($ccSsIssue = $this->getInfo()->getCcSsIssue()) {
53
+ $data[Mage::helper('payment')->__('Switch/Solo/Maestro Issue Number')] = $ccSsIssue;
54
+ }
55
+ $year = $this->getInfo()->getCcSsStartYear();
56
+ $month = $this->getInfo()->getCcSsStartMonth();
57
+ if ($year && $month) {
58
+ $data[Mage::helper('payment')->__('Switch/Solo/Maestro Start Date')] = $this->_formatCardDate($year, $month);
59
+ }
60
+ }
61
+ return $transport->setData(array_merge($data, $transport->getData()));
62
+ }
63
+
64
+ }
app/code/community/Yoma/Realex/Block/Info/Redirect.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Info_Redirect extends Mage_Payment_Block_Info_Cc {
21
+
22
+ /**
23
+ * Prepare payment information
24
+ *
25
+ * @param Varien_Object $transport
26
+ * @return Varien_Object
27
+ */
28
+ protected function _prepareSpecificInformation($transport = null)
29
+ {
30
+ if (null !== $this->_paymentSpecificInformation) {
31
+ return $this->_paymentSpecificInformation;
32
+ }
33
+ $transport = parent::_prepareSpecificInformation($transport);
34
+ if($transport->getData('Credit Card Type') == 'N/A' || $transport->getData('Card Type') == 'N/A'){
35
+ $transport->setData(array());
36
+ }
37
+ return $transport;
38
+ }
39
+
40
+ }
app/code/community/Yoma/Realex/Block/Info/Token.php ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Info_Token extends Mage_Payment_Block_Info_Cc {
21
+
22
+ /**
23
+ * Retrieve token info
24
+ *
25
+ * @return mixed
26
+ */
27
+ protected function _getTokenInfo() {
28
+
29
+ $data = mage::helper('realex')->getTokenAsArray($this->getInfo()->getRealexTokenCcId());
30
+ $paymentMethod = mage::helper('realex')->getTokenPaymentCode($this->getInfo()->getRealexTokenCcId());
31
+
32
+ if(isset($data['Credit Card Type']) || isset($data['Card Type'])){
33
+ if(isset($data['Credit Card Type'])) {
34
+ $data['Credit Card Type'] = $this->getTokenCcTypeName($data['Credit Card Type'], $paymentMethod);
35
+ }else{
36
+ $data['Card Type'] = $this->getTokenCcTypeName($data['Card Type'], $paymentMethod);
37
+ }
38
+ }
39
+
40
+ return $data;
41
+ }
42
+
43
+ /**
44
+ * Prepare payment information
45
+ *
46
+ * @param Varien_Object $transport
47
+ * @return Varien_Object
48
+ */
49
+ protected function _prepareSpecificInformation($transport = null)
50
+ {
51
+ if (null !== $this->_paymentSpecificInformation) {
52
+ return $this->_paymentSpecificInformation;
53
+ }
54
+ $transport = parent::_prepareSpecificInformation($transport);
55
+
56
+ return $transport->setData($this->_getTokenInfo());
57
+ }
58
+
59
+ /**
60
+ * Get token name from cards
61
+ *
62
+ * @param string $ccType
63
+ * @param bool $method
64
+ * @return string
65
+ */
66
+ public function getTokenCcTypeName($ccType,$method = false)
67
+ {
68
+ $types = Mage::getSingleton('payment/config')->getCcTypes();
69
+ if (isset($types[$ccType])) {
70
+ if($method == 'redirect' && $ccType == 'MC'){
71
+ return "MasterCard / Maestro";
72
+ }
73
+ return $types[$ccType];
74
+ }
75
+ return (empty($ccType)) ? Mage::helper('payment')->__('N/A') : $ccType;
76
+ }
77
+ }
app/code/community/Yoma/Realex/Block/Onepage/Success.php ADDED
@@ -0,0 +1,64 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Onepage_Success extends Mage_Checkout_Block_Onepage_Success
21
+ {
22
+
23
+ /**
24
+ * Check if token saved
25
+ *
26
+ *
27
+ * @param int $orderId
28
+ * @return bool|mixed
29
+ * @throws Exception
30
+ */
31
+ public function getRememberToken($orderId){
32
+
33
+ $tokenSaved = false;
34
+
35
+ $order = Mage::getModel('sales/order')->loadByIncrementId($orderId);
36
+ if (!$order->getId()) {
37
+ return false;
38
+ }
39
+
40
+ $payment = $order->getPayment();
41
+ if (!$payment->getId()) {
42
+ return false;
43
+ }
44
+
45
+ if (!in_array($payment->getMethod(),array('realexdirect','realexredirect'))) {
46
+ return false;
47
+ }
48
+
49
+ // if token param then redirect else check session
50
+ if($this->getRequest()->getParam('token')){
51
+ $tokenSaved = $this->getRequest()->getParam( 'token' );
52
+ }else{
53
+ $tokenSaved = Mage::getSingleton('customer/session')->getTokenSaved();
54
+ Mage::getSingleton('customer/session')->unsTokenSaved();
55
+ Mage::getSingleton('realex/session')->unsTokenSaved();
56
+ }
57
+
58
+ if($tokenSaved){
59
+ return true;
60
+ }
61
+ return false;
62
+ }
63
+
64
+ }
app/code/community/Yoma/Realex/Block/Redirect/Form.php ADDED
@@ -0,0 +1,113 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Redirect_Form extends Mage_Core_Block_Template
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ parent::_construct();
26
+
27
+ $this->setTemplate('realex/payment/redirect/form.phtml');
28
+ }
29
+
30
+ /**
31
+ * Get redirect url
32
+ *
33
+ * @return mixed
34
+ */
35
+ public function getRedirectUrl(){
36
+
37
+ $mode = $this->_getHelper()->getConfigData('realexredirect','mode');
38
+ if($mode == 'test'){
39
+ $url = $this->_getHelper()->getConfigData('realexredirect','sandbox_url');
40
+ }else{
41
+ $url = $this->_getHelper()->getConfigData('realexredirect','live_url');
42
+ }
43
+
44
+ return $url;
45
+ }
46
+
47
+ /**
48
+ * Return no direct error message
49
+ *
50
+ * @return string
51
+ */
52
+ public function getNoRedirectUrlMessage()
53
+ {
54
+ return 'Unable to redirect.';
55
+ }
56
+
57
+ /**
58
+ * Return title text
59
+ *
60
+ * @return string
61
+ */
62
+ public function getTitle()
63
+ {
64
+
65
+ return 'Please wait while you are redirected...';
66
+ }
67
+
68
+ /**
69
+ * Get transaction data
70
+ *
71
+ * @return mixed
72
+ * @throws Exception
73
+ */
74
+ public function getMessageData(){
75
+
76
+ $transaction = $this->_getTransaction();
77
+ if (!$transaction) {
78
+ throw new Exception($this->_getHelper()
79
+ ->__("Unable to load transaction'"));
80
+ }
81
+ return $transaction;
82
+
83
+ }
84
+
85
+ protected function _toHtml()
86
+ {
87
+ return parent::_toHtml();
88
+
89
+ }
90
+
91
+ /**
92
+ * Get transaction data from session
93
+ *
94
+ * @return mixed
95
+ *
96
+ */
97
+ protected function _getTransaction(){
98
+ return mage::getSingleton('realex/session')->getTransactionData();
99
+
100
+ }
101
+
102
+ protected function _getPayment($id){
103
+ return Mage::getModel('sales/order_payment')->load($id);
104
+ }
105
+
106
+ protected function _getOrder($id){
107
+ return Mage::getModel('sales/order')->load($id);
108
+ }
109
+
110
+ protected function _getHelper(){
111
+ return mage::helper('realex/redirect');
112
+ }
113
+ }
app/code/community/Yoma/Realex/Block/Redirect/Frame.php ADDED
@@ -0,0 +1,89 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Redirect_Frame extends Mage_Core_Block_Template {
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+
26
+ $this->setTemplate('realex/payment/redirect/frame.phtml');
27
+ }
28
+
29
+ protected function _toHtml()
30
+ {
31
+ return parent::_toHtml();
32
+
33
+ }
34
+
35
+ /**
36
+ * Get redirect url
37
+ *
38
+ * @return string
39
+ */
40
+ public function getRedirectUrl(){
41
+
42
+ return mage::getUrl('realex/redirect/form');
43
+ }
44
+
45
+ /**
46
+ * Get fail url
47
+ *
48
+ * @return string
49
+ */
50
+ public function getFailUrl(){
51
+
52
+ return mage::getUrl('checkout/onepage/failure');
53
+ }
54
+
55
+ /**
56
+ * Get terminal url
57
+ *
58
+ * @return mixed
59
+ */
60
+ public function getTerminalUrl(){
61
+
62
+ $mode = $this->_getHelper()->getConfigData('realexredirect','mode');
63
+ if($mode == 1){
64
+ $url = $this->_getHelper()->getConfigData('realexredirect','sandbox_url');
65
+ }else{
66
+ $url = $this->_getHelper()->getConfigData('realexredirect','live_url');
67
+ }
68
+
69
+ return $url;
70
+ }
71
+
72
+ protected function _getHelper(){
73
+ return mage::helper('realex/redirect');
74
+ }
75
+
76
+ /**
77
+ * Get iFrame size
78
+ *
79
+ * @return mixed
80
+ */
81
+ public function getIframeSize(){
82
+
83
+ $size = $this->_getHelper()->getConfigData('realexredirect','iframe_size');
84
+
85
+ return mage::getModel('realex/realex_source_iframeSize')->getDimensions($size);
86
+
87
+ }
88
+
89
+ }
app/code/community/Yoma/Realex/Block/Redirect/Result.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Block_Redirect_Result extends Mage_Core_Block_Template{
21
+
22
+ protected function _construct()
23
+ {
24
+ parent::_construct();
25
+
26
+ $this->setTemplate('realex/payment/redirect/result.phtml');
27
+ }
28
+
29
+ protected function _toHtml()
30
+ {
31
+ return parent::_toHtml();
32
+
33
+ }
34
+ }
app/code/community/Yoma/Realex/Helper/Data.php ADDED
@@ -0,0 +1,920 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Helper_Data extends Mage_Core_Helper_Abstract{
21
+
22
+ const XML_PATH_CURRENCY_DECIMALS = 'yoma_realex/currency_decimals';
23
+ const XML_PATH_OUT_MAPPING = 'yoma_realex/mapping/';
24
+ const REGISTRY_KEY_CURRENT_TIMESTAMP = 'yoma_realex_current_timestamp';
25
+
26
+ protected $_tokenCards = null;
27
+ protected $_conversions = array('authorize'=>'Authorisation','partial'=>'Settle','capture'=>'Capture','refund'=>'Rebate');
28
+
29
+ /**
30
+ * Validate quote
31
+ *
32
+ * @return bool
33
+ */
34
+ public function validateQuote() {
35
+
36
+ $quote = Mage::getSingleton('realex/api_payment')->getQuote();
37
+
38
+ if (!$quote->isVirtual()) {
39
+ $address = $quote->getShippingAddress();
40
+ $addressValidation = $address->validate();
41
+ if ($addressValidation !== true) {
42
+ return false;
43
+ }
44
+ $method = $address->getShippingMethod();
45
+ $rate = $address->getShippingRateByCode($method);
46
+ if (!$quote->isVirtual() && (!$method || !$rate)) {
47
+ return false;
48
+ }
49
+ }
50
+
51
+ $addressValidation = $quote->getBillingAddress()->validate();
52
+ if ($addressValidation !== true) {
53
+ return false;
54
+ }
55
+
56
+ if (!($quote->getPayment()->getMethod())) {
57
+ return false;
58
+ }
59
+
60
+ return true;
61
+ }
62
+
63
+ /**
64
+ * Shorten String
65
+ *
66
+ * @param $string
67
+ * @param $length
68
+ * @return string
69
+ */
70
+ public function ss($string, $length) {
71
+ return substr($string, 0, $length);
72
+ }
73
+
74
+ public function realexEmail($text){
75
+ return preg_replace("/[\+]/", "", $text);
76
+ }
77
+
78
+ /**
79
+ * Sanatize postcode
80
+ *
81
+ * @param $text
82
+ * @return mixed
83
+ */
84
+ public function sanitizePostcode($text) {
85
+ return preg_replace("/[^a-zA-Z0-9-\s]/", "", $text);
86
+ }
87
+
88
+ /**
89
+ * Get decimal places of currency
90
+ *
91
+ * @param string $currencyCode
92
+ * @return int
93
+ * @throws Exception
94
+ */
95
+ public function getDecimalPlaces($currencyCode)
96
+ {
97
+ if (strlen($currencyCode) < 1) {
98
+ throw new Exception(
99
+ $this->__('Currency code must be provided to retrieve decimal places.')
100
+ );
101
+ }
102
+
103
+ $currencyDecimals = Mage::getConfig()->getNode(self::XML_PATH_CURRENCY_DECIMALS);
104
+ if (isset($currencyDecimals->$currencyCode)) {
105
+ $decimalPlaces = $currencyDecimals->$currencyCode;
106
+ } else {
107
+ $decimalPlaces = $currencyDecimals->DEFAULT;
108
+ }
109
+
110
+ return (int)$decimalPlaces;
111
+ }
112
+
113
+ /**
114
+ *Format amount by currency code
115
+ *
116
+ * @param string $amount
117
+ * @param string $currencyCode
118
+ * @param string $decimalCharacter
119
+ * @return float|string
120
+ * @throws Exception
121
+ */
122
+ public function formatAmount($amount, $currencyCode, $decimalCharacter = '')
123
+ {
124
+ $decimalPlaces = $this->getDecimalPlaces($currencyCode);
125
+
126
+ if ($decimalCharacter == '') {
127
+ $multiplier = pow(10, $decimalPlaces);
128
+ $amount = $amount * $multiplier;
129
+ $amount = round($amount);
130
+ } else {
131
+ $amount = number_format($amount, $decimalPlaces, $decimalCharacter, '');
132
+ }
133
+
134
+ return $amount;
135
+ }
136
+
137
+ /**
138
+ * @TODO remove redundant routine
139
+ * @param $code
140
+ * @param $direction
141
+ * @param $needle
142
+ * @return string
143
+ */
144
+ public function getMapping($code,$direction,$needle){
145
+
146
+ $path = self::XML_PATH_OUT_MAPPING . $code . '/' . $direction .'/' . $needle;
147
+
148
+ return (string)Mage::getConfig()->getNode($path);
149
+ }
150
+
151
+ /**
152
+ * Get config data
153
+ *
154
+ * @param string $code
155
+ * @param string $field
156
+ * @param null $storeId
157
+ * @return mixed
158
+ */
159
+ public function getConfigData($code, $field, $storeId = null){
160
+
161
+ if (null === $storeId) {
162
+ $storeId = $this->getStore();
163
+ }
164
+ $path = 'payment/' . $code . '/' . $field;
165
+
166
+ return Mage::getStoreConfig($path, $storeId);
167
+ }
168
+
169
+ /**
170
+ * Get customer email
171
+ *
172
+ * @return null
173
+ */
174
+ public function getCustomerEmail() {
175
+ $s = Mage::getSingleton('customer/session');
176
+ if ($s->getCustomerId()) {
177
+ return $s->getCustomer()->getEmail();
178
+ }
179
+ return null;
180
+ }
181
+
182
+ /**
183
+ * Get current store
184
+ *
185
+ * @return mixed
186
+ */
187
+ public function getStore(){
188
+
189
+ return Mage::app()->getStore()->getStoreId();
190
+ }
191
+
192
+ /**
193
+ * Re populate cart
194
+ *
195
+ * @param Mage_Sales_Model_Order $order
196
+ * @return $this
197
+ * @throws Exception
198
+ */
199
+ public function reorder($order)
200
+ {
201
+ if (is_null($order)) {
202
+ return $this;
203
+ }
204
+
205
+ $cart = Mage::getSingleton('checkout/cart');
206
+ if ($cart->getItemsCount() > 0) {
207
+ return $this;
208
+ }
209
+
210
+ if (!$order instanceof Mage_Sales_Model_Order) {
211
+ $order = Mage::getModel('sales/order')->load($order);
212
+ }
213
+ if (!$order->getId()) {
214
+ return $this;
215
+ }
216
+
217
+ foreach ($order->getItemsCollection() as $_item) {
218
+ try {
219
+ $cart->addOrderItem($_item);
220
+ } catch (Exception $e) {
221
+
222
+ }
223
+ }
224
+
225
+ $cart->save();
226
+
227
+ return $this;
228
+ }
229
+
230
+ /**
231
+ * Set session error message
232
+ *
233
+ * @param string $message
234
+ * @return $this
235
+ */
236
+ public function setSessionErrorMessage($message)
237
+ {
238
+ $this->_getSession()->setErrorMessage($message);
239
+
240
+ return $this;
241
+ }
242
+
243
+ /**
244
+ * Generate transaction reference
245
+ *
246
+ * @param Varien_Object $order
247
+ * @return mixed|string
248
+ * @throws Exception
249
+ */
250
+ public function getTransactionReference(Varien_Object $order = null)
251
+ {
252
+ $transactionReference
253
+ = Mage::registry('transaction_reference');
254
+
255
+ if (!is_null($transactionReference)) {
256
+ return $transactionReference;
257
+ }
258
+
259
+ if (!$order->getIncrementId()) {
260
+ throw new Exception(
261
+ $this->__('Order Not Set.')
262
+ );
263
+ }
264
+
265
+ $transactionReference = $this->_generateGuid($order->getIncrementId());
266
+ $this->setTransactionReference($transactionReference);
267
+
268
+ return $transactionReference;
269
+ }
270
+
271
+ /**
272
+ * Generate random string
273
+ *
274
+ * @param $prefix
275
+ * @return string
276
+ */
277
+ protected function _generateGuid($prefix)
278
+ {
279
+ return $prefix . '-' . time() . '-' . mt_rand(111111,999999);
280
+ }
281
+
282
+ public function getCardReference($cardType){
283
+ return strtolower($this->_generateGuid($cardType));
284
+ }
285
+
286
+ /**
287
+ * Get customer payer reference
288
+ *
289
+ * @param $customerId
290
+ * @return string
291
+ */
292
+ public function getEditPayerReference($customerId){
293
+ return $this->_generateGuid($customerId);
294
+ }
295
+
296
+ /**
297
+ *Set transaction reference
298
+ *
299
+ * @param $transactionReference
300
+ * @return $this
301
+ * @throws Exception
302
+ */
303
+ public function setTransactionReference($transactionReference)
304
+ {
305
+ $transactionReference
306
+ = Mage::registry('transaction_reference');
307
+
308
+ if (!is_null($transactionReference)) {
309
+ throw new Exception(
310
+ $this->__('transaction reference has already been set.')
311
+ );
312
+ }
313
+
314
+ Mage::register(
315
+ 'transaction_reference',
316
+ $transactionReference
317
+ );
318
+
319
+ return $this;
320
+ }
321
+
322
+ protected function _getSession()
323
+ {
324
+ return Mage::getSingleton('checkout/session');
325
+ }
326
+
327
+ /**
328
+ * Get TSS code from address
329
+ *
330
+ * @param Mage_Customer_Model_Address_Abstract $address
331
+ * @return string
332
+ */
333
+ public function getTssCode(Mage_Customer_Model_Address_Abstract $address = null)
334
+ {
335
+ if (!$address instanceof Mage_Customer_Model_Address_Abstract) {
336
+ return '|';
337
+ }
338
+
339
+ $streetNumbers = '';
340
+ for ($i = 1; $i <= 4; $i++) {
341
+ $street = $address->getStreet($i);
342
+
343
+ $streetNumbers = preg_replace("/[^0-9]/","",$street);
344
+
345
+ if (strlen($streetNumbers) > 0) {
346
+ break;
347
+ }
348
+ }
349
+
350
+ $postcodeNumbers = preg_replace("/[^0-9]/","",$address->getPostcode());
351
+
352
+ $result = substr($postcodeNumbers,0,5) . '|' . substr($streetNumbers,0,5);
353
+ return $result;
354
+ }
355
+
356
+ /**
357
+ * Get client ip address
358
+ *
359
+ * @return null
360
+ */
361
+ public function getClientIpAddress()
362
+ {
363
+ $ip = Mage::helper('core/http')->getRemoteAddr();
364
+
365
+ if(!filter_var($ip, FILTER_VALIDATE_IP, FILTER_FLAG_IPV4)){
366
+ return null;
367
+ }
368
+
369
+ return $ip;
370
+ }
371
+
372
+ /**
373
+ * Check if logged or registering
374
+ *
375
+ * @return bool
376
+ */
377
+ public function isLoggedInOrRegistering()
378
+ {
379
+ if (Mage::helper('customer')->isLoggedIn()) {
380
+ return true;
381
+ }
382
+
383
+ $checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
384
+
385
+ if (strcmp($checkoutMethod, Mage_Sales_Model_Quote::CHECKOUT_METHOD_LOGIN_IN) === 0) {
386
+ return true;
387
+ }
388
+
389
+ if (strcmp($checkoutMethod, Mage_Checkout_Model_Type_Onepage::METHOD_REGISTER) === 0) {
390
+ return true;
391
+ }
392
+
393
+ return false;
394
+ }
395
+
396
+ /**
397
+ * Check if logged in checkout
398
+ *
399
+ * @return bool
400
+ */
401
+ public function isCheckoutLoggedIn()
402
+ {
403
+ if (Mage::helper('customer')->isLoggedIn()) {
404
+ return true;
405
+ }
406
+
407
+ $checkoutMethod = Mage::getSingleton('checkout/session')->getQuote()->getCheckoutMethod();
408
+
409
+ if (strcmp($checkoutMethod, Mage_Sales_Model_Quote::CHECKOUT_METHOD_LOGIN_IN) === 0) {
410
+ return true;
411
+ }
412
+
413
+ return false;
414
+ }
415
+
416
+ /**
417
+ * Convert to camel case
418
+ *
419
+ * @param $str
420
+ * @param array $exclude
421
+ * @return string
422
+ */
423
+ public function camelCase($str, $exclude = array())
424
+ {
425
+ // replace accents by equivalent non-accents
426
+ $str = self::replaceAccents($str);
427
+ // non-alpha and non-numeric characters become spaces
428
+ $str = preg_replace('/[^a-z0-9' . implode("", $exclude) . ']+/i', ' ', $str);
429
+ // uppercase the first character of each word
430
+ $str = ucwords(trim($str));
431
+ return lcfirst(str_replace(" ", "", $str));
432
+ }
433
+
434
+ /**
435
+ * Replace accents in string
436
+ *
437
+ * @param $str
438
+ * @return mixed
439
+ */
440
+ public function replaceAccents($str) {
441
+ $search = explode(",",
442
+ "ç,æ,œ,á,é,í,ó,ú,à,è,ì,ò,ù,ä,ë,ï,ö,ü,ÿ,â,ê,î,ô,û,å,ø,Ø,Å,Á,À,Â,Ä,È,É,Ê,Ë,Í,Î,Ï,Ì,Ò,Ó,Ô,Ö,Ú,Ù,Û,Ü,Ÿ,Ç,Æ,Œ");
443
+ $replace = explode(",",
444
+ "c,ae,oe,a,e,i,o,u,a,e,i,o,u,a,e,i,o,u,y,a,e,i,o,u,a,o,O,A,A,A,A,A,E,E,E,E,I,I,I,I,O,O,O,O,U,U,U,U,Y,C,AE,OE");
445
+ return str_replace($search, $replace, $str);
446
+ }
447
+
448
+ /**
449
+ * Calculate sub account
450
+ *
451
+ * @param Varien_Object $payment
452
+ * @param $code
453
+ * @return string
454
+ */
455
+ public function getSubAccount(Varien_Object $payment, $code)
456
+ {
457
+ $default = $this->getConfigData($code, 'sub_account');
458
+
459
+ $processed = Mage::getSingleton('realex/subAccountProcessor')->process(
460
+ $default,
461
+ unserialize($this->getConfigData($code, 'sub_account_rules')),
462
+ array(
463
+ 'card_type' => $payment->getCcType(),
464
+ ),
465
+ $payment
466
+ );
467
+
468
+ if(trim($processed) != ''){
469
+ return trim($processed);
470
+ }
471
+
472
+ return trim($default);
473
+ }
474
+
475
+ /**
476
+ * Return card expiration date in a normal format: MM/YYYY
477
+ * @return string
478
+ */
479
+ public function getCardDateFormatted($string) {
480
+ $newString = $string;
481
+ if (strlen($string) == 4) {
482
+ $date = str_split($string, 2);
483
+ $newString = $date[0] . '/' . '20' . $date[1];
484
+ }
485
+ return $newString;
486
+ }
487
+
488
+ /**
489
+ * Get log dir
490
+ *
491
+ * @return string
492
+ */
493
+ public function getRealexLogDir() {
494
+ return Mage::getBaseDir('log') . DS . 'realex';
495
+ }
496
+
497
+ /**
498
+ * Convert xml to array
499
+ *
500
+ * @param $data
501
+ * @return array
502
+ */
503
+ public function xmlToArray($data){
504
+ if(is_array($data)){
505
+ return $this->flatten($data);
506
+ }
507
+ try{
508
+ $xml = simplexml_load_string($data);
509
+ $json = json_encode($xml);
510
+ return $this->flatten(json_decode($json, true));
511
+
512
+ }catch(Exception $e){
513
+ return $data;
514
+ }
515
+ }
516
+
517
+ /**
518
+ * Flatten array
519
+ *
520
+ * @param array $arr
521
+ * @param string $prefix
522
+ * @return array
523
+ */
524
+ public function flatten(array $arr, $prefix = '')
525
+ {
526
+ $out = array();
527
+ foreach ($arr as $k => $v) {
528
+ $key = (!strlen($prefix)) ? strtolower($k) : ($prefix=='@attributes'?strtolower($k):strtolower($prefix) . '_' . strtolower($k));
529
+ if (is_array($v)) {
530
+ $out += $this->flatten($v, $key);
531
+ } else {
532
+ $out[$key] = $v;
533
+ }
534
+ }
535
+ return $out;
536
+ }
537
+
538
+ public function getSessionCustomerId() {
539
+ return $this->getCustomerQuoteId();
540
+ }
541
+
542
+ /**
543
+ * Get customer quote
544
+ *
545
+ * @return int|string
546
+ */
547
+ public function getCustomerQuoteId() {
548
+ $id = null;
549
+
550
+ if (Mage::getSingleton('adminhtml/session_quote')->getQuoteId()) { #Admin
551
+ $id = Mage::getSingleton('adminhtml/session_quote')->getCustomerId();
552
+ } else if (Mage::getSingleton('customer/session')->getCustomerId()) { #Logged in frontend
553
+ $id = Mage::getSingleton('customer/session')->getCustomerId();
554
+ } else { #Guest/Register
555
+ $vdata = Mage::getSingleton('core/session')->getVisitorData();
556
+ return (string) $vdata['session_id'];
557
+ }
558
+
559
+ return (int) $id;
560
+ }
561
+
562
+ /**
563
+ * Get store code option
564
+ *
565
+ * @return string
566
+ */
567
+ public function storeCardOption(){
568
+ $value = Mage::getStoreConfig('payment/realvault/store_card', Mage::app()->getStore());
569
+ if($value) {
570
+ return '1';
571
+ }
572
+
573
+ return '0';
574
+ }
575
+
576
+ /**
577
+ * Get customer ref from session
578
+ *
579
+ * @return mixed
580
+ */
581
+ public function getPayerRef(){
582
+
583
+ return mage::helper('realex')->getSessionCustomerId();
584
+ }
585
+
586
+ /**
587
+ * Check if payer exist
588
+ *
589
+ * @return string
590
+ */
591
+ public function payerExist(){
592
+ $payerId = $this->getPayerRef();
593
+ $customer = Mage::getModel('customer/customer')->load($payerId);
594
+ if(!$customer->getId()){
595
+ $customer = $payerId;
596
+ }
597
+
598
+ $collection = mage::getModel('realex/tokencard')->getCollection()->addCustomerFilter($customer);
599
+
600
+ if($collection->count() > 0){
601
+ return '1';
602
+ }
603
+ return '0';
604
+ }
605
+
606
+ /**
607
+ * Load customer cards
608
+ *
609
+ * @param null $methodCode
610
+ * @return null|Varien_Object
611
+ */
612
+ public function loadCustomerCards($methodCode = null) {
613
+
614
+ $this->_tokenCards = new Varien_Object;
615
+
616
+ if (!$this->_tokenCards->getSize()) {
617
+
618
+ $_id = $this->getCustomerQuoteId();
619
+
620
+ if(is_numeric($_id)) {
621
+ if($_id === 0) {
622
+ return $this->_tokenCards;
623
+ }
624
+ }
625
+ $this->_tokenCards = Mage::getModel('realex/tokencard')->getCollection()
626
+ ->setOrder('id', 'DESC')
627
+ ->addCustomerFilter($_id);
628
+
629
+ $this->_tokenCards->load();
630
+
631
+ }
632
+
633
+ return $this->_tokenCards;
634
+ }
635
+
636
+ /**
637
+ * Get default token
638
+ *
639
+ * @return mixed
640
+ */
641
+ public function getDefaultToken() {
642
+ return Mage::getModel('realex/tokencard')->getDefaultCard();
643
+ }
644
+
645
+ public function getCardNiceDate($string) {
646
+ $newString = $string;
647
+
648
+ if (strlen($string) == 4) {
649
+ $date = str_split($string, 2);
650
+ $newString = $date[0] . '/' . '20' . $date[1];
651
+ }
652
+
653
+ return $newString;
654
+ }
655
+
656
+ /**
657
+ * Create payer ref
658
+ *
659
+ * @param Mage_Customer_Model_Customer $customer
660
+ * @return string
661
+ * @throws Mage_Core_Exception
662
+ */
663
+ public function createPayerRef($customer){
664
+
665
+ $payerRef = $customer->getId();
666
+ $payerRef .= '-' . preg_replace( "/[^a-z]/i", "_", $customer->getEmail());
667
+ $payerRef .= '-' . preg_replace( "/[^a-z]/i", "", Mage::app()->getWebsite()->getCode());
668
+ $payerRef .= '-' . preg_replace( "/[^a-z]/i", "", Mage::app()->getStore()->getCode());
669
+
670
+ return $this->ss($payerRef,50);
671
+ }
672
+
673
+ /**
674
+ * Get customer id from session
675
+ *
676
+ * @return mixed
677
+ */
678
+ public function getCustomerId(){
679
+ return Mage::getSingleton('customer/session')->getId();
680
+ }
681
+
682
+ /**
683
+ * Get token
684
+ *
685
+ * @param string $id
686
+ * @return Mage_Core_Model_Abstract
687
+ */
688
+ public function getToken($id){
689
+ return Mage::getModel('realex/tokencard')->load($id);
690
+ }
691
+
692
+ /**
693
+ * Get customer ref
694
+ *
695
+ * @param string $id
696
+ * @return bool
697
+ */
698
+ public function getCustomerPayerRef($id){
699
+
700
+ $customer = Mage::getModel('customer/customer')->load($id);
701
+ if(!$customer->getId()){
702
+ return false;
703
+ }
704
+
705
+ return $customer->getRealexPayerRef();
706
+ }
707
+
708
+ /**
709
+ * Get Token card
710
+ *
711
+ * @param $id
712
+ * @return mixed
713
+ */
714
+ public function getTokenCardType($id){
715
+ return Mage::getModel('realex/tokencard')->load($id)->getCardType();
716
+ }
717
+
718
+ /**
719
+ * Check if token exist
720
+ *
721
+ * @param Mage_Customer_Model_Customer $customer
722
+ * @param $payment
723
+ * @param $ccnumber
724
+ * @return bool
725
+ */
726
+ public function tokenExist($customer,$payment,$ccnumber){
727
+
728
+ $cards = Mage::getModel('realex/realex_source_cards');
729
+ $tokens = Mage::getModel('realex/tokencard')->getCollection()
730
+ ->addDuplicateFilter(
731
+ $customer->getId(),
732
+ substr(($ccnumber?$ccnumber:$payment->getCcNumber()), -4),
733
+ $cards->getGatewayCardType($payment->getCcType()),
734
+ $this->getCreditCardDate($payment)
735
+ )
736
+ ->load();
737
+ if($tokens->count() > 0){
738
+ return true;
739
+ }
740
+
741
+ return false;
742
+ }
743
+
744
+ /**
745
+ * Split credit card date
746
+ *
747
+ * @param Varien_Object $payment
748
+ * @return string
749
+ */
750
+ public function getCreditCardDate(Varien_Object $payment)
751
+ {
752
+ $month = $payment->getCcExpMonth();
753
+ $year = $payment->getCcExpYear();
754
+
755
+ if (!$month || !$year) {
756
+ return '';
757
+ }
758
+
759
+ $month = str_pad($month, 2, '0', STR_PAD_LEFT);
760
+ $year = substr($year, -2, 2);
761
+
762
+ return $month . $year;
763
+ }
764
+
765
+ /**
766
+ * Genrate timestamp
767
+ *
768
+ * @return bool|mixed|string
769
+ */
770
+ public function getTimestamp()
771
+ {
772
+ $timestamp = Mage::registry(self::REGISTRY_KEY_CURRENT_TIMESTAMP);
773
+
774
+ if (is_null($timestamp)) {
775
+ $timestamp = date('YmdHis');
776
+ Mage::register(self::REGISTRY_KEY_CURRENT_TIMESTAMP, $timestamp);
777
+ }
778
+
779
+ return $timestamp;
780
+ }
781
+
782
+ /**
783
+ * Generate sha1hash
784
+ *
785
+ * @param string $secret
786
+ * @param null $args
787
+ * @return string
788
+ */
789
+ public function generateSha1Hash($secret, $args = null)
790
+ {
791
+
792
+ $secret = Mage::helper('core')->decrypt($secret);
793
+ $hash = sha1(implode('.', $args));
794
+ $hash = sha1("{$hash}.{$secret}");
795
+
796
+ return $hash;
797
+ }
798
+
799
+ /**
800
+ * Get number of cards
801
+ *
802
+ * @return int
803
+ */
804
+ public function getMaxSavedCards(){
805
+ $default = 3;
806
+
807
+ $maxCards = $this->getConfigData('realvault','max_saved');
808
+ if(is_int((int)$maxCards)){
809
+ return (int)$maxCards;
810
+ }
811
+ return $default;
812
+ }
813
+
814
+ /**
815
+ * Check if can add card
816
+ *
817
+ * @param int $cardCount
818
+ * @return bool
819
+ */
820
+ public function canAddCard($cardCount){
821
+ if($cardCount < $this->getMaxSavedCards()){
822
+ return true;
823
+ }
824
+ return false;
825
+ }
826
+
827
+ /**
828
+ * Return token data as array
829
+ *
830
+ * @param int $cardId
831
+ * @return array
832
+ */
833
+ public function getTokenAsArray($cardId) {
834
+
835
+ $card = Mage::getModel('realex/tokencard')->load($cardId);
836
+
837
+ $_rest = array();
838
+
839
+ if ($card->getId()) {
840
+ $_rest[Mage::helper('realex')->__('Credit Card Type')] = $card->getMagentoCardType();
841
+ $_rest[Mage::helper('realex')->__('Credit Card Number')] = sprintf('xxxx-%s', $card->getLastFour());
842
+ }
843
+
844
+ return $_rest;
845
+ }
846
+
847
+ /**
848
+ * Get token payment code
849
+ *
850
+ * @param string $cardId
851
+ * @return bool
852
+ */
853
+ public function getTokenPaymentCode($cardId) {
854
+
855
+ $card = Mage::getModel('realex/tokencard')->load($cardId);
856
+
857
+ if ($card->getId()) {
858
+ return $card->getPaymentCode();
859
+ }
860
+
861
+ return false;
862
+ }
863
+
864
+ /**
865
+ * Check if admin controller
866
+ *
867
+ * @return bool
868
+ */
869
+ public function updateAdminCard() {
870
+
871
+ $controllerName = Mage::app()->getRequest()->getControllerName();
872
+ return ($controllerName == 'adminhtml_tokencard');
873
+
874
+ }
875
+
876
+ /**
877
+ * Check if real vault on hpp enabled
878
+ *
879
+ * @param bool $storeCard
880
+ * @return bool
881
+ */
882
+ public function hppChoseRealVault($storeCard = false){
883
+
884
+ if($this->storeCardOption() && !$storeCard ){
885
+ return false;
886
+ }
887
+
888
+ return true;
889
+
890
+ }
891
+
892
+ /**
893
+ * Apply conversion to string
894
+ *
895
+ * @param string $string
896
+ * @return mixed
897
+ */
898
+ public function conversion($string){
899
+
900
+ if(array_key_exists(strtolower($string),$this->_conversions)){
901
+ return $this->_conversions[strtolower($string)];
902
+ }
903
+ return $string;
904
+ }
905
+
906
+ /**
907
+ * Get magento version
908
+ *
909
+ * @return string
910
+ */
911
+ public function getVersion()
912
+ {
913
+ return (string) Mage::getConfig()->getNode()->modules->Yoma_Realex->version;
914
+ }
915
+
916
+ public function isInt($value)
917
+ {
918
+ return preg_match('/^\-*\d+$/', (string)$value) === 1;
919
+ }
920
+ }
app/code/community/Yoma/Realex/Helper/Direct.php ADDED
@@ -0,0 +1,93 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Helper_Direct extends Yoma_Realex_Helper_Data{
21
+
22
+ /**
23
+ * Create new string
24
+ *
25
+ * @param string $prefix
26
+ * @return string
27
+ */
28
+ public function generateUniqueString($prefix)
29
+ {
30
+ return $prefix . '-' . time();
31
+ }
32
+
33
+ protected $_DataWhitelist = array(
34
+ 'amount',
35
+ 'auth_code',
36
+ 'auth_pasref',
37
+ 'auth_auth_code',
38
+ 'card_expiry',
39
+ 'card_name',
40
+ 'card_number',
41
+ 'card_type',
42
+ 'card_type',
43
+ 'currency',
44
+ 'multisettle',
45
+ 'pasref',
46
+ 'payer_reference',
47
+ 'payment_method_reference',
48
+ 'sub_account',
49
+ 'unique_order_id',
50
+ 'order_id',
51
+ 'auto_settle_flag',
52
+ 'cust_num',
53
+ 'authcode',
54
+ 'account',
55
+ );
56
+
57
+ /**
58
+ * Filter data from array based upon list
59
+ *
60
+ * @param array $data
61
+ * @param bool $customWhitelist
62
+ * @return mixed
63
+ */
64
+ public function filterData($data, $customWhitelist = false)
65
+ {
66
+ $whitelist = $this->_DataWhitelist;
67
+ if ($customWhitelist != false) {
68
+ $whitelist = $customWhitelist;
69
+ }
70
+
71
+ foreach ($data as $_key => $_value) {
72
+ if (!in_array(strtolower($_key), $whitelist)) {
73
+ unset($data[$_key]);
74
+ }
75
+ }
76
+
77
+ return $data;
78
+ }
79
+
80
+ /**
81
+ * Create credit name
82
+ *
83
+ * @param Varien_Object $payment
84
+ * @return string
85
+ */
86
+ public function getCreditCardName(Varien_Object $payment)
87
+ {
88
+ $billingAddress = $payment->getOrder()->getBillingAddress();
89
+ return $this->ss($billingAddress->getFirstname() . ' ' . $billingAddress->getLastname(),100);
90
+ }
91
+
92
+
93
+ }
app/code/community/Yoma/Realex/Helper/Redirect.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Helper_Redirect extends Yoma_Realex_Helper_Data{
21
+
22
+ const REGISTRY_KEY_CURRENT_TIMESTAMP = 'yoma_realex_current_timestamp';
23
+
24
+ /**
25
+ * Generate sha1hash
26
+ *
27
+ * @param string $secret
28
+ * @param null $args
29
+ * @return string
30
+ */
31
+ public function generateSha1Hash($secret, $args = null)
32
+ {
33
+ $secret = Mage::helper('core')->decrypt($secret);
34
+ $hash = sha1(implode('.', $args));
35
+ $hash = sha1("{$hash}.{$secret}");
36
+
37
+ return $hash;
38
+ }
39
+
40
+ /**
41
+ * Create timestamp
42
+ *
43
+ * @return bool|mixed|string
44
+ */
45
+ public function getTimestamp()
46
+ {
47
+ $timestamp = Mage::registry(self::REGISTRY_KEY_CURRENT_TIMESTAMP);
48
+
49
+ if (is_null($timestamp)) {
50
+ $timestamp = date('YmdHis');
51
+ Mage::register(self::REGISTRY_KEY_CURRENT_TIMESTAMP, $timestamp);
52
+ }
53
+
54
+ return $timestamp;
55
+ }
56
+
57
+ /**
58
+ * Generate unique string
59
+ *
60
+ * @param $prefix
61
+ * @return string
62
+ */
63
+ public function generateUniqueString($prefix)
64
+ {
65
+ return $prefix . '-' . time();
66
+ }
67
+
68
+ protected $_DataWhitelist = array(
69
+ 'amount',
70
+ 'auth_code',
71
+ 'auth_pasref',
72
+ 'auth_auth_code',
73
+ 'card_expiry',
74
+ 'card_name',
75
+ 'card_number',
76
+ 'card_type',
77
+ 'card_type',
78
+ 'currency',
79
+ 'multisettle',
80
+ 'pasref',
81
+ 'payer_reference',
82
+ 'payment_method_reference',
83
+ 'sub_account',
84
+ 'unique_order_id',
85
+ 'order_id',
86
+ 'auto_settle_flag',
87
+ 'cust_num',
88
+ 'authcode',
89
+ 'account',
90
+ );
91
+
92
+ /**
93
+ * Filter data by list
94
+ *
95
+ * @param array $data
96
+ * @param bool $customWhitelist
97
+ * @return mixed
98
+ *
99
+ */
100
+ public function filterData($data, $customWhitelist = false)
101
+ {
102
+ $whitelist = $this->_DataWhitelist;
103
+ if ($customWhitelist != false) {
104
+ $whitelist = $customWhitelist;
105
+ }
106
+
107
+ foreach ($data as $_key => $_value) {
108
+ if (!in_array(strtolower($_key), $whitelist)) {
109
+ unset($data[$_key]);
110
+ }
111
+ }
112
+
113
+ return $data;
114
+ }
115
+ }
app/code/community/Yoma/Realex/Model/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/Model/Api/Payment.php ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Yoma_Realex_Model_Api_Payment extends Mage_Payment_Model_Method_Cc {
22
+
23
+ protected $_isGateway = true;
24
+ protected $_canOrder = false;
25
+ protected $_canAuthorize = false;
26
+ protected $_canCapture = false;
27
+ protected $_canCapturePartial = false;
28
+ protected $_canRefund = false;
29
+ protected $_canRefundInvoicePartial = false;
30
+ protected $_canVoid = false;
31
+ protected $_canUseInternal = false;
32
+ protected $_canUseCheckout = true;
33
+ protected $_canUseForMultishipping = false;
34
+ protected $_isInitializeNeeded = false;
35
+ protected $_canFetchTransactionInfo = false;
36
+ protected $_canReviewPayment = true;
37
+ protected $_canCreateBillingAgreement = false;
38
+ protected $_canManageRecurringProfiles = false;
39
+ protected $_canCancelInvoice = false;
40
+ protected $_canSaveCc = false;
41
+ protected $_isCcTypeRequired = false;
42
+ protected $_canCallbackAccessSession = false;
43
+
44
+ /**
45
+ * Fields that should be replaced in debug with '***'
46
+ *
47
+ * @var array
48
+ */
49
+ protected $_debugReplacePrivateDataKeys = array(
50
+ 'sha1hash', 'SHA1HASH','md5hash','MD5HASH','refundhash'
51
+ // 'sha1hash', 'SHA1HASH', 'card_number', 'card_cvn_number','md5hash','MD5HASH'
52
+ );
53
+
54
+ protected $_redirectUrl = NULL;
55
+
56
+ /**
57
+ * Set redirect url
58
+ *
59
+ * @param $url
60
+ */
61
+ public function setRedirectUrl($url) {
62
+
63
+ $this->_redirectUrl = $url;
64
+ }
65
+
66
+ /**
67
+ * Cancel payment method calls service method
68
+ *
69
+ * @param Varien_Object $payment
70
+ * @param float $amount
71
+ *
72
+ */
73
+ public function cancel(Varien_Object $payment) {
74
+
75
+ parent::void($payment);
76
+ $this->getService()->void($payment);
77
+
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Retrieve current service model
83
+ *
84
+ * @return Yoma_Realex_Model_Service_Absract
85
+ *
86
+ */
87
+ public function getService() {
88
+ if (is_null($this->_service)) {
89
+ $this->_service = $this->_getService();
90
+ $this->_service->setMethodInstance($this);
91
+ }
92
+
93
+ return $this->_service;
94
+ }
95
+
96
+ /**
97
+ * Authorize payment method calls service method
98
+ *
99
+ * @param Varien_Object $payment
100
+ * @param float $amount
101
+ *
102
+ */
103
+ public function authorize(Varien_Object $payment, $amount) {
104
+ parent::authorize($payment, $amount);
105
+ $this->getService()->authorize($payment, $amount);
106
+
107
+ return $this;
108
+ }
109
+
110
+ /**
111
+ * Capture payment method calls service method
112
+ *
113
+ * @param Varien_Object $payment
114
+ * @param float $amount
115
+ *
116
+ */
117
+ public function capture(Varien_Object $payment, $amount) {
118
+ parent::capture($payment, $amount);
119
+ $this->getService()->capture($payment, $amount);
120
+
121
+ return $this;
122
+ }
123
+
124
+ /**
125
+ * Refund payment method calls service method
126
+ *
127
+ * @param Varien_Object $payment
128
+ * @param float $amount
129
+ *
130
+ */
131
+ public function refund(Varien_Object $payment, $amount) {
132
+ parent::refund($payment, $amount);
133
+ $this->getService()->refund($payment, $amount);
134
+
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Void payment method calls service method
140
+ *
141
+ * @param Varien_Object $payment
142
+ *
143
+ */
144
+ public function void(Varien_Object $payment) {
145
+ parent::void($payment);
146
+ $this->getService()->void($payment);
147
+
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Assign card data
153
+ *
154
+ * @param mixed $data
155
+ * @return $this|Mage_Payment_Model_Info
156
+ */
157
+ public function assignData($data) {
158
+ if (!($data instanceof Varien_Object)) {
159
+ $data = new Varien_Object($data);
160
+ }
161
+ $info = $this->getInfoInstance();
162
+
163
+ // Check to see if we need to tokenize card
164
+ $info->setRemembertoken((!is_null($data->getRemembertoken()) ? 1 : 0));
165
+
166
+ // if set save token cvv to session
167
+ if (!is_null($data->getTokenCvv())) {
168
+ $this->getRealexSession()->setTokenCvv($data->getTokenCvv());
169
+ }
170
+
171
+ $info->setCcType($data->getCcType())
172
+ ->setCcOwner($data->getCcOwner())
173
+ ->setCcLast4(substr($data->getCcNumber(), -4))
174
+ ->setCcNumber($data->getCcNumber())
175
+ ->setCcCid($data->getCcCid())
176
+ ->setCcExpMonth($data->getCcExpMonth())
177
+ ->setCcExpYear($data->getCcExpYear())
178
+ ->setCcSsIssue($data->getCcSsIssue())
179
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
180
+ ->setCcSsStartYear($data->getCcSsStartYear())
181
+ ->setRealexTokenCcId($data->getRealexTokenCcId());
182
+
183
+ return $this;
184
+ }
185
+
186
+ public function getRealexSession() {
187
+
188
+ return Mage::getSingleton('realex/session');
189
+ }
190
+
191
+ /**
192
+ * Retrieve if Card Type Required
193
+ *
194
+ * @return boolean
195
+ */
196
+ public function getIsCcTypeRequired() {
197
+ return $this->_isCcTypeRequired;
198
+ }
199
+
200
+ /**
201
+ * Retrieve redirect url
202
+ *
203
+ * @return string
204
+ */
205
+ public function getOrderPlaceRedirectUrl() {
206
+ // retrieve url from session
207
+ $url = Mage::getSingleton('customer/session')->getRedirectUrl();
208
+ Mage::getSingleton('customer/session')->setRedirectUrl(false);
209
+
210
+ return $url;
211
+
212
+ }
213
+
214
+ /**
215
+ * Add value to payment info array
216
+ *
217
+ * @param mixed $key
218
+ * @param string $value
219
+ * @return Yoma_Realex_Model_Api_Payment
220
+ */
221
+ public function addPaymentInfo($key, $value = '') {
222
+ if (is_array($key)) {
223
+ $this->_paymentInfo = array_merge($this->_paymentInfo, $key);
224
+ } else {
225
+ $this->_paymentInfo[$key] = $value;
226
+ }
227
+
228
+ return $this;
229
+ }
230
+
231
+ /**
232
+ * Format date
233
+ *
234
+ * @param string $format
235
+ * @return string
236
+ */
237
+ public function getDate($format = 'Y-m-d H:i:s') {
238
+ return Mage::getModel('core/date')->date($format);
239
+ }
240
+
241
+ /**
242
+ * Retrieve email address of logged in customer
243
+ *
244
+ * @return null
245
+ */
246
+ public function getCustomerLoggedEmail() {
247
+
248
+ $s = Mage::getSingleton('customer/session');
249
+ if ($s->getCustomerId()) {
250
+ return $s->getCustomer()->getEmail();
251
+ }
252
+
253
+ return NULL;
254
+ }
255
+
256
+ /**
257
+ * Set method code
258
+ *
259
+ * @param string $code
260
+ * @return Yoma_Realex_Model_Api_Payment
261
+ */
262
+ public function setMcode($code) {
263
+
264
+ $this->_code = $code;
265
+
266
+ return $this;
267
+ }
268
+
269
+ /**
270
+ * Retrieve client IP Address
271
+ *
272
+ * @return string
273
+ */
274
+ public function getClientIp() {
275
+
276
+ return Mage::helper('core/http')->getRemoteAddr();
277
+ }
278
+
279
+ /**
280
+ * Check if checkout multi shipping and current step overview
281
+ *
282
+ * @return bool
283
+ */
284
+ public function isMsOnOverview() {
285
+
286
+ return ($this->_getQuote()->getIsMultiShipping() && $this->getMsActiveStep() == 'multishipping_overview');
287
+ }
288
+
289
+ /**
290
+ * Retrieve Quote from session
291
+ *
292
+ * @return Mage_Sales_Model_Quote
293
+ */
294
+ protected function _getQuote() {
295
+
296
+ return Mage::getSingleton('checkout/type_onepage')->getQuote();
297
+ }
298
+
299
+ /**
300
+ * Retieve active multiShipping checkout step
301
+ *
302
+ * @return mixed
303
+ */
304
+ public function getMsActiveStep() {
305
+
306
+ return Mage::getSingleton('checkout/type_multishipping_state')->getActiveStep();
307
+ }
308
+
309
+ /**
310
+ * Get config payment action url
311
+ * Used to universalize payment actions when processing payment place
312
+ *
313
+ * @return string
314
+ */
315
+ public function getConfigPaymentAction() {
316
+ $transport = new varien_object();
317
+ $transport->setPaymentAction($this->getConfigData('payment_action'));
318
+ Mage::dispatchEvent('realex_config_payment_action', array('payment' => $this, 'transport' => $transport));
319
+
320
+ return $transport->getPaymentAction();
321
+
322
+ }
323
+
324
+ public function getQuote() {
325
+
326
+ return $this->_getQuote();
327
+ }
328
+
329
+ public function getDebugFlag() {
330
+ return true;
331
+ }
332
+
333
+ /**
334
+ * Log data to file
335
+ *
336
+ * @param mixed $debugData
337
+ */
338
+ protected function _debug($debugData) {
339
+ $logFile = 'payment_' . $this->getCode() . '.log';
340
+ // if live filter data
341
+ if ($this->_getHelper()->getConfigData($this->getCode(), 'mode') == 'live') {
342
+ $debugData = $this->_filterDebugData($debugData);
343
+ }
344
+ Realex_Log::log($debugData, NULL, $logFile);
345
+ }
346
+
347
+ /**
348
+ * Obfuscate data
349
+ *
350
+ * @param array $debugData
351
+ * @return array
352
+ */
353
+ protected function _filterDebugData($debugData) {
354
+
355
+ if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) {
356
+ foreach ($debugData as $key => $value) {
357
+ if (in_array($key, $this->_debugReplacePrivateDataKeys)) {
358
+ $temp = NULL;
359
+ for ($i = 0; $i < strlen($debugData[$key]); $i++) {
360
+ $temp .= '*';
361
+ }
362
+ $debugData[$key] = $temp;
363
+ } else {
364
+ if (is_array($debugData[$key])) {
365
+ $debugData[$key] = $this->_filterDebugData($debugData[$key]);
366
+ }
367
+ }
368
+ }
369
+ }
370
+
371
+ return $debugData;
372
+ }
373
+
374
+ /**
375
+ * Set current response object
376
+ *
377
+ * @param Yoma_Realex_Model_Response_Abstract $response
378
+ * @return $this|Yoma_Realex_Model_Response_Abstract
379
+ */
380
+ protected function _setResponse($response) {
381
+ $this->_response = $response;
382
+
383
+ return $this;
384
+ }
385
+
386
+ /**
387
+ * Retrieve response object
388
+ *
389
+ * @return Yoma_Realex_Model_Response_Abstract
390
+ */
391
+ protected function _getResponse() {
392
+ return $this->_response;
393
+ }
394
+
395
+ /**
396
+ * @return false|Mage_Core_Model_Abstract
397
+ */
398
+ protected function _getCoreUrl() {
399
+ return Mage::getModel('core/url');
400
+ }
401
+
402
+ /**
403
+ * @return Mage_Core_Helper_Abstract
404
+ */
405
+ protected function _getCoreHelper() {
406
+
407
+ return Mage::helper('core');
408
+ }
409
+
410
+ /**
411
+ * @return Mage_Core_Helper_Abstract
412
+ */
413
+ protected function realexHelper() {
414
+
415
+ return Mage::helper('realex');
416
+ }
417
+
418
+ /**
419
+ * @param Varien_Object $payment
420
+ * @return $this
421
+ */
422
+ protected function _setPayment(Varien_Object $payment) {
423
+ $this->_payment = $payment;
424
+
425
+ return $this;
426
+ }
427
+
428
+ protected function _getPayment() {
429
+ return $this->_payment;
430
+ }
431
+
432
+ /**
433
+ * @param Varien_Object $order
434
+ * @return $this
435
+ */
436
+ protected function _setOrder(Varien_Object $order) {
437
+ $this->_order = $order;
438
+
439
+ return $this;
440
+ }
441
+
442
+ protected function _getOrder() {
443
+ return $this->_order;
444
+ }
445
+
446
+ /**
447
+ * @param Yoma_Realex_Model_Transaction $transaction
448
+ * @return $this
449
+ */
450
+ protected function _setTransaction(Yoma_Realex_Model_Transaction $transaction) {
451
+ $this->_transaction = $transaction;
452
+
453
+ return $this;
454
+ }
455
+
456
+ protected function _getTransaction() {
457
+ return $this->_transaction;
458
+ }
459
+
460
+ protected function _setTransactionReference($transactionReference) {
461
+ $this->_transactionReference = $transactionReference;
462
+ Mage::register('transaction_reference', $transactionReference);
463
+
464
+ return $this;
465
+ }
466
+
467
+ protected function _getTransactionReference() {
468
+ if ($this->_transactionReference == '') {
469
+ throw new Exception('Transaction reference not set.');
470
+ }
471
+
472
+ return $this->_transactionReference;
473
+ }
474
+ }
app/code/community/Yoma/Realex/Model/Direct.php ADDED
@@ -0,0 +1,296 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Direct extends Yoma_Realex_Model_Api_Payment{
21
+
22
+ /**
23
+ * Constant payment method code
24
+ */
25
+ const PAYMENT_METHOD_CODE = 'realexdirect';
26
+
27
+ /**
28
+ * Magento payment code.
29
+ *
30
+ * @var string $_code
31
+ */
32
+ protected $_code = self::PAYMENT_METHOD_CODE;
33
+ protected $_infoBlockType = 'realex/info_direct';
34
+ protected $_formBlockType = 'realex/form_direct';
35
+
36
+ protected $_isGateway = true;
37
+ protected $_canAuthorize = true;
38
+ protected $_canCapture = true;
39
+ protected $_canCapturePartial = false;
40
+ protected $_canReviewPayment = true;
41
+ protected $_canRefund = true;
42
+ protected $_canRefundInvoicePartial = true;
43
+ protected $_canUseInternal = false;
44
+ protected $_canUseForMultishipping = true;
45
+ protected $_isCcTypeRequired = true;
46
+ protected $_canVoid = true;
47
+ protected $_canOrder = false;
48
+ protected $_canUseCheckout = true;
49
+ protected $_isInitializeNeeded = false;
50
+ protected $_canFetchTransactionInfo = false;
51
+ protected $_canCreateBillingAgreement = false;
52
+ protected $_canManageRecurringProfiles = false;
53
+ protected $_canCancelInvoice = false;
54
+ protected $_canSaveCc = false;
55
+
56
+ protected $_canCallbackAccessSession = false;
57
+
58
+ protected $_realexCustomCcNumberRegex = array(
59
+ 'YOMA_DINERS_CLUB' => false,
60
+ 'YOMA_MAESTRO' => false,
61
+ );
62
+
63
+ protected $_realexCustomCsvRegex = array(
64
+ 'YOMA_DINERS_CLUB' => '/^([0-9]{3}|[0-9]{4})?$/',
65
+ 'YOMA_MAESTRO'=> '/^([0-9]{3})?$/',
66
+ );
67
+
68
+ /**
69
+ * @TOD0 check if issue with OSC
70
+ */
71
+ protected function _getService()
72
+ {
73
+ $info = $this->getInfoInstance();
74
+ if($info->getRealexTokenCcId()){
75
+ return Mage::getModel('realex/service_token');
76
+ }
77
+ return Mage::getModel('realex/service_direct');
78
+ }
79
+
80
+ /**
81
+ * @TOD0 check validity
82
+ */
83
+ protected function _registerTransaction(){
84
+
85
+ $this->_saveTransaction();
86
+
87
+ $this->_getPayment()->setIsTransactionPending(true);
88
+
89
+ }
90
+
91
+ /**
92
+ * Validate card info
93
+ *
94
+ * @return $this|Mage_Payment_Model_Abstract
95
+ * @throws Mage_Core_Exception
96
+ */
97
+ public function validate()
98
+ {
99
+ $info = $this->getInfoInstance();
100
+
101
+ if($info->getRealexTokenCcId()){
102
+ return $this;
103
+ }
104
+
105
+ if (!array_key_exists($info->getCcType(), $this->_realexCustomCcNumberRegex)) {
106
+ return parent::validate();
107
+ }
108
+
109
+ $ccNumber = preg_replace('/[\-\s]+/', '', $info->getCcNumber());
110
+ $info->setCcNumber($ccNumber);
111
+
112
+ $ccTypeRegExp = $this->_realexCustomCcNumberRegex[$info->getCcType()];
113
+ if ($ccTypeRegExp && (!$ccNumber || !preg_match($ccTypeRegExp, $ccNumber))) {
114
+ Mage::throwException($this->_getHelper()->__('Credit card number mismatch with credit card type.'));
115
+ }
116
+
117
+
118
+ if ($this->hasVerification() && array_key_exists($info->getCcType(), $this->_realexCustomCsvRegex)) {
119
+ $verifcationRegEx = $this->_realexCustomCsvRegex[$info->getCcType()];
120
+ if (!$info->getCcCid() || !preg_match($verifcationRegEx, $info->getCcCid())) {
121
+ Mage::throwException($this->_getHelper()->__('Please enter a valid credit card verification number.'));
122
+ }
123
+ }
124
+
125
+ if (!$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
126
+ Mage::throwException($this->_getHelper()->__('Incorrect credit card expiration date.'));
127
+ }
128
+
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Accept payment
134
+ *
135
+ * @param Mage_Payment_Model_Info $payment
136
+ * @return bool
137
+ * @throws Exception
138
+ * @throws Mage_Core_Exception
139
+ */
140
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
141
+ {
142
+ if (method_exists(get_parent_class(), 'acceptPayment')) {
143
+ parent::acceptPayment($payment);
144
+ } else {
145
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
146
+ Mage::throwException(Mage::helper('realex')
147
+ ->__('The payment review action is unavailable.'));
148
+ }
149
+ }
150
+
151
+ if (true !== $payment->getData('payment_accept')) {
152
+ Mage::throwException('Online payments cannot be accepted manually.');
153
+ }
154
+
155
+ $requiredState = 'payment_review';
156
+
157
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
158
+ $comment = $payment->getOrder()->addStatusHistoryComment('An attempt was made to accept this payment.');
159
+ $comment->save();
160
+
161
+ throw new Exception('Only orders with status Payment Review can be accepted');
162
+ }
163
+
164
+ return true;
165
+ }
166
+
167
+ /**
168
+ * Deny payment
169
+ *
170
+ * @param Mage_Payment_Model_Info $payment
171
+ * @return bool
172
+ * @throws Exception
173
+ * @throws Mage_Core_Exception
174
+ */
175
+ public function denyPayment(Mage_Payment_Model_Info $payment)
176
+ {
177
+ if (method_exists(get_parent_class(), 'denyPayment')) {
178
+ parent::denyPayment($payment);
179
+ } else {
180
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
181
+ Mage::throwException(Mage::helper('realex')
182
+ ->__('The payment review action is unavailable.'));
183
+ }
184
+ }
185
+
186
+ $requiredState = 'payment_review';
187
+
188
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
189
+ $comment = $payment->getOrder()->addStatusHistoryComment('Warning: An attempt was made to deny this payment.');
190
+ $comment->save();
191
+
192
+ throw new Exception("Only orders with status '{$requiredState}' can be denied online.");
193
+ }
194
+
195
+ return true;
196
+ }
197
+
198
+ /**
199
+ * Retrieve if available for quote
200
+ *
201
+ * @param null $quote
202
+ * @return bool
203
+ */
204
+ public function isAvailable($quote = null) {
205
+ return Mage_Payment_Model_Method_Abstract::isAvailable($quote);
206
+ }
207
+
208
+ /**
209
+ * Assign data to payment model
210
+ *
211
+ * @param mixed array $data
212
+ * @return $this|Mage_Payment_Model_Info
213
+ */
214
+ public function assignData($data)
215
+ {
216
+ if (!($data instanceof Varien_Object)) {
217
+ $data = new Varien_Object($data);
218
+ }
219
+ $info = $this->getInfoInstance();
220
+
221
+ $info->setRemembertoken((!is_null($data->getRemembertoken()) ? 1 : 0));
222
+
223
+ if(!is_null($data->getTokenCvv())){
224
+ $this->getRealexSession()->setTokenCvv($data->getTokenCvv());
225
+ }
226
+
227
+ $info->setCcType($data->getCcType())
228
+ ->setCcOwner($data->getCcOwner())
229
+ ->setCcLast4(substr($data->getCcNumber(), -4))
230
+ ->setCcNumber($data->getCcNumber())
231
+ ->setCcCid($data->getCcCid())
232
+ ->setCcExpMonth($data->getCcExpMonth())
233
+ ->setCcExpYear($data->getCcExpYear())
234
+ ->setCcSsIssue($data->getCcSsIssue())
235
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
236
+ ->setCcSsStartYear($data->getCcSsStartYear())
237
+ ;
238
+ return $this;
239
+ }
240
+
241
+ /**
242
+ * @return Mage_Core_Helper_Abstract|Mage_Payment_Helper_Data
243
+ */
244
+ protected function _getHelper()
245
+ {
246
+ return Mage::helper('realex/direct');
247
+ }
248
+
249
+ /**
250
+ * Check if can void payment
251
+ *
252
+ * @param Varien_Object $payment
253
+ * @return bool
254
+ */
255
+ public function canVoid(Varien_Object $payment)
256
+ {
257
+
258
+ $order = $this->getInfoInstance()->getOrder();
259
+ // if invoiced and invoice not created today return false
260
+ if($order->getInvoiceCollection()->count()){
261
+ $date = false;
262
+ foreach($order->getInvoiceCollection() as $invoice){
263
+ if(strtotime($date) < strtotime($invoice->getCreatedAt())){
264
+ $date = $invoice->getCreatedAt();
265
+ }
266
+ }
267
+
268
+ if(strtotime($date) < strtotime('tomorrow')){
269
+ return true;
270
+ }
271
+
272
+ return false;
273
+ }
274
+
275
+ // if order has been payment review then cancelled return false
276
+ if($order->getStatusHistoryCollection()->count() == 2){
277
+
278
+ $statusHistory = $order->getStatusHistoryCollection();
279
+
280
+ $requiredState = 0;
281
+ $requiredStates = array('canceled','payment_review');
282
+
283
+ foreach($statusHistory as $status){
284
+ if(in_array($status->getStatus(),$requiredStates)){
285
+ $requiredState ++;
286
+ }
287
+ }
288
+ if($requiredState == 2){
289
+ return false;
290
+ }
291
+ }
292
+
293
+ return $this->_canVoid;
294
+ }
295
+
296
+ }
app/code/community/Yoma/Realex/Model/Exception/DenyPayment.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_DenyPayment extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/NoLiabilityShift.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_NoLiabilityShift extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/NoneParticipatingCard.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_NoneParticipatingCard extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/NotAuthenticated.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_NotAuthenticated extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/NotEnrolled.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_NotEnrolled extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/NotVerified.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_NotVerified extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/PayerNew.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_PayerNew extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/Payment.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_Payment extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Exception/ThreedSecure.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Exception_ThreedSecure extends Exception
21
+ {
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Log.php ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Log {
21
+
22
+
23
+ /**
24
+ * Alias methods
25
+ */
26
+ public static function log($message, $level = null, $file = '') {
27
+ self::write($message, $level, $file);
28
+ }
29
+
30
+ public static function logException(Exception $e) {
31
+ self::writeException($e);
32
+ }
33
+
34
+ /**
35
+ * Write exception to log
36
+ *
37
+ * @param Exception $e
38
+ */
39
+ public static function writeException(Exception $e) {
40
+ self::write("\n" . $e->__toString(), Zend_Log::ERR, 'exceptions.log');
41
+ }
42
+
43
+ /**
44
+ * Write log messages
45
+ *
46
+ * @param string $message Message to write
47
+ * @param int $level Message severity level, @see Zend_Log
48
+ * @param string $file Filename, ie: Errors.log
49
+ */
50
+ public static function write($message, $level = null, $file = '') {
51
+ try {
52
+ $logActive = Mage::getStoreConfig('payment/realex/logs');
53
+ if (empty($file)) {
54
+ $file = 'realex.log';
55
+ }
56
+ } catch (Exception $e) {
57
+ $logActive = true;
58
+ }
59
+
60
+ if (!$logActive) {
61
+ return;
62
+ }
63
+
64
+ $level = is_null($level) ? Zend_Log::DEBUG : $level;
65
+ $file = empty($file) ? 'realex.log' : self::_renameLogsFiles($file);
66
+
67
+ try {
68
+ $logFile = Mage::getBaseDir('var') . DS . 'log' . DS . 'realex' . DS . $file;
69
+
70
+ if (!is_dir(Mage::getBaseDir('var') . DS . 'log')) {
71
+ mkdir(Mage::getBaseDir('var') . DS . 'log', 0777);
72
+ }
73
+ if (!is_dir(Mage::getBaseDir('var') . DS . 'log' . DS . 'realex')) {
74
+ mkdir(Mage::getBaseDir('var') . DS . 'log' . DS . 'realex', 0777);
75
+ }
76
+
77
+ if (!file_exists($logFile)) {
78
+ file_put_contents($logFile, '');
79
+ chmod($logFile, 0777);
80
+ }
81
+
82
+ $format = Mage::getSingleton('core/date')->date('Y-m-d H:i:s.u') . ' (' . microtime(true) . ') ' . '%priorityName%: %message%' . PHP_EOL;
83
+
84
+ $formatter = new Zend_Log_Formatter_Simple($format);
85
+ $writerModel = (string) Mage::getConfig()->getNode('global/log/core/writer_model');
86
+ if (!$writerModel) {
87
+ $writer = new Zend_Log_Writer_Stream($logFile);
88
+ } else {
89
+ $writer = new $writerModel($logFile);
90
+ }
91
+ $writer->setFormatter($formatter);
92
+ $logger = new Zend_Log($writer);
93
+
94
+ if (is_array($message) || is_object($message)) {
95
+ if(is_array($message)){
96
+ if(isset($message['request']['paymentdata_cvn_number'])){
97
+ $message['request']['paymentdata_cvn_number'] = '***';
98
+ }
99
+ if(isset($message['request']['paymentdata_card_cvn_number'])){
100
+ $message['request']['paymentdata_card_cvn_number'] = '***';
101
+ }
102
+ if(isset($message['request']['card_cvn_number'])){
103
+ $message['request']['card_cvn_number'] = '***';
104
+ }
105
+ if(isset($message['request']['card_number'])){
106
+ $message['request']['card_number'] = '************' . substr($message['request']['card_number'], -4);
107
+ }
108
+ if(isset($message['response']['md'])){
109
+ $message['response']['md'] = "***";
110
+ }
111
+ if(isset($message['request']['post_md'])){
112
+ $message['request']['post_md'] = '***';
113
+ }
114
+ if(isset($message['request']['card_expdate'])){
115
+ $message['request']['card_expdate'] = '****';
116
+ }
117
+ if(isset($message['response']['saved_pmt_digits'])){
118
+ $message['response']['saved_pmt_digits'] = '************' . substr($message['response']['saved_pmt_digits'], -4);
119
+ }
120
+ if(isset($message['response']['saved_pmt_expdate'])){
121
+ $message['response']['saved_pmt_expdate'] = "***";
122
+ }
123
+ }
124
+ $message = print_r($message, true);
125
+ }
126
+
127
+ $logger->log($message, $level);
128
+
129
+ } catch (Exception $e) {
130
+
131
+ }
132
+ }
133
+
134
+ /**
135
+ * Rename log file to user friendly name
136
+ *
137
+ * @param $file
138
+ * @return mixed
139
+ */
140
+ protected static function _renameLogsFiles($file){
141
+
142
+
143
+ $logNames = array(
144
+ 'realexredirect'=>'hpp',
145
+ 'realexdirect'=>'api'
146
+ );
147
+
148
+ foreach($logNames as $key=>$value){
149
+ if(strpos($file,$key)){
150
+ $file = str_replace($key,$value,$file);
151
+ break;
152
+ }
153
+ }
154
+ return $file;
155
+ }
156
+
157
+ }
app/code/community/Yoma/Realex/Model/Message/Abstract.php ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Abstract extends Mage_Core_Model_Abstract{
21
+
22
+ protected $_node = null;
23
+ protected $_messageData;
24
+ protected $_service;
25
+
26
+ protected $_attributes = array(
27
+ 'currency' => 'amount',
28
+ 'timestamp' => 'request',
29
+ 'flag' =>'autosettle',
30
+ 'type' => 'request'
31
+ );
32
+
33
+ public function _construct(){
34
+ $this->_node = new DOMDocument;
35
+ }
36
+
37
+ /**
38
+ * Create new Dom Document
39
+ *
40
+ * @param string $xml
41
+ */
42
+ public function setNode($xml){
43
+ $this->_node = new DOMDocument;
44
+ }
45
+
46
+ /**
47
+ * Convert array to xml message
48
+ *
49
+ * @param array $data
50
+ * @return null|string
51
+ */
52
+ public function prepareMessage($data = null){
53
+
54
+ if(!$data){
55
+ $data = $this->getData();
56
+ }
57
+ $this->_prepareMessage($data,$this->_node);
58
+ $message = null;
59
+
60
+ foreach($this->_node->childNodes as $node){
61
+ $message .= $this->_node->saveXML($node);
62
+ }
63
+
64
+ $this->_messageData = $message;
65
+
66
+ return $message;
67
+ }
68
+
69
+ /**
70
+ * Return xml string
71
+ *
72
+ * @return string
73
+ */
74
+ public function getMessage(){
75
+ return $this->_messageData;
76
+ }
77
+
78
+ /**
79
+ * Construct xml from array
80
+ *
81
+ * @param array $data
82
+ * @param DOMDocument $domnode
83
+ */
84
+ protected function _prepareMessage($data, $domnode){
85
+
86
+ foreach($data as $key=>$value){
87
+ if(in_array($key,array('value','attributes'))){
88
+ if($key == 'value' ){
89
+ if(isset($data['value'])) {
90
+ $domnode->nodeValue = $data['value'];
91
+ }
92
+ unset($data[$key]);
93
+ }else{
94
+ foreach($value as $attrib=>$v ){
95
+ $domnode->setAttribute($attrib, $v);
96
+ }
97
+ unset($data[$key]);
98
+ }
99
+ }else{
100
+ if($key == 'multiple'){
101
+ foreach($value as $alias=>$element){
102
+ foreach($element as $newElement){
103
+ $node = $this->_node->createElement($alias);
104
+ $newnode = $domnode->appendChild($node);
105
+ $this->_prepareMessage( $newElement,$newnode);
106
+ }
107
+ }
108
+ }else{
109
+ $node = $this->_node->createElement($key);
110
+ $newnode = $domnode->appendChild($node);
111
+ if(is_array($value)){
112
+ $this->_prepareMessage($value,$newnode);
113
+ }
114
+ }
115
+ }
116
+ }
117
+
118
+ }
119
+
120
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/Authorize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_Authorize extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/Capture.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_Capture extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/Partial.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_Partial extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/Refund.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_Refund extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/ThreedSecure.php ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_ThreedSecure extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+
23
+ public function getTransactionData(){
24
+ $request = $this->getRequest();
25
+
26
+ $data = array(
27
+ 'account' => $request['account']['value'],
28
+ 'orderid' => $request['orderid']['value'],
29
+ 'payment_amount' => $request['amount']['value'],
30
+ 'currency' => $request['amount']['attributes']['currency'],
31
+ 'card_expiry' => $request['card']['expdate']['value'],
32
+ 'card_type' => $request['card']['type']['value'],
33
+ 'card_cvn' => $request['card']['cvn']['number']['value'],
34
+ 'card_name' => $request['card']['chname']['value'],
35
+ );
36
+
37
+
38
+ return $data;
39
+ }
40
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/ThreedSecureVerify.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_ThreedSecureVerify extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+
23
+ public function getTransactionData(){
24
+ $request = $this->getRequest();
25
+
26
+ $data = array(
27
+ 'orderid' => $request['orderid']['value'],
28
+ 'payment_amount' => $request['amount']['value'],
29
+ 'currency' => $request['amount']['attributes']['currency'],
30
+ 'card_expiry' => $request['card']['expdate']['value'],
31
+ 'card_type' => $request['card']['type']['value'],
32
+ 'card_cvn' => $request['card']['cvn']['number']['value'],
33
+ 'card_name' => $request['card']['chname']['value'],
34
+ );
35
+
36
+ return $data;
37
+ }
38
+ }
app/code/community/Yoma/Realex/Model/Message/Direct/Void.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Direct_Void extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/Authorize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_Authorize extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/Capture.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_Capture extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/EditPayer.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_EditPayer extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/Partial.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_Partial extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/Refund.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_Refund extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Redirect/Void.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Redirect_Void extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Authorize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Authorize extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Capture.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Capture extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Delete.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Delete extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/EditPayer.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_EditPayer extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/EditToken.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_EditToken extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Partial.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Partial extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/PayerNew.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_PayerNew extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Refund.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Refund extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Message/Token/RegisterToken.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_RegisterToken extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ public function getTransactionData(){
23
+ $request = $this->getRequest();
24
+
25
+ $data = array(
26
+ 'orderid' => $request['orderid']['value'],
27
+ 'payer_ref' => $request['card']['payerref']['value'],
28
+ 'token_ref' => $request['card']['ref']['value'],
29
+ 'card_expiry' => $request['card']['expdate']['value'],
30
+ 'card_type' => $request['card']['type']['value'],
31
+ 'card_number' => $request['card']['number']['value'],
32
+ 'card_name' => $request['card']['chname']['value'],
33
+ );
34
+
35
+
36
+ return $data;
37
+ }
38
+ }
app/code/community/Yoma/Realex/Model/Message/Token/ThreedSecure.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_ThreedSecure extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+
23
+ public function getTransactionData(){
24
+ $request = $this->getRequest();
25
+
26
+ $data = array(
27
+ 'account' => $request['account']['value'],
28
+ 'orderid' => $request['orderid']['value'],
29
+ 'payment_amount' => $request['amount']['value'],
30
+ 'currency' => $request['amount']['attributes']['currency'],
31
+ 'card_ref' => $request['paymentmethod']['value'],
32
+ 'payer_ref' => $request['payerref']['value'],
33
+ );
34
+
35
+
36
+ return $data;
37
+ }
38
+ }
app/code/community/Yoma/Realex/Model/Message/Token/ThreedSecureVerify.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_ThreedSecureVerify extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+
23
+ public function getTransactionData(){
24
+ $request = $this->getRequest();
25
+
26
+ $data = array(
27
+ 'orderid' => $request['orderid']['value'],
28
+ 'payment_amount' => $request['amount']['value'],
29
+ 'currency' => $request['amount']['attributes']['currency'],
30
+ 'card_expiry' => $request['card']['expdate']['value'],
31
+ 'card_type' => $request['card']['type']['value'],
32
+ 'card_cvn' => $request['card']['cvn']['number']['value'],
33
+ 'card_name' => $request['card']['chname']['value'],
34
+ );
35
+
36
+ return $data;
37
+ }
38
+ }
app/code/community/Yoma/Realex/Model/Message/Token/Void.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Token_Void extends Yoma_Realex_Model_Message_Abstract{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Observer.php ADDED
@@ -0,0 +1,165 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Observer{
21
+
22
+ protected $_paymentMethods = array('realexdirect','realvault','realexredirect');
23
+
24
+ /**
25
+ * Append payment block to sales order
26
+ *
27
+ * @param Varien_Event_Observer $observer
28
+ */
29
+ public function appendPaymentBlock(Varien_Event_Observer $observer)
30
+ {
31
+ $block = $observer->getEvent()->getBlock();
32
+ $payment = $observer->getEvent()->getPayment();
33
+
34
+ $blockType = 'core/template';
35
+ if ($layout = Mage::helper('payment')->getLayout()) {
36
+ $paymentInfoBlock = $layout->createBlock($blockType);
37
+ }
38
+ else {
39
+ $className = Mage::getConfig()->getBlockClassName($blockType);
40
+ $paymentInfoBlock = new $className;
41
+ }
42
+
43
+ $paymentData = Mage::getModel('realex/paymentInfo')
44
+ ->getDataPairs($payment->getId());
45
+
46
+ if(Mage::getConfig()->getModuleConfig('Yoma_RealexExtended')->is('active', 'true')){
47
+ $observer = mage::getModel('realexExtended/observer');
48
+ if(isset($observer)){
49
+ $paymentData = $observer->appendRuleInfoPaymentBlock($payment,$paymentData);
50
+ }
51
+ }
52
+
53
+ $paymentInfoBlock
54
+ ->setPayment($payment)
55
+ ->setPaymentInfo($paymentData)
56
+ ->setTemplate('realex/payment/info/payment-info.phtml');
57
+
58
+ $block->append($paymentInfoBlock);
59
+ }
60
+
61
+ public function appendSettleAmount(Varien_Event_Observer $observer){
62
+
63
+ }
64
+
65
+ /**
66
+ * Save failed transaction data
67
+ *
68
+ * @param Varien_Event_Observer $observer
69
+ * @return $this
70
+ */
71
+ public function quoteSubmitFailure(Varien_Event_Observer $observer){
72
+
73
+ $order = $observer->getOrder();
74
+ $payment = $order->getPayment();
75
+ if(in_array($payment->getMethod(),$this->_paymentMethods)){
76
+ $info = $payment->getMethodInstance();
77
+ if($info && $info->getService()){
78
+
79
+ $service = $info->getService();
80
+
81
+ $transactionData = $service->getMethod()->getTransactionData();
82
+ $transaction = Mage::getModel('realex/transaction')
83
+ ->setData(array(
84
+ 'service_code' => $service->getMethodInstance()->getCode(),
85
+ 'transaction_reference' => $service->getTransactionReference(),
86
+ 'payment_id' => $payment->getId(),
87
+ 'order_id' => $order->getIncrementId(),
88
+ 'transaction_type' => $service->getTransactionType(),
89
+ 'additional_information' => $transactionData,
90
+ 'payment_amount' => $payment->getData('payment_amount'),
91
+ 'remembertoken' => $payment->getData('remembertoken'),
92
+ 'error_message' => $transactionData['message'],
93
+ ));
94
+
95
+ $transaction->save();
96
+
97
+ }
98
+ }
99
+
100
+ return $this;
101
+ }
102
+
103
+ /**
104
+ * Add canel to payment review
105
+ *
106
+ * @param Varien_Event_Observer $event
107
+ * @return $this
108
+ */
109
+ public function orderViewBefore(Varien_Event_Observer $event){
110
+
111
+ $block = $event->getBlock();
112
+
113
+ if ($block instanceof Mage_Adminhtml_Block_Sales_Order_View) {
114
+
115
+ $order = $block->getOrder();
116
+ if ($this->_isAllowedAction('cancel') && $order->canCancel()) {
117
+ return $this;
118
+ }else{
119
+ if(in_array($order->getPayment()->getMethod(),$this->_paymentMethods) && $this->_canNotVoidOrder($order)){
120
+ $lastUpdated = date('Y-m-d H:i:s', strtotime("-1 hours"));
121
+ if($order->getUpdatedAt() <= $lastUpdated){
122
+
123
+ $block->removeButton('accept_payment');
124
+ $block->removeButton('deny_payment');
125
+
126
+ $message = Mage::helper('realex')->__('Are you sure you want to do this?');
127
+ $block->addButton('order_cancel', array(
128
+ 'label' => Mage::helper('sales')->__('Cancel'),
129
+ 'onclick' => 'deleteConfirm(\''.$message.'\', \'' . $block->getReviewPaymentUrl('deny') . '\')',
130
+ ));
131
+ }
132
+ }
133
+ }
134
+
135
+ }
136
+
137
+ return $this;
138
+ }
139
+
140
+ /**
141
+ * Check if allowed order action
142
+ *
143
+ * @param string $action
144
+ * @return mixed
145
+ */
146
+ protected function _isAllowedAction($action)
147
+ {
148
+ return Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/' . $action);
149
+ }
150
+
151
+ /**
152
+ * Check if can void order
153
+ *
154
+ * @param Mage_Sales_Model_Order$order
155
+ * @return bool
156
+ */
157
+ protected function _canNotVoidOrder($order)
158
+ {
159
+ if ($order->canUnhold() || $order->isPaymentReview()) {
160
+ return true;
161
+ }
162
+ return false;
163
+ }
164
+
165
+ }
app/code/community/Yoma/Realex/Model/Observer/Cron.php ADDED
@@ -0,0 +1,78 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Observer_Cron {
21
+
22
+ public function orderCleanup() {
23
+
24
+ $paymentMethods = array('realexdirect','realexredirect','realvault');
25
+
26
+ if (!Mage::getStoreConfig('payment/cleanup/cleanup_active')) {
27
+ return;
28
+ }
29
+
30
+ $hours = Mage::getStoreConfig('payment/cleanup/cleanup_timeframe');
31
+
32
+ if (!Mage::helper('realex')->isInt($hours) || $hours < 1) {
33
+ Mage::throwException(
34
+ 'A value must be provided for the age, in hours, of orders to cancel.'
35
+ );
36
+ }
37
+
38
+ $reviewState = 'payment_review';
39
+
40
+ $lastUpdated = date('Y-m-d H:i:s', strtotime("-{$hours} hours"));
41
+ $orderCollection = Mage::getModel('sales/order')->getCollection()
42
+ ->addAttributeToFilter('state', $reviewState)
43
+ ->addAttributeToFilter('updated_at', array('lt' => $lastUpdated))
44
+ ->addAttributeToSort('entity_id', 'ASC');
45
+
46
+ foreach ($orderCollection as $_order) {
47
+ try {
48
+ $_order = Mage::getModel('sales/order')->load($_order->getId());
49
+ if ($_order->getState() != $reviewState) {
50
+ continue;
51
+ }
52
+
53
+ $_payment = $_order->getPayment();
54
+
55
+ if(!in_array($_payment->getMethod(),$paymentMethods)){
56
+ continue;
57
+ }
58
+
59
+ $_payment->setData('payment_deny',true);
60
+
61
+ if (method_exists($_payment, 'deny')) {
62
+ $_payment->deny();
63
+ }
64
+
65
+ $_order->save();
66
+
67
+ $_comment = $_order->addStatusHistoryComment(
68
+ Mage::helper('realex')->__(
69
+ "Order cancelled as not converted within {$hours} hours."
70
+ )
71
+ );
72
+ $_comment->save();
73
+ } catch (Exception $e) {
74
+ Mage::logException($e);
75
+ }
76
+ }
77
+ }
78
+ }
app/code/community/Yoma/Realex/Model/Observer/Tokencard.php ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Observer_Tokencard {
21
+
22
+ /**
23
+ * Create token
24
+ *
25
+ * @param Varien_Event_Observer $observer
26
+ * @return $this
27
+ */
28
+ public function saveCustomerCard(Varien_Event_Observer $observer) {
29
+
30
+ $service = $observer->getService();
31
+ $transport = $observer->getTransport();
32
+ try{
33
+ $service->setTransactionType('registerToken');
34
+ $service->setMethod();
35
+ $service->setMd($observer->getData('md'));
36
+ $service->run();
37
+
38
+ }catch(Exception $e){
39
+ mage::logException($e);
40
+ $transport->setToken(false);
41
+ }
42
+
43
+ return $this;
44
+ }
45
+
46
+ /**
47
+ * Delete Token
48
+ *
49
+ * @param Varien_Event_Observer $observer
50
+ * @return $this
51
+ */
52
+ public function deleteCustomerCard(Varien_Event_Observer $observer) {
53
+
54
+ try{
55
+ $service = Mage::getModel('realex/service_token');
56
+ $service->setTransactionType('delete');
57
+ $service->setToken($observer->getToken());
58
+ $service->setMethod();
59
+ $service->run();
60
+
61
+ }catch(Exception $e){
62
+ mage::logException($e);
63
+ }
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * Edit Payer
70
+ *
71
+ * @param Varien_Event_Observer $observer
72
+ * @return $this
73
+ * @throws Exception
74
+ */
75
+ public function editPayer(Varien_Event_Observer $observer) {
76
+
77
+ try{
78
+ $service = Mage::getModel('realex/service_token');
79
+ $service->setTransactionType('editPayer');
80
+ $service->setToken($observer->getToken());
81
+ $service->setMethod();
82
+ $service->run();
83
+
84
+ }catch(Exception $e){
85
+ mage::logException($e);
86
+ throw $e;
87
+ }
88
+
89
+ return $this;
90
+ }
91
+
92
+ /**
93
+ * Edit Token
94
+ *
95
+ * @param Varien_Event_Observer $observer
96
+ * @return $this
97
+ * @throws Exception
98
+ */
99
+ public function editCustomerCard(Varien_Event_Observer $observer) {
100
+
101
+ try{
102
+ $service = Mage::getModel('realex/service_token');
103
+ $service->setTransactionType('editToken');
104
+ $service->setToken($observer->getToken());
105
+ $service->setCardData($observer->getDetails());
106
+ $service->setMethod();
107
+ $service->run();
108
+
109
+ }catch(Exception $e){
110
+ mage::logException($e);
111
+ throw $e;
112
+ }
113
+
114
+ return $this;
115
+ }
116
+
117
+ /**
118
+ * Add magento admin alert for expiring cards
119
+ *
120
+ * @return $this
121
+ */
122
+ public function alertExpiredCards(){
123
+
124
+ foreach($this->_cardsExpiring() as $card) {
125
+ $inbox = mage::getModel('adminNotification/feed');
126
+ $description = "<strong>Realex Payments:</strong> You have cards that are about to expire.";
127
+ $inbox->addNotice($description, Mage::helper('adminhtml')->getUrl('realexAdmin/adminhtml_tokencard/edit', array('id' => $card->getId())));
128
+ }
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Returnn expiring tokens
134
+ *
135
+ * @return mixed
136
+ */
137
+ private function _cardsExpiring() {
138
+ return Mage::getModel("realex/tokencard")->getCollection()->addExpiringFilter();
139
+
140
+ }
141
+
142
+ /**
143
+ * @TODO remove redundant function
144
+ *
145
+ * @param Varien_Event_Observer $observer
146
+ */
147
+ public function setPaymentMethod(Varien_Event_Observer $observer){
148
+
149
+ if($observer->getInput()->getRealexTokenCcId()){
150
+ $observer->getInput()->setMethod('realvault');
151
+ }
152
+
153
+ }
154
+
155
+ /**
156
+ * @TODO remove redundant function
157
+ *
158
+ * @param Varien_Event_Observer $observer
159
+ */
160
+ public function checkPaymentMethod(Varien_Event_Observer $observer){
161
+
162
+ if($observer->getMethodInstance()->getCode() == 'realvault'){
163
+ $observer->getResult()->setIsAvailable = true;
164
+ }
165
+
166
+ }
167
+
168
+ /**
169
+ * Delete tokens on customer delete
170
+ *
171
+ * @param Varien_Event_Observer $observer
172
+ * @return $this
173
+ */
174
+ public function deleteCustomerCards(Varien_Event_Observer $observer){
175
+
176
+ try{
177
+ $service = Mage::getModel('realex/service_token');
178
+ $service->setTransactionType('delete');
179
+
180
+ $tokens = mage::getModel('realex/tokencard')
181
+ ->getCollection()
182
+ ->addCustomerFilter($observer->getCustomer())
183
+ ->load();
184
+
185
+ foreach($tokens as $token) {
186
+ $service->setToken($token);
187
+ $service->setMethod();
188
+ $service->run();
189
+ }
190
+
191
+ }catch(Exception $e){
192
+ mage::logException($e);
193
+ }
194
+
195
+ return $this;
196
+ }
197
+ }
app/code/community/Yoma/Realex/Model/Order/Creditmemo/Total/Rebate.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Order_Creditmemo_Total_Rebate extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
21
+ {
22
+
23
+ /**
24
+ * @param Mage_Sales_Model_Order_Creditmemo $creditMemo
25
+ * @return $this|Mage_Sales_Model_Order_Creditmemo_Total_Abstract
26
+ */
27
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditMemo)
28
+ {
29
+ $order = $creditMemo->getOrder();
30
+
31
+ return $this;
32
+ }
33
+ }
app/code/community/Yoma/Realex/Model/Order/Invoice/Total/SettleAmount.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Order_Invoice_Total_SettleAmount extends Mage_Sales_Model_Order_Invoice_Total_Abstract
21
+ {
22
+
23
+ /**
24
+ * @param Mage_Sales_Model_Order_Invoice $invoice
25
+ * @return $this|Mage_Sales_Model_Order_Invoice_Total_Abstract
26
+ */
27
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
28
+ {
29
+ $order = $invoice->getOrder();
30
+
31
+ return $this;
32
+ }
33
+ }
app/code/community/Yoma/Realex/Model/Payment/Abstract.php ADDED
@@ -0,0 +1,534 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ abstract class Yoma_Realex_Model_Payment_Abstract {
21
+
22
+ protected $_service = null;
23
+ protected $_function = '_pay';
24
+ protected $_method = null;
25
+ protected $_action = null;
26
+ protected $_redirect = false;
27
+ protected $_paymentInfo = array();
28
+ protected $_obf = array('card_cvn','sha1hash','md5hash','SHA1HASH','MD5HASH');
29
+ protected $_participatingCard = true;
30
+ protected $_message = null;
31
+
32
+ protected $_threedSecureCardTypes = array(
33
+ 'VISA',
34
+ 'MC',
35
+ 'AMEX',
36
+ );
37
+
38
+ /**
39
+ * Set service
40
+ *
41
+ * @param Yoma_Realex_Model_Service_Abstracy$service
42
+ */
43
+ function __construct($service){
44
+
45
+ $this->_service = $service;
46
+ }
47
+
48
+ /**
49
+ * Retrive helper from service
50
+ *
51
+ * @return mixed
52
+ */
53
+ protected function _getHelper(){
54
+
55
+ return $this->_service->getHelper();
56
+ }
57
+
58
+ /**
59
+ * Magic method to implement method
60
+ *
61
+ * @param string $name
62
+ * @param $args
63
+ * @return mixed
64
+ * @throws Exception
65
+ */
66
+ function __call($name, $args){
67
+
68
+ // if function call allowed
69
+ if(!in_array($name,$this->_allowedMethods)){
70
+
71
+ throw new Exception('Payment Method Not Available');
72
+ }
73
+ return call_user_func_array(array($this, $this->_function),$args);
74
+ }
75
+
76
+ /**
77
+ * Abstract method
78
+ *
79
+ * @return mixed
80
+ */
81
+ abstract protected function _Pay();
82
+
83
+ /**
84
+ * Call payment gateway
85
+ *
86
+ * @param string $endpoint
87
+ * @param string $data
88
+ * @throws Exception
89
+ */
90
+ protected function _send($endpoint, $data)
91
+ {
92
+ try {
93
+ $client = new Zend_Http_Client($endpoint);
94
+ $client->setMethod(Zend_Http_Client::POST);
95
+ $client->setRawData(trim($data));
96
+ $client->setEncType('text/xml');
97
+
98
+ $this->_response->setResponse($client->request());
99
+ $this->_service->debugData(array('request'=>$this->_getHelper()->xmlToArray(trim($data))));
100
+ $this->_service->debugData(array('response'=>$this->_getHelper()->xmlToArray($client->getLastResponse()->getBody())));
101
+ } catch(Exception $e){
102
+ Realex_Log::logException($e);
103
+ throw $e;
104
+ } catch (Zend_Http_Client_Adapter_Exception $e){
105
+ Realex_Log::logException($e);
106
+ throw $e;
107
+ }
108
+ }
109
+
110
+ /**
111
+ * Set message for gateway call
112
+ *
113
+ * @param string $type
114
+ * @param null $method
115
+ * @return $this
116
+ */
117
+ protected function _setMessage($type,$method = null){
118
+
119
+ // @TODO replace call to get adapter now redundant
120
+ if($method == null){
121
+ $model = $this->_service->getAdapter() . '_' . $type;
122
+ }else{
123
+ $model = $method . '_' . $type;
124
+ }
125
+ $this->_message = Mage::getModel('realex/message_' . $model);
126
+
127
+ return $this;
128
+ }
129
+
130
+ /**
131
+ * Set response for gateway call
132
+ *
133
+ * @param string $type
134
+ * @param array $data
135
+ * @param null $method
136
+ * @return $this
137
+ */
138
+ protected function _setResponse($type, $data = null, $method = null){
139
+
140
+ // @TODO replace call to get adapter now redundant
141
+ if($method == null){
142
+ $model = $this->_service->getAdapter() . '_' . $type;
143
+ }else{
144
+ $model = $method . '_' . $type;
145
+ }
146
+
147
+ $this->_response = Mage::getModel('realex/response_' . $model);
148
+ // set response data
149
+ if(is_array($data)){
150
+ $this->_response->setData($this->flatten($data));
151
+ }
152
+
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Retrieve response from gateway
158
+ *
159
+ * @param bool $obf
160
+ * @return mixed
161
+ */
162
+ public function getTransactionData($obf = false){
163
+ // unset sensitive data
164
+ if($obf){
165
+ $data = $this->_response->getData();
166
+
167
+ foreach($this->_obf as $key){
168
+ if(array_key_exists($key,$data)){
169
+ unset($data[$key]);
170
+ }
171
+ }
172
+
173
+ return $data;
174
+ }
175
+ return $this->_response->getData();
176
+
177
+ }
178
+
179
+ /**
180
+ * Retrieve data from session for transactional post
181
+ *
182
+ * @return mixed
183
+ */
184
+ public function getRegisterTransactionData(){
185
+
186
+ return $this->_message->getTransactionData();
187
+ }
188
+
189
+ /**
190
+ * Create url for gateway callback
191
+ *
192
+ * @return string
193
+ */
194
+ public function getCallbackUrl(){
195
+
196
+ return Mage::getUrl(
197
+ 'realex' . '/'
198
+ . $this->_code . '/'
199
+ . $this->_action,
200
+ array(
201
+ '_forced_secure' => true,
202
+ 'type' => (isset($type)?$type:$this->_service->getTransactionType()),
203
+ 'reference' => $this->_service->getTransactionReference(),
204
+ )
205
+ );
206
+ }
207
+
208
+ /**
209
+ * Create url for callback to dent method
210
+ *
211
+ * @return string
212
+ */
213
+ public function getCallDenyUrl(){
214
+
215
+ return Mage::getUrl(
216
+ 'realex' . '/'
217
+ . $this->_code . '/onepageFailureOrder',
218
+
219
+ array(
220
+ '_forced_secure' => true,
221
+ 'type' => (isset($type)?$type:$this->_service->getTransactionType()),
222
+ 'reference' => $this->_service->getTransactionReference(),
223
+ )
224
+ );
225
+ }
226
+
227
+ /**
228
+ * Retrieve payment gateway redirect url
229
+ *
230
+ * @return string
231
+ */
232
+ protected function _getRedirectUrl(){
233
+
234
+ // if using iframe
235
+ if($this->_getHelper()->getConfigData($this->_service->getCode(), 'iframe')){
236
+ // if using iframe on checkout page
237
+ if($this->_getHelper()->getConfigData($this->_service->getCode(), 'iframe_display')){
238
+ return Mage::getUrl('realex/' . $this->_code . '/form', array('_forced_secure' => true,));
239
+ }
240
+ return Mage::getUrl('realex/' . $this->_code . '/iframe', array('_forced_secure' => true,));
241
+ }
242
+
243
+ return Mage::getUrl('realex/' . $this->_code . '/form', array('_forced_secure' => true,));
244
+ }
245
+
246
+ /**
247
+ * Set payment method redirect url
248
+ *
249
+ * @param string $url
250
+ */
251
+ protected function _setMethodRedirect($url){
252
+
253
+ Mage::getSingleton('customer/session')->setRedirectUrl($url);
254
+ }
255
+
256
+ /**
257
+ * Set response object
258
+ *
259
+ * @param string $type
260
+ * @param array $data
261
+ * @return $this
262
+ */
263
+ public function setResponse($type = null, $data = null){
264
+
265
+ if(!isset($type)){
266
+ $type = $this->_action;
267
+ }
268
+ $this->_setResponse($type, $data);
269
+ return $this;
270
+ }
271
+
272
+ /**
273
+ * Add payment info
274
+ *
275
+ * @param $mixed key
276
+ * @param string $value
277
+ * @return $this
278
+ */
279
+ public function addPaymentInfo($key, $value = '')
280
+ {
281
+ if (is_array($key)) {
282
+ $this->_paymentInfo = array_merge($this->_paymentInfo, $key);
283
+ } else {
284
+ $this->_paymentInfo[$key] = $value;
285
+ }
286
+
287
+ return $this;
288
+ }
289
+
290
+ /**
291
+ * Retrieve payment info
292
+ *
293
+ * @param bool $clear
294
+ * @return array
295
+ */
296
+ public function getPaymentInfo($clear = true)
297
+ {
298
+ $paymentInfo = $this->_paymentInfo;
299
+ // if set clear payment info
300
+ if ($clear == true) {
301
+ $this->_paymentInfo = array();
302
+ }
303
+
304
+ return $paymentInfo;
305
+ }
306
+
307
+ public function unsetPaymentInfo($keys){
308
+ if(is_array($keys)){
309
+ foreach($keys as $key){
310
+ if(isset($this->_paymentInfo[$key])){
311
+ $this->unsetInfo($key);
312
+ }
313
+ }
314
+ }
315
+ }
316
+
317
+ public function unsetInfo($key){
318
+ unset($this->_paymentInfo[$key]);
319
+ }
320
+
321
+ /**
322
+ * Flatten multidimensional array
323
+ *
324
+ * @param array $arr
325
+ * @param string $prefix
326
+ * @return array
327
+ */
328
+ public function flatten(array $arr, $prefix = '')
329
+ {
330
+ $out = array();
331
+ foreach ($arr as $k => $v) {
332
+ $key = (!strlen($prefix)) ? strtolower($k) : ($prefix=='@attributes'?strtolower($k):strtolower($prefix) . '_' . strtolower($k));
333
+ if (is_array($v)) {
334
+ $out += $this->flatten($v, $key);
335
+ } else {
336
+ $out[$key] = $v;
337
+ }
338
+ }
339
+ return $out;
340
+ }
341
+
342
+ /**
343
+ * Convert magento card type to realex card type
344
+ *
345
+ * @param string $type
346
+ * @return string
347
+ */
348
+
349
+ protected function _getRealexCardType($type){
350
+
351
+ $cards = Mage::getModel('realex/realex_source_cards');
352
+ return $cards->getGatewayCardType($type);
353
+ }
354
+
355
+ /**
356
+ *
357
+ * @return Mage_Core_Model_Abstract
358
+ */
359
+ public function getRealexSession() {
360
+
361
+ return Mage::getSingleton('realex/session');
362
+ }
363
+
364
+ /**
365
+ * Retrieve existing payment transaction data
366
+ *
367
+ * @param Varien_Object $payment
368
+ * @param mixed $key
369
+ * @return mixed
370
+ *
371
+ */
372
+ protected function _getTransactionData($payment,$key = null){
373
+
374
+ $transaction = $payment->getTransaction($payment->getParentTransactionId());
375
+
376
+ while($transaction->getParentTxnId()){
377
+ $transaction = $payment->getTransaction($transaction->getParentTxnId());
378
+ }
379
+
380
+ $transactionData = $transaction->getAdditionalInformation('raw_details_info');
381
+ if($key && isset($transactionData[$key])){
382
+ return $transactionData[$key];
383
+ }
384
+
385
+ return $transactionData;
386
+ }
387
+
388
+ /**
389
+ * Check if 3dSecure required
390
+ *
391
+ * @param string $cardType
392
+ * @param string $serviceCode
393
+ * @return Varien_Object
394
+ */
395
+ protected function _requireThreedSecure($cardType,$serviceCode = null){
396
+
397
+ $transport = new Varien_Object();
398
+ // start with false
399
+ $transport->setRequire3DSecure(false);
400
+
401
+ if(!isset($serviceCode)){
402
+ $serviceCode = $this->_service->getCode();
403
+ }
404
+ // check if card can use 3dSecure
405
+ $cardInScheme = $this->_isThreedSecure(
406
+ $cardType
407
+ );
408
+
409
+ // allow if 3dSecure card and onepage checkout and 3dSecure enabled for model
410
+ if ($cardInScheme && !$this->_isAdminOrMultiShipping() && $this->_getHelper()->getConfigData($serviceCode,'use_threed_secure')) {
411
+
412
+ $transport->setRequire3DSecure(true);
413
+ Mage::dispatchEvent('realex_process_threedsecure_after', array('payment'=> $this->_service->getPayment(),'transport'=>$transport));
414
+ }
415
+
416
+ return $transport;
417
+ }
418
+
419
+ /**
420
+ * Check if multiShippingCheckout
421
+ *
422
+ * @return bool
423
+ */
424
+ protected function _isMultishippingCheckout() {
425
+
426
+ return (bool) Mage::getSingleton('checkout/session')->getQuote()->getIsMultiShipping();
427
+ }
428
+
429
+ /**
430
+ * Check if current transaction is from the Backend admin
431
+ *
432
+ * @return bool
433
+ */
434
+ protected function _getIsAdminOrder() {
435
+ return (bool) (Mage::getSingleton('admin/session')->isLoggedIn() &&
436
+ Mage::getSingleton('adminhtml/session_quote')->getQuoteId());
437
+ }
438
+
439
+ /**
440
+ * Check if admin order or multiShippingCheckout
441
+ *
442
+ * @return bool
443
+ */
444
+ protected function _isAdminOrMultiShipping(){
445
+
446
+ return (bool)($this->_isMultishippingCheckout() || $this->_getIsAdminOrder());
447
+ }
448
+
449
+ /**
450
+ * Unserialize and decrypt MD data
451
+ *
452
+ * @param string $encryptedData
453
+ * @return array
454
+ */
455
+ protected function _recieveMdData($encryptedData)
456
+ {
457
+ $decryptedData = Mage::helper('core')->decrypt(base64_decode($encryptedData));
458
+ $data = unserialize($decryptedData);
459
+
460
+ return $data;
461
+ }
462
+
463
+ /**
464
+ * Set mpi data
465
+ *
466
+ * @param string $key
467
+ * @param string $value
468
+ */
469
+ protected function _setMpiData($key, $value){
470
+ $this->_mpiData[$key] = array('value'=>$value);
471
+ }
472
+
473
+ /**
474
+ * Clear mpi data
475
+ */
476
+ protected function _clearMpiData(){
477
+
478
+ $this->_mpiData = array();
479
+ }
480
+
481
+ /**
482
+ * Serialize and encrypt MD data
483
+ *
484
+ * @param string $encryptedData
485
+ * @return array
486
+ */
487
+ protected function _prepareMdData($data)
488
+ {
489
+ if (!is_array($data) || empty($data)) {
490
+ throw new Exception($this->_getHelper()->__('Invalid MD data provided.'));
491
+ }
492
+
493
+ $serializedData = serialize($data);
494
+ $encryptedData = base64_encode(Mage::helper('core')->encrypt($serializedData));
495
+
496
+ return $encryptedData;
497
+ }
498
+
499
+ /**
500
+ * Populate MD Data
501
+ *
502
+ * @return array
503
+ * @throws Exception
504
+ */
505
+ protected function _createMd(){
506
+
507
+ return $this->_prepareMdData(array(
508
+ 'card_number' => $this->_service->getPayment()->getCcNumber(),
509
+ 'card_cvn' => $this->_service->getPayment()->getCcCid(),
510
+ 'xid' => $this->_response->getXid(),
511
+ 'transaction_reference' => $this->_service->getTransactionReference(),
512
+ 'token_cvv' => mage::getSingleton('realex/session')->getTokenCvv()
513
+ ));
514
+ }
515
+
516
+ /**
517
+ * Check if card 3dSecure
518
+ *
519
+ * @param string $cardType
520
+ * @return bool
521
+ */
522
+ protected function _isThreedSecure($cardType ) {
523
+
524
+ if (is_null($cardType)) {
525
+ return true;
526
+ }
527
+
528
+ if (in_array($cardType, $this->_threedSecureCardTypes)) {
529
+ return true;
530
+ }
531
+
532
+ return false;
533
+ }
534
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct.php ADDED
@@ -0,0 +1,499 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ abstract class Yoma_Realex_Model_Payment_Direct extends Yoma_Realex_Model_Payment_Abstract{
21
+
22
+ /**
23
+ * Get gateway url
24
+ *
25
+ * @param string $serviceCode
26
+ * @return string
27
+ */
28
+ protected function _getServiceUrl($serviceCode = null){
29
+
30
+ if(!isset($serviceCode)){
31
+ $serviceCode = $this->_service->getCode();
32
+ }
33
+
34
+ if($this->_getHelper()->getConfigData($serviceCode,'use_threed_secure')){
35
+ return $this->_getHelper()->getConfigData($serviceCode,'threed_url');
36
+ }
37
+
38
+ return $this->_getHelper()->getConfigData($serviceCode,'live_url');
39
+ }
40
+
41
+ /**
42
+ * Prepare transaction request acl post
43
+ *
44
+ * @return $this
45
+ */
46
+ protected function _prepareAclPost(){
47
+
48
+ $mdData = $this->_createMd();
49
+
50
+ $acl = array();
51
+
52
+ $acl['post']['PaReq'] = $this->_response->getPareq();
53
+ $acl['action'] = $this->_response->getUrl();
54
+ $acl['post']['MD'] = $mdData;
55
+ $acl['post']['TermUrl'] = $this->getCallbackUrl();
56
+
57
+ mage::getSingleton('realex/session')->setTransactionData($acl);
58
+
59
+ $this->_service->debugData(array('request'=>$this->_getHelper()->xmlToArray($acl)));
60
+
61
+ return $this;
62
+
63
+ }
64
+
65
+ /**
66
+ * Prepare transaction request 3d register
67
+ *
68
+ * @return $this
69
+ */
70
+ protected function _prepareThreedRegister(){
71
+
72
+ $payment = $this->_service->getPayment();
73
+ $order = $this->_service->getOrder();
74
+ $helper = $this->_getHelper();
75
+ $cards = Mage::getModel('realex/realex_source_cards');
76
+ $transactionReference = $this->_service->getTransactionReference();
77
+
78
+ $request = array(
79
+ 'attributes' => array(
80
+ 'timestamp' => $helper->getTimestamp(),
81
+ 'type' => '3ds-verifyenrolled'
82
+ ),
83
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
84
+ 'account' => array('value' => $helper->getSubAccount($payment,$this->_service->getCode())),
85
+ 'orderid' => array('value' => $transactionReference),
86
+ 'amount' => array(
87
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
88
+ 'attributes' => array(
89
+ 'currency' => $order->getBaseCurrencyCode(),
90
+ )
91
+ )
92
+ );
93
+
94
+
95
+ $card = array(
96
+ 'number'=>array('value' => $payment->getCcNumber()),
97
+ 'expdate' =>array('value' => $helper->getCreditCardDate($payment)),
98
+ 'chname' => array('value' => $helper->getCreditCardName($payment)),
99
+ 'type' => array('value' => $cards->getGatewayCardType($payment->getCcType())),
100
+ );
101
+
102
+ if($payment->getCcSsIssue()){
103
+ $card['issueno'] = array('value' => $payment->getCcSsIssue());
104
+ }
105
+
106
+ $cvn = array(
107
+ 'number'=>array('value' => $payment->getCcCid()),
108
+ 'presind' =>array('value' => ($payment->getCcCid()?'1':'2'))
109
+ );
110
+
111
+ $card['cvn'] = $cvn;
112
+
113
+ $request['card'] = $card;
114
+
115
+
116
+ $sha1hash = array(
117
+ $request['attributes']['timestamp'] ,
118
+ $request['merchantid']['value'],
119
+ $request['orderid']['value'],
120
+ $request['amount']['value'],
121
+ $request['amount']['attributes']['currency'],
122
+ $request['card']['number']['value']
123
+ );
124
+
125
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
126
+
127
+ $this->_message->setData(array('request'=>$request));
128
+
129
+ return $this;
130
+ }
131
+
132
+ /**
133
+ * Prepare transaction request capture
134
+ *
135
+ * @return $this
136
+ */
137
+ protected function _prepareCapture(){
138
+
139
+ $payment = $this->_service->getPayment();
140
+ $order = $this->_service->getOrder();
141
+ $helper = $this->_getHelper();
142
+ $cards = Mage::getModel('realex/realex_source_cards');
143
+ $transactionReference = $this->_service->getTransactionReference();
144
+
145
+ $request = array(
146
+ 'attributes' => array(
147
+ 'timestamp' => $helper->getTimestamp(),
148
+ 'type' => 'auth'
149
+ ),
150
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
151
+ 'account' => array('value' => $helper->getSubAccount($payment,$this->_service->getCode())),
152
+ 'orderid' => array('value' => $transactionReference),
153
+ 'amount' => array(
154
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
155
+ 'attributes' => array(
156
+ 'currency' => $order->getBaseCurrencyCode(),
157
+ )
158
+ )
159
+ );
160
+
161
+ $card = array(
162
+ 'number'=>array('value' => $payment->getCcNumber()),
163
+ 'expdate' =>array('value' => $helper->getCreditCardDate($payment)),
164
+ 'chname' => array('value' => $helper->getCreditCardName($payment)),
165
+ 'type' => array('value' => $cards->getGatewayCardType($payment->getCcType())),
166
+ );
167
+
168
+ if($payment->getCcSsIssue()){
169
+ $card['issueno'] = array('value' => $payment->getCcSsIssue());
170
+ }
171
+
172
+ $cvn = array(
173
+ 'number'=>array('value' => $payment->getCcCid()),
174
+ 'presind' =>array('value' => ($payment->getCcCid()?'1':'2'))
175
+ );
176
+
177
+ $card['cvn'] = $cvn;
178
+
179
+ $request['card'] = $card;
180
+
181
+ $sha1hash = array(
182
+ $request['attributes']['timestamp'] ,
183
+ $request['merchantid']['value'],
184
+ $request['orderid']['value'],
185
+ $request['amount']['value'],
186
+ $request['amount']['attributes']['currency'],
187
+ $request['card']['number']['value']
188
+ );
189
+
190
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
191
+
192
+ if(!empty($this->_mpiData)){
193
+
194
+ $request['mpi'] = $this->_mpiData;
195
+ }
196
+
197
+ $billing = $order->getBillingAddress();
198
+ if($order->getIsVirtual()){
199
+ $shipping = $billing;
200
+ }else{
201
+ $shipping = $order->getShippingAddress();
202
+ }
203
+
204
+ $tssinfo = array(
205
+ 'custnum' => array('value' => $helper->getSessionCustomerId()),
206
+ 'custipaddress' => array('value' => $helper->getClientIpAddress()),
207
+ 'varref' => array('value' => $billing->getEmail())
208
+ );
209
+
210
+ $billingAddress = array(
211
+ 'attributes' => array(
212
+ 'type' => 'billing'
213
+ ),
214
+ 'code' => array('value' => $helper->getTssCode($billing)),
215
+ 'country' => array('value' => $billing->getCountry()),
216
+
217
+ );
218
+
219
+ $shippingAddress = array(
220
+ 'attributes' => array(
221
+ 'type' => 'shipping'
222
+ ),
223
+ 'code' => array('value' => $helper->getTssCode($shipping)),
224
+ 'country' => array('value' => $shipping->getCountry()),
225
+ );
226
+
227
+ $tssinfo['multiple']['address'][] = $billingAddress;
228
+ $tssinfo['multiple']['address'][] = $shippingAddress;
229
+
230
+
231
+ $request['tssinfo'] = $tssinfo;
232
+
233
+ $request['autosettle'] = array(
234
+ 'attributes' =>
235
+ array(
236
+ 'flag' => ($this->_method == 'capture'?'1':'0')
237
+ )
238
+ );
239
+
240
+ $request['comments'] = $this->_addComments();
241
+
242
+ $this->_message->setData(array('request'=>$request));
243
+
244
+ $this->getRealexSession()->setTokenCvv('');
245
+
246
+ return $this;
247
+ }
248
+
249
+ /**
250
+ * Prepare transaction request settle
251
+ *
252
+ * @return $this
253
+ */
254
+ protected function _preparePartial(){
255
+
256
+ $payment = $this->_service->getPayment();
257
+ $order = $this->_service->getOrder();
258
+ $helper = $this->_getHelper();
259
+
260
+ $request = array(
261
+ 'attributes' => array(
262
+ 'timestamp' => $helper->getTimestamp(),
263
+ 'type' => 'settle'
264
+ ),
265
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
266
+ 'account' => array('value' => $this->_getSubAccount($payment)),
267
+ 'orderid' => array('value' => $payment->getParentTransactionId()),
268
+ 'amount' => array(
269
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
270
+ 'attributes' => array(
271
+ 'currency' => $order->getOrderCurrencyCode(),
272
+ )
273
+ ),
274
+ 'pasref' => array('value' => $this->_getTransactionData($payment,'pasref')),
275
+ 'authcode' => array('value' => $this->_getTransactionData($payment,'authcode'))
276
+ );
277
+
278
+ $sha1hash = array(
279
+ $request['attributes']['timestamp'] ,
280
+ $request['merchantid']['value'],
281
+ $request['orderid']['value'],
282
+ $request['amount']['value'],
283
+ $request['amount']['attributes']['currency'],
284
+ '',
285
+ );
286
+
287
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
288
+
289
+ $request['comments'] = $this->_addComments();
290
+
291
+ $this->_message->setData(array('request'=>$request));
292
+
293
+ return $this;
294
+ }
295
+
296
+ /**
297
+ * Prepare transaction request 3d capture
298
+ *
299
+ * @return $this
300
+ */
301
+ protected function _prepareThreedCapture($mdData){
302
+
303
+ $transaction = $this->_service->getTransaction();
304
+ $helper = $this->_getHelper();
305
+ $order = $this->_service->getOrder();
306
+
307
+ $request = array(
308
+ 'attributes' => array(
309
+ 'timestamp' => $helper->getTimestamp(),
310
+ 'type' => 'auth'
311
+ ),
312
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
313
+ 'account' => array('value' => $transaction->getAdditionalInformation('account')),
314
+ 'orderid' => array('value' => $transaction->getAdditionalInformation('orderid')),
315
+ 'amount' => array(
316
+ 'value' => $transaction->getAdditionalInformation('payment_amount'),
317
+ 'attributes' => array(
318
+ 'currency' => $transaction->getAdditionalInformation('currency'),
319
+ )
320
+ )
321
+ );
322
+
323
+ $card = array(
324
+ 'number'=>array('value' => $mdData['card_number']),
325
+ 'expdate' =>array('value' => $transaction->getAdditionalInformation('card_expiry')),
326
+ 'chname' => array('value' => $transaction->getAdditionalInformation('card_name')),
327
+ 'type' => array('value' => $transaction->getAdditionalInformation('card_type')),
328
+ );
329
+
330
+
331
+ $cvn = array(
332
+ 'number'=>array('value' => $mdData['card_cvn']),
333
+ 'presind' =>array('value' => (isset($mdData['card_cvn']) && !$mdData['card_cvn']=='' ? '1':'2'))
334
+ );
335
+
336
+ $card['cvn'] = $cvn;
337
+ $request['card'] = $card;
338
+
339
+ $sha1hash = array(
340
+ $request['attributes']['timestamp'],
341
+ $request['merchantid']['value'],
342
+ $request['orderid']['value'],
343
+ $request['amount']['value'],
344
+ $request['amount']['attributes']['currency'],
345
+ $request['card']['number']['value'],
346
+ );
347
+
348
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
349
+
350
+ $request['mpi'] = $this->_mpiData;
351
+
352
+ $billing = $order->getBillingAddress();
353
+ if($order->getIsVirtual()){
354
+ $shipping = $billing;
355
+ }else{
356
+ $shipping = $order->getShippingAddress();
357
+ }
358
+
359
+ $tssinfo = array(
360
+ 'custnum' => array('value' => $helper->getSessionCustomerId()),
361
+ 'custipaddress' => array('value' => $helper->getClientIpAddress()),
362
+ 'varref' => array('value' => $billing->getEmail())
363
+ );
364
+
365
+ $billingAddress = array(
366
+ 'attributes' => array(
367
+ 'type' => 'billing'
368
+ ),
369
+ 'code' => array('value' => $helper->getTssCode($billing)),
370
+ 'country' => array('value' => $billing->getCountry()),
371
+
372
+ );
373
+
374
+ $shippingAddress = array(
375
+ 'attributes' => array(
376
+ 'type' => 'shipping'
377
+ ),
378
+ 'code' => array('value' => $helper->getTssCode($shipping)),
379
+ 'country' => array('value' => $shipping->getCountry()),
380
+ );
381
+
382
+ $tssinfo['multiple']['address'][] = $billingAddress;
383
+ $tssinfo['multiple']['address'][] = $shippingAddress;
384
+
385
+
386
+ $request['tssinfo'] = $tssinfo;
387
+
388
+ $request['autosettle'] = array(
389
+ 'attributes' =>
390
+ array(
391
+ 'flag' => ($this->_method == 'capture'?'1':'0')
392
+ )
393
+ );
394
+
395
+ $request['comments'] = $this->_addComments();
396
+
397
+ $this->_message->setData(array('request'=>$request));
398
+
399
+ return $this;
400
+ }
401
+
402
+ /**
403
+ * Prepare transaction request 3d verify
404
+ *
405
+ * @return $this
406
+ */
407
+ protected function _prepareThreedVerify($pares, $mdData){
408
+
409
+ $transaction = $this->_service->getTransaction();
410
+
411
+ $helper = $this->_getHelper();
412
+
413
+ $request = array(
414
+ 'attributes' => array(
415
+ 'timestamp' => $helper->getTimestamp(),
416
+ 'type' => '3ds-verifysig'
417
+ ),
418
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
419
+ 'account' => array('value' => $transaction->getAdditionalInformation('account')),
420
+ 'orderid' => array('value' => $transaction->getAdditionalInformation('orderid')),
421
+ 'amount' => array(
422
+ 'value' => $transaction->getAdditionalInformation('payment_amount'),
423
+ 'attributes' => array(
424
+ 'currency' => $transaction->getAdditionalInformation('currency'),
425
+ )
426
+ )
427
+ );
428
+
429
+ $sha1hash = array(
430
+ $request['attributes']['timestamp'] ,
431
+ $request['merchantid']['value'],
432
+ $request['orderid']['value'],
433
+ $request['amount']['value'],
434
+ $request['amount']['attributes']['currency'],
435
+ ''
436
+ );
437
+
438
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
439
+ $request['pares'] = array('value'=>$pares);
440
+
441
+ $this->_message->setData(array('request'=>$request));
442
+ return $this;
443
+ }
444
+
445
+ /**
446
+ * Append comments to transaction message
447
+ *
448
+ * @return array
449
+ */
450
+ protected function _addComments(){
451
+
452
+ $comments = array();
453
+ $comment1 = array(
454
+ 'attributes' => array(
455
+ 'id' => 1,
456
+ ),
457
+ 'value' => 'magento - ' . Mage::getVersion()
458
+ );
459
+ $comment2 = array(
460
+ 'attributes' => array(
461
+ 'id' => 2,
462
+ ),
463
+ 'value' => 'yoma ' . $this->_getHelper()->getVersion()
464
+ );
465
+
466
+ $comments['multiple']['comment'][] = $comment1;
467
+ $comments['multiple']['comment'][] = $comment2;
468
+
469
+ return $comments;
470
+ }
471
+
472
+ /**
473
+ * @TODO refractor
474
+ *
475
+ * @return null
476
+ */
477
+ protected function _hasToken(){
478
+
479
+ return NULL;
480
+ }
481
+
482
+ /**
483
+ * Get original sub account
484
+ *
485
+ * @param Varien_Object$payment
486
+ * @return string
487
+ */
488
+ protected function _getSubAccount($payment){
489
+
490
+ $subAccount = $this->_getTransactionData($payment,'account');
491
+ if(is_array($subAccount)) {
492
+ $this->_getHelper()->getSubAccount($payment, $this->_service->getCode());
493
+ }
494
+
495
+ $payment->setOriginalSubAccount($subAccount);
496
+
497
+ return $subAccount;
498
+ }
499
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/Authorize.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_Authorize extends Yoma_Realex_Model_Payment_Direct_Capture{
21
+
22
+ protected $_allowedMethods = array('authorize');
23
+ protected $_method = 'authorize';
24
+ protected $_action = 'authorize';
25
+ protected $_captureType = 'authorize';
26
+
27
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/Capture.php ADDED
@@ -0,0 +1,366 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_Capture extends Yoma_Realex_Model_Payment_Direct{
21
+
22
+ protected $_code = 'direct';
23
+ protected $_allowedMethods = array('capture');
24
+ protected $_method = 'capture';
25
+ protected $_action = 'capture';
26
+ protected $_mpiData = array();
27
+ protected $_useToken = null;
28
+ protected $_captureType = 'capture';
29
+ protected $_customer = NULL;
30
+
31
+ /**
32
+ * Create reference for current transaction.
33
+ *
34
+ * @param Varien_Object $payment
35
+ * @return String
36
+ */
37
+ public function getTransactionReference($payment){
38
+
39
+ return $this->_getHelper()
40
+ ->getTransactionReference($payment->getOrder());
41
+ }
42
+
43
+ /**
44
+ * Process 3dSecure Callback
45
+ *
46
+ * @return $this
47
+ * @throws Exception
48
+ */
49
+ public function processCallback(){
50
+
51
+ $this->addPaymentInfo('Customer returned from 3DSecure ACS URL', 'Complete');
52
+
53
+ $this->_service->debugData(array('response'=>$this->_response->getData()));
54
+
55
+ // check for MD data
56
+ if (!$this->_response->getMd() || !$this->_response->getPares()) {
57
+ throw new Exception(
58
+ $this->_getHelper()->__('MD or PARES not provided in 3D Secure callback.')
59
+ );
60
+ }
61
+ $pares = $this->_response->getPares();
62
+
63
+ // decrypt the MD data from the 3D Secure response
64
+ $mdData = $this->_recieveMdData($this->_response->getMd());
65
+
66
+
67
+ // ensure the transaction reference in the response data matches Magento
68
+ $callbackReference = $mdData['transaction_reference'];
69
+ $savedReference = $this->_service->getTransaction()->getTransactionReference();
70
+
71
+ if (strcmp($callbackReference, $savedReference) !== 0) {
72
+ $message = $this->_getHelper()->__('Transaction reference mismatch.');
73
+
74
+ throw new Exception(
75
+ $message
76
+ );
77
+ }
78
+ try{
79
+
80
+ $transConfig = new varien_object();
81
+
82
+ Mage::dispatchEvent('realex_process_callback', array('transaction'=>$this->_service->getTransaction(),'transport'=>$transConfig));
83
+
84
+ $this->_token = $this->_hasToken();
85
+ // get customer from order
86
+ $customer = $this->_service->getOrder()->getCustomer();
87
+ $customerId = '';
88
+ if(isset($customer)){
89
+ $customerId = $customer->getId();
90
+ }else{
91
+ $customerId = $this->_service->getOrder()->getCustomerId();
92
+ }
93
+ $this->_customer = mage::getModel('customer/customer')->load($customerId);
94
+ // set method
95
+ $this->_method = 'threedSecureVerify';
96
+ $this->_setMessage($this->_method);
97
+ $this->_setResponse($this->_method);
98
+ // prepare message
99
+ $this->_prepareThreedVerify($pares,$mdData);
100
+
101
+ $this->addPaymentInfo('3DSecure Signature Verification', 'Started');
102
+
103
+ // call payment gateway
104
+ $this->_send(
105
+ $this->_getServiceUrl(),
106
+ $this->_message->prepareMessage()
107
+ );
108
+ // add eci data to payment info
109
+ $this->addPaymentInfo('ECI Result', $this->_response->getThreedsecureEci());
110
+
111
+ //get correct eci
112
+ $eci = $this->_response->getEciFromThreedSecureVerifySignature(
113
+ $this->_response->getResult(),
114
+ $this->_response->getThreedsecureStatus(),
115
+ ($this->_token?$this->_token->getCardType():$this->_service->getTransaction()->getAdditionalInformation('card_type')),
116
+ $this->_threedSecureCardTypes,
117
+ $this->_getHelper()->getConfigData('realexdirect','require_liability_shift'),
118
+ $transConfig
119
+ );
120
+
121
+ $this->addPaymentInfo('ECI Result', $eci);
122
+ $this->_setMpiData('eci',$eci);
123
+
124
+ }catch(Yoma_Realex_Model_Exception_NoLiabilityShift $e){
125
+
126
+ throw new Exception($e->getMessage());
127
+ }
128
+ // set mpi data for capture
129
+ $this->_setMpiData('cavv',$this->_response->getThreedsecureCavv());
130
+ $this->_setMpiData('xid',$this->_response->getThreedsecureXid());
131
+ // call capture
132
+ $this->_threedCapture(
133
+ $mdData
134
+ );
135
+ // if remember call observer
136
+ if($this->_service->getTransaction()->getRemembertoken()){
137
+ $transport = new varien_object();
138
+ $transport->setToken(true);
139
+ Mage::dispatchEvent('realex_register_token', array('service'=> clone $this->_service,'md'=>$mdData,'transport'=>$transport));
140
+ if($transport->getToken()) {
141
+ Mage::getSingleton('customer/session')->setTokenSaved(true);
142
+ }
143
+ $transaction = $this->_service->getTransaction();
144
+ $transaction->setRemembertoken(0);
145
+ $transaction->save();
146
+ }
147
+
148
+ return $this;
149
+ }
150
+
151
+ /**
152
+ * Call 3dCapture on payment gateway
153
+ *
154
+ * @param array $mdData
155
+ * @param string $method
156
+ * @throws Exception
157
+ */
158
+ protected function _threedCapture($mdData,$method = 'capture'){
159
+
160
+ $this->_method = $this->_captureType;
161
+ $this->_action = $this->_captureType;
162
+ $this->_setMessage($this->_method);
163
+ $this->_setResponse($this->_method);
164
+
165
+ $this->_prepareThreedCapture($mdData);
166
+
167
+ Mage::dispatchEvent(
168
+ 'realex_before_capture',
169
+ array(
170
+ 'method'=>$this->_method,
171
+ 'message'=>$this->_message->getData(),
172
+ 'code'=>$this->_code,
173
+ 'url'=>$this->_getServiceUrl()
174
+ )
175
+ );
176
+
177
+ $this->addPaymentInfo('Payment ' . $this->_method, 'Started');
178
+ $this->_send(
179
+ $this->_getServiceUrl(),
180
+ $this->_message->prepareMessage()
181
+ );
182
+
183
+ $this->_response->isValid();
184
+
185
+ Mage::dispatchEvent(
186
+ 'realex_before_process_response',
187
+ array(
188
+ 'method'=>$this->_method,
189
+ 'response'=>$this->_response->getData(),
190
+ 'code'=>$this->_code
191
+ )
192
+ );
193
+
194
+ $this->addPaymentInfo(array(
195
+ 'Result' => $this->_response->getResult(),
196
+ 'Auth Code' => $this->_response->getAuthcode(),
197
+ 'Message' => $this->_response->getMessage(),
198
+ 'Transaction Reference' => $this->_response->getOrderid(),
199
+ 'CVN Result' => $this->_response->getCvnresult(),
200
+ 'AVS Address Result' => $this->_response->getAvsaddressresponse(),
201
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesponse(),
202
+ 'TSS Result' => $this->_response->getTssResult(),
203
+ ));
204
+
205
+ if($this->_method == 'authorize'){
206
+ $this->unsetPaymentInfo(array('CVN Result','AVS Address Result','AVS Postcode Result'));
207
+ }
208
+
209
+ $this->_response->processResult();
210
+
211
+ }
212
+
213
+ /**
214
+ * Start transaction with payment gateway
215
+ *
216
+ * @return $this|mixed
217
+ * @throws Exception
218
+ */
219
+ protected function _pay(){
220
+
221
+ $eci = null;
222
+ $this->_setMethodRedirect(null);
223
+ $this->getRealexSession()->setTokenSaved(false);
224
+ $this->_token = $this->_hasToken();
225
+ $this->_token = false;
226
+
227
+ $cardType = $this->_getRealexCardType($this->_service->getPayment()->getCcType());
228
+
229
+ $transConfig = $this->_requireThreedSecure($cardType);
230
+
231
+ // check id 3dSecure requrired
232
+ if($transConfig->getRequire3DSecure()){
233
+
234
+ $this->_method = 'threedSecure';
235
+ $this->_action = 'threedSecureCapture';
236
+ $this->_setMessage($this->_method);
237
+ $this->_setResponse($this->_method);
238
+
239
+ $this->_setMpiData('eci',
240
+ $this->_response->getEciValue($cardType,false)
241
+ );
242
+
243
+ try{
244
+ $this->addPaymentInfo('3DSecure Verify Cardholder Enrollment', 'Started');
245
+ $this->_prepareThreedRegister();
246
+ $this->_service->saveTransaction();
247
+ $this->_send(
248
+ $this->_getServiceUrl(),
249
+ $this->_message->prepareMessage()
250
+ );
251
+ $this->_response->processResult();
252
+ $this->_response->isValid();
253
+
254
+ if($this->_response->getUrl() == ''){
255
+ $message = $this->_getHelper()->__('ThreedSecure-VerifyEnrolled Returned No Url');
256
+
257
+ throw new Exception($message);
258
+ }
259
+ $this->_service->getPayment()->setIsTransactionPending(true);
260
+ $this->_prepareAclPost();
261
+ $this->_setMethodRedirect($this->_getRedirectUrl());
262
+ $this->addPaymentInfo('Customer redirected to 3DSecure ACS URL', 'Started');
263
+ return;
264
+
265
+ }catch(Yoma_Realex_Model_Exception_NoneParticipatingCard $e) {
266
+ // set participating cord to false
267
+ $this->_participatingCard = false;
268
+ $this->_clearMpiData();
269
+ }catch(Yoma_Realex_Model_Exception_NotEnrolled $e){
270
+ //nothing to do
271
+ }
272
+ // set eci if participating card
273
+ if($this->_participatingCard) {
274
+ try {
275
+ $eci = $this->_response->getEciFromThreedSecureSignature(
276
+ $this->_response->getResult(),
277
+ $this->_response->getEnrolled(),
278
+ $cardType,
279
+ $this->_getHelper()->getConfigData('realexdirect', 'require_liability_shift'),
280
+ $transConfig
281
+ );
282
+
283
+ $this->_setMpiData('eci', $eci);
284
+ } catch (Yoma_Realex_Model_Exception_NoLiabilityShift $e) {
285
+ throw new Exception($e->getMessage());
286
+ }
287
+ }
288
+ }
289
+
290
+ $this->_capture();
291
+
292
+ if($this->_service->getPayment()->getRemembertoken()){
293
+ $transport = new varien_object();
294
+ $transport->setToken(true);
295
+ Mage::dispatchEvent('realex_register_token', array('service'=> clone $this->_service,'transport'=>$transport));
296
+ if($transport->getToken()) {
297
+ Mage::getSingleton('customer/session')->setTokenSaved(true);
298
+ $this->_service->getPayment()->setRemembertoken(0);
299
+ }
300
+ }
301
+ return $this;
302
+
303
+ }
304
+
305
+ /**
306
+ * Capture payment on gateway
307
+ *
308
+ * @param string $method
309
+ * @throws Exception
310
+ */
311
+ protected function _capture($method = 'capture'){
312
+
313
+ $this->_method = $this->_captureType;
314
+ $this->_action = $this->_captureType;
315
+ $this->_setMessage($this->_method);
316
+ $this->_setResponse($this->_method);
317
+
318
+ $this->_prepareCapture();
319
+
320
+ Mage::dispatchEvent(
321
+ 'realex_before_capture',
322
+ array(
323
+ 'method'=>$this->_method,
324
+ 'message'=>$this->_message->getData(),
325
+ 'code'=>$this->_code,
326
+ 'url'=>$this->_getServiceUrl()
327
+ )
328
+ );
329
+
330
+ $this->addPaymentInfo('Payment ' . $this->_method, 'Started');
331
+ $this->_send(
332
+ $this->_getServiceUrl(),
333
+ $this->_message->prepareMessage()
334
+ );
335
+
336
+ $this->_response->isValid();
337
+
338
+ Mage::dispatchEvent(
339
+ 'realex_before_process_response',
340
+ array(
341
+ 'method'=>$this->_method,
342
+ 'response'=>$this->_response->getData(),
343
+ 'code'=>$this->_code
344
+ )
345
+ );
346
+
347
+ $this->addPaymentInfo(array(
348
+ 'Result' => $this->_response->getResult(),
349
+ 'Auth Code' => $this->_response->getAuthcode(),
350
+ 'Message' => $this->_response->getMessage(),
351
+ 'Transaction Reference' => $this->_response->getOrderid(),
352
+ 'CVN Result' => $this->_response->getCvnresult(),
353
+ 'AVS Address Result' => $this->_response->getAvsaddressresponse(),
354
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesponse(),
355
+ 'TSS Result' => $this->_response->getTssResult(),
356
+ 'Card Owner' => $this->_service->getCardOwner()
357
+ ));
358
+
359
+ if($this->_method == 'authorize'){
360
+ $this->unsetPaymentInfo(array('CVN Result','AVS Address Result','AVS Postcode Result'));
361
+ }
362
+
363
+ $this->_response->processResult();
364
+ }
365
+
366
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/Partial.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_Partial extends Yoma_Realex_Model_Payment_Direct{
21
+
22
+ protected $_code = 'direct';
23
+ protected $_allowedMethods = array('partial');
24
+ protected $_method = 'partial';
25
+ protected $_action = 'partial';
26
+ protected $_mpiData = array();
27
+ protected $_useToken = null;
28
+ protected $_captureType = 'partial';
29
+ protected $_customer = NULL;
30
+
31
+ /**
32
+ * Create reference for current transaction.
33
+ *
34
+ * @param Varien_Object $payment
35
+ * @return String
36
+ */
37
+ public function getTransactionReference($payment){
38
+
39
+ return $payment->getParentTransactionId() . '-partial';
40
+ }
41
+
42
+
43
+ /**
44
+ * Start transaction with payment gateway
45
+ *
46
+ * @return $this|mixed
47
+ * @throws Exception
48
+ */
49
+ protected function _pay(){
50
+
51
+ $this->_capture();
52
+ return $this;
53
+
54
+ }
55
+
56
+
57
+ /**
58
+ * Capture payment on gateway
59
+ *
60
+ * @param string $method
61
+ * @throws Exception
62
+ */
63
+ protected function _capture($method = 'partial'){
64
+
65
+ $this->_method = $this->_captureType;
66
+ $this->_action = $this->_captureType;
67
+ $this->_setMessage($this->_method);
68
+ $this->_setResponse($this->_method);
69
+
70
+ $this->_preparePartial();
71
+
72
+ $this->_send(
73
+ $this->_getServiceUrl(),
74
+ $this->_message->prepareMessage()
75
+ );
76
+
77
+ $this->_response->isValid();
78
+
79
+ Mage::dispatchEvent(
80
+ 'realex_before_process_response',
81
+ array('method'=>$this->_method,'response'=>$this->_response->getData())
82
+ );
83
+
84
+ $this->_response->processResult();
85
+
86
+ $this->addPaymentInfo(array(
87
+ 'Result' => $this->_response->getResult(),
88
+ 'Auth Code' => $this->_response->getAuthcode(),
89
+ 'Message' => $this->_response->getMessage(),
90
+ 'Transaction Reference' => $this->_response->getOrderid(),
91
+ 'CVN Result' => $this->_response->getCvnresult(),
92
+ 'AVS Address Result' => $this->_response->getAvsaddressresponse(),
93
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesponse(),
94
+ 'TSS Result' => $this->_response->getTssResult(),
95
+ 'Card Owner' => $this->_service->getCardOwner()
96
+ ));
97
+
98
+ }
99
+
100
+ /**
101
+ * Retrieve method code
102
+ *
103
+ * @param string $serviceCode
104
+ * @return mixed
105
+ */
106
+ protected function _getServiceUrl($serviceCode = null){
107
+
108
+ if(!isset($serviceCode)){
109
+ $serviceCode = $this->_service->getCode();
110
+ }
111
+
112
+ return $this->_getHelper()->getConfigData($serviceCode,'live_url');
113
+ }
114
+
115
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/Refund.php ADDED
@@ -0,0 +1,137 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_Refund extends Yoma_Realex_Model_Payment_Direct{
21
+
22
+ protected $_code = 'direct';
23
+ protected $_method = 'refund';
24
+ protected $_action = 'refund';
25
+ protected $_allowedMethods = array('refund');
26
+
27
+
28
+ /**
29
+ * Create reference for current transaction.
30
+ *
31
+ * @param Varien_Object $payment
32
+ * @return String
33
+ */
34
+ public function getTransactionReference($payment){
35
+
36
+ return $payment->getParentTransactionId() . '-refund';
37
+
38
+ }
39
+
40
+ /**
41
+ * Start transaction with payment gateway
42
+ *
43
+ * @return $this|mixed
44
+ * @throws Exception
45
+ */
46
+ protected function _pay(){
47
+
48
+ $this->_setMessage($this->_method);
49
+ $this->_setResponse($this->_method);
50
+
51
+ $this->_prepareRefund();
52
+
53
+ $this->_send(
54
+ $this->_getServiceUrl(),
55
+ $this->_message->prepareMessage()
56
+ );
57
+
58
+ $this->_response->isValid();
59
+ $this->_response->processResult();
60
+
61
+ $this->addPaymentInfo(array(
62
+ 'Result' => $this->_response->getResult(),
63
+ 'Auth Code' => $this->_response->getAuthcode(),
64
+ 'Message' => $this->_response->getMessage(),
65
+ 'Transaction Reference' => $this->_response->getOrderid(),
66
+ )
67
+ );
68
+
69
+ }
70
+
71
+ /**
72
+ * Prepare transaction request
73
+ *
74
+ * @return $this
75
+ */
76
+ protected function _prepareRefund(){
77
+
78
+ $payment = $this->_service->getPayment();
79
+ $order = $this->_service->getOrder();
80
+ $helper = $this->_getHelper();
81
+
82
+ $transaction = $payment->getTransaction($payment->getParentTransactionId());
83
+
84
+ $request = array(
85
+ 'attributes' => array(
86
+ 'timestamp' => $helper->getTimestamp(),
87
+ 'type' => 'rebate'
88
+ ),
89
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
90
+ 'orderid' => array('value' => $this->_getTransactionData($payment,'orderid')),
91
+ 'amount' => array(
92
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
93
+ 'attributes' => array(
94
+ 'currency' => $order->getBaseCurrencyCode(),
95
+ ),
96
+ ),
97
+ 'ccnumber' => array('value' => ''),
98
+ 'refundhash' => array('value' =>sha1($helper->getConfigData('realex','rebate_pass'))),
99
+ 'autosettle' => array(
100
+ 'attributes' =>
101
+ array(
102
+ 'flag' => '1'
103
+ )
104
+ ),
105
+ 'pasref' => array('value' => $this->_getTransactionData($payment,'pasref')),
106
+ 'authcode' => array('value' => $this->_getTransactionData($payment,'authcode'))
107
+ );
108
+
109
+ $sha1hash = array(
110
+ $request['attributes']['timestamp'] ,
111
+ $request['merchantid']['value'],
112
+ $request['orderid']['value'],
113
+ $request['amount']['value'],
114
+ $request['amount']['attributes']['currency'],
115
+ ''
116
+ );
117
+
118
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
119
+
120
+ $request['comments'] = $this->_addComments();
121
+
122
+ $this->_message->setData(array('request'=>$request));
123
+
124
+ return $this;
125
+ }
126
+
127
+ /**
128
+ * Retrieve Gateway url
129
+ *
130
+ * @return string
131
+ */
132
+ protected function _getServiceUrl($serviceCode = null){
133
+
134
+ return $this->_getHelper()->getConfigData($this->_service->getCode(),'live_url');
135
+ }
136
+
137
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/RegisterToken.php ADDED
@@ -0,0 +1,258 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_RegisterToken extends Yoma_Realex_Model_Payment_Direct{
21
+
22
+ protected $_code = 'direct';
23
+ protected $_allowedMethods = array('registerToken');
24
+ protected $_method = 'registerToken';
25
+ protected $_action = 'registerToken';
26
+ protected $_payerRef = null;
27
+ protected $_customer = null;
28
+
29
+ /**
30
+ * Start transaction with payment gateway
31
+ *
32
+ * @return $this|mixed
33
+ * @throws Exception
34
+ */
35
+ protected function _pay(){
36
+
37
+ $customer = $this->_service->getOrder()->getCustomer();
38
+ $customerId = '';
39
+ if(isset($customer)){
40
+ $customerId = $customer->getId();
41
+ }else{
42
+ $customerId = $this->_service->getOrder()->getCustomerId();
43
+ }
44
+ $this->_customer = mage::getModel('customer/customer')->load($customerId);
45
+
46
+ $this->_payerRef = $this->_customer->getData('realex_payer_ref');
47
+ // if not existing payer create payer
48
+ if(!isset($this->_payerRef)){
49
+ $this->_method = 'payerNew';
50
+ $this->_action = 'payerNew';
51
+ $this->_setMessage($this->_method,'token');
52
+ $this->_setResponse($this->_method,null,'token');
53
+
54
+ $this->_preparePayerNew();
55
+
56
+ $this->_send(
57
+ $this->_getServiceUrl(),
58
+ $this->_message->prepareMessage()
59
+ );
60
+
61
+ $this->_response->processResult();
62
+ try{
63
+ $this->_customer->setRealexPayerRef($this->_payerRef);
64
+ $this->_customer->save();
65
+ }catch(Exception $e){
66
+ $this->getRealexSession()->setTokenSaved(false);
67
+ Mage::getSingleton('customer/session')->setTokenSaved(false);
68
+ throw $e;
69
+ }catch(Yoma_Realex_Model_Exception_PayerNew $e){
70
+ $this->getRealexSession()->setTokenSaved(false);
71
+ Mage::getSingleton('customer/session')->setTokenSaved(false);
72
+ throw $e;
73
+ return $this;
74
+ }
75
+
76
+ }
77
+ // if token not all ready exist create
78
+ if(!$this->_getHelper()->tokenExist(
79
+ $this->_customer,$this->_service->getPayment(),
80
+ $this->_service->getMd('card_number'))){
81
+ $this->_method = 'registerToken';
82
+ $this->_action = 'registerToken';
83
+ $this->_setMessage($this->_method,'token');
84
+ $this->_setResponse($this->_method,null,'token');
85
+
86
+ $this->_prepareRegisterToken();
87
+
88
+ $this->_send(
89
+ $this->_getServiceUrl(),
90
+ $this->_message->prepareMessage()
91
+ );
92
+
93
+ $this->_response->processResult();
94
+
95
+ $this->_saveToken();
96
+ $this->getRealexSession()->setTokenSaved(true);
97
+ Mage::getSingleton('customer/session')->setTokenSaved(true);
98
+ }
99
+ return $this;
100
+ }
101
+
102
+ /**
103
+ * Prepare transaction request register token
104
+ *
105
+ * @return $this
106
+ */
107
+ protected function _prepareRegisterToken(){
108
+
109
+ $payment = $this->_service->getPayment();
110
+ $helper = $this->_getHelper();
111
+ $cards = Mage::getModel('realex/realex_source_cards');
112
+ $transactionReference = $this->_service->getTransactionReference();
113
+
114
+
115
+ $request = array(
116
+ 'attributes' => array(
117
+ 'timestamp' => $helper->getTimestamp(),
118
+ 'type' => 'card-new'
119
+ ),
120
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
121
+ 'orderid' => array('value' => $transactionReference . '-card')
122
+ );
123
+
124
+ $card = array(
125
+
126
+ 'ref' => array('value' => $helper->getCardReference($cards->getGatewayCardType($payment->getCcType()))),
127
+ 'payerref' => array('value' => $this->_payerRef),
128
+ 'number'=>array('value' => ($this->_service->getMd('card_number')?$this->_service->getMd('card_number'):$payment->getCcNumber())),
129
+ 'expdate' =>array('value' => $helper->getCreditCardDate($payment)),
130
+ 'chname' => array('value' => ($helper->ss($payment->getCcOwner(),100))),
131
+ 'type' => array('value' => $cards->getGatewayCardType($payment->getCcType())),
132
+ );
133
+
134
+ if($payment->getCcSsIssue()){
135
+ $card['issueno'] = array('value' => $payment->getCcSsIssue());
136
+ }
137
+
138
+ $request['card'] = $card;
139
+
140
+ $sha1hash = array(
141
+ $request['attributes']['timestamp'] ,
142
+ $request['merchantid']['value'],
143
+ $request['orderid']['value'],
144
+ '',
145
+ '',
146
+ $this->_payerRef,
147
+ $request['card']['chname']['value'],
148
+ $request['card']['number']['value']
149
+ );
150
+
151
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
152
+
153
+ $this->_message->setData(array('request'=>$request));
154
+ return $this;
155
+
156
+
157
+ }
158
+
159
+ /**
160
+ * Prepare transaction request payer new
161
+ *
162
+ * @return $this
163
+ */
164
+ protected function _preparePayerNew(){
165
+
166
+ $order = $this->_service->getOrder();
167
+ $helper = $this->_getHelper();
168
+ $transactionReference = $this->_service->getTransactionReference();
169
+
170
+ $address = $order->getBillingAddress();
171
+
172
+ $request = array(
173
+ 'attributes' => array(
174
+ 'timestamp' => $helper->getTimestamp(),
175
+ 'type' => 'payer-new'
176
+ ),
177
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
178
+ 'orderid' => array('value' => $transactionReference . '-payer')
179
+ );
180
+
181
+ $this->_payerRef = $helper->createPayerRef($this->_customer);
182
+ $payer = array(
183
+ 'attributes' => array(
184
+ 'ref' => $this->_payerRef,
185
+ 'type'=> $helper->getConfigData('realvault','payer_type')
186
+ ),
187
+ 'firstname' => array('value' => $helper->ss($this->_customer->getFirstname(),30)),
188
+ 'surname' => array('value' => $helper->ss($this->_customer->getLastname(),50)),
189
+ 'email' => array('value' => $helper->realexEmail($helper->ss($this->_customer->getEmail(),50)))
190
+ );
191
+
192
+ $payerAddress = array(
193
+
194
+ 'line1' => array('value' => $helper->ss($address->getStreet(1),50)),
195
+ 'line2' => array('value' => $helper->ss($address->getStreet(2),50)),
196
+ 'line3' => array('value' => $helper->ss($address->getStreet(3),50)),
197
+ 'city' => array('value' => $helper->ss($address->getCity(),20)),
198
+ 'county'=> array('value' => $address->getRegion()),
199
+ 'postcode' => array('value' => $helper->ss($address->getPostcode(),8)),
200
+ 'country' => array(
201
+ 'attributes' => array(
202
+ 'code' => $address->getCountryId()
203
+ ),
204
+ 'value' => Mage::app()->getLocale()->getCountryTranslation($address->getCountryId())
205
+ )
206
+ );
207
+
208
+ $payer['address'] = $payerAddress;
209
+ $request['payer'] = $payer;
210
+
211
+ $sha1hash = array(
212
+ $request['attributes']['timestamp'] ,
213
+ $request['merchantid']['value'],
214
+ $request['orderid']['value'],
215
+ '',
216
+ '',
217
+ $this->_payerRef
218
+ );
219
+
220
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
221
+
222
+ $this->_message->setData(array('request'=>$request));
223
+ return $this;
224
+ }
225
+
226
+ /**
227
+ * Save Token
228
+ */
229
+ protected function _saveToken(){
230
+ $tokenData = $this->_message->getTransactionData();
231
+ $magentoCardType = $payment = $this->_service->getPayment()->getCcType();
232
+ $token = Mage::getModel("realex/tokencard");
233
+
234
+ $token
235
+ ->setCustomerId($this->_customer->getId())
236
+ ->setToken($tokenData['token_ref'])
237
+ ->setStatus(1)
238
+ ->setCardType($tokenData['card_type'])
239
+ ->setMagentoCardType($magentoCardType)
240
+ ->setLastFour(substr($tokenData['card_number'], -4))
241
+ ->setExpiryDate($tokenData['card_expiry'])
242
+ ->setChName($tokenData['card_name'])
243
+ ->setIsDefault(0)
244
+ ->setPayerRef($tokenData['payer_ref'])
245
+ ->setPaymentMethod($this->_code)
246
+ ->save();
247
+ }
248
+
249
+ /**
250
+ * @param string $serviceCode
251
+ * @return string
252
+ */
253
+ protected function _getServiceUrl($serviceCode = null){
254
+
255
+ return $this->_getHelper()->getConfigData($this->_service->getCode(),'live_url');
256
+ }
257
+
258
+ }
app/code/community/Yoma/Realex/Model/Payment/Direct/Void.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Direct_Void extends Yoma_Realex_Model_Payment_Direct{
21
+
22
+ protected $_code = 'direct';
23
+ protected $_method = 'void';
24
+ protected $_action = 'void';
25
+ protected $_allowedMethods = array('void');
26
+
27
+
28
+ /**
29
+ * Create reference for current transaction.
30
+ *
31
+ * @param Varien_Object $payment
32
+ * @return String
33
+ */
34
+ public function getTransactionReference($payment){
35
+
36
+ return $payment->getParentTransactionId() . '-void';
37
+ }
38
+
39
+ /**
40
+ * Start transaction with payment gateway
41
+ *
42
+ * @return $this|mixed
43
+ * @throws Exception
44
+ */
45
+ protected function _pay(){
46
+
47
+ $this->_setMessage($this->_method);
48
+ $this->_setResponse($this->_method);
49
+
50
+ $this->_prepareVoid();
51
+
52
+ $this->_send(
53
+ $this->_getServiceUrl(),
54
+ $this->_message->prepareMessage()
55
+ );
56
+
57
+ $this->_response->isValid();
58
+ $this->_response->processResult();
59
+
60
+ $this->addPaymentInfo(array(
61
+ 'Result' => $this->_response->getResult(),
62
+ 'Auth Code' => $this->_response->getAuthcode(),
63
+ 'Message' => $this->_response->getMessage(),
64
+ 'Transaction Reference' => $this->_response->getOrderid(),
65
+ )
66
+ );
67
+
68
+ }
69
+
70
+ /**
71
+ * Prepare transaction request void
72
+ *
73
+ * @return $this
74
+ */
75
+ protected function _prepareVoid(){
76
+
77
+ $payment = $this->_service->getPayment();
78
+ $helper = $this->_getHelper();
79
+
80
+ $request = array(
81
+ 'attributes' => array(
82
+ 'timestamp' => $helper->getTimestamp(),
83
+ 'type' => 'void'
84
+ ),
85
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
86
+ 'account' => array('value' => $this->_getSubAccount($payment)),
87
+ 'orderid' => array('value' => $payment->getParentTransactionId()),
88
+ 'pasref' => array('value' => $this->_getTransactionData($payment,'pasref')),
89
+ 'authcode' => array('value' => $this->_getTransactionData($payment,'authcode'))
90
+ );
91
+
92
+ $sha1hash = array(
93
+ $request['attributes']['timestamp'] ,
94
+ $request['merchantid']['value'],
95
+ $request['orderid']['value'],
96
+ '',
97
+ '',
98
+ ''
99
+ );
100
+
101
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
102
+
103
+ $request['comments'] = $this->_addComments();
104
+
105
+ $this->_message->setData(array('request'=>$request));
106
+ return $this;
107
+ }
108
+
109
+ /**
110
+ * @param string $serviceCode
111
+ * @return string
112
+ */
113
+ protected function _getServiceUrl($serviceCode = null){
114
+ return $this->_getHelper()->getConfigData($this->_service->getCode(),'live_url');
115
+ }
116
+
117
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect.php ADDED
@@ -0,0 +1,205 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ abstract class Yoma_Realex_Model_Payment_Redirect extends Yoma_Realex_Model_Payment_Abstract{
21
+
22
+ protected $_payerRef = null;
23
+ protected $_customer = null;
24
+
25
+ /**
26
+ * Prepare transaction request hpp
27
+ *
28
+ * @return $this
29
+ */
30
+ protected function _prepareTransactionPost(){
31
+
32
+ $data = array();
33
+
34
+ $data['TIMESTAMP'] = $this->_getHelper()->getTimestamp();
35
+ $data['MERCHANT_ID'] = $this->_getHelper()->getConfigData('realex','vendor');
36
+ $data['ORDER_ID'] = $this->_service->getTransactionReference();
37
+ $data['AMOUNT'] = $this->_getHelper()->formatAmount($this->_service->getPayment()->getPaymentAmount(),$this->_service->getOrder()->getOrderCurrencyCode());
38
+ $data['CURRENCY'] = $this->_service->getOrder()->getBaseCurrencyCode();
39
+ $loggedInOrRegistering = $this->_getHelper()->isLoggedInOrRegistering();
40
+ $useRealVault = $this->_getHelper()->getConfigData('realvault','active');
41
+ if($loggedInOrRegistering && $useRealVault && $this->_getHelper()->hppChoseRealVault($this->_service->getPayment()->getRemembertoken())){
42
+
43
+ $customer = $this->_service->getOrder()->getCustomer();
44
+
45
+ $payerExist = '1';
46
+ if(isset($customer)){
47
+ $customerId = $customer->getId();
48
+ }else{
49
+ $customerId = $this->_service->getOrder()->getCustomerId();
50
+ }
51
+ $this->_customer = mage::getModel('customer/customer')->load($customerId);
52
+
53
+ $this->_payerRef = $this->_customer->getData('realex_payer_ref');
54
+
55
+ if(!isset($this->_payerRef)){
56
+ $this->_payerRef = $this->_getHelper()->createPayerRef($this->_customer);
57
+ $payerExist = '0';
58
+ }
59
+
60
+ $data['PAYER_REF'] = $this->_payerRef;
61
+ $data['PMT_REF'] = '';
62
+ $data['SHA1HASH'] = $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$data);
63
+ $data['PAYER_EXIST'] = $payerExist;
64
+
65
+ $data['OFFER_SAVE_CARD'] = '0';
66
+ $data['CARD_STORAGE_ENABLE'] = '1';
67
+ }else{
68
+ $data['SHA1HASH'] = $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$data);
69
+ }
70
+
71
+ $subAccount = trim($this->_getHelper()->getConfigData('realexredirect','sub_account'));
72
+
73
+ $transport = new Varien_Object();
74
+ $transport->setSubAccount($subAccount);
75
+
76
+ Mage::dispatchEvent('realex_process_subaccount_after', array('payment'=> $this->_service->getPayment(),'transport'=>$transport));
77
+
78
+ if($transport->getSubAccount() !== ''){
79
+ $data['ACCOUNT'] = $transport->getSubAccount();
80
+ }
81
+
82
+ $data['AUTO_SETTLE_FLAG'] = ($this->_method == 'capture'?'1':'0');
83
+ $data['RETURN_TSS'] = 1;
84
+ $billing = $this->_service->getOrder()->getBillingAddress();
85
+ $shipping = $this->_service->getOrder()->getShippingAddress();
86
+ $customerEmail = $this->_getHelper()->getCustomerEmail();
87
+ if ($this->_service->getOrder()->getIsVirtual()) {
88
+ $data['SHIPPING_CODE'] = $this->_getHelper()->sanitizePostcode($this->_getHelper()->ss($billing->getPostcode(), 30));
89
+ $data['SHIPPING_CO'] = $this->_getHelper()->ss($billing->getCountry(),50);
90
+ $data['SHIPPING_CODE'] = $this->_getHelper()->getTssCode($billing);
91
+ }
92
+ else {
93
+ $data['SHIPPING_CODE'] = $this->_getHelper()->sanitizePostcode($this->_getHelper()->ss($shipping->getPostcode(), 30));
94
+ $data['SHIPPING_CO'] = $this->_getHelper()->ss($shipping->getCountry(),50);
95
+ $data['SHIPPING_CODE'] = $this->_getHelper()->getTssCode($shipping);
96
+ }
97
+ $data['BILLING_CODE'] = $this->_getHelper()->sanitizePostcode($this->_getHelper()->ss($billing->getPostcode(), 30));
98
+ $data['BILLING_CO'] = $this->_getHelper()->ss($billing->getCountry(),50);
99
+ $data['BILLING_CODE'] = $this->_getHelper()->getTssCode($billing);
100
+ $data['CUST_NUM'] = ($customerEmail == null ? $billing->getEmail() : $customerEmail);
101
+
102
+ $data['MERCHANT_RESPONSE_URL'] = $this->getCallbackUrl();
103
+
104
+ foreach($this->_addComments() as $key=>$value){
105
+ $data[$key] = $value;
106
+ }
107
+ mage::getSingleton('realex/session')->setTransactionData($data);
108
+ $this->_service->debugData(array('request'=>$data));
109
+
110
+ return $this;
111
+
112
+ }
113
+
114
+ /**
115
+ * Append comments to transaction message
116
+ *
117
+ * @return array
118
+ */
119
+ protected function _addComments(){
120
+
121
+ $comments = array();
122
+
123
+ $comments['COMMENT1'] = 'magento - ' . Mage::getVersion();
124
+ $comments['COMMENT2'] = 'yoma ' . $this->_getHelper()->getVersion();
125
+
126
+ return $comments;
127
+ }
128
+
129
+ /**
130
+ * Get gateway response data
131
+ *
132
+ * @param bool $obf
133
+ * @return array
134
+ */
135
+ public function getTransactionData($obf = false){
136
+
137
+ if(!isset($this->_response)){
138
+ $data = mage::getSingleton('realex/session')->getTransactionData();
139
+ }else{
140
+ $data = $this->_response->getData();
141
+ }
142
+
143
+ //if true obscure data
144
+ if($obf){
145
+ foreach($this->_obf as $key){
146
+ if(array_key_exists($key,$data)){
147
+ unset($data[$key]);
148
+ }
149
+ }
150
+ }
151
+
152
+ return $data;
153
+ }
154
+
155
+ /**
156
+ * Retrieve transaction data from session
157
+ *
158
+ * @return array
159
+ */
160
+ public function getRegisterTransactionData() {
161
+
162
+ return mage::getSingleton('realex/session')->getTransactionData();
163
+ }
164
+
165
+ /**
166
+ * Add additional payment info
167
+ *
168
+ * @param Yoma_Realex_Model_Response_Abstract $response
169
+ * @return $this|void
170
+ */
171
+
172
+ public function addExtraPaymentInfo(Yoma_Realex_Model_Response_Abstract $response){
173
+
174
+ // if different payment method chosen
175
+ if($value = $response->getPaymentmethod()){
176
+ $this->addPaymentInfo('Payment Method Chosen',$value);
177
+ }
178
+ // if ddc chosen
179
+ if($response->getDccchoice()){
180
+
181
+ $this->addPaymentInfo('DCC Choice','Currency of card chosen');
182
+
183
+ if($value = $response->getDccmerchantamount()){
184
+ $this->addPaymentInfo('DCC Merchant Amount',$value);
185
+ }
186
+ if($value = $response->getDccmerchantcurrency()){
187
+ $this->addPaymentInfo('DCC Merchant Currency',$value);
188
+ }
189
+ if($value = $response->getDcccardholderamount()){
190
+ $this->addPaymentInfo('DCC Card Holder Amount',$value);
191
+ }
192
+ if($value = $response->getDcccardholdercurrency()){
193
+ $this->addPaymentInfo('DCC Card Holder Currency',$value);
194
+ }
195
+ }
196
+
197
+ // score data Currency of card chosen
198
+ if($value = $response->getEci()){
199
+ $this->addPaymentInfo('Electronic Commerce Indicator',$value);
200
+ }
201
+
202
+ return $this;
203
+
204
+ }
205
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/Authorize.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_Authorize extends Yoma_Realex_Model_Payment_Redirect_Capture{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_allowedMethods = array('authorize');
24
+ protected $_method = 'authorize';
25
+ protected $_action = 'authorize';
26
+
27
+
28
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/Capture.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_Capture extends Yoma_Realex_Model_Payment_Redirect{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_allowedMethods = array('capture');
24
+ protected $_method = 'capture';
25
+ protected $_action = 'capture';
26
+ protected $_mpiData = array();
27
+
28
+ /**
29
+ * Create reference for current transaction.
30
+ *
31
+ * @param Varien_Object $payment
32
+ * @return String
33
+ */
34
+ public function getTransactionReference($payment){
35
+
36
+ return $this->_getHelper()
37
+ ->getTransactionReference($payment->getOrder());
38
+ }
39
+
40
+ /**
41
+ * Process HPP Callback
42
+ *
43
+ * @return $this
44
+ * @throws Exception
45
+ */
46
+ public function processCallback(){
47
+
48
+ $this->_service->debugData(array('response'=>$this->_response->getData()));
49
+
50
+ $this->_response->isValid();
51
+
52
+ Mage::dispatchEvent(
53
+ 'realex_before_process_response',
54
+ array('method'=>$this->_method,'response'=>$this->_response->getData())
55
+ );
56
+
57
+ $this->addPaymentInfo(array(
58
+ 'Result' => $this->_response->getResult(),
59
+ 'Auth Code' => $this->_response->getAuthcode(),
60
+ 'Message' => $this->_response->getMessage(),
61
+ 'Transaction Reference' => $this->_response->getOrderId(),
62
+ 'CVN Result' => $this->_response->getCvnresult(),
63
+ 'AVS Address Result' => $this->_response->getAvsaddressresult(),
64
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesult(),
65
+ 'TSS Result' => $this->_response->getTss(),
66
+ ));
67
+
68
+ $this->addExtraPaymentInfo($this->_response);
69
+
70
+ $this->_response->processResult();
71
+
72
+ // if use real vault see if we have token
73
+ if($this->_response->useRealVault()){
74
+ try {
75
+ $customerId = $this->_service->getOrder()->getCustomerId();
76
+ $this->_customer = mage::getModel('customer/customer')->load($customerId);
77
+ $cards = mage::getModel('realex/realex_source_cards');
78
+
79
+ $token = false;
80
+ // if token save
81
+ if ($this->_response->isPaymentSetup()) {
82
+
83
+ $token = Mage::getModel("realex/tokencard");
84
+ $token
85
+ ->setCustomerId($this->_customer->getId())
86
+ ->setToken($this->_response->getSavedPmtRef())
87
+ ->setStatus(1)
88
+ ->setCardType($cards->convertLegacyCardType($this->_response->getSavedPmtType())) //SAVED_PMT_TYPE
89
+ ->setMagentoCardType($cards->getMagentoCardType($this->_response->getSavedPmtType())) //SAVED_PMT_TYPE
90
+ ->setLastFour(substr($this->_response->getSavedPmtDigits(), -4)) //SAVED_PMT_DIGITS
91
+ ->setExpiryDate($this->_response->getSavedPmtExpdate()) // SAVED_PMT_EXPDATE
92
+ ->setChName($this->_response->getSavedPmtName())
93
+ ->setIsDefault(0)
94
+ ->setPayerRef($this->_response->getSavedPayerRef())
95
+ ->setPaymentMethod($this->_code)
96
+ ->save();
97
+
98
+ Mage::getSingleton('customer/session')->setTokenSaved(true);
99
+
100
+ $this->addPaymentInfo('Card Saved Successfully','Yes');
101
+ }
102
+
103
+ if ($this->_response->isPayerSetup()) {
104
+ $this->_customer->setRealexPayerRef($this->_response->getSavedPayerRef());
105
+ $this->_customer->save();
106
+ if($token) {
107
+ Mage::dispatchEvent('realex_edit_payer', array('token' => $token));
108
+ }
109
+ }
110
+ }catch (Exception $e){
111
+ mage::logException($e);
112
+ }
113
+ }
114
+
115
+ return $this;
116
+ }
117
+
118
+ /**
119
+ * Start transaction with payment gateway
120
+ *
121
+ * @return $this|mixed
122
+ * @throws Exception
123
+ */
124
+ protected function _pay(){
125
+
126
+ $this->_setMethodRedirect(null);
127
+ $this->getRealexSession()->setTokenSaved(false);
128
+ $this->_service->saveTransaction();
129
+ $this->_service->getPayment()->setIsTransactionPending(true);
130
+ $this->_prepareTransactionPost();
131
+ $this->_setMethodRedirect($this->_getRedirectUrl());
132
+ return;
133
+
134
+ }
135
+
136
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/EditPayer.php ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_EditPayer extends Yoma_Realex_Model_Payment_Redirect{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_allowedMethods = array('editPayer');
24
+ protected $_method = 'editPayer';
25
+ protected $_action = 'editPayer';
26
+ protected $_mpiData = array();
27
+
28
+ /**
29
+ * Start transaction with payment gateway
30
+ *
31
+ * @return $this|mixed
32
+ * @throws Exception
33
+ */
34
+ protected function _pay(){
35
+
36
+ $this->_method = $this->_method;
37
+ $this->_action = $this->_action;
38
+ $this->_setMessage($this->_method);
39
+ $this->_setResponse($this->_method);
40
+
41
+ $this->_prepareEditPayer();
42
+
43
+ $this->_send(
44
+ $this->_getServiceUrl(),
45
+ $this->_message->prepareMessage()
46
+ );
47
+
48
+ $this->_response->isValid();
49
+ $this->_response->processResult();
50
+
51
+ return $this;
52
+
53
+ }
54
+
55
+ /**
56
+ * Prepare transaction request edit payer
57
+ *
58
+ * @return $this
59
+ */
60
+ protected function _prepareEditPayer() {
61
+
62
+ $token = $this->_service->getToken();
63
+
64
+ if(!$token->getId()){
65
+ throw new Exception($this->__('Token not valid'));
66
+ }
67
+
68
+ $customer = mage::getModel('customer/customer')->load($token->getCustomerId());
69
+
70
+ if(!$customer->getId()){
71
+ throw new Exception($this->__('Customer not valid'));
72
+ }
73
+
74
+ $address = $customer->getPrimaryBillingAddress();
75
+ if (!$address->getId()){
76
+ throw new Exception($this->__('Customer Address not valid'));
77
+ }
78
+
79
+ $request = array(
80
+ 'attributes' => array(
81
+ 'timestamp' => $this->_getHelper()->getTimestamp(),
82
+ 'type' => 'payer-edit'
83
+ ),
84
+ 'merchantid' => array('value' => $this->_getHelper()->getConfigData('realex', 'vendor')),
85
+ 'orderid' => array('value' => $this->_getHelper()->getEditPayerReference($customer->getId()) . '-payer')
86
+ );
87
+
88
+ $payer = array(
89
+ 'attributes' => array(
90
+ 'ref' => $customer->getRealexPayerRef(),
91
+ 'type'=> $this->_getHelper()->getConfigData('realvault','payer_type')
92
+ ),
93
+ 'firstname' => array('value' => $customer->getFirstname()),
94
+ 'surname' => array('value' => $customer->getLastname()),
95
+ 'email' => array('value' => $customer->getEmail())
96
+ );
97
+
98
+ $payerAddress = array(
99
+
100
+ 'line1' => array('value' => $address->getStreet(1)),
101
+ 'line2' => array('value' => $address->getStreet(2)),
102
+ 'line3' => array('value' => $address->getStreet(3)),
103
+ 'city' => array('value' => $address->getCity()),
104
+ 'county'=> array('value' => $address->getRegion()),
105
+ 'postcode' => array('value' => $address->getPostcode()),
106
+ 'country' => array(
107
+ 'attributes' => array(
108
+ 'code' => $address->getCountryId()
109
+ ),
110
+ 'value' => Mage::app()->getLocale()->getCountryTranslation($address->getCountryId())
111
+ )
112
+ );
113
+
114
+ $payer['address'] = $payerAddress;
115
+ $request['payer'] = $payer;
116
+
117
+ $sha1hash = array(
118
+ $request['attributes']['timestamp'] ,
119
+ $request['merchantid']['value'],
120
+ $request['orderid']['value'],
121
+ '',
122
+ '',
123
+ $request['payer']['attributes']['ref'],
124
+ );
125
+
126
+ $request['sha1hash'] = array('value' => $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$sha1hash));
127
+
128
+ $this->_message->setData(array('request'=>$request));
129
+ return $this;
130
+ }
131
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/Partial.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_Partial extends Yoma_Realex_Model_Payment_Direct_Partial{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_allowedMethods = array('partial');
24
+ protected $_method = 'partial';
25
+ protected $_action = 'partial';
26
+ protected $_mpiData = array();
27
+ protected $_useToken = null;
28
+ protected $_captureType = 'partial';
29
+ protected $_customer = NULL;
30
+
31
+ /**
32
+ * Get Gateway url
33
+ *
34
+ * @param string $serviceCode
35
+ * @return string
36
+ */
37
+ protected function _getServiceUrl($serviceCode = null){
38
+
39
+ return $this->_getHelper()->getConfigData('realexdirect','live_url');
40
+ }
41
+
42
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/Refund.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_Refund extends Yoma_Realex_Model_Payment_Direct_Refund{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_method = 'refund';
24
+ protected $_action = 'refund';
25
+ protected $_allowedMethods = array('refund');
26
+
27
+
28
+ /**
29
+ * Prepare transaction request refund
30
+ *
31
+ * @return $this
32
+ */
33
+ protected function _prepareRefund(){
34
+
35
+ $payment = $this->_service->getPayment();
36
+ $order = $this->_service->getOrder();
37
+ $helper = $this->_getHelper();
38
+
39
+ $transaction = $payment->getTransaction($payment->getParentTransactionId());
40
+
41
+ $request = array(
42
+ 'attributes' => array(
43
+ 'timestamp' => $helper->getTimestamp(),
44
+ 'type' => 'rebate'
45
+ ),
46
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
47
+ 'orderid' => array('value' => $this->_getTransactionData($payment,'order_id')),
48
+ 'amount' => array(
49
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
50
+ 'attributes' => array(
51
+ 'currency' => $order->getBaseCurrencyCode(),
52
+ ),
53
+ ),
54
+ 'ccnumber' => array('value' => ''),
55
+ 'refundhash' => array('value' =>sha1($helper->getConfigData('realex','rebate_pass'))),
56
+ 'autosettle' => array(
57
+ 'attributes' =>
58
+ array(
59
+ 'flag' => '1'
60
+ )
61
+ ),
62
+ 'pasref' => array('value' => $this->_getTransactionData($payment,'pasref')),
63
+ 'authcode' => array('value' => $this->_getTransactionData($payment,'authcode'))
64
+ );
65
+
66
+ $sha1hash = array(
67
+ $request['attributes']['timestamp'] ,
68
+ $request['merchantid']['value'],
69
+ $request['orderid']['value'],
70
+ $request['amount']['value'],
71
+ $request['amount']['attributes']['currency'],
72
+ ''
73
+ );
74
+
75
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
76
+
77
+ $request['comments'] = $this->_addComments();
78
+
79
+ $this->_message->setData(array('request'=>$request));
80
+
81
+ return $this;
82
+ }
83
+
84
+ /**
85
+ * Get Gateway url
86
+ *
87
+ * @param string $serviceCode
88
+ * @return string
89
+ */
90
+ protected function _getServiceUrl($serviceCode = null){
91
+
92
+ return $this->_getHelper()->getConfigData('realexdirect','live_url');
93
+ }
94
+
95
+ }
app/code/community/Yoma/Realex/Model/Payment/Redirect/Void.php ADDED
@@ -0,0 +1,76 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Redirect_Void extends Yoma_Realex_Model_Payment_Direct_Void{
21
+
22
+ protected $_code = 'redirect';
23
+ protected $_method = 'void';
24
+ protected $_action = 'void';
25
+ protected $_allowedMethods = array('void');
26
+
27
+ /**
28
+ * Prepare transaction request void
29
+ *
30
+ * @return $this
31
+ */
32
+ protected function _prepareVoid(){
33
+
34
+ $payment = $this->_service->getPayment();
35
+ $helper = $this->_getHelper();
36
+
37
+ $request = array(
38
+ 'attributes' => array(
39
+ 'timestamp' => $helper->getTimestamp(),
40
+ 'type' => 'void'
41
+ ),
42
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
43
+ 'account' => array('value' => $this->_getSubAccount($payment)),
44
+ 'orderid' => array('value' => $payment->getParentTransactionId()),
45
+ 'pasref' => array('value' => $this->_getTransactionData($payment,'pasref')),
46
+ 'authcode' => array('value' => $this->_getTransactionData($payment,'authcode'))
47
+ );
48
+
49
+ $sha1hash = array(
50
+ $request['attributes']['timestamp'] ,
51
+ $request['merchantid']['value'],
52
+ $request['orderid']['value'],
53
+ '',
54
+ '',
55
+ ''
56
+ );
57
+
58
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
59
+
60
+ $request['comments'] = $this->_addComments();
61
+
62
+ $this->_message->setData(array('request'=>$request));
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * Get Gateway url
68
+ *
69
+ * @param string $serviceCode
70
+ * @return string
71
+ */
72
+ protected function _getServiceUrl($serviceCode = null){
73
+
74
+ return $this->_getHelper()->getConfigData('realexdirect','live_url');
75
+ }
76
+ }
app/code/community/Yoma/Realex/Model/Payment/Token.php ADDED
@@ -0,0 +1,415 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ abstract class Yoma_Realex_Model_Payment_Token extends Yoma_Realex_Model_Payment_Abstract{
21
+
22
+ protected $_participatingCard = true;
23
+
24
+ /**
25
+ * Get gateway url
26
+ *
27
+ * @param string $serviceCode
28
+ * @return string
29
+ */
30
+ protected function _getServiceUrl($serviceCode = null){
31
+
32
+ if(!isset($serviceCode)){
33
+ $serviceCode = $this->_service->getCode();
34
+ }
35
+
36
+ if($this->_getHelper()->getConfigData($serviceCode,'use_threed_secure')){
37
+ return $this->_getHelper()->getConfigData($serviceCode,'threed_url');
38
+ }
39
+
40
+ return $this->_getHelper()->getConfigData($serviceCode,'live_url');
41
+ }
42
+
43
+ /**
44
+ * Prepare transaction request acl post
45
+ *
46
+ * @return $this
47
+ */
48
+ protected function _prepareAclPost(){
49
+
50
+ $acl = array();
51
+
52
+ $acl['post']['PaReq'] = $this->_response->getPareq();
53
+ $acl['action'] = $this->_response->getUrl();
54
+ $acl['post']['MD'] = $this->_createMd();
55
+ $acl['post']['TermUrl'] = $this->getCallbackUrl();
56
+ mage::getSingleton('realex/session')->setTransactionData($acl);
57
+ $this->_service->debugData(array('request'=>$this->_getHelper()->xmlToArray($acl)));
58
+
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Prepare transaction request 3D register
64
+ *
65
+ * @return $this
66
+ */
67
+ protected function _prepareThreedRegister(){
68
+
69
+ $payment = $this->_service->getPayment();
70
+ $order = $this->_service->getOrder();
71
+ $helper = $this->_getHelper();
72
+ $cards = Mage::getModel('realex/realex_source_cards');
73
+ $transactionReference = $this->_service->getTransactionReference();
74
+
75
+ $request = array(
76
+ 'attributes' => array(
77
+ 'timestamp' => $helper->getTimestamp(),
78
+ 'type' => "realvault-3ds-verifyenrolled"
79
+ ),
80
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
81
+ 'account' => array('value' => $helper->getSubAccount($payment,$this->_service->getCode())),
82
+ 'orderid' => array('value' => $transactionReference),
83
+ 'amount' => array(
84
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getOrderCurrencyCode()),
85
+ 'attributes' => array(
86
+ 'currency' => $order->getOrderCurrencyCode(),
87
+ )
88
+ )
89
+ );
90
+
91
+ if(isset($this->_token)){
92
+ $request['payerref'] = array('value' => $helper->getCustomerPayerRef($helper->getCustomerId()));
93
+ $request['paymentmethod'] = array('value' => $this->_token->getToken());
94
+ }
95
+
96
+ $sha1hash = array(
97
+ $request['attributes']['timestamp'] ,
98
+ $request['merchantid']['value'],
99
+ $request['orderid']['value'],
100
+ $request['amount']['value'],
101
+ $request['amount']['attributes']['currency'],
102
+ $request['payerref']['value']
103
+ //(isset($this->_token)?$request['payerref']['value']:'')
104
+ );
105
+
106
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
107
+
108
+ $this->_message->setData(array('request'=>$request));
109
+ return $this;
110
+ }
111
+
112
+ /**
113
+ * Prepare transaction request capture
114
+ *
115
+ * @return $this
116
+ */
117
+ protected function _prepareCapture(){
118
+
119
+ $payment = $this->_service->getPayment();
120
+ $order = $this->_service->getOrder();
121
+ $helper = $this->_getHelper();
122
+ $cards = Mage::getModel('realex/realex_source_cards');
123
+ $transactionReference = $this->_service->getTransactionReference();
124
+
125
+ $request = array(
126
+ 'attributes' => array(
127
+ 'timestamp' => $helper->getTimestamp(),
128
+ 'type' => "receipt-in"
129
+ ),
130
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
131
+ 'account' => array('value' => $helper->getSubAccount($payment,$this->_service->getCode())),
132
+ 'orderid' => array('value' => $transactionReference),
133
+ 'amount' => array(
134
+ 'value' => $helper->formatAmount($payment->getPaymentAmount(),$order->getBaseCurrencyCode()),
135
+ 'attributes' => array(
136
+ 'currency' => $order->getBaseCurrencyCode(),
137
+ )
138
+ )
139
+ );
140
+
141
+ $paymentData = array(
142
+ 'cvn' => array(
143
+ 'number' => array('value' => $this->getRealexSession()->getTokenCvv())
144
+ )
145
+ );
146
+ $request['paymentdata'] = $paymentData;
147
+
148
+ $request['payerref'] = array('value' => $helper->getCustomerPayerRef($order->getCustomer()->getId()));
149
+ $request['paymentmethod'] = array('value' => $this->_token->getToken());
150
+
151
+ $sha1hash = array(
152
+ $request['attributes']['timestamp'] ,
153
+ $request['merchantid']['value'],
154
+ $request['orderid']['value'],
155
+ $request['amount']['value'],
156
+ $request['amount']['attributes']['currency'],
157
+ $request['payerref']['value']
158
+ );
159
+
160
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
161
+
162
+ if(!empty($this->_mpiData)){
163
+
164
+ $request['mpi'] = $this->_mpiData;
165
+ }
166
+
167
+ $billing = $order->getBillingAddress();
168
+ if($order->getIsVirtual()){
169
+ $shipping = $billing;
170
+ }else{
171
+ $shipping = $order->getShippingAddress();
172
+ }
173
+
174
+ $tssinfo = array(
175
+ 'custnum' => array('value' => $helper->getSessionCustomerId()),
176
+ 'custipaddress' => array('value' => $helper->getClientIpAddress()),
177
+ 'varref' => array('value' => $billing->getEmail())
178
+ );
179
+
180
+ $billingAddress = array(
181
+ 'attributes' => array(
182
+ 'type' => 'billing'
183
+ ),
184
+ 'code' => array('value' => $helper->getTssCode($billing)),
185
+ 'country' => array('value' => $billing->getCountry()),
186
+
187
+ );
188
+
189
+ $shippingAddress = array(
190
+ 'attributes' => array(
191
+ 'type' => 'shipping'
192
+ ),
193
+ 'code' => array('value' => $helper->getTssCode($shipping)),
194
+ 'country' => array('value' => $shipping->getCountry()),
195
+ );
196
+
197
+ $tssinfo['multiple']['address'][] = $billingAddress;
198
+ $tssinfo['multiple']['address'][] = $shippingAddress;
199
+
200
+
201
+ $request['tssinfo'] = $tssinfo;
202
+
203
+ $request['autosettle'] = array(
204
+ 'attributes' =>
205
+ array(
206
+ 'flag' => ($this->_method == 'capture'?'1':'0')
207
+ )
208
+ );
209
+
210
+ $request['comments'] = $this->_addComments();
211
+
212
+ $this->_message->setData(array('request'=>$request));
213
+
214
+ $this->getRealexSession()->setTokenCvv('');
215
+
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * Prepare transaction request 3d capture
221
+ *
222
+ * @return $this
223
+ */
224
+ protected function _prepareThreedCapture($mdData){
225
+
226
+ $transaction = $this->_service->getTransaction();
227
+ $helper = $this->_getHelper();
228
+ $order = $this->_service->getOrder();
229
+
230
+ $request = array(
231
+ 'attributes' => array(
232
+ 'timestamp' => $helper->getTimestamp(),
233
+ 'type' => "receipt-in"
234
+ ),
235
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
236
+ 'account' => array('value' => $transaction->getAdditionalInformation('account')),
237
+ 'orderid' => array('value' => $transaction->getAdditionalInformation('orderid')),
238
+ 'amount' => array(
239
+ 'value' => $transaction->getAdditionalInformation('payment_amount'),
240
+ 'attributes' => array(
241
+ 'currency' => $transaction->getAdditionalInformation('currency'),
242
+ )
243
+ )
244
+ );
245
+
246
+ $paymentData = array(
247
+ 'cvn' => array(
248
+ 'number' => array('value' => $mdData['token_cvv'])
249
+ )
250
+ );
251
+ $request['paymentdata'] = $paymentData;
252
+
253
+ $request['payerref'] = array('value' => $helper->getCustomerPayerRef($this->_customer->getId()));
254
+ $request['paymentmethod'] = array('value' => $this->_token->getToken());
255
+
256
+ $sha1hash = array(
257
+ $request['attributes']['timestamp'] ,
258
+ $request['merchantid']['value'],
259
+ $request['orderid']['value'],
260
+ $request['amount']['value'],
261
+ $request['amount']['attributes']['currency'],
262
+ $request['payerref']['value']
263
+ );
264
+
265
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
266
+
267
+ $request['mpi'] = $this->_mpiData;
268
+
269
+ $billing = $order->getBillingAddress();
270
+ if($order->getIsVirtual()){
271
+ $shipping = $billing;
272
+ }else{
273
+ $shipping = $order->getShippingAddress();
274
+ }
275
+
276
+ $tssinfo = array(
277
+ 'custnum' => array('value' => $helper->getSessionCustomerId()),
278
+ 'custipaddress' => array('value' => $helper->getClientIpAddress()),
279
+ 'varref' => array('value' => $billing->getEmail())
280
+ );
281
+
282
+ $billingAddress = array(
283
+ 'attributes' => array(
284
+ 'type' => 'billing'
285
+ ),
286
+ 'code' => array('value' => $helper->getTssCode($billing)),
287
+ 'country' => array('value' => $billing->getCountry()),
288
+
289
+ );
290
+
291
+ $shippingAddress = array(
292
+ 'attributes' => array(
293
+ 'type' => 'shipping'
294
+ ),
295
+ 'code' => array('value' => $helper->getTssCode($shipping)),
296
+ 'country' => array('value' => $shipping->getCountry()),
297
+ );
298
+
299
+ $tssinfo['multiple']['address'][] = $billingAddress;
300
+ $tssinfo['multiple']['address'][] = $shippingAddress;
301
+
302
+
303
+ $request['tssinfo'] = $tssinfo;
304
+
305
+ $request['autosettle'] = array(
306
+ 'attributes' =>
307
+ array(
308
+ 'flag' => ($this->_method == 'capture'?'1':'0')
309
+ )
310
+ );
311
+
312
+ $request['comments'] = $this->_addComments();
313
+
314
+ $this->_message->setData(array('request'=>$request));
315
+
316
+ return $this;
317
+ }
318
+
319
+ /**
320
+ * Prepare transaction request 3d verify
321
+ *
322
+ * @return $this
323
+ */
324
+ protected function _prepareThreedVerify($pares, $mdData){
325
+
326
+ $transaction = $this->_service->getTransaction();
327
+
328
+ $helper = $this->_getHelper();
329
+
330
+
331
+ $request = array(
332
+ 'attributes' => array(
333
+ 'timestamp' => $helper->getTimestamp(),
334
+ 'type' => '3ds-verifysig'
335
+ ),
336
+ 'merchantid' => array('value' => $helper->getConfigData('realex','vendor')),
337
+ 'account' => array('value' => $transaction->getAdditionalInformation('account')),
338
+ 'orderid' => array('value' => $transaction->getAdditionalInformation('orderid')),
339
+ 'amount' => array(
340
+ 'value' => $transaction->getAdditionalInformation('payment_amount'),
341
+ 'attributes' => array(
342
+ 'currency' => $transaction->getAdditionalInformation('currency'),
343
+ )
344
+ )
345
+ );
346
+
347
+ $sha1hash = array(
348
+ $request['attributes']['timestamp'] ,
349
+ $request['merchantid']['value'],
350
+ $request['orderid']['value'],
351
+ $request['amount']['value'],
352
+ $request['amount']['attributes']['currency'],
353
+ ''
354
+ );
355
+
356
+ $request['sha1hash'] = array('value' => $helper->generateSha1Hash($helper->getConfigData('realex','secret'),$sha1hash));
357
+ $request['pares'] = array('value'=>$pares);
358
+
359
+ $this->_message->setData(array('request'=>$request));
360
+
361
+ return $this;
362
+ }
363
+
364
+ /**
365
+ * Append comments to transaction message
366
+ *
367
+ * @return array
368
+ */
369
+ protected function _addComments(){
370
+
371
+ $comments = array();
372
+
373
+ $comment1 = array(
374
+ 'attributes' => array(
375
+ 'id' => 1,
376
+ ),
377
+ 'value' => 'magento - ' . Mage::getVersion()
378
+ );
379
+ $comment2 = array(
380
+ 'attributes' => array(
381
+ 'id' => 2,
382
+ ),
383
+ 'value' => 'yoma ' . $this->_getHelper()->getVersion()
384
+ );
385
+
386
+ $comments['multiple']['comment'][] = $comment1;
387
+ $comments['multiple']['comment'][] = $comment2;
388
+
389
+ return $comments;
390
+ }
391
+
392
+ /**
393
+ * Retrieve token
394
+ *
395
+ * @return mixed
396
+ */
397
+ protected function _hasToken(){
398
+
399
+ // if active and have id get token
400
+ if( Mage::getStoreConfig('payment/realvault/active', Mage::app()->getStore()) && $this->_service->getPayment()->getRealexTokenCcId()){
401
+ return $this->_getHelper()->getToken($this->_service->getPayment()->getRealexTokenCcId());
402
+ }
403
+
404
+ return NULL;
405
+ }
406
+
407
+ /**
408
+ * @return Mage_Core_Helper_Abstract|mixed
409
+ */
410
+ protected function _getHelper(){
411
+
412
+ return mage::helper('realex');
413
+ }
414
+
415
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Authorize.php ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Authorize extends Yoma_Realex_Model_Payment_Token_Capture{
21
+
22
+ protected $_allowedMethods = array('authorize');
23
+ protected $_method = 'authorize';
24
+ protected $_action = 'authorize';
25
+ protected $_captureType = 'authorize';
26
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Capture.php ADDED
@@ -0,0 +1,333 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Capture extends Yoma_Realex_Model_Payment_Token{
21
+
22
+ protected $_code = 'token';
23
+ protected $_allowedMethods = array('capture');
24
+ protected $_method = 'capture';
25
+ protected $_action = 'capture';
26
+ protected $_mpiData = array();
27
+ protected $_useToken = null;
28
+ protected $_captureType = 'capture';
29
+ protected $_customer = NULL;
30
+
31
+ /**
32
+ * Create reference for current transaction.
33
+ *
34
+ * @param Varien_Object $payment
35
+ * @return String
36
+ */
37
+ public function getTransactionReference($payment){
38
+
39
+ return $this->_getHelper()
40
+ ->getTransactionReference($payment->getOrder());
41
+ }
42
+
43
+ /**
44
+ * Process 3dSecure Callback
45
+ *
46
+ * @return $this
47
+ * @throws Exception
48
+ */
49
+ public function processCallback(){
50
+
51
+ $this->addPaymentInfo('Customer returned from 3DSecure ACS URL', 'Complete');
52
+
53
+ $this->_service->debugData(array('response'=>$this->_response->getData()));
54
+
55
+ if (!$this->_response->getMd() || !$this->_response->getPares()) {
56
+ throw new Exception(
57
+ $this->_getHelper()->__('MD or PARES not provided in 3D Secure callback.')
58
+ );
59
+ }
60
+ $pares = $this->_response->getPares();
61
+
62
+ // decrypt the MD data from the 3D Secure response
63
+ $mdData = $this->_recieveMdData($this->_response->getMd());
64
+
65
+
66
+ // ensure the transaction reference in the response data matches Magento
67
+ $callbackReference = $mdData['transaction_reference'];
68
+ $savedReference = $this->_service->getTransaction()->getTransactionReference();
69
+ if (strcmp($callbackReference, $savedReference) !== 0) {
70
+ $message = $this->_getHelper()->__('Transaction reference mismatch.');
71
+
72
+ throw new Exception(
73
+ $message
74
+ );
75
+ }
76
+ try{
77
+
78
+ $transConfig = new varien_object();
79
+ Mage::dispatchEvent('realex_process_callback', array('transaction'=>$this->_service->getTransaction(),'transport'=>$transConfig));
80
+
81
+ $this->_token = $this->_hasToken();
82
+
83
+ $customer = $this->_service->getOrder()->getCustomer();
84
+ $customerId = '';
85
+ if(isset($customer)){
86
+ $customerId = $customer->getId();
87
+ }else{
88
+ $customerId = $this->_service->getOrder()->getCustomerId();
89
+ }
90
+ $this->_customer = mage::getModel('customer/customer')->load($customerId);
91
+
92
+ $this->_method = 'threedSecureVerify';
93
+ $this->_setMessage($this->_method);
94
+ $this->_setResponse($this->_method);
95
+ $this->_prepareThreedVerify($pares,$mdData);
96
+
97
+ $this->addPaymentInfo('3DSecure Signature Verification', 'Started');
98
+
99
+ $this->_send(
100
+ $this->_getServiceUrl(),
101
+ $this->_message->prepareMessage()
102
+ );
103
+
104
+ $this->addPaymentInfo('ECI Result', $this->_response->getThreedsecureEci());
105
+
106
+ $eci = $this->_response->getEciFromThreedSecureVerifySignature(
107
+ $this->_response->getResult(),
108
+ $this->_response->getThreedsecureStatus(),
109
+ ($this->_token?$this->_token->getCardType():$this->_service->getTransaction()->getAdditionalInformation('card_type')),
110
+ $this->_threedSecureCardTypes,
111
+ $this->_getHelper()->getConfigData('realvault','require_liability_shift'),
112
+ $transConfig
113
+ );
114
+
115
+ $this->addPaymentInfo('ECI Result', $eci);
116
+ $this->_setMpiData('eci',$eci);
117
+
118
+ }catch(Yoma_Realex_Model_Exception_NoLiabilityShift $e){
119
+ throw new Exception($e->getMessage());
120
+ }
121
+
122
+ $this->_setMpiData('cavv',$this->_response->getThreedsecureCavv());
123
+ $this->_setMpiData('xid',$this->_response->getThreedsecureXid());
124
+ $this->_threedCapture(
125
+ $mdData
126
+ );
127
+
128
+ return $this;
129
+ }
130
+
131
+ /**
132
+ * Call 3dCapture on payment gateway
133
+ *
134
+ * @param array $mdData
135
+ * @param string $method
136
+ * @throws Exception
137
+ */
138
+ protected function _threedCapture($mdData,$method = 'capture'){
139
+
140
+ $this->_method = $this->_captureType;
141
+ $this->_action = $this->_captureType;
142
+ $this->_setMessage($this->_method);
143
+ $this->_setResponse($this->_method);
144
+
145
+ $this->_prepareThreedCapture($mdData);
146
+
147
+ Mage::dispatchEvent(
148
+ 'realex_before_capture',
149
+ array(
150
+ 'method'=>$this->_method,
151
+ 'message'=>$this->_message->getData(),
152
+ 'code'=>$this->_code,
153
+ 'url'=>$this->_getServiceUrl(),
154
+ )
155
+ );
156
+
157
+ $this->addPaymentInfo('Payment ' . $this->_method, 'Started');
158
+ $this->_send(
159
+ $this->_getServiceUrl(),
160
+ $this->_message->prepareMessage()
161
+ );
162
+
163
+ $this->_response->isValid();
164
+
165
+ Mage::dispatchEvent(
166
+ 'realex_before_process_response',
167
+ array(
168
+ 'method'=>$this->_method,
169
+ 'response'=>$this->_response->getData(),
170
+ 'code'=>$this->_code
171
+ )
172
+ );
173
+
174
+ $this->addPaymentInfo(array(
175
+ 'Result' => $this->_response->getResult(),
176
+ 'Auth Code' => $this->_response->getAuthcode(),
177
+ 'Message' => $this->_response->getMessage(),
178
+ 'Transaction Reference' => $this->_response->getOrderid(),
179
+ 'CVN Result' => $this->_response->getCvnresult(),
180
+ 'AVS Address Result' => $this->_response->getAvsaddressresponse(),
181
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesponse(),
182
+ 'TSS Result' => $this->_response->getTssResult(),
183
+ ));
184
+
185
+ if($this->_method == 'authorize'){
186
+ $this->unsetPaymentInfo(array('CVN Result','AVS Address Result','AVS Postcode Result'));
187
+ }
188
+
189
+ $this->_response->processResult();
190
+
191
+ }
192
+
193
+ /**
194
+ * Start transaction with payment gateway
195
+ *
196
+ * @return $this|mixed
197
+ * @throws Exception
198
+ */
199
+ protected function _pay(){
200
+
201
+ $eci = null;
202
+ $this->_setMethodRedirect(null);
203
+ $this->getRealexSession()->setTokenSaved(false);
204
+ $this->_token = $this->_hasToken();
205
+
206
+ if($this->_token){
207
+ $cardType = $this->_token->getCardType();
208
+ }else{
209
+ throw new Mage_Payment_Model_Info_Exception('Token Not Valid');
210
+ }
211
+
212
+ $transConfig = $this->_requireThreedSecure($cardType);
213
+
214
+ if($transConfig->getRequire3DSecure()){
215
+
216
+ $this->_method = 'threedSecure';
217
+ $this->_action = 'threedSecureCapture';
218
+ $this->_setMessage($this->_method);
219
+ $this->_setResponse($this->_method);
220
+
221
+ $this->_setMpiData('eci',
222
+ $this->_response->getEciValue($cardType,false)
223
+ );
224
+
225
+ try{
226
+ $this->addPaymentInfo('3DSecure Verify Cardholder Enrollment', 'Started');
227
+ $this->_prepareThreedRegister();
228
+ $this->_service->saveTransaction();
229
+ $this->_send(
230
+ $this->_getServiceUrl(),
231
+ $this->_message->prepareMessage()
232
+ );
233
+ $this->_response->processResult();
234
+ $this->_response->isValid();
235
+
236
+ if($this->_response->getUrl() == ''){
237
+ $message = $this->_getHelper()->__('ThreedSecure-VerifyEnrolled Returned No Url');
238
+
239
+ throw new Exception($message);
240
+ }
241
+ $this->_service->getPayment()->setIsTransactionPending(true);
242
+ $this->_prepareAclPost();
243
+ $this->_setMethodRedirect($this->_getRedirectUrl());
244
+ $this->addPaymentInfo('Customer redirected to 3DSecure ACS URL', 'Started');
245
+ return;
246
+
247
+ }catch(Yoma_Realex_Model_Exception_NoneParticipatingCard $e) {
248
+
249
+ $this->_participatingCard = false;
250
+ $this->_clearMpiData();
251
+ }catch(Yoma_Realex_Model_Exception_NotEnrolled $e) {
252
+ //nothing to do
253
+ }
254
+ if($this->_participatingCard) {
255
+
256
+ try {
257
+ $eci = $this->_response->getEciFromThreedSecureSignature(
258
+ $this->_response->getResult(),
259
+ $this->_response->getEnrolled(),
260
+ $cardType,
261
+ $this->_getHelper()->getConfigData('realvault', 'require_liability_shift'),
262
+ $transConfig
263
+ );
264
+ $this->_setMpiData('eci', $eci);
265
+
266
+ } catch (Yoma_Realex_Model_Exception_NoLiabilityShift $e) {
267
+ throw new Exception($e->getMessage());
268
+ }
269
+
270
+ }
271
+ }
272
+
273
+ $this->_capture();
274
+
275
+ return $this;
276
+ }
277
+
278
+ /**
279
+ * Capture payment on gateway
280
+ *
281
+ * @param string $method
282
+ * @throws Exception
283
+ */
284
+ protected function _capture($method = 'capture'){
285
+
286
+ $this->_method = $this->_captureType;
287
+ $this->_action = $this->_captureType;
288
+ $this->_setMessage($this->_method);
289
+ $this->_setResponse($this->_method);
290
+
291
+ $this->_prepareCapture();
292
+
293
+ Mage::dispatchEvent(
294
+ 'realex_before_capture',
295
+ array(
296
+ 'method'=>$this->_method,
297
+ 'message'=>$this->_message->getData(),
298
+ 'url'=>$this->_getServiceUrl()
299
+ )
300
+ );
301
+ $this->addPaymentInfo('Payment ' . $this->_method, 'Started');
302
+ $this->_send(
303
+ $this->_getServiceUrl(),
304
+ $this->_message->prepareMessage()
305
+ );
306
+
307
+ $this->_response->isValid();
308
+
309
+ Mage::dispatchEvent(
310
+ 'realex_before_process_response',
311
+ array('method'=>$this->_method,'response'=>$this->_response->getData())
312
+ );
313
+
314
+ $this->addPaymentInfo(array(
315
+ 'Result' => $this->_response->getResult(),
316
+ 'Auth Code' => $this->_response->getAuthcode(),
317
+ 'Message' => $this->_response->getMessage(),
318
+ 'Transaction Reference' => $this->_response->getOrderid(),
319
+ 'CVN Result' => $this->_response->getCvnresult(),
320
+ 'AVS Address Result' => $this->_response->getAvsaddressresponse(),
321
+ 'AVS Postcode Result' => $this->_response->getAvspostcoderesponse(),
322
+ 'TSS Result' => $this->_response->getTssResult(),
323
+ ));
324
+
325
+ if($this->_method == 'authorize'){
326
+ $this->unsetPaymentInfo(array('CVN Result','AVS Address Result','AVS Postcode Result'));
327
+ }
328
+
329
+ $this->_response->processResult();
330
+
331
+ }
332
+
333
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Delete.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Delete extends Yoma_Realex_Model_Payment_Token{
21
+
22
+ protected $_code = 'token';
23
+ protected $_allowedMethods = array('delete');
24
+ protected $_method = 'delete';
25
+ protected $_action = 'delete';
26
+ protected $_mpiData = array();
27
+
28
+
29
+ /**
30
+ * Start transaction with payment gateway
31
+ *
32
+ * @return $this|mixed
33
+ * @throws Exception
34
+ */
35
+ protected function _pay(){
36
+
37
+ $this->_method = $this->_method;
38
+ $this->_action = $this->_action;
39
+ $this->_setMessage($this->_method);
40
+ $this->_setResponse($this->_method);
41
+
42
+ $this->_prepareDelete();
43
+
44
+ $this->_send(
45
+ $this->_getServiceUrl(),
46
+ $this->_message->prepareMessage()
47
+ );
48
+
49
+ $this->_response->isValid();
50
+ $this->_response->processResult();
51
+
52
+ $token = $this->_service->getToken();
53
+ $token->delete();
54
+
55
+ return $this;
56
+
57
+ }
58
+
59
+ /**
60
+ * Prepare transaction request delete
61
+ *
62
+ * @return $this
63
+ */
64
+ protected function _prepareDelete() {
65
+
66
+ $token = $this->_service->getToken();
67
+
68
+ if(!$token->getId()){
69
+ throw new Exception($this->__('Token not valid'));
70
+ }
71
+
72
+ $customer = mage::getModel('customer/customer')->load($token->getCustomerId());
73
+ if(!$customer->getId()){
74
+ throw new Exception($this->__('Customer not valid'));
75
+ }
76
+
77
+ $request = array(
78
+ 'attributes' => array(
79
+ 'timestamp' => $this->_getHelper()->getTimestamp(),
80
+ 'type' => 'card-cancel-card'
81
+ ),
82
+ 'merchantid' => array('value' => $this->_getHelper()->getConfigData('realex', 'vendor')),
83
+ );
84
+
85
+ $card = array(
86
+ 'ref'=>array('value' => $token->getToken()),
87
+ 'payerref' =>array('value' => $customer->getRealexPayerRef()),
88
+
89
+ );
90
+
91
+ $request['card'] = $card;
92
+
93
+ $sha1hash = array(
94
+ $request['attributes']['timestamp'] ,
95
+ $request['merchantid']['value'],
96
+ $request['card']['payerref']['value'],
97
+ $request['card']['ref']['value'],
98
+ );
99
+
100
+ $request['sha1hash'] = array('value' => $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$sha1hash));
101
+
102
+ $request['comments'] = $this->_addComments();
103
+
104
+ $this->_message->setData(array('request'=>$request));
105
+ return $this;
106
+ }
107
+
108
+ /**
109
+ * Append comments to transaction message
110
+ *
111
+ * @return array
112
+ */
113
+ protected function _addComments(){
114
+
115
+ $comments = array();
116
+
117
+ $comment1 = array(
118
+ 'attributes' => array(
119
+ 'id' => 1,
120
+ ),
121
+ 'value' => ($this->_getHelper()->updateAdminCard()?'Magento admin request':'Magento customer request')
122
+ );
123
+ $comment2 = array(
124
+ 'attributes' => array(
125
+ 'id' => 2,
126
+ ),
127
+ 'value' => 'yoma ' . $this->_getHelper()->getVersion()
128
+ );
129
+
130
+ $comments['multiple']['comment'][] = $comment1;
131
+ $comments['multiple']['comment'][] = $comment2;
132
+
133
+ return $comments;
134
+
135
+ }
136
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/EditPayer.php ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_EditPayer extends Yoma_Realex_Model_Payment_Token{
21
+
22
+ protected $_code = 'token';
23
+ protected $_allowedMethods = array('editPayer');
24
+ protected $_method = 'editPayer';
25
+ protected $_action = 'editPayer';
26
+ protected $_mpiData = array();
27
+
28
+
29
+ /**
30
+ * Start transaction with payment gateway
31
+ *
32
+ * @return $this|mixed
33
+ * @throws Exception
34
+ */
35
+ protected function _pay(){
36
+
37
+ $this->_method = $this->_method;
38
+ $this->_action = $this->_action;
39
+ $this->_setMessage($this->_method);
40
+ $this->_setResponse($this->_method);
41
+
42
+ $this->_prepareEditPayer();
43
+
44
+ $this->_send(
45
+ $this->_getServiceUrl(),
46
+ $this->_message->prepareMessage()
47
+ );
48
+
49
+ $this->_response->isValid();
50
+ $this->_response->processResult();
51
+
52
+ return $this;
53
+
54
+ }
55
+
56
+ /**
57
+ * Prepare transaction request edit payer
58
+ *
59
+ * @return $this
60
+ */
61
+ protected function _prepareEditPayer() {
62
+
63
+ $token = $this->_service->getToken();
64
+
65
+ if(!$token->getId()){
66
+ throw new Exception($this->__('Token not valid'));
67
+ }
68
+
69
+ $customer = mage::getModel('customer/customer')->load($token->getCustomerId());
70
+
71
+ if(!$customer->getId()){
72
+ throw new Exception($this->__('Customer not valid'));
73
+ }
74
+
75
+ $address = $customer->getPrimaryBillingAddress();
76
+ if (!$address->getId()){
77
+ throw new Exception($this->__('Customer Address not valid'));
78
+ }
79
+
80
+ $request = array(
81
+ 'attributes' => array(
82
+ 'timestamp' => $this->_getHelper()->getTimestamp(),
83
+ 'type' => 'payer-edit'
84
+ ),
85
+ 'merchantid' => array('value' => $this->_getHelper()->getConfigData('realex', 'vendor')),
86
+ 'orderid' => array('value' => $this->_getHelper()->getEditPayerReference($customer->getId()) . '-payer')
87
+ );
88
+
89
+ $payer = array(
90
+ 'attributes' => array(
91
+ 'ref' => $customer->getRealexPayerRef(),
92
+ 'type'=> $this->_getHelper()->getConfigData('realvault','payer_type')
93
+ ),
94
+ 'firstname' => array('value' => $customer->getFirstname()),
95
+ 'surname' => array('value' => $customer->getLastname()),
96
+ 'email' => array('value' => $customer->getEmail())
97
+ );
98
+
99
+ $payerAddress = array(
100
+
101
+ 'line1' => array('value' => $address->getStreet(1)),
102
+ 'line2' => array('value' => $address->getStreet(2)),
103
+ 'line3' => array('value' => $address->getStreet(3)),
104
+ 'city' => array('value' => $address->getCity()),
105
+ 'county'=> array('value' => $address->getRegion()),
106
+ 'postcode' => array('value' => $address->getPostcode()),
107
+ 'country' => array(
108
+ 'attributes' => array(
109
+ 'code' => $address->getCountryId()
110
+ ),
111
+ 'value' => Mage::app()->getLocale()->getCountryTranslation($address->getCountryId())
112
+ )
113
+ );
114
+
115
+ $payer['address'] = $payerAddress;
116
+ $request['payer'] = $payer;
117
+
118
+ $sha1hash = array(
119
+ $request['attributes']['timestamp'] ,
120
+ $request['merchantid']['value'],
121
+ $request['orderid']['value'],
122
+ '',
123
+ '',
124
+ $request['payer']['attributes']['ref'],
125
+ );
126
+
127
+ $request['sha1hash'] = array('value' => $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$sha1hash));
128
+
129
+ $this->_message->setData(array('request'=>$request));
130
+ return $this;
131
+ }
132
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/EditToken.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_EditToken extends Yoma_Realex_Model_Payment_Token{
21
+
22
+ protected $_code = 'token';
23
+ protected $_allowedMethods = array('editToken');
24
+ protected $_method = 'editToken';
25
+ protected $_action = 'editToken';
26
+ protected $_mpiData = array();
27
+
28
+ protected function _pay(){
29
+
30
+ $this->_method = $this->_method;
31
+ $this->_action = $this->_action;
32
+ $this->_setMessage($this->_method);
33
+ $this->_setResponse($this->_method);
34
+
35
+ $this->_prepareEditToken();
36
+
37
+ $this->_send(
38
+ $this->_getServiceUrl(),
39
+ $this->_message->prepareMessage()
40
+ );
41
+
42
+ $this->_response->isValid();
43
+ $this->_response->processResult();
44
+
45
+ $model = Mage::getModel("realex/tokencard")
46
+ ->addData($this->_service->getCardData())
47
+ ->setId($this->_service->getToken()->getId())
48
+ ->save();
49
+
50
+ return $this;
51
+
52
+ }
53
+
54
+
55
+ /**
56
+ * Prepare transaction request edit token
57
+ *
58
+ * @return $this
59
+ */
60
+ protected function _prepareEditToken() {
61
+
62
+ $token = $this->_service->getToken();
63
+ $data = $this->_service->getCardData();
64
+
65
+ if(!$token->getId()){
66
+ throw new Exception($this->__('Token not valid'));
67
+ }
68
+
69
+ $request = array(
70
+ 'attributes' => array(
71
+ 'timestamp' => $this->_getHelper()->getTimestamp(),
72
+ 'type' => 'card-update-card'
73
+ ),
74
+ 'merchantid' => array('value' => $this->_getHelper()->getConfigData('realex', 'vendor')),
75
+ );
76
+
77
+ $card = array(
78
+
79
+ 'ref' => array('value' => $token->getToken()),
80
+ 'payerref' => array('value' => $token->getPayerRef()),
81
+ 'expdate' =>array('value' => $data['expiry_date']),
82
+ 'chname' => array('value' => $data['ch_name']),
83
+ 'type' => array('value' => $token->getCardType()),
84
+ );
85
+
86
+ $request['card'] = $card;
87
+
88
+ $sha1hash = array(
89
+ $request['attributes']['timestamp'] ,
90
+ $request['merchantid']['value'],
91
+ $request['card']['payerref']['value'],
92
+ $request['card']['ref']['value'],
93
+ $request['card']['expdate']['value'],
94
+ '',
95
+ );
96
+
97
+ $request['sha1hash'] = array('value' => $this->_getHelper()->generateSha1Hash($this->_getHelper()->getConfigData('realex','secret'),$sha1hash));
98
+
99
+ $request['comments'] = $this->_addComments();
100
+
101
+ $this->_message->setData(array('request'=>$request));
102
+ return $this;
103
+ }
104
+
105
+
106
+ /**
107
+ * Append comments to transaction message
108
+ *
109
+ * @return array
110
+ */
111
+ protected function _addComments(){
112
+
113
+ $comments = array();
114
+ $comment1 = array(
115
+ 'attributes' => array(
116
+ 'id' => 1,
117
+ ),
118
+ 'value' => ($this->_getHelper()->updateAdminCard()?'Magento admin request':'Magento customer request')
119
+ );
120
+ $comment2 = array(
121
+ 'attributes' => array(
122
+ 'id' => 2,
123
+ ),
124
+ 'value' => 'yoma ' . $this->_getHelper()->getVersion()
125
+ );
126
+
127
+ $comments['multiple']['comment'][] = $comment1;
128
+ $comments['multiple']['comment'][] = $comment2;
129
+
130
+ return $comments;
131
+
132
+ }
133
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Partial.php ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Partial extends Yoma_Realex_Model_Payment_Direct_Partial{
21
+
22
+ protected $_code = 'token';
23
+ protected $_allowedMethods = array('partial');
24
+ protected $_method = 'partial';
25
+ protected $_action = 'partial';
26
+ protected $_mpiData = array();
27
+ protected $_useToken = null;
28
+ protected $_captureType = 'partial';
29
+ protected $_customer = NULL;
30
+
31
+
32
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Refund.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Refund extends Yoma_Realex_Model_Payment_Direct_Refund{
21
+
22
+ protected $_code = 'token';
23
+ protected $_method = 'refund';
24
+ protected $_action = 'refund';
25
+ protected $_allowedMethods = array('refund');
26
+
27
+ }
app/code/community/Yoma/Realex/Model/Payment/Token/Void.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Payment_Token_Void extends Yoma_Realex_Model_Payment_Direct_Void{
21
+
22
+ protected $_code = 'token';
23
+ protected $_method = 'void';
24
+ protected $_action = 'void';
25
+ protected $_allowedMethods = array('void');
26
+
27
+
28
+ }
app/code/community/Yoma/Realex/Model/PaymentInfo.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_PaymentInfo extends Mage_Core_Model_Abstract
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ $this->_init('realex/paymentInfo');
26
+ }
27
+
28
+ public function saveSectionData($paymentId, $identifier, $data)
29
+ {
30
+ if (is_null($paymentId) || $identifier == '') {
31
+ return $this;
32
+ }
33
+
34
+ if (is_array($data)) {
35
+ foreach ($data as $_key => $_value) {
36
+ if (is_null($_value) || !is_string($_value) || $_value == '') {
37
+ unset($data[$_key]);
38
+ }
39
+ }
40
+ if (count($data) < 1) {
41
+ return $this;
42
+ }
43
+ } elseif (trim($data) == '') {
44
+ return $this;
45
+ }
46
+
47
+ if (is_array($data)) {
48
+ $data = @serialize($data);
49
+ } else {
50
+ $data = trim($data);
51
+ }
52
+
53
+ $this->_getInstance()
54
+ ->addData(array(
55
+ 'payment_id' => $paymentId,
56
+ 'field' => $identifier,
57
+ 'value' => $data,
58
+ ))
59
+ ->save();
60
+
61
+ return $this;
62
+ }
63
+
64
+
65
+ public function getDataPairs($paymentId)
66
+ {
67
+ $data = array();
68
+
69
+ if (is_null($paymentId)) {
70
+ return $data;
71
+ }
72
+
73
+ $collection = $this->getCollection()
74
+ ->addFieldToFilter('payment_id', $paymentId);
75
+
76
+ foreach ($collection as $_paymentInfo) {
77
+ $arrayData = @unserialize($_paymentInfo->getValue());
78
+ if (is_array($arrayData)) {
79
+ $data[$_paymentInfo->getField()] = $arrayData;
80
+ } else {
81
+ $data[$_paymentInfo->getField()] = $_paymentInfo->getValue();
82
+ }
83
+ }
84
+
85
+ return $data;
86
+ }
87
+
88
+ protected function _getInstance()
89
+ {
90
+ return Mage::getModel('realex/paymentInfo');
91
+ }
92
+ }
app/code/community/Yoma/Realex/Model/Realex/Source/Cards.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Realex_Source_Cards extends Mage_Payment_Model_Source_Cctype
21
+ {
22
+
23
+ protected $_supportedCcTypes = array(
24
+ 'AE' => 'AMEX',
25
+ 'VI' => 'VISA',
26
+ 'MC' => 'MC',
27
+ //'SM' => 'SWITCH',
28
+ 'YOMA_DINERS_CLUB' => 'DINERS',
29
+ 'YOMA_MAESTRO' => 'MC'
30
+ );
31
+
32
+ protected $_legacyCcTypes = array(
33
+ 'SWITCH' => 'YOMA_MAESTRO'
34
+ );
35
+
36
+ /**
37
+ * Get supported card types to option array
38
+ *
39
+ * @return array
40
+ */
41
+ public function toOptionArray()
42
+ {
43
+ $this->setAllowedTypes(array_keys($this->getSupportedCardTypes()));
44
+
45
+ return parent::toOptionArray();
46
+ }
47
+
48
+ /**
49
+ * Get supported card types
50
+ *
51
+ * @return array
52
+ */
53
+ public function getSupportedCardTypes()
54
+ {
55
+ return $this->_supportedCcTypes;
56
+ }
57
+
58
+ /**
59
+ * Get redundant card types
60
+ *
61
+ * @return array
62
+ */
63
+ public function getLegacyCardTypes()
64
+ {
65
+ return $this->_legacyCcTypes;
66
+ }
67
+
68
+ /**
69
+ * Convert magento card type to realex type
70
+ *
71
+ * @param string $type
72
+ * @param bool $error
73
+ * @return mixed
74
+ * @throws Exception
75
+ */
76
+ public function getGatewayCardType($type,$error = true)
77
+ {
78
+ $supportedCardTypes = $this->getSupportedCardTypes();
79
+
80
+ if (!array_key_exists($type, $supportedCardTypes)) {
81
+ // if true throw exception else return type
82
+ if(!$error){
83
+ return $type;
84
+ }else {
85
+ throw new Exception(
86
+ mage::helper('realex')->__("Gateway does not support card type '{$type}'.")
87
+ );
88
+ }
89
+ }
90
+
91
+ return $supportedCardTypes[$type];
92
+ }
93
+
94
+ /**
95
+ * Retrieve magento card types
96
+ *
97
+ * @param string $type
98
+ * @return mixed
99
+ */
100
+ public function getMagentoCardType($type)
101
+ {
102
+ $cardTypes = $this->getSupportedCardTypes();
103
+
104
+ $legacyCardTypes = $this->getLegacyCardTypes();
105
+
106
+ if (array_key_exists($type, $legacyCardTypes)) {
107
+
108
+ return $legacyCardTypes[$type];
109
+ }
110
+
111
+ $result = $type;
112
+
113
+ while ($cardname = current($cardTypes)) {
114
+ if ($cardname == $type) {
115
+ $result = key($cardTypes);
116
+ break;
117
+ }
118
+ next($cardTypes);
119
+ }
120
+
121
+ return $result;
122
+
123
+ }
124
+
125
+ /**
126
+ * Convert legacy card to realex card
127
+ *
128
+ * @param string $type
129
+ * @return mixed
130
+ * @throws Exception
131
+ */
132
+ public function convertLegacyCardType($type){
133
+
134
+ $legacyCardTypes = $this->getLegacyCardTypes();
135
+
136
+ if (array_key_exists($type, $legacyCardTypes)) {
137
+
138
+ return $this->getGatewayCardType($legacyCardTypes[$type],false);
139
+ }
140
+
141
+ return $type;
142
+
143
+ }
144
+
145
+
146
+
147
+ }
app/code/community/Yoma/Realex/Model/Realex/Source/IframeSize.php ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Realex_Source_IframeSize
21
+ {
22
+
23
+ const SIZE_STANDARD = 1;
24
+ const SIZE_STANDARD_SECURE = 2;
25
+
26
+ protected $_sizes = array(
27
+ self::SIZE_STANDARD => 'Standard Card Processing',
28
+ self::SIZE_STANDARD_SECURE => 'Standard Card Processing with 3DSecure',
29
+ );
30
+
31
+ protected $_dimensions = array(
32
+ self::SIZE_STANDARD => array('600','620'),
33
+ self::SIZE_STANDARD_SECURE => array('600','650'),
34
+ );
35
+
36
+ /**
37
+ * Return sizes to option array
38
+ *
39
+ * @return array
40
+ */
41
+ public function toOptionArray()
42
+ {
43
+ $sizeOptions = array();
44
+
45
+ foreach ($this->_sizes as $key=>$_size) {
46
+
47
+ $sizeOptions[] = array(
48
+ 'value' => $key,
49
+ 'label' => Mage::helper('realex')->__($_size)
50
+ );
51
+ }
52
+
53
+ return $sizeOptions;
54
+ }
55
+
56
+ /**
57
+ * Return frame size
58
+ *
59
+ * @param string $size
60
+ * @return mixed
61
+ */
62
+ public function getDimensions($size){
63
+
64
+ if(in_array($size,$this->_dimensions)){
65
+ return $this->_dimensions[$size];
66
+ }
67
+
68
+ return $this->_dimensions[self::SIZE_STANDARD];
69
+ }
70
+ }
app/code/community/Yoma/Realex/Model/Realex/Source/PaymentAction.php ADDED
@@ -0,0 +1,92 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Realex_Source_PaymentAction extends Mage_Payment_Model_Method_Abstract
21
+ {
22
+
23
+ protected $_allowedActions = array(
24
+ self::ACTION_AUTHORIZE,
25
+ self::ACTION_AUTHORIZE_CAPTURE,
26
+ );
27
+
28
+ protected $_actions = array(
29
+ self::ACTION_AUTHORIZE => 'Authorize Only',
30
+ self::ACTION_AUTHORIZE_CAPTURE => 'Authorize and Capture',
31
+ );
32
+
33
+ /**
34
+ * Return payment actions to option array
35
+ *
36
+ * @return array
37
+ */
38
+ public function toOptionArray()
39
+ {
40
+ $paymentActions = array();
41
+
42
+ foreach ($this->_allowedActions as $_action) {
43
+ if (!array_key_exists($_action, $this->_actions)) {
44
+ continue;
45
+ }
46
+
47
+ $paymentActions[] = array(
48
+ 'value' => $_action,
49
+ 'label' => Mage::helper('realex')->__($this->_actions[$_action])
50
+ );
51
+ }
52
+
53
+ return $paymentActions;
54
+ }
55
+
56
+ /**
57
+ * Convert capture to authorize
58
+ *
59
+ * @param string $action
60
+ * @return string
61
+ */
62
+ public function toAuthorize($action){
63
+
64
+ if($action == self::ACTION_AUTHORIZE_CAPTURE){
65
+ return self::ACTION_AUTHORIZE;
66
+ }
67
+
68
+ return $action;
69
+ }
70
+
71
+ /**
72
+ * Return payment actions to array
73
+ *
74
+ * @return array
75
+ */
76
+ public function toArray(array $arrAttributes = Array())
77
+ {
78
+ return $this->_actions;
79
+ }
80
+
81
+ /**
82
+ * Check if payment method available
83
+ *
84
+ * @return bool
85
+ */
86
+ public function isActionAllowed($action){
87
+ if(in_array($action,$this->_allowedActions)){
88
+ return true;
89
+ }
90
+ return false;
91
+ }
92
+ }
app/code/community/Yoma/Realex/Model/Realex/Source/PaymentMode.php ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Realex_Source_PaymentMode {
21
+
22
+ /**
23
+ * Return modes to option array
24
+ *
25
+ * @return array
26
+ */
27
+ public function toOptionArray() {
28
+ return array(
29
+ array(
30
+ 'value' => 'test',
31
+ 'label' => Mage::helper('realex')->__('Sandbox')
32
+ ),
33
+ array(
34
+ 'value' => 'live',
35
+ 'label' => Mage::helper('realex')->__('Live')
36
+ )
37
+ );
38
+ }
39
+
40
+ /**
41
+ * Return modes to options
42
+ *
43
+ * @return array
44
+ */
45
+ public function toOptions() {
46
+ $options = $this->toOptionArray();
47
+
48
+ $modes = array();
49
+
50
+ for($i = 0; $i < count($options); $i++) {
51
+ $modes[$options[$i]['value']] = $options[$i]['label'];
52
+ }
53
+
54
+ return $modes;
55
+ }
56
+ }
app/code/community/Yoma/Realex/Model/Realex/Source/Status.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Realex_Source_Status
21
+ {
22
+
23
+ protected $_stateStatuses = array(
24
+ Mage_Sales_Model_Order::STATE_NEW,
25
+ Mage_Sales_Model_Order::STATE_PROCESSING,
26
+ );
27
+
28
+ /**
29
+ * Return statuses to option array
30
+ *
31
+ * @return array
32
+ */
33
+ public function toOptionArray()
34
+ {
35
+ $statuses = Mage::getSingleton('sales/order_config')
36
+ ->getStateStatuses($this->_stateStatuses);
37
+
38
+ $options = array();
39
+ foreach ($statuses as $code => $label) {
40
+ $options[] = array(
41
+ 'value' => $code,
42
+ 'label' => $label
43
+ );
44
+ }
45
+
46
+ return $options;
47
+ }
48
+ }
app/code/community/Yoma/Realex/Model/Redirect.php ADDED
@@ -0,0 +1,226 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Redirect extends Yoma_Realex_Model_Api_Payment{
21
+
22
+ /**
23
+ * Constant payment method code
24
+ */
25
+ const PAYMENT_METHOD_CODE = 'realexredirect';
26
+
27
+ /**
28
+ * Magento payment code.
29
+ *
30
+ * @var string $_code
31
+ */
32
+ protected $_code = self::PAYMENT_METHOD_CODE;
33
+
34
+ protected $_formBlockType = 'realex/form_redirect';
35
+ protected $_infoBlockType = 'realex/info_redirect';
36
+
37
+ protected $_isGateway = true;
38
+ protected $_canAuthorize = true;
39
+ protected $_canCapture = true;
40
+ protected $_canCapturePartial = false;
41
+ protected $_canReviewPayment = true;
42
+ protected $_canRefund = true;
43
+ protected $_canRefundInvoicePartial = true;
44
+ protected $_canUseInternal = false;
45
+ protected $_canUseForMultishipping = false;
46
+ protected $_isCcTypeRequired = false;
47
+ protected $_canVoid = true;
48
+ protected $_canOrder = false;
49
+ protected $_canUseCheckout = true;
50
+ protected $_isInitializeNeeded = false;
51
+ protected $_canFetchTransactionInfo = false;
52
+ protected $_canCreateBillingAgreement = false;
53
+ protected $_canManageRecurringProfiles = false;
54
+ protected $_canCancelInvoice = false;
55
+ protected $_canSaveCc = false;
56
+
57
+ protected $_canCallbackAccessSession = false;
58
+
59
+
60
+ protected function _getService()
61
+ {
62
+ $info = $this->getInfoInstance();
63
+ if($info->getRealexTokenCcId()){
64
+ return Mage::getModel('realex/service_token');
65
+ }
66
+ return Mage::getModel('realex/service_redirect');
67
+ }
68
+
69
+ protected function _registerTransaction(){
70
+
71
+ $this->_saveTransaction();
72
+
73
+ $this->_getPayment()->setIsTransactionPending(true);
74
+
75
+ }
76
+
77
+ /**
78
+ * Accept payment
79
+ *
80
+ * @TODO refactor to payment api
81
+ * @param Mage_Payment_Model_Info $payment
82
+ * @return bool
83
+ * @throws Exception
84
+ * @throws Mage_Core_Exception
85
+ */
86
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
87
+ {
88
+ if (method_exists(get_parent_class(), 'acceptPayment')) {
89
+ parent::acceptPayment($payment);
90
+ } else {
91
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
92
+ Mage::throwException(Mage::helper('realex')
93
+ ->__('The payment review action is unavailable.'));
94
+ }
95
+ }
96
+
97
+ if (true !== $payment->getData('payment_accept')) {
98
+ Mage::throwException('Online payments cannot be accepted manually.');
99
+ }
100
+
101
+ $requiredState = 'payment_review';
102
+
103
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
104
+ $comment = $payment->getOrder()->addStatusHistoryComment('An attempt was made to accept this payment.');
105
+ $comment->save();
106
+
107
+ throw new Exception('Only orders with status Payment Review can be accepted');
108
+ }
109
+
110
+ return true;
111
+ }
112
+
113
+ /**
114
+ * Deny payment
115
+ *
116
+ * @TODO refactor to payment api
117
+ * @param Mage_Payment_Model_Info $payment
118
+ * @return bool
119
+ * @throws Exception
120
+ * @throws Mage_Core_Exception
121
+ */
122
+ public function denyPayment(Mage_Payment_Model_Info $payment)
123
+ {
124
+ if (method_exists(get_parent_class(), 'denyPayment')) {
125
+ parent::denyPayment($payment);
126
+ } else {
127
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
128
+ Mage::throwException(Mage::helper('realex')
129
+ ->__('The payment review action is unavailable.'));
130
+ }
131
+ }
132
+
133
+
134
+ $requiredState = 'payment_review';
135
+
136
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
137
+ $comment = $payment->getOrder()->addStatusHistoryComment('Warning: An attempt was made to deny this payment.');
138
+ $comment->save();
139
+
140
+ throw new Exception("Only orders with status '{$requiredState}' can be denied online.");
141
+ }
142
+
143
+ return true;
144
+ }
145
+
146
+ public function isAvailable($quote = null) {
147
+ return Mage_Payment_Model_Method_Abstract::isAvailable($quote);
148
+ }
149
+
150
+
151
+ /**
152
+ * @return Mage_Core_Helper_Abstract|Mage_Payment_Helper_Data
153
+ */
154
+ protected function _getHelper()
155
+ {
156
+ return Mage::helper('realex/redirect');
157
+ }
158
+
159
+ /**
160
+ * Check if can void payment
161
+ *
162
+ * @TODO refactor
163
+ * @param Varien_Object $payment
164
+ * @return bool
165
+ */
166
+ public function canVoid(Varien_Object $payment)
167
+ {
168
+ $order = $this->getInfoInstance()->getOrder();
169
+
170
+ if($order->getInvoiceCollection()->count()){
171
+ $date = false;
172
+ foreach($order->getInvoiceCollection() as $invoice){
173
+ if(strtotime($date) < strtotime($invoice->getCreatedAt())){
174
+ $date = $invoice->getCreatedAt();
175
+ }
176
+ }
177
+
178
+ if(strtotime($date) < strtotime('tomorrow')){
179
+ return true;
180
+ }
181
+
182
+ return false;
183
+ }
184
+
185
+ if($order->getStatusHistoryCollection()->count() == 2){
186
+
187
+ $statusHistory = $order->getStatusHistoryCollection();
188
+
189
+ $requiredState = 0;
190
+ $requiredStates = array('canceled','payment_review');
191
+
192
+ foreach($statusHistory as $status){
193
+ if(in_array($status->getStatus(),$requiredStates)){
194
+ $requiredState ++;
195
+ }
196
+ }
197
+ if($requiredState == 2){
198
+ return false;
199
+ }
200
+ }
201
+
202
+ return $this->_canVoid;
203
+ }
204
+
205
+ /**
206
+ * Validate payment
207
+ *
208
+ * @return $this|Mage_Payment_Model_Abstract
209
+ * @throws Mage_Core_Exception
210
+ */
211
+ public function validate()
212
+ {
213
+
214
+ $paymentInfo = $this->getInfoInstance();
215
+ if ($paymentInfo instanceof Mage_Sales_Model_Order_Payment) {
216
+ $billingCountry = $paymentInfo->getOrder()->getBillingAddress()->getCountryId();
217
+ } else {
218
+ $billingCountry = $paymentInfo->getQuote()->getBillingAddress()->getCountryId();
219
+ }
220
+ if (!$this->canUseForCountry($billingCountry)) {
221
+ Mage::throwException(Mage::helper('payment')->__('Selected payment type is not allowed for billing country.'));
222
+ }
223
+ return $this;
224
+ }
225
+
226
+ }
app/code/community/Yoma/Realex/Model/Redirect.php.orig ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ class Yoma_Realex_Model_Redirect extends Yoma_Realex_Model_Api_Payment{
4
+
5
+ /**
6
+ * Constant payment method code
7
+ */
8
+ const PAYMENT_METHOD_CODE = 'realexredirect';
9
+
10
+ /**
11
+ * Magento payment code.
12
+ *
13
+ * @var string $_code
14
+ */
15
+ protected $_code = self::PAYMENT_METHOD_CODE;
16
+
17
+ protected $_formBlockType = 'realex/form_redirect';
18
+ protected $_infoBlockType = 'realex/info_redirect';
19
+
20
+ protected $_isGateway = true;
21
+ protected $_canAuthorize = true;
22
+ protected $_canCapture = true;
23
+ protected $_canCapturePartial = false;
24
+ protected $_canReviewPayment = true;
25
+ protected $_canRefund = true;
26
+ protected $_canRefundInvoicePartial = true;
27
+ protected $_canUseInternal = false;
28
+ protected $_canUseForMultishipping = false;
29
+ protected $_isCcTypeRequired = true;
30
+ protected $_canVoid = false;
31
+ protected $_canOrder = false;
32
+ protected $_canUseCheckout = true;
33
+ protected $_isInitializeNeeded = false;
34
+ protected $_canFetchTransactionInfo = false;
35
+ protected $_canCreateBillingAgreement = false;
36
+ protected $_canManageRecurringProfiles = false;
37
+ protected $_canCancelInvoice = false;
38
+ protected $_canSaveCc = false;
39
+
40
+ protected $_canCallbackAccessSession = false;
41
+
42
+
43
+ protected function _getService()
44
+ {
45
+ return Mage::getModel('realex/service_redirect');
46
+ }
47
+
48
+ protected function _registerTransaction(){
49
+
50
+ $this->_saveTransaction();
51
+
52
+ $this->_getPayment()->setIsTransactionPending(true);
53
+
54
+ }
55
+
56
+ <<<<<<< mine
57
+ public function getOrderPlaceRedirectUrl()
58
+ {
59
+ if($this->_getHelper()->getConfigData('realexredirect', 'iframe')){
60
+ return Mage::getUrl('realex/redirect/iframe', array('_forced_secure' => true,));
61
+ =======
62
+
63
+
64
+ /*
65
+ protected function _init(){
66
+
67
+ //$this->_getResponse();
68
+
69
+ $this->setTransactionType('capture');
70
+
71
+ $transactionReference = $this->_getResponse()->getOrderId();
72
+ $this->setTransactionReference($transactionReference);
73
+
74
+ $transaction = Mage::getModel('realex/transaction')
75
+ ->loadByServiceTransactionReference($this->getCode(), $transactionReference);
76
+ $this->_setTransaction($transaction);
77
+
78
+ //check transaction match
79
+
80
+ $order = Mage::getModel('sales/order')->load($transaction->getOrderId());
81
+ $this->_setOrder($order);
82
+
83
+ //check we have one
84
+
85
+ if ($order->getStatus() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
86
+ $comment = $order->addStatusHistoryComment($this->_getHelper()
87
+ ->__('Warning: A payment gateway callback occured for this order.'));
88
+ $comment->save();
89
+
90
+ return;
91
+ }
92
+
93
+ $payment = Mage::getModel('sales/order_payment')->load($transaction->getPaymentId());
94
+ $payment->setOrder($order);
95
+ $this->_setPayment($payment);
96
+ if (!$payment->getId()) {
97
+ throw new Exception($this->_getHelper()
98
+ ->__("Unable to load payment for Transaction '{$transactionReference}'"));
99
+ }
100
+ $this->setMethodInstance($payment->getMethodInstance());
101
+
102
+ return $this;
103
+ >>>>>>> theirs
104
+ }
105
+ <<<<<<< mine
106
+ return Mage::getUrl('realex/redirect/form', array('_forced_secure' => true,));
107
+ =======
108
+ */
109
+ /*
110
+ protected function _processResponse(){
111
+ >>>>>>> theirs
112
+
113
+ <<<<<<< mine
114
+ }
115
+ =======
116
+ $this->addPaymentInfo(array(
117
+ 'Result' => $this->_getResponse()->getResult(),
118
+ 'Message' => $this->_getResponse()->getMessage(),
119
+ 'CVN Result' => $this->_getResponse()->getCvnResult(),
120
+ 'AVS Address Result' => $this->_getResponse()->getAvsAddressResponse(),
121
+ 'AVS Postcode Result' => $this->_getResponse()->getAvsPostcodeResponse(),
122
+ 'ECI Result' => $this->_getResponse()->getEci(),
123
+ ));
124
+
125
+
126
+
127
+ $this->_getResponse()->processResult();
128
+
129
+ return $this;
130
+
131
+ }
132
+
133
+ */
134
+ >>>>>>> theirs
135
+
136
+ public function acceptPayment(Mage_Payment_Model_Info $payment)
137
+ {
138
+ if (method_exists(get_parent_class(), 'acceptPayment')) {
139
+ parent::acceptPayment($payment);
140
+ } else {
141
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
142
+ Mage::throwException(Mage::helper('realex')
143
+ ->__('The payment review action is unavailable.'));
144
+ }
145
+ }
146
+
147
+ if (true !== $payment->getData('payment_accept')) {
148
+ Mage::throwException('Online payments cannot be accepted manually.');
149
+ }
150
+
151
+ $requiredState = 'payment_review';
152
+
153
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
154
+ $comment = $payment->getOrder()->addStatusHistoryComment('An attempt was made to accept this payment.');
155
+ $comment->save();
156
+
157
+ throw new Exception('Only orders with status Payment Review can be accepted');
158
+ }
159
+
160
+ return true;
161
+ }
162
+
163
+ public function denyPayment(Mage_Payment_Model_Info $payment)
164
+ {
165
+ if (method_exists(get_parent_class(), 'denyPayment')) {
166
+ parent::denyPayment($payment);
167
+ } else {
168
+ if (is_null($this->_canReviewPayment) || !$this->_canReviewPayment) {
169
+ Mage::throwException(Mage::helper('realex')
170
+ ->__('The payment review action is unavailable.'));
171
+ }
172
+ }
173
+
174
+ if (true !== $payment->getData('payment_deny')) {
175
+ Mage::throwException('Online payments cannot be accepted manually.');
176
+ }
177
+
178
+ $requiredState = 'payment_review';
179
+
180
+ if ($payment->getOrder()->getStatus() !== $requiredState) {
181
+ $comment = $payment->getOrder()->addStatusHistoryComment('Warning: An attempt was made to deny this payment.');
182
+ $comment->save();
183
+
184
+ throw new Exception("Only orders with status '{$requiredState}' can be denied online.");
185
+ }
186
+
187
+ return true;
188
+ }
189
+
190
+ public function isAvailable($quote = null) {
191
+ return Mage_Payment_Model_Method_Abstract::isAvailable($quote);
192
+ }
193
+
194
+
195
+
196
+ protected function _getHelper()
197
+ {
198
+ return Mage::helper('realex/redirect');
199
+ }
200
+
201
+ }
app/code/community/Yoma/Realex/Model/Resource/PaymentInfo.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_PaymentInfo extends Mage_Core_Model_Mysql4_Abstract
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ $this->_init('realex/paymentInfo', 'entity_id');
26
+ }
27
+
28
+
29
+ protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
30
+ {
31
+ $now = now();
32
+ if (!$object->getId() || $object->isObjectNew()) {
33
+ $object->setCreatedAt($now);
34
+ }
35
+ $object->setUpdatedAt($now);
36
+
37
+ return parent::_prepareDataForSave($object);
38
+ }
39
+ }
app/code/community/Yoma/Realex/Model/Resource/PaymentInfo/Collection.php ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_PaymentInfo_Collection
21
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+
24
+ protected function _construct()
25
+ {
26
+ $this->_init('realex/paymentInfo');
27
+ }
28
+ }
app/code/community/Yoma/Realex/Model/Resource/Tokencard.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_TokenCard extends Mage_Core_Model_Mysql4_Abstract {
21
+
22
+ protected function _construct() {
23
+ $this->_init('realex/tokencard', 'id');
24
+ }
25
+
26
+
27
+ }
app/code/community/Yoma/Realex/Model/Resource/Tokencard/Collection.php ADDED
@@ -0,0 +1,97 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_Tokencard_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract {
21
+
22
+ protected function _construct() {
23
+ $this->_init('realex/tokencard');
24
+ }
25
+
26
+ /**
27
+ * Filter by customer
28
+ *
29
+ * @param mixed $customer
30
+ * @return $this
31
+ */
32
+ public function addCustomerFilter($customer) {
33
+
34
+ if (is_string($customer)) {
35
+ $this->addFieldToFilter('customer_id', $customer);
36
+ } else if ($customer instanceof Mage_Customer_Model_Customer) {
37
+ $this->addFieldToFilter('customer_id', $customer->getId());
38
+ } elseif (is_numeric($customer)) {
39
+ $this->addFieldToFilter('customer_id', $customer);
40
+ } elseif (is_array($customer)) {
41
+ $this->addFieldToFilter('customer_id', $customer);
42
+ }
43
+
44
+ return $this;
45
+ }
46
+
47
+ /**
48
+ * Filter duplicates
49
+ *
50
+ * @param mixed $customer
51
+ * @param string $lastFour
52
+ * @param string $type
53
+ * @param string $expireDate
54
+ * @return $this
55
+ */
56
+ public function addDuplicateFilter($customer,$lastFour,$type,$expireDate){
57
+ $this->addCustomerFilter($customer);
58
+ $this->addFieldToFilter('last_four', $lastFour);
59
+ $this->addFieldToFilter('card_type', $type);
60
+ $this->addFieldToFilter('expiry_date', $expireDate);
61
+
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Filter active cards
67
+ *
68
+ * @param mixed $customer
69
+ * @return $this
70
+ */
71
+ public function addActiveCardsByCustomerFilter($customer){
72
+ $this->addCustomerFilter($customer);
73
+ $this->addFieldToFilter('status', 1);
74
+
75
+ return $this;
76
+
77
+ }
78
+
79
+ /**
80
+ * Filter expiring cards
81
+ *
82
+ * @return $this
83
+ */
84
+ public function addExpiringFilter(){
85
+
86
+ $this->addFieldToFilter('status', (int) 1)
87
+ ->addFieldToFilter(
88
+ new Zend_Db_Expr("str_to_date(expiry_date, '%m%y')"),
89
+ array('
90
+ from' => date("Y-m-d H:i:s"),
91
+ 'to' => date("Y-m-d H:i:s", strtotime("+1 month"))
92
+ )
93
+ );
94
+
95
+ return $this;
96
+ }
97
+ }
app/code/community/Yoma/Realex/Model/Resource/Transaction.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_Transaction extends Mage_Core_Model_Mysql4_Abstract
21
+ {
22
+
23
+ protected function _construct()
24
+ {
25
+ $this->_init('realex/transaction', 'entity_id');
26
+ }
27
+
28
+ protected function _prepareDataForSave(Mage_Core_Model_Abstract $object)
29
+ {
30
+ $now = now();
31
+ if (!$object->getId() || $object->isObjectNew()) {
32
+ $object->setCreatedAt($now);
33
+ }
34
+ $object->setUpdatedAt($now);
35
+
36
+ return parent::_prepareDataForSave($object);
37
+ }
38
+
39
+ }
app/code/community/Yoma/Realex/Model/Resource/Transaction/Collection.php ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Resource_Transaction_Collection
21
+ extends Mage_Core_Model_Mysql4_Collection_Abstract
22
+ {
23
+
24
+ protected function _construct()
25
+ {
26
+ $this->_init('realex/transaction');
27
+ }
28
+
29
+ protected function _afterLoad()
30
+ {
31
+ foreach ($this->_items as $_item) {
32
+ $_additionalInformation = $_item->getData('additional_information');
33
+ if ($_additionalInformation != '') {
34
+ $_item->setData('additional_information', unserialize($_additionalInformation));
35
+ }
36
+
37
+ }
38
+
39
+ parent::_afterLoad();
40
+
41
+ return $this;
42
+ }
43
+
44
+ public function addErrorFilter(){
45
+
46
+ $this->addFieldToFilter('error_message', array('neq' => ''));
47
+
48
+ return $this;
49
+
50
+ }
51
+ }
app/code/community/Yoma/Realex/Model/Response/Abstract.php ADDED
@@ -0,0 +1,136 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Abstract extends Mage_Core_Model_Abstract{
21
+
22
+ const AUTH_RESULT_AUTHENTICATED = '00';
23
+ const AUTH_RESULT_DECLINED = '101';
24
+ const AUTH_RESULT_REFERRAL = '102';
25
+ const AUTH_RESULT_LOST = '103';
26
+
27
+ protected $_serviceResponse;
28
+
29
+ /**
30
+ * Set response data
31
+ *
32
+ * @param mixed $response
33
+ * @return $this
34
+ */
35
+ public function setResponse($response){
36
+ $this->_serviceResponse = $response;
37
+ $this->_populateData();
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Return response message
43
+ *
44
+ * @return string
45
+ */
46
+ public function getMessages(){
47
+
48
+ return $this->_serviceResponse->getMessage();
49
+ }
50
+
51
+ /**
52
+ * Populate data from response
53
+ *
54
+ * @return $this
55
+ */
56
+ protected function _populateData(){
57
+
58
+ $xml = $this->_serviceResponse->getBody();
59
+
60
+ // convert xml response to array
61
+ try {
62
+
63
+ $response = new DOMDocument();
64
+ $response->loadXML($xml);
65
+
66
+ $xpath = new DOMXPath($response);
67
+ // handle tss check rules
68
+ $checks = $xpath->query('//tss/check');
69
+ // convert to unique element check_ruleNumber
70
+ foreach ($checks as $check) {
71
+ $id = $check->getAttribute('id');
72
+ $value = $check->nodeValue;
73
+ $node = $response->createElement("check_" . $id,$value);
74
+ $check->parentNode->replaceChild($node, $check);
75
+ }
76
+ $xml = $response->saveXML();
77
+
78
+ /**$transform = new DOMDocument();
79
+ $xlsFile = Mage::getBaseDir('lib') . DS . 'Realex' . DS . 'check.xsl';
80
+ $transform->load($xlsFile);
81
+
82
+ // process attributes to element
83
+ $processor = new XSLTProcessor;
84
+ $processor->importStyleSheet($transform); // attach the xsl rules
85
+
86
+ $xmlDoc = $processor->transformToDoc($response);
87
+ $xml = $xmlDoc->saveXML();
88
+ * **/
89
+ }catch (Exception $e){
90
+
91
+ }
92
+
93
+ $xml = simplexml_load_string($xml);
94
+ // convert string to array
95
+ $json = json_encode($xml);
96
+ //flatten array
97
+ $array = $this->flatten(json_decode($json, true));
98
+ foreach($array as $key=>$value){
99
+ $this->setData($key,$value);
100
+ }
101
+
102
+ return $this;
103
+
104
+ }
105
+
106
+ /**
107
+ * Flatten Multi dimensional array
108
+ *
109
+ * @param array $arr
110
+ * @param string $prefix
111
+ * @return array
112
+ */
113
+ public function flatten(array $arr, $prefix = '')
114
+ {
115
+ $out = array();
116
+ foreach ($arr as $k => $v) {
117
+ $key = (!strlen($prefix)) ? strtolower($k) : ($prefix=='@attributes'?strtolower($k):strtolower($prefix) . '_' . strtolower($k));
118
+ if (is_array($v)) {
119
+ $out += $this->flatten($v, $key);
120
+ } else {
121
+ $out[$key] = $v;
122
+ }
123
+ }
124
+ return $out;
125
+ }
126
+
127
+ /**
128
+ * Convert ot lower case
129
+ *
130
+ * @param string $key
131
+ * @return string
132
+ */
133
+ protected function _normalizeKeys($key){
134
+ return strtolower($key);
135
+ }
136
+ }
app/code/community/Yoma/Realex/Model/Response/Direct.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct extends Yoma_Realex_Model_Response_Abstract{
21
+
22
+ /**
23
+ * Response results from 3D Secure Verify Enrolled
24
+ */
25
+ const THREED_SECURE_VERIFY_ENROLLED_RESULT_ENROLLED = '00';
26
+ const THREED_SECURE_VERIFY_ENROLLED_RESULT_NOT_ENROLLED = '110';
27
+ const THREED_SECURE_VERIFY_ENROLLED_RESULT_INVALID_RESPONSE = '5xx';
28
+ const THREED_SECURE_VERIFY_ENROLLED_RESULT_FATAL_ERROR = '220';
29
+ const THREED_SECURE_VERIFY_ENROLLED_RESULT_NON_PARTICIPATING = '503';
30
+
31
+ /**
32
+ * Response tags from 3D Secure Verify Enrolled
33
+ */
34
+ const THREED_SECURE_VERIFY_ENROLLED_TAG_ENROLLED = 'Y';
35
+ const THREED_SECURE_VERIFY_ENROLLED_TAG_UNABLE_TO_VERIFY = 'U';
36
+ const THREED_SECURE_VERIFY_ENROLLED_TAG_NOT_ENROLLED = 'N';
37
+
38
+ /**
39
+ * Response results from 3D Secure Verify Signature
40
+ */
41
+ const THREED_SECURE_VERIFY_SIGNATURE_RESULT_VALIDATED = '00';
42
+ const THREED_SECURE_VERIFY_SIGNATURE_RESULT_ENROLLED_INVALID_ACS_RESPONSE = '110';
43
+ const THREED_SECURE_VERIFY_SIGNATURE_RESULT_INVALID_ACS_RESPONSE = '5xx';
44
+
45
+ /**
46
+ * Response statuses from 3D Secure Verify Signature
47
+ */
48
+ const THREED_SECURE_VERIFY_SIGNATURE_STATUS_AUTHENTICATED = 'Y';
49
+ const THREED_SECURE_VERIFY_SIGNATURE_STATUS_NOT_AUTHENTICATED = 'N';
50
+ const THREED_SECURE_VERIFY_SIGNATURE_STATUS_ACKNOWLEDGED = 'A';
51
+ const THREED_SECURE_VERIFY_SIGNATURE_STATUS_UNAVAILABLE = 'U';
52
+
53
+ /**
54
+ * ECI values to send to Realex
55
+ */
56
+ const THREED_SECURE_ECI_VISA_AUTHENTICATED = '5';
57
+ const THREED_SECURE_ECI_VISA_WITH_LIABILITY_SHIFT = '6';
58
+ const THREED_SECURE_ECI_VISA_WITHOUT_LIABILITY_SHIFT = '7';
59
+ const THREED_SECURE_ECI_MASTERCARD_AUTHENTICATED = '2';
60
+ const THREED_SECURE_ECI_MASTERCARD_WITH_LIABILITY_SHIFT = '1';
61
+ const THREED_SECURE_ECI_MASTERCARD_WITHOUT_LIABILITY_SHIFT = '0';
62
+
63
+
64
+ /**
65
+ * Check if valid message
66
+ *
67
+ * @return $this
68
+ * @throws Exception
69
+ */
70
+ public function isValid(){
71
+
72
+ $hash = $this->_getHelper()->generateSha1Hash(
73
+ $this->_getHelper()->getConfigData('realex','secret'),
74
+ array(
75
+ $this->getTimestamp(),
76
+ $this->getMerchantid(),
77
+ $this->getOrderid(),
78
+ $this->getResult(),
79
+ $this->getMessage(),
80
+ $this->getPasref(),
81
+ $this->getAuthcode()
82
+ )
83
+
84
+ );
85
+
86
+ if ($hash != $this->getSha1hash()) {
87
+ throw new Exception(
88
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
89
+ );
90
+ }
91
+
92
+ return $this;
93
+ }
94
+
95
+ /**
96
+ * @return Mage_Core_Helper_Abstract
97
+ */
98
+ protected function _getHelper()
99
+ {
100
+ return Mage::helper('realex/direct');
101
+ }
102
+
103
+ /**
104
+ * Retrieve eci value
105
+ *
106
+ * @param string $cardType
107
+ * @param boll $liabilityShift
108
+ * @param bool $threedSecureAuthentication
109
+ * @return bool|string
110
+ */
111
+ public function getEciValue($cardType, $liabilityShift, $threedSecureAuthentication = null)
112
+ {
113
+ $eci = false;
114
+
115
+ switch ($cardType) {
116
+ case 'VISA':
117
+ case 'AMEX':
118
+ if ($threedSecureAuthentication === true) {
119
+ $eci = self::THREED_SECURE_ECI_VISA_AUTHENTICATED;
120
+ } else {
121
+ if ($liabilityShift === true) {
122
+ $eci = self::THREED_SECURE_ECI_VISA_WITH_LIABILITY_SHIFT;
123
+ } else {
124
+ $eci = self::THREED_SECURE_ECI_VISA_WITHOUT_LIABILITY_SHIFT;
125
+ }
126
+ }
127
+ break;
128
+
129
+ case 'MC':
130
+ case 'YOMA_MAESTRO':
131
+ case 'SWITCH':
132
+ if ($threedSecureAuthentication === true) {
133
+ $eci = self::THREED_SECURE_ECI_MASTERCARD_AUTHENTICATED;
134
+ } else {
135
+ if ($liabilityShift === true) {
136
+ $eci = self::THREED_SECURE_ECI_MASTERCARD_WITH_LIABILITY_SHIFT;
137
+ } else {
138
+ $eci = self::THREED_SECURE_ECI_MASTERCARD_WITHOUT_LIABILITY_SHIFT;
139
+ }
140
+ }
141
+ break;
142
+
143
+ default:
144
+ $eci = false;
145
+ break;
146
+ }
147
+
148
+ return $eci;
149
+ }
150
+
151
+ /**
152
+ * Retrieve eci signature
153
+ *
154
+ * @param string $result
155
+ * @param bool $enrolled
156
+ * @param string $cardType
157
+ * @param bool $requireLiabilityShift
158
+ * @param null $profile
159
+ * @return bool|string
160
+ * @throws Yoma_Realex_Model_Exception_NoLiabilityShift
161
+ */
162
+ public function getEciFromThreedSecureSignature($result, $enrolled, $cardType, $requireLiabilityShift = true, $profile = null)
163
+ {
164
+
165
+ if(!isset($profile)){
166
+ $profile = new Varien_Object();
167
+ }
168
+
169
+ $profile->setRequireLiabilityShift($requireLiabilityShift);
170
+ $profile->setResult($result);
171
+ $profile->setEnrolled($enrolled);
172
+
173
+ if($result == self::THREED_SECURE_VERIFY_ENROLLED_RESULT_NOT_ENROLLED && $enrolled == self::THREED_SECURE_VERIFY_ENROLLED_TAG_NOT_ENROLLED){
174
+
175
+ $profile->setLiabilityShift(true);
176
+ $profile->setThreedSecureAuthentication(false);
177
+ }else{
178
+
179
+ $profile->setLiabilityShift(false);
180
+ $profile->setThreedSecureAuthentication(false);
181
+ }
182
+
183
+
184
+ Mage::dispatchEvent('realex_process_threedsecure_eci_after', array('transport'=>$profile));
185
+
186
+ // if there is no liability shift, and it is required by the client, throw exception
187
+ if (!$profile->getLiabilityShift() && $profile->getRequireLiabilityShift()) {
188
+ throw new Yoma_Realex_Model_Exception_NoLiabilityShift($this->_getHelper()
189
+ ->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
190
+ );
191
+ }
192
+
193
+ return $this->getEciValue($cardType, $profile->getLiabilityShift(), $profile->getThreedSecureAuthentication());
194
+ }
195
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/Authorize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_Authorize extends Yoma_Realex_Model_Response_Direct_Capture{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/Capture.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_Capture extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Exception
26
+ * @throws Yoma_Realex_Model_Exception_DenyPayment
27
+ */
28
+ public function processResult(){
29
+ switch ($this->getResult()) {
30
+ case self::AUTH_RESULT_AUTHENTICATED:
31
+ break;
32
+
33
+ case self::AUTH_RESULT_DECLINED:
34
+ case self::AUTH_RESULT_REFERRAL:
35
+ case self::AUTH_RESULT_LOST:
36
+ throw new Yoma_Realex_Model_Exception_DenyPayment(
37
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
38
+ );
39
+ break;
40
+
41
+ default:
42
+ throw new Exception(
43
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
44
+ );
45
+ break;
46
+ }
47
+ }
48
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/Partial.php ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_Partial extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Exception
26
+ * @throws Yoma_Realex_Model_Exception_DenyPayment
27
+ */
28
+ public function processResult(){
29
+ switch ($this->getResult()) {
30
+ case self::AUTH_RESULT_AUTHENTICATED:
31
+ break;
32
+
33
+ case self::AUTH_RESULT_DECLINED:
34
+ throw new Yoma_Realex_Model_Exception_DenyPayment(
35
+ $this->_getHelper()->__('The transaction was declined.')
36
+ );
37
+ break;
38
+
39
+ default:
40
+ throw new Exception(
41
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
42
+ );
43
+ break;
44
+ }
45
+ }
46
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/Refund.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_Refund extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Exception
26
+ */
27
+ public function processResult(){
28
+
29
+ switch ($this->getResult()) {
30
+ case self::AUTH_RESULT_AUTHENTICATED:
31
+ break;
32
+ default:
33
+ throw new Exception(
34
+ $this->_getHelper()->__($this->getMessage())
35
+ );
36
+ break;
37
+ }
38
+ }
39
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/ThreedSecure.php ADDED
@@ -0,0 +1,82 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_ThreedSecure extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @param mixed $threeDSecureProfile
26
+ * @return bool
27
+ * @throws Yoma_Realex_Model_Exception_NoneParticipatingCard
28
+ * @throws Yoma_Realex_Model_Exception_NotEnrolled
29
+ */
30
+ public function processResult($threeDSecureProfile = null){
31
+
32
+ if($this->getResult() == self::THREED_SECURE_VERIFY_ENROLLED_RESULT_ENROLLED
33
+ && $this->getEnrolled() == self::THREED_SECURE_VERIFY_ENROLLED_TAG_ENROLLED){
34
+ return true;
35
+ }else{
36
+ if($this->getResult() == self::THREED_SECURE_VERIFY_ENROLLED_RESULT_NON_PARTICIPATING){
37
+ throw new Yoma_Realex_Model_Exception_NoneParticipatingCard (
38
+ $this->_getHelper()->__($this->getMessage())
39
+ );
40
+ }
41
+ throw new Yoma_Realex_Model_Exception_NotEnrolled (
42
+ $this->_getHelper()->__($this->getMessage())
43
+ );
44
+ }
45
+
46
+ return true;
47
+ }
48
+
49
+ /**
50
+ * Check if valid message
51
+ *
52
+ * @return $this
53
+ * @throws Yoma_Realex_Model_Exception_NotEnrolled
54
+ */
55
+ public function isValid(){
56
+
57
+ $hash = $this->_getHelper()->generateSha1Hash(
58
+ $this->_getHelper()->getConfigData('realex','secret'),
59
+ array(
60
+ $this->getTimestamp(),
61
+ $this->getMerchantid(),
62
+ $this->getOrderid(),
63
+ $this->getResult(),
64
+ $this->getMessage(),
65
+ $this->getPasref(),
66
+ $this->getAuthcode()
67
+ )
68
+
69
+ );
70
+
71
+ if ($hash != $this->getSha1hash()) {
72
+ throw new Yoma_Realex_Model_Exception_NotEnrolled(
73
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
74
+ );
75
+ }
76
+
77
+ return $this;
78
+ }
79
+
80
+ }
81
+
82
+
app/code/community/Yoma/Realex/Model/Response/Direct/ThreedSecureVerify.php ADDED
@@ -0,0 +1,153 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_ThreedSecureVerify extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Exception
26
+ */
27
+ public function processResult(){
28
+
29
+ switch ($this->getResult()) {
30
+ case self::AUTH_RESULT_AUTHENTICATED:
31
+ break;
32
+ default:
33
+ throw new Exception(
34
+ $this->_getHelper()->__($this->getMessages())
35
+ );
36
+ break;
37
+ }
38
+ }
39
+
40
+ /**
41
+ * Retrieve eci from 3d secure signature
42
+ *
43
+ * @param string $result
44
+ * @param string $status
45
+ * @param string $cardType
46
+ * @param array $enrolledCards
47
+ * @param bool $requireLiabilityShift
48
+ * @param mixed $profile
49
+ * @return bool|string
50
+ * @throws Yoma_Realex_Model_Exception_NoLiabilityShift
51
+ */
52
+ public function getEciFromThreedSecureVerifySignature($result, $status, $cardType, $enrolledCards,
53
+ $requireLiabilityShift = true, $profile = null)
54
+ {
55
+
56
+ if(!isset($profile)){
57
+ $profile = new Varien_Object();
58
+ }
59
+
60
+ $profile->setRequireLiabilityShift($requireLiabilityShift);
61
+ $profile->setResult($result);
62
+ $profile->setStatus($status);
63
+
64
+ // if the card type is not enrolled in 3D Secure, return false
65
+ if (!is_null($cardType) && !in_array($cardType, $enrolledCards)) {
66
+ return false;
67
+ }
68
+
69
+ // default liability shift to false, to be proven otherwise
70
+ $profile->setLiabilityShift(false);
71
+
72
+ // default 3D Secure authentication result to false, to be proven otherwise
73
+
74
+ $profile->setThreedSecureAuthentication(false);
75
+
76
+ // all results starting with 5 should be handled the same way
77
+ if (substr($result, 0, 1) == '5') {
78
+ $result = '5xx';
79
+ }
80
+
81
+ // determine whether this transaction would cause a liability shift
82
+ switch ($result) {
83
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_VALIDATED:
84
+ switch ($status) {
85
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_AUTHENTICATED:
86
+ $profile->setLiabilityShift(true);
87
+ $profile->setThreedSecureAuthentication(true);
88
+ break;
89
+
90
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_ACKNOWLEDGED:
91
+ $profile->setLiabilityShift(true);
92
+ $profile->setThreedSecureAuthentication(false);
93
+ break;
94
+
95
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_NOT_AUTHENTICATED:
96
+ $profile->setLiabilityShift(false);
97
+ $profile->setThreedSecureAuthentication(false);
98
+ break;
99
+
100
+ default:
101
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_UNAVAILABLE:
102
+ $profile->setLiabilityShift(false);
103
+ $profile->setThreedSecureAuthentication(false);
104
+ break;
105
+ }
106
+ break;
107
+
108
+ default:
109
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_ENROLLED_INVALID_ACS_RESPONSE:
110
+ throw new Yoma_Realex_Model_Exception_NoLiabilityShift($this->_getHelper()
111
+ ->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
112
+ );
113
+ break;
114
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_INVALID_ACS_RESPONSE:
115
+ $profile->setLiabilityShift(false);
116
+ $profile->setThreedSecureAuthentication(false);
117
+ break;
118
+ }
119
+
120
+ $hash = $this->_getHelper()->generateSha1Hash(
121
+ $this->_getHelper()->getConfigData('realex','secret'),
122
+ array(
123
+ $this->getTimestamp(),
124
+ $this->getMerchantid(),
125
+ $this->getOrderid(),
126
+ $this->getResult(),
127
+ $this->getMessage(),
128
+ $this->getPasref(),
129
+ $this->getAuthcode()
130
+ )
131
+
132
+ );
133
+
134
+ if ($hash != $this->getSha1hash()) {
135
+ $profile->setLiabilityShift(false);
136
+ $profile->setThreedSecureAuthentication(false);
137
+ }
138
+
139
+
140
+ Mage::dispatchEvent('realex_process_threedsecure_verify_after', array('transport'=>$profile));
141
+
142
+ // if there is no liability shift, and it is required by the client, throw exception
143
+ if (!$profile->getLiabilityShift() && $profile->getRequireLiabilityShift()) {
144
+ throw new Yoma_Realex_Model_Exception_NoLiabilityShift($this->_getHelper()
145
+ ->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
146
+ );
147
+ }
148
+
149
+ // determine the eci value to use if the card is not enrolled in the 3D Secure scheme
150
+ return $this->getEciValue($cardType, $profile->getLiabilityShift(), $profile->getThreedSecureAuthentication());
151
+ }
152
+
153
+ }
app/code/community/Yoma/Realex/Model/Response/Direct/Void.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Direct_Void extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Exception
26
+ */
27
+ public function processResult(){
28
+
29
+ switch ($this->getResult()) {
30
+ case self::AUTH_RESULT_AUTHENTICATED:
31
+ break;
32
+ default:
33
+ throw new Exception(
34
+ $this->_getHelper()->__($this->getMessage())
35
+ );
36
+ break;
37
+ }
38
+ }
39
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect extends Yoma_Realex_Model_Response_Abstract{
21
+
22
+ const REALVAULT_PAYER_SETUP = '00';
23
+ const REALVAULT_PAYMENT_SETUP = '00';
24
+
25
+ /**
26
+ * Check if valid message
27
+ *
28
+ * @return $this
29
+ * @throws Exception
30
+ */
31
+ public function isValid(){
32
+
33
+ $hash = $this->_getHelper()->generateSha1Hash(
34
+ $this->_getHelper()->getConfigData('realex','secret'),
35
+ array(
36
+ $this->getTimestamp(),
37
+ $this->getMerchantId(),
38
+ $this->getOrderId(),
39
+ $this->getResult(),
40
+ $this->getMessage(),
41
+ $this->getPasref(),
42
+ $this->getAuthcode()
43
+ )
44
+
45
+ );
46
+
47
+
48
+ if ($hash != $this->getSha1hash()) {
49
+ throw new Exception(
50
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
51
+ );
52
+ }
53
+
54
+ return $this;
55
+ }
56
+
57
+ /**
58
+ * @return Mage_Core_Helper_Abstract
59
+ */
60
+ protected function _getHelper()
61
+ {
62
+ return Mage::helper('realex/redirect');
63
+ }
64
+
65
+ /**
66
+ * Check if new payer
67
+ *
68
+ * @return bool
69
+ */
70
+ public function isPayerSetup(){
71
+ if($this->getPayerSetup() == self::REALVAULT_PAYER_SETUP){
72
+ return true;
73
+ }
74
+ return false;
75
+ }
76
+
77
+ /**
78
+ * Check if using real vault
79
+ *
80
+ * @return bool
81
+ */
82
+ public function useRealVault(){
83
+
84
+ if($this->getRealwalletChosen()){
85
+ return true;
86
+ }
87
+ return false;
88
+ }
89
+
90
+ /**
91
+ * Check if token created
92
+ *
93
+ * @return bool
94
+ */
95
+ public function isPaymentSetup(){
96
+ if($this->getPmtSetup() == self::REALVAULT_PAYMENT_SETUP){
97
+ return true;
98
+ }
99
+ return false;
100
+ }
101
+ }
102
+
app/code/community/Yoma/Realex/Model/Response/Redirect/Abstract.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Message_Response_Redirect_Abstract extends Yoma_Realex_Model_Message_Response_Abstract{
21
+
22
+ protected function _getHelper()
23
+ {
24
+ return Mage::helper('realex/redirect');
25
+ }
26
+
27
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/Authorize.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_Authorize extends Yoma_Realex_Model_Response_Redirect_Capture{
21
+
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/Capture.php ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_Capture extends Yoma_Realex_Model_Response_Redirect{
21
+
22
+ /**
23
+ * Process response
24
+ *
25
+ * @throws Yoma_Realex_Model_Exception_DenyPayment
26
+ */
27
+ public function processResult(){
28
+ switch ($this->getResult()) {
29
+ case self::AUTH_RESULT_AUTHENTICATED:
30
+ break;
31
+
32
+ case self::AUTH_RESULT_DECLINED:
33
+ case self::AUTH_RESULT_REFERRAL:
34
+ case self::AUTH_RESULT_LOST:
35
+ throw new Yoma_Realex_Model_Exception_DenyPayment(
36
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
37
+ );
38
+ break;
39
+
40
+ default:
41
+ throw new Yoma_Realex_Model_Exception_DenyPayment(
42
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
43
+ );
44
+ break;
45
+ }
46
+ }
47
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/EditPayer.php ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_EditPayer extends Yoma_Realex_Model_Response_Redirect{
21
+
22
+ const REAL_VAULT_EDIT_PAYER = '00';
23
+
24
+ /**
25
+ * Process response
26
+ *
27
+ * @throws Exception
28
+ */
29
+ public function processResult(){
30
+ switch ($this->getResult()) {
31
+ case self::REAL_VAULT_EDIT_PAYER:
32
+ break;
33
+
34
+ default:
35
+ throw new Exception(
36
+ $this->_getHelper()->__('An unexpected issue occured.')
37
+ );
38
+ break;
39
+ }
40
+ }
41
+
42
+ /**
43
+ * Check if valid message
44
+ *
45
+ * @return $this
46
+ * @throws Exception
47
+ */
48
+ public function isValid(){
49
+
50
+ $hash = $this->_getHelper()->generateSha1Hash(
51
+ $this->_getHelper()->getConfigData('realex','secret'),
52
+ array(
53
+ $this->getTimestamp(),
54
+ $this->getMerchantid(),
55
+ $this->getOrderid(),
56
+ $this->getResult(),
57
+ $this->getMessage(),
58
+ $this->getPasref(),
59
+ $this->getAuthcode()
60
+ )
61
+
62
+ );
63
+
64
+ if ($hash != $this->getSha1hash()) {
65
+ throw new Exception(
66
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
67
+ );
68
+ }
69
+
70
+ return $this;
71
+ }
72
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/Partial.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_Partial extends Yoma_Realex_Model_Response_Direct_Partial{
21
+
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/Refund.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_Refund extends Yoma_Realex_Model_Response_Direct_Refund{
21
+
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Response/Redirect/Void.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Redirect_Void extends Yoma_Realex_Model_Response_Direct_Void{
21
+
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Response/Token.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token extends Yoma_Realex_Model_Response_Direct{
21
+
22
+ /**
23
+ * @return Mage_Core_Helper_Abstract
24
+ */
25
+ protected function _getHelper()
26
+ {
27
+ return Mage::helper('realex');
28
+ }
29
+
30
+ }
app/code/community/Yoma/Realex/Model/Response/Token/Authorize.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Authorize extends Yoma_Realex_Model_Response_Token_Capture{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Response/Token/Capture.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Capture extends Yoma_Realex_Model_Response_Token{
21
+
22
+
23
+ public function processResult(){
24
+ switch ($this->getResult()) {
25
+ case self::AUTH_RESULT_AUTHENTICATED:
26
+ break;
27
+
28
+ case self::AUTH_RESULT_DECLINED:
29
+ case self::AUTH_RESULT_REFERRAL:
30
+ case self::AUTH_RESULT_LOST:
31
+ throw new Yoma_Realex_Model_Exception_DenyPayment(
32
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
33
+ );
34
+ break;
35
+
36
+ default:
37
+ throw new Exception(
38
+ $this->_getHelper()->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
39
+ );
40
+ break;
41
+ }
42
+ }
43
+ }
app/code/community/Yoma/Realex/Model/Response/Token/Delete.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Delete extends Yoma_Realex_Model_Response_Token{
21
+
22
+ const REAL_VAULT_TOKEN_DELETED = '00';
23
+
24
+ public function processResult(){
25
+ switch ($this->getResult()) {
26
+ case self::REAL_VAULT_TOKEN_DELETED:
27
+ break;
28
+
29
+ default:
30
+ throw new Exception(
31
+ $this->_getHelper()->__('An unexpected issue occured.')
32
+ );
33
+ break;
34
+ }
35
+ }
36
+
37
+ public function isValid(){
38
+
39
+ $hash = $this->_getHelper()->generateSha1Hash(
40
+ $this->_getHelper()->getConfigData('realex','secret'),
41
+ array(
42
+ $this->getTimestamp(),
43
+ $this->getMerchantid(),
44
+ $this->getOrderid(),
45
+ $this->getResult(),
46
+ $this->getMessage(),
47
+ $this->getPasref(),
48
+ $this->getAuthcode()
49
+ )
50
+
51
+ );
52
+
53
+ if ($hash != $this->getSha1hash()) {
54
+ throw new Exception(
55
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
56
+ );
57
+ }
58
+
59
+ return $this;
60
+ }
61
+ }
app/code/community/Yoma/Realex/Model/Response/Token/EditPayer.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_EditPayer extends Yoma_Realex_Model_Response_Token{
21
+
22
+ const REAL_VAULT_EDIT_PAYER = '00';
23
+
24
+ public function processResult(){
25
+ switch ($this->getResult()) {
26
+ case self::REAL_VAULT_EDIT_PAYER:
27
+ break;
28
+
29
+ default:
30
+ throw new Exception(
31
+ $this->_getHelper()->__('An unexpected issue occured.')
32
+ );
33
+ break;
34
+ }
35
+ }
36
+
37
+ public function isValid(){
38
+
39
+ $hash = $this->_getHelper()->generateSha1Hash(
40
+ $this->_getHelper()->getConfigData('realex','secret'),
41
+ array(
42
+ $this->getTimestamp(),
43
+ $this->getMerchantid(),
44
+ $this->getOrderid(),
45
+ $this->getResult(),
46
+ $this->getMessage(),
47
+ $this->getPasref(),
48
+ $this->getAuthcode()
49
+ )
50
+
51
+ );
52
+
53
+ if ($hash != $this->getSha1hash()) {
54
+ throw new Exception(
55
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
56
+ );
57
+ }
58
+
59
+ return $this;
60
+ }
61
+ }
app/code/community/Yoma/Realex/Model/Response/Token/EditToken.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_EditToken extends Yoma_Realex_Model_Response_Token{
21
+
22
+ const REAL_VAULT_EDIT_TOKEN = '00';
23
+
24
+ public function processResult(){
25
+ switch ($this->getResult()) {
26
+ case self::REAL_VAULT_EDIT_TOKEN:
27
+ break;
28
+
29
+ default:
30
+ throw new Exception(
31
+ $this->_getHelper()->__('An unexpected issue occured.')
32
+ );
33
+ break;
34
+ }
35
+ }
36
+
37
+ public function isValid(){
38
+
39
+ $hash = $this->_getHelper()->generateSha1Hash(
40
+ $this->_getHelper()->getConfigData('realex','secret'),
41
+ array(
42
+ $this->getTimestamp(),
43
+ $this->getMerchantid(),
44
+ $this->getOrderid(),
45
+ $this->getResult(),
46
+ $this->getMessage(),
47
+ $this->getPasref(),
48
+ $this->getAuthcode()
49
+ )
50
+
51
+ );
52
+
53
+ if ($hash != $this->getSha1hash()) {
54
+ throw new Exception(
55
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
56
+ );
57
+ }
58
+
59
+ return $this;
60
+ }
61
+ }
app/code/community/Yoma/Realex/Model/Response/Token/Partial.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Partial extends Yoma_Realex_Model_Response_Direct_Partial{
21
+
22
+
23
+ }
app/code/community/Yoma/Realex/Model/Response/Token/PayerNew.php ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_PayerNew extends Yoma_Realex_Model_Response_Token{
21
+
22
+ const REAL_VAULT_PAYER_RESULT_ENROLLED = '00';
23
+
24
+ public function processResult(){
25
+ switch ($this->getResult()) {
26
+ case self::REAL_VAULT_PAYER_RESULT_ENROLLED:
27
+ break;
28
+
29
+ default:
30
+ throw new Yoma_Realex_Model_Exception_PayerNew(
31
+ $this->_getHelper()->__('An unexpected issue occured.')
32
+ );
33
+ break;
34
+ }
35
+ }
36
+
37
+ public function isValid(){
38
+
39
+ $hash = $this->_getHelper()->generateSha1Hash(
40
+ $this->_getHelper()->getConfigData('realex','secret'),
41
+ array(
42
+ $this->getTimestamp(),
43
+ $this->getMerchantid(),
44
+ $this->getOrderid(),
45
+ $this->getResult(),
46
+ $this->getMessage(),
47
+ $this->getPasref(),
48
+ $this->getAuthcode()
49
+ )
50
+
51
+ );
52
+
53
+ if ($hash != $this->getSha1hash()) {
54
+ throw new Exception(
55
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
56
+ );
57
+ }
58
+
59
+ return $this;
60
+ }
61
+
62
+ }
63
+
app/code/community/Yoma/Realex/Model/Response/Token/Refund.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Refund extends Yoma_Realex_Model_Response_Direct_Refund{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Response/Token/RegisterToken.php ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_RegisterToken extends Yoma_Realex_Model_Response_Token{
21
+
22
+
23
+ const REAL_VAULT_TOKEN_RESULT_STORED = '00';
24
+
25
+ public function processResult(){
26
+ switch ($this->getResult()) {
27
+ case self::REAL_VAULT_TOKEN_RESULT_STORED :
28
+ break;
29
+
30
+ default:
31
+ throw new Exception(
32
+ $this->_getHelper()->__('The Token was unsuccessful at this time. Please try again or contact us for more information.')
33
+ );
34
+ break;
35
+ }
36
+ }
37
+
38
+ public function isValid(){
39
+
40
+ $hash = $this->_getHelper()->generateSha1Hash(
41
+ $this->_getHelper()->getConfigData('realex','secret'),
42
+ array(
43
+ $this->getTimestamp(),
44
+ $this->getMerchantid(),
45
+ $this->getOrderid(),
46
+ $this->getResult(),
47
+ $this->getMessage(),
48
+ $this->getPasref(),
49
+ $this->getAuthcode()
50
+ )
51
+
52
+ );
53
+
54
+ if ($hash != $this->getSha1hash()) {
55
+ throw new Yoma_Realex_Model_Exception_NotEnrolled(
56
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
57
+ );
58
+ }
59
+
60
+ return $this;
61
+ }
62
+
63
+ }
64
+
65
+
app/code/community/Yoma/Realex/Model/Response/Token/ThreedSecure.php ADDED
@@ -0,0 +1,68 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_ThreedSecure extends Yoma_Realex_Model_Response_Token{
21
+
22
+ public function processResult($threeDSecureProfile = null){
23
+
24
+ if($this->getResult() == self::THREED_SECURE_VERIFY_ENROLLED_RESULT_ENROLLED
25
+ && $this->getEnrolled() == self::THREED_SECURE_VERIFY_ENROLLED_TAG_ENROLLED){
26
+ return true;
27
+ }else{
28
+ if($this->getResult() == self::THREED_SECURE_VERIFY_ENROLLED_RESULT_NON_PARTICIPATING){
29
+ throw new Yoma_Realex_Model_Exception_NoneParticipatingCard (
30
+ $this->_getHelper()->__($this->getMessage())
31
+ );
32
+ }
33
+ throw new Yoma_Realex_Model_Exception_NotEnrolled (
34
+ $this->_getHelper()->__($this->getMessage())
35
+ );
36
+ }
37
+
38
+ return true;
39
+ }
40
+
41
+ public function isValid(){
42
+
43
+ $hash = $this->_getHelper()->generateSha1Hash(
44
+ $this->_getHelper()->getConfigData('realex','secret'),
45
+ array(
46
+ $this->getTimestamp(),
47
+ $this->getMerchantid(),
48
+ $this->getOrderid(),
49
+ $this->getResult(),
50
+ $this->getMessage(),
51
+ $this->getPasref(),
52
+ $this->getAuthcode()
53
+ )
54
+
55
+ );
56
+
57
+ if ($hash != $this->getSha1hash()) {
58
+ throw new Yoma_Realex_Model_Exception_NotEnrolled(
59
+ $this->_getHelper()->__('Payment Gateway Response Can Not be Validated.')
60
+ );
61
+ }
62
+
63
+ return $this;
64
+ }
65
+
66
+ }
67
+
68
+
app/code/community/Yoma/Realex/Model/Response/Token/ThreedSecureVerify.php ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_ThreedSecureVerify extends Yoma_Realex_Model_Response_Token{
21
+
22
+ public function processResult(){
23
+
24
+ switch ($this->getResult()) {
25
+ case self::AUTH_RESULT_AUTHENTICATED:
26
+ break;
27
+ default:
28
+ throw new Exception(
29
+ $this->_getHelper()->__($this->getMessages())
30
+ );
31
+ break;
32
+ }
33
+ }
34
+
35
+ public function getEciFromThreedSecureVerifySignature($result, $status, $cardType, $enrolledCards,
36
+ $requireLiabilityShift = true, $profile = null)
37
+ {
38
+
39
+ if(!isset($profile)){
40
+ $profile = new Varien_Object();
41
+ }
42
+
43
+ $profile->setRequireLiabilityShift($requireLiabilityShift);
44
+ $profile->setResult($result);
45
+ $profile->setStatus($status);
46
+
47
+ // if the card type is not enrolled in 3D Secure, return false
48
+ if (!is_null($cardType) && !in_array($cardType, $enrolledCards)) {
49
+ return false;
50
+ }
51
+
52
+ // default liability shift to false, to be proven otherwise
53
+ $profile->setLiabilityShift(false);
54
+
55
+ // default 3D Secure authentication result to false, to be proven otherwise
56
+
57
+ $profile->setThreedSecureAuthentication(false);
58
+
59
+ // all results starting with 5 should be handled the same way
60
+ if (substr($result, 0, 1) == '5') {
61
+ $result = '5xx';
62
+ }
63
+
64
+ // determine whether this transaction would cause a liability shift
65
+ switch ($result) {
66
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_VALIDATED:
67
+ switch ($status) {
68
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_AUTHENTICATED:
69
+ $profile->setLiabilityShift(true);
70
+ $profile->setThreedSecureAuthentication(true);
71
+ break;
72
+
73
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_ACKNOWLEDGED:
74
+ $profile->setLiabilityShift(true);
75
+ $profile->setThreedSecureAuthentication(false);
76
+ break;
77
+
78
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_NOT_AUTHENTICATED:
79
+ $profile->setLiabilityShift(false);
80
+ $profile->setThreedSecureAuthentication(false);
81
+ break;
82
+
83
+ default:
84
+ case self::THREED_SECURE_VERIFY_SIGNATURE_STATUS_UNAVAILABLE:
85
+ $profile->setLiabilityShift(false);
86
+ $profile->setThreedSecureAuthentication(false);
87
+ break;
88
+ }
89
+ break;
90
+
91
+ default:
92
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_ENROLLED_INVALID_ACS_RESPONSE:
93
+ throw new Yoma_Realex_Model_Exception_NoLiabilityShift($this->_getHelper()
94
+ ->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
95
+ );
96
+ break;
97
+ case self::THREED_SECURE_VERIFY_SIGNATURE_RESULT_INVALID_ACS_RESPONSE:
98
+ $profile->setLiabilityShift(false);
99
+ $profile->setThreedSecureAuthentication(false);
100
+ break;
101
+ }
102
+
103
+ $hash = $this->_getHelper()->generateSha1Hash(
104
+ $this->_getHelper()->getConfigData('realex','secret'),
105
+ array(
106
+ $this->getTimestamp(),
107
+ $this->getMerchantid(),
108
+ $this->getOrderid(),
109
+ $this->getResult(),
110
+ $this->getMessage(),
111
+ $this->getPasref(),
112
+ $this->getAuthcode()
113
+ )
114
+
115
+ );
116
+
117
+ if ($hash != $this->getSha1hash()) {
118
+ $profile->setLiabilityShift(false);
119
+ $profile->setThreedSecureAuthentication(false);
120
+ }
121
+
122
+ Mage::dispatchEvent('realex_process_threedsecure_verify_after', array('transport'=>$profile));
123
+
124
+ // if there is no liability shift, and it is required by the client, throw exception
125
+ if (!$profile->getLiabilityShift() && $profile->getRequireLiabilityShift()) {
126
+ throw new Yoma_Realex_Model_Exception_NoLiabilityShift($this->_getHelper()
127
+ ->__('The payment was unsuccessful at this time. Please try again or contact us for more information.')
128
+ );
129
+ }
130
+
131
+ // determine the eci value to use if the card is not enrolled in the 3D Secure scheme
132
+ return $this->getEciValue($cardType, $profile->getLiabilityShift(), $profile->getThreedSecureAuthentication());
133
+ }
134
+
135
+ }
app/code/community/Yoma/Realex/Model/Response/Token/Void.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Response_Token_Void extends Yoma_Realex_Model_Response_Direct_Void{
21
+
22
+ }
app/code/community/Yoma/Realex/Model/Service/Abstract.php ADDED
@@ -0,0 +1,1147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Yoma_Realex_Model_Service_Abstract {
22
+
23
+ protected $_methodInstance = NULL;
24
+ protected $_payment = NULL;
25
+ protected $_order = NULL;
26
+ protected $_transaction = NULL;
27
+ protected $_transactionReference = NULL;
28
+ protected $_transactionType = NULL;
29
+ protected $_response = NULL;
30
+ protected $_type = NULL;
31
+ protected $_serviceCode = NULL;
32
+ protected $_method = NULL;
33
+ protected $_md = NULL;
34
+ protected $_cardData = NULL;
35
+ protected $_token = NULL;
36
+
37
+ /**
38
+ * @return array
39
+ */
40
+ public function getCardData() {
41
+
42
+ return $this->_cardData;
43
+ }
44
+
45
+ public function setCardData($cardData) {
46
+
47
+ $this->_cardData = $cardData;
48
+ }
49
+
50
+
51
+ public function getMd($key = '') {
52
+
53
+ if (!isset($this->_md)) {
54
+ return false;
55
+ }
56
+ if (isset($this->_md[$key])) {
57
+ return $this->_md[$key];
58
+ }
59
+
60
+ return false;
61
+ }
62
+
63
+ public function setMd($md) {
64
+
65
+ $this->_md = $md;
66
+ }
67
+
68
+ public function getMethod() {
69
+
70
+ return $this->_method;
71
+ }
72
+
73
+ public function setMethod() {
74
+
75
+ $this->_method = NULL;
76
+ $this->_setMethod();
77
+ }
78
+
79
+ /**
80
+ * @return false|Mage_Core_Model_Abstract|null
81
+ */
82
+ protected function _setMethod() {
83
+
84
+ if ($this->_method == NULL) {
85
+ // construct method name from payment model type and method
86
+ $method = $this->_adapter . '_' . $this->getTransactionType();
87
+ // pass reference to self
88
+ $this->_method = Mage::getModel('realex/payment_' . $method, $this);
89
+ }
90
+
91
+ return $this->_method;
92
+ }
93
+
94
+ public function getHelper() {
95
+
96
+ return $this->_getHelper();
97
+ }
98
+
99
+ /**
100
+ * Retrieve payment method instance code
101
+ *
102
+ * @return string
103
+ */
104
+ public function getCode() {
105
+
106
+ return $this->getMethodInstance()->getCode();
107
+ }
108
+
109
+ /**
110
+ * @return Mage_Payment_Model_Method_Abstract
111
+ */
112
+ public function getMethodInstance() {
113
+
114
+ return $this->_methodInstance;
115
+ }
116
+
117
+ /**
118
+ * @param Mage_Payment_Model_Method_Abstract $methodInstance
119
+ * @return $this
120
+ * @throws Exception
121
+ */
122
+ public function setMethodInstance(Mage_Payment_Model_Method_Abstract $methodInstance) {
123
+
124
+ if (!$methodInstance instanceof Mage_Payment_Model_Method_Abstract) {
125
+ throw new Exception('Invalid method instance');
126
+ }
127
+
128
+ $this->_methodInstance = $methodInstance;
129
+
130
+ return $this;
131
+ }
132
+
133
+ public function run() {
134
+
135
+ $this->_pay();
136
+ }
137
+
138
+ /**
139
+ * Call current action on method model
140
+ */
141
+ protected function _pay() {
142
+
143
+ $action = $this->getTransactionType();
144
+ $this->_method->$action();
145
+ }
146
+
147
+ /**
148
+ * @param bool $convert
149
+ * @return string
150
+ */
151
+ public function getTransactionType($convert = false) {
152
+ if ($convert) {
153
+ // if $convert true then change transaction name for display only
154
+ return mage::helper('realex')->conversion($this->_transactionType);
155
+ }
156
+
157
+ return $this->_transactionType;
158
+ }
159
+
160
+ /**
161
+ * @param $transactionType
162
+ * @return $this
163
+ */
164
+ public function setTransactionType($transactionType) {
165
+
166
+ $this->_transactionType = $transactionType;
167
+
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Capture payment.
173
+ *
174
+ * @param Varien_Object $payment
175
+ * @param float $amount
176
+ * @return Yoma_Realex_Model_Service_Abstract
177
+ */
178
+ public function capture(Varien_Object $payment, $amount) {
179
+
180
+ $this->_addTransactionParent($payment);
181
+
182
+ // if existing transaction assume authorize taken place so settle
183
+ if ($payment->hasParentTransactionData()) {
184
+ $this->setTransactionType('partial');
185
+
186
+ return $this->_partialCapture($payment, $amount);
187
+ } else {
188
+
189
+ $transactionType = 'capture';
190
+ $this->setTransactionType($transactionType);
191
+
192
+ return $this->_authorizeAndCapture($payment, $amount);
193
+ }
194
+ }
195
+
196
+ /**
197
+ * Add transaction data to payment.
198
+ *
199
+ * @param Varien_Object $payment
200
+ * @return Yoma_Realex_Model_Service_Abstract
201
+ */
202
+ protected function _addTransactionParent(Varien_Object $payment) {
203
+
204
+ if ($parentId = $payment->getParentTransactionId()) {
205
+ $parent = $payment->getTransaction($parentId);
206
+ $parentData = $parent->getAdditionalInformation();
207
+ $payment->setParentTransactionData(
208
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
209
+ $parentData[Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS]
210
+ );
211
+ }
212
+
213
+ return $this;
214
+ }
215
+
216
+ /**
217
+ * Settle payment.
218
+ *
219
+ * @param Varien_Object $payment
220
+ * @param float $amount
221
+ * @return Yoma_Realex_Model_Service_Abstract
222
+ */
223
+ public function _partialCapture(Varien_Object $payment, $amount) {
224
+
225
+ $this->_addTransactionParent($payment);
226
+
227
+ $this->_setPayment($payment);
228
+ $this->_setOrder($payment->getOrder());
229
+
230
+ $this->setTransactionType('partial');
231
+ $payment->setData('payment_amount', $amount);
232
+ // load method to perform transaction
233
+ $this->_setMethod();
234
+
235
+ $transactionReference = $this->_method->getTransactionReference($payment);
236
+ $this->_setTransactionReference($transactionReference);
237
+ if ($transactionReference == "") {
238
+ throw new Exception('Unable to create transaction.');
239
+ }
240
+ try {
241
+ // call method action
242
+ $this->_pay();
243
+ } catch (Exception $e) {
244
+ Realex_Log::logException($e);
245
+ throw $e;
246
+ }
247
+ // add transaction data to payment
248
+ $payment
249
+ ->setIsTransactionClosed(false)
250
+ ->setShouldCloseParentTransaction(false)
251
+ ->setTransactionId($this->_getTransactionReference())
252
+ ->setTransactionAdditionalInfo(
253
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
254
+ $this->_method->getTransactionData(true)
255
+ );
256
+
257
+ // add payment info for display
258
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
259
+ $payment->getId(),
260
+ $this->getTransactionType(true),
261
+ $this->_method->getPaymentInfo()
262
+ );
263
+
264
+ return $this;
265
+ }
266
+
267
+ /**
268
+ * @return string
269
+ * @throws Exception
270
+ */
271
+ protected function _getTransactionReference() {
272
+
273
+ if ($this->_transactionReference == '') {
274
+ throw new Exception('Transaction reference not set.');
275
+ }
276
+
277
+ return $this->_transactionReference;
278
+ }
279
+
280
+ public function getTransactionReference() {
281
+
282
+ return $this->_getTransactionReference();
283
+ }
284
+
285
+ /**
286
+ * Set the transaction reference.
287
+ *
288
+ * @param string $transactionReference
289
+ * @return Yoma_Realex_Model_Service_Abstract
290
+ */
291
+ protected function _setTransactionReference($transactionReference) {
292
+
293
+ $this->_transactionReference = $transactionReference;
294
+ if (Mage::registry('transaction_reference')) {
295
+ Mage::unregister('name-of-registry-key');
296
+ Mage::register('transaction_reference', $transactionReference);
297
+ }
298
+
299
+ return $this;
300
+ }
301
+
302
+ /**
303
+ * Capture payment on gateway.
304
+ *
305
+ * @param Varien_Object $payment
306
+ * @param float $amount
307
+ * @return Yoma_Realex_Model_Service_Abstract
308
+ */
309
+ protected function _authorizeAndCapture(Varien_Object $payment, $amount) {
310
+
311
+ $this->_setPayment($payment);
312
+ $this->_setOrder($payment->getOrder());
313
+ $payment->setData('payment_amount', $amount);
314
+
315
+ $this->_setMethod();
316
+
317
+ $transactionReference = $this->_method->getTransactionReference($payment);
318
+ $this->_setTransactionReference($transactionReference);
319
+ if ($transactionReference == "") {
320
+ throw new Exception('Unable to create transaction.');
321
+ }
322
+ try {
323
+
324
+ $this->_pay();
325
+
326
+ } catch (Yoma_Realex_Model_Exception_DenyPayment $e) {
327
+
328
+ // catch 101, 102, 103 errors
329
+ $payment->setIsTransactionPending(true);
330
+ $this->saveDeniedTransaction($e->getMessage());
331
+ //set redirect url for checkout
332
+ $url = $this->_method->getCallDenyUrl();
333
+ Mage::getSingleton('customer/session')->setRedirectUrl($url);
334
+
335
+ } catch (Exception $e) {
336
+
337
+ Realex_Log::logException($e);
338
+ throw new Mage_Payment_Model_Info_Exception($e->getMessage());
339
+ }
340
+
341
+ $payment
342
+ ->setIsTransactionClosed(false)
343
+ ->setShouldCloseParentTransaction(false)
344
+ ->setTransactionId($this->_getTransactionReference())
345
+ ->setTransactionAdditionalInfo(
346
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
347
+ $this->_method->getTransactionData(true)
348
+ );
349
+
350
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
351
+ $payment->getId(),
352
+ $this->getTransactionType(true),
353
+ $this->_method->getPaymentInfo()
354
+ );
355
+
356
+ return $this;
357
+ }
358
+
359
+ /**
360
+ * update current transaction before redirect
361
+ *
362
+ * @param string $errorMessage
363
+ * @return $this
364
+ */
365
+ public function saveDeniedTransaction($errorMessage = false) {
366
+
367
+ $serviceCode = $this->getMethodInstance()->getCode();
368
+ $transactionReference = $this->getTransactionReference();
369
+ // check if we have a transaction
370
+ $transaction = Mage::getModel('realex/transaction')->loadByServiceTransactionReference($serviceCode, $transactionReference, false);
371
+ // update transaction data
372
+ if ($transaction) {
373
+ $transaction
374
+ ->addData(array(
375
+ 'service_code' => $this->getMethodInstance()->getCode(),
376
+ 'transaction_reference' => $this->getTransactionReference(),
377
+ 'payment_id' => $this->_getPayment()->getId(),
378
+ 'order_id' => $this->_getOrder()->getId(),
379
+ 'transaction_type' => $this->getTransactionType(),
380
+ 'additional_information' => $this->_method->getRegisterTransactionData(),
381
+ 'payment_amount' => $this->_getPayment()->getData('payment_amount'),
382
+ 'remembertoken' => $this->_getPayment()->getData('remembertoken'),
383
+ ));
384
+
385
+ if ($errorMessage) {
386
+ $transaction->setErrorMessage($errorMessage);
387
+ }
388
+
389
+ $transaction->save();
390
+
391
+ $this->_setTransaction($transaction);
392
+
393
+ } else {
394
+ // create new transaction
395
+ $this->saveTransaction();
396
+ }
397
+
398
+ return $this;
399
+ }
400
+
401
+ protected function _getPayment() {
402
+ return $this->_payment;
403
+ }
404
+
405
+ public function getPayment() {
406
+ return $this->_getPayment();
407
+ }
408
+
409
+ protected function _setPayment(Varien_Object $payment) {
410
+ $this->_payment = $payment;
411
+
412
+ return $this;
413
+ }
414
+
415
+ protected function _getOrder() {
416
+ return $this->_order;
417
+ }
418
+
419
+ public function getOrder() {
420
+ return $this->_getOrder();
421
+ }
422
+
423
+ protected function _setOrder(Varien_Object $order) {
424
+ $this->_order = $order;
425
+
426
+ return $this;
427
+ }
428
+
429
+ public function saveTransaction() {
430
+ return $this->_saveTransaction();
431
+ }
432
+
433
+ /**
434
+ * Save transaction data
435
+ *
436
+ * @param string $errorMessage
437
+ * @return $this|Yoma_Realex_Model_Service_Abstract
438
+ */
439
+ protected function _saveTransaction($errorMessage = false)
440
+ {
441
+ $transaction = Mage::getModel('realex/transaction')
442
+ ->setData(array(
443
+ 'service_code' => $this->getMethodInstance()->getCode(),
444
+ 'transaction_reference' => $this->getTransactionReference(),
445
+ 'payment_id' => $this->_getPayment()->getId(),
446
+ 'order_id' => $this->_getOrder()->getId(),
447
+ 'transaction_type' => $this->getTransactionType(),
448
+ 'additional_information' => $this->_method->getRegisterTransactionData(),
449
+ 'payment_amount' => $this->_getPayment()->getData('payment_amount'),
450
+ 'remembertoken' => $this->_getPayment()->getData('remembertoken'),
451
+ ));
452
+
453
+ if($errorMessage){
454
+ $transaction->setErrorMessage($errorMessage);
455
+ }
456
+
457
+ $transaction->save();
458
+
459
+ $this->_setTransaction($transaction);
460
+
461
+ return $this;
462
+ }
463
+
464
+ /**
465
+ * Authorize payment on gateway.
466
+ *
467
+ * @param Varien_Object $payment
468
+ * @param float $amount
469
+ * @return Yoma_Realex_Model_Service_Abstract
470
+ */
471
+ public function authorize($payment, $amount) {
472
+
473
+ $this->_addTransactionParent($payment);
474
+
475
+ $this->_setPayment($payment);
476
+ $this->_setOrder($payment->getOrder());
477
+
478
+ $this->setTransactionType('authorize');
479
+ $payment->setData('payment_amount', $amount);
480
+
481
+ $this->_setMethod();
482
+
483
+ $transactionReference = $this->_method->getTransactionReference($payment);
484
+ $this->_setTransactionReference($transactionReference);
485
+ if ($transactionReference == "") {
486
+ throw new Exception('Unable to create transaction.');
487
+ }
488
+ try {
489
+
490
+ $this->_pay();
491
+
492
+ } catch (Yoma_Realex_Model_Exception_DenyPayment $e) {
493
+
494
+ $payment->setIsTransactionPending(true);
495
+ $this->saveDeniedTransaction($e->getMessage());
496
+ $url = $this->_method->getCallDenyUrl();
497
+ Mage::getSingleton('customer/session')->setRedirectUrl($url);
498
+
499
+ } catch (Exception $e) {
500
+
501
+ Realex_Log::logException($e);
502
+ throw new Mage_Payment_Model_Info_Exception($e->getMessage());
503
+ }
504
+
505
+ $payment
506
+ ->setIsTransactionClosed(false)
507
+ ->setShouldCloseParentTransaction(false)
508
+ ->setTransactionId($this->_getTransactionReference())
509
+ ->setTransactionAdditionalInfo(
510
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
511
+ $this->_method->getTransactionData(true)
512
+ );
513
+
514
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
515
+ $payment->getId(),
516
+ $this->getTransactionType(true),
517
+ $this->_method->getPaymentInfo()
518
+ );
519
+
520
+ return $this;
521
+ }
522
+
523
+ /**
524
+ * Refund payment on gateway.
525
+ *
526
+ * @param Varien_Object $payment
527
+ * @param float $amount
528
+ * @return Yoma_Realex_Model_Service_Abstract
529
+ */
530
+ public function refund(Varien_Object $payment, $amount) {
531
+
532
+ $this->_addTransactionParent($payment);
533
+ $payment->setData('payment_amount', $amount);
534
+
535
+ $this->_setPayment($payment);
536
+ $this->_setOrder($payment->getOrder());
537
+ $this->setTransactionType('refund');
538
+
539
+ $this->_setMethod();
540
+
541
+ $transactionReference = $this->_method->getTransactionReference($payment);
542
+ $transactionReference = $this->_incrementTransactionId($payment, $transactionReference);
543
+ $this->_setTransactionReference($transactionReference);
544
+ if ($transactionReference == '') {
545
+ throw new Exception('Unable to retrieve transaction reference from adapter.');
546
+ }
547
+
548
+ try {
549
+ $this->_pay();
550
+ } catch (Exception $e) {
551
+ Realex_Log::logException($e);
552
+ throw new Mage_Payment_Model_Info_Exception($e->getMessage());
553
+ }
554
+
555
+ $payment
556
+ ->setIsTransactionClosed(true)
557
+ ->setShouldCloseParentTransaction(true)
558
+ ->setTransactionId($this->_getTransactionReference())
559
+ ->setTransactionAdditionalInfo(
560
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
561
+ $this->_method->getTransactionData(true)
562
+ );
563
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
564
+ $payment->getId(),
565
+ $this->getTransactionType(true),
566
+ $this->_method->getPaymentInfo()
567
+ );
568
+
569
+ return $this;
570
+ }
571
+
572
+ /**
573
+ * increment transaction id
574
+ *
575
+ * @param Mage_Sales_Model_Order_Payment $payment
576
+ * @param string $transactionId
577
+ * @return string
578
+ */
579
+ protected function _incrementTransactionId(Mage_Sales_Model_Order_Payment $payment, $transactionId) {
580
+
581
+ if (!$payment->getTransaction($transactionId)) {
582
+ return $transactionId;
583
+ }
584
+ $_parts = explode('-', $transactionId);
585
+ if (preg_match('/^\-*\d+$/', (string)end($_parts)) === 1) {
586
+
587
+ $lastNumber = array_pop($_parts);
588
+ $_parts[] = $lastNumber + 1;
589
+ } else {
590
+ $_parts[] = '1';
591
+ }
592
+ $transactionId = implode('-', $_parts);
593
+
594
+ return $this->_incrementTransactionId($payment, $transactionId);
595
+ }
596
+
597
+ /**
598
+ * Void payment on gateway.
599
+ *
600
+ * @param Varien_Object $payment
601
+ * @param float $amount
602
+ * @return Yoma_Realex_Model_Service_Abstract
603
+ */
604
+ public function void(Varien_Object $payment) {
605
+
606
+ $this->_addTransactionParent($payment);
607
+
608
+ $this->setTransactionType('void');
609
+
610
+ $this->_setPayment($payment);
611
+ $this->_setOrder($payment->getOrder());
612
+
613
+ $this->_setMethod();
614
+
615
+ $transactionReference = $this->_method->getTransactionReference($payment);
616
+ $transactionReference = $this->_incrementTransactionId($payment, $transactionReference);
617
+ $this->_setTransactionReference($transactionReference);
618
+ if ($transactionReference == '') {
619
+ throw new Exception('Unable to retrieve transaction reference from adapter.');
620
+ }
621
+
622
+ try {
623
+ $this->_pay();
624
+ } catch (Exception $e) {
625
+ Realex_Log::logException($e);
626
+ $this->_getAdminSession()->addError($this->_gethelper()->__($e->getMessage()));
627
+ throw $e;
628
+ }
629
+
630
+ $payment
631
+ ->setIsTransactionClosed(true)
632
+ ->setShouldCloseParentTransaction(true)
633
+ ->setTransactionId($this->_getTransactionReference())
634
+ ->setTransactionAdditionalInfo(
635
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
636
+ $this->_method->getTransactionData(true)
637
+ );
638
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
639
+ $payment->getId(),
640
+ $this->getTransactionType(true),
641
+ $this->_method->getPaymentInfo()
642
+ );
643
+
644
+ return $this;
645
+ }
646
+
647
+ protected function _getAdminSession() {
648
+ return Mage::getSingleton('adminhtml/session');
649
+ }
650
+
651
+ /**
652
+ * Prepare payment deny from callback
653
+ *
654
+ * @throws Exception
655
+ */
656
+ public function callDeny() {
657
+
658
+ // initialise model variables
659
+ $this->_init();
660
+
661
+ $errorMessage = 'The transaction was declined.';
662
+
663
+ $transaction = $this->_getTransaction();
664
+ if (empty($transaction)) {
665
+ throw new Exception($this->_getHelper()
666
+ ->__("Unable to load Transaction '{$this->getTransactionReference()}'"));
667
+ }
668
+ // set error message
669
+ if ($transaction->getId() && (string)$transaction->getErrorMessage() == '') {
670
+
671
+ Mage::getModel('realex/transaction')
672
+ ->load($transaction->getId())
673
+ ->setErrorMessage($errorMessage)
674
+ ->save();
675
+ } elseif ($transaction->getId()) {
676
+ $errorMessage = (string)$transaction->getErrorMessage();
677
+ }
678
+
679
+ // update the transaction data
680
+ $this->_updateTransactionAfterDeny();
681
+
682
+ // deny the payment
683
+ $this->_denyPayment();
684
+
685
+ throw new Exception($errorMessage);
686
+ }
687
+
688
+ /**
689
+ * Process callback from gateway
690
+ *
691
+ * @throws Exception
692
+ */
693
+ public function callBack(){
694
+
695
+ try {
696
+
697
+ $this->_init();
698
+ $this->_method->processCallback();
699
+ $this->_updateTransactionAfterCallback();
700
+ $this->_acceptPayment();
701
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
702
+ $this->_getPayment()->getId(),
703
+ $this->getTransactionType(true),
704
+ $this->_method->getPaymentInfo()
705
+ );
706
+ Mage::dispatchEvent('realex_accept_payment_after', array('order'=> $this->_getPayment()->getOrder()));
707
+ return true;
708
+
709
+ } catch (Yoma_Realex_Model_Exception_DenyPayment $e) {
710
+
711
+ $this->_processFailure($e,'payment_deny');
712
+ $this->_updateTransactionAfterCallback();
713
+ $this->_denyPayment();
714
+
715
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
716
+ $this->_getPayment()->getId(),
717
+ $this->getTransactionType(true),
718
+ $this->_method->getPaymentInfo()
719
+ );
720
+
721
+ Mage::logException($e);
722
+ throw new Exception($e->getMessage());
723
+
724
+ }catch (Yoma_Realex_Model_Exception_Payment $e){
725
+
726
+ $this->_processFailure($e,'error');
727
+
728
+ //update the transaction data
729
+ $this->_updateTransactionAfterCallback();
730
+
731
+ Mage::getModel('realex/paymentInfo')->saveSectionData(
732
+ $this->_getPayment()->getId(),
733
+ $this->getTransactionType(true),
734
+ $this->_method->getPaymentInfo()
735
+ );
736
+
737
+ Mage::logException($e);
738
+ throw new Exception($e->getMessage());
739
+ }
740
+ }
741
+
742
+ /**
743
+ * Initialize models after callback
744
+ *
745
+ * @return $this
746
+ * @throws Exception
747
+ */
748
+ protected function _init(){
749
+
750
+ $this->setTransactionType(Mage::app()->getRequest()->getParam('type'));
751
+ $this->_setTransactionReference(Mage::app()->getRequest()->getParam('reference'));
752
+
753
+ $this->_setMethod()->setResponse(
754
+ $this->getTransactionType(),
755
+ Mage::app()->getRequest()->getPost()
756
+ );
757
+
758
+ $transaction = Mage::getModel('realex/transaction')
759
+ ->loadByServiceTransactionReference($this->_serviceCode,$this->getTransactionReference());
760
+
761
+ $this->_setTransaction($transaction);
762
+
763
+ if ($transaction->getTransactionType() != $this->getTransactionType()) {
764
+ throw new Exception($this->_getHelper()
765
+ ->__("Transaction type '{$this->getTransactionType()}' does not match expected '{$transaction->getTransactionType()}'."));
766
+ }
767
+
768
+ $order = Mage::getModel('sales/order')->load($transaction->getOrderId());
769
+ $this->_setOrder($order);
770
+ if (!$order->getId()) {
771
+ throw new Exception($this->_getHelper()
772
+ ->__("Unable to load order for Transaction '{$this->getTransactionReference()}'"));
773
+ }
774
+
775
+ $payment = Mage::getModel('sales/order_payment')->load($transaction->getPaymentId());
776
+ $payment->setOrder($order);
777
+ $this->_setPayment($payment);
778
+ if (!$payment->getId()) {
779
+ throw new Exception($this->_getHelper()
780
+ ->__("Unable to load payment for Transaction '{$this->getTransactionReference()}'"));
781
+ }
782
+
783
+ $this->setMethodInstance($payment->getMethodInstance());
784
+
785
+ if ($order->getStatus() !== Mage_Sales_Model_Order::STATE_PAYMENT_REVIEW) {
786
+ $comment = $order->addStatusHistoryComment($this->_getHelper()
787
+ ->__('Realex Callback Occurred.'));
788
+ $comment->save();
789
+
790
+ throw new Exception($this->_getHelper()
791
+ ->__("Incorrect Order Status"));
792
+ }
793
+
794
+ return $this;
795
+ }
796
+
797
+ /**
798
+ * Update transaction after callback
799
+ *
800
+ * @return $this|Yoma_Realex_Model_Service_Abstract
801
+ */
802
+ protected function _updateTransactionAfterCallback()
803
+ {
804
+ if($this->_getPayment()){
805
+ $transaction = $this->_getPayment()->getTransaction(
806
+ $this->getTransactionReference()
807
+ );
808
+ }
809
+ if($transaction) {
810
+ $transaction
811
+ ->setIsClosed(false)
812
+ ->setShouldCloseParentTransaction(false)
813
+ ->setAdditionalInformation(
814
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
815
+ $this->_method->getTransactionData(true)
816
+ );
817
+
818
+ $transaction->save();
819
+ }
820
+ return $this;
821
+ }
822
+
823
+ /**
824
+ * Close transaction after deny
825
+ *
826
+ * @return $this
827
+ */
828
+ protected function _updateTransactionAfterDeny() {
829
+ if ($this->_getPayment()) {
830
+ $transaction = $this->_getPayment()->getTransaction(
831
+ $this->getTransactionReference()
832
+ );
833
+ }
834
+ if ($transaction) {
835
+ $transaction
836
+ ->setIsClosed(true)
837
+ ->setShouldCloseParentTransaction(true);
838
+ $transaction->save();
839
+ }
840
+
841
+ return $this;
842
+ }
843
+
844
+ /**
845
+ * Deny payment
846
+ *
847
+ * @return $this
848
+ * @throws Exception
849
+ */
850
+ protected function _denyPayment() {
851
+
852
+ $payment = $this->_getPayment()
853
+ ->setData('payment_deny', true);
854
+
855
+ if (method_exists($payment, 'deny')) {
856
+ $payment->deny();
857
+ } else {
858
+ $this->registerPaymentReviewAction($payment, 'payment_deny');
859
+ }
860
+
861
+ $this->_getOrder()->save();
862
+
863
+ return $this;
864
+ }
865
+
866
+ /**
867
+ * Update transaction for orders in payment review
868
+ *
869
+ * @param Mage_Sales_Model_Order_Payment $payment
870
+ * @param string $action
871
+ * @return $this
872
+ * @throws Exception
873
+ */
874
+ public function registerPaymentReviewAction($payment, $action) {
875
+ $order = $payment->getOrder();
876
+
877
+ $transactionId = $payment->getLastTransId();
878
+ $invoice = $this->_getInvoiceForTransactionId($order, $transactionId);
879
+
880
+ $result = NULL;
881
+ $message = NULL;
882
+
883
+ switch ($action) {
884
+ case 'payment_accept':
885
+ if ($payment->getMethodInstance()->setStore($order->getStoreId())->acceptPayment($payment)) {
886
+ $result = true;
887
+ $message = Mage::helper('realex')->__('Approved the payment online.');
888
+ } else {
889
+ $result = -1;
890
+ $message = Mage::helper('realex')->__('There is no need to approve this payment.');
891
+ }
892
+ break;
893
+
894
+ case 'payment_deny':
895
+ if ($payment->getMethodInstance()->setStore($order->getStoreId())->denyPayment($payment)) {
896
+ $result = false;
897
+ $message = Mage::helper('realex')->__('Denied the payment online.');
898
+ } else {
899
+ $result = -1;
900
+ $message = Mage::helper('realex')->__('There is no need to deny this payment.');
901
+ }
902
+ break;
903
+
904
+ default:
905
+ throw new Exception('Not implemented.');
906
+ break;
907
+ }
908
+
909
+ $message = $payment->_prependMessage($message);
910
+
911
+ if ($transactionId) {
912
+ $message .= ' ' . Mage::helper('realex')
913
+ ->__('Transaction ID: "%s".', $transactionId);
914
+ }
915
+
916
+ if (-1 === $result) {
917
+ $order->addStatusHistoryComment($message);
918
+ } elseif (true === $result) {
919
+ if ($invoice) {
920
+ $invoice->pay();
921
+ $payment->_updateTotals(array('base_amount_paid_online' => $invoice->getBaseGrandTotal()));
922
+ $order->addRelatedObject($invoice);
923
+ }
924
+ if ($order->getState() == Mage_Sales_Model_Order::STATE_HOLDED) {
925
+ $this->_unhold($order, $message);
926
+ } else {
927
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, $message);
928
+ }
929
+ } elseif (false === $result) {
930
+ if ($invoice) {
931
+ $invoice->cancel();
932
+ $order->addRelatedObject($invoice);
933
+ }
934
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING);
935
+ $order->registerCancellation($message, false);
936
+ }
937
+
938
+ return $this;
939
+ }
940
+
941
+ /**
942
+ * Check order for existing invoice
943
+ *
944
+ * @param Mage_Sales_Model_Order $order
945
+ * @param string $transactionId
946
+ * @return bool
947
+ */
948
+ protected function _getInvoiceForTransactionId($order, $transactionId) {
949
+ foreach ($order->getInvoiceCollection() as $invoice) {
950
+ if ($invoice->getTransactionId() == $transactionId) {
951
+ $invoice->load($invoice->getId());
952
+
953
+ return $invoice;
954
+ }
955
+ }
956
+ foreach ($order->getInvoiceCollection() as $invoice) {
957
+ if ($invoice->getState() == Mage_Sales_Model_Order_Invoice::STATE_OPEN
958
+ && $invoice->load($invoice->getId())
959
+ ) {
960
+ $invoice->setTransactionId($transactionId);
961
+
962
+ return $invoice;
963
+ }
964
+ }
965
+
966
+ return false;
967
+ }
968
+
969
+ public function getTransaction() {
970
+ return $this->_getTransaction();
971
+ }
972
+
973
+ protected function _getTransaction() {
974
+ return $this->_transaction;
975
+ }
976
+
977
+ protected function _setTransaction(Yoma_Realex_Model_Transaction $transaction) {
978
+ $this->_transaction = $transaction;
979
+
980
+ return $this;
981
+ }
982
+
983
+ public function debugData($debugData) {
984
+
985
+ $this->getMethodInstance()->debugData($debugData);
986
+ }
987
+
988
+ public function getToken() {
989
+
990
+ return $this->_token;
991
+ }
992
+
993
+ public function setToken($token) {
994
+
995
+ $this->_token = $token;
996
+ }
997
+
998
+ /**
999
+ * Accept payment
1000
+ *
1001
+ * @return $this
1002
+ * @throws Exception
1003
+ */
1004
+ protected function _acceptPayment() {
1005
+ $payment = $this->_getPayment()
1006
+ ->setData('payment_accept', true);
1007
+
1008
+ if (method_exists($payment, 'accept')) {
1009
+ $payment->accept();
1010
+ } else {
1011
+ $this->registerPaymentReviewAction($payment, 'payment_accept');
1012
+ }
1013
+
1014
+ $order = $payment->getOrder()
1015
+ ->save()->sendNewOrderEmail();
1016
+
1017
+
1018
+ $orderStatus = $payment->getMethodInstance()->getConfigData('order_status');
1019
+ if ($orderStatus != '' && $orderStatus != $order->getStatus()) {
1020
+
1021
+ $order->setStatus($orderStatus);
1022
+ $comment = $order->addStatusHistoryComment($this->_getHelper()
1023
+ ->__("Order status updated."));
1024
+ $comment->save();
1025
+
1026
+ $order->save();
1027
+ }
1028
+
1029
+ return $this;
1030
+ }
1031
+
1032
+ /**
1033
+ * Add message to payment
1034
+ *
1035
+ * @param mixed $messagePrependTo
1036
+ * @param Mage_Sales_Model_Payment $payment
1037
+ * @return string
1038
+ */
1039
+ protected function _prependMessage($messagePrependTo, $payment) {
1040
+ $preparedMessage = $payment->getPreparedMessage();
1041
+ if ($preparedMessage) {
1042
+ if (is_string($preparedMessage)) {
1043
+ return $preparedMessage . ' ' . $messagePrependTo;
1044
+ } elseif (is_object($preparedMessage)
1045
+ && ($preparedMessage instanceof Mage_Sales_Model_Order_Status_History)
1046
+ ) {
1047
+ $comment = $preparedMessage->getComment() . ' ' . $messagePrependTo;
1048
+ $preparedMessage->setComment($comment);
1049
+
1050
+ return $comment;
1051
+ }
1052
+ }
1053
+
1054
+ return $messagePrependTo;
1055
+ }
1056
+
1057
+ protected function _formatAmount($amount, $asFloat = false) {
1058
+ $amount = Mage::app()->getStore()->roundPrice($amount);
1059
+
1060
+ return !$asFloat ? (string)$amount : $amount;
1061
+ }
1062
+
1063
+ /**
1064
+ * To be removed
1065
+ *
1066
+ * @param $payment
1067
+ * @param $reference
1068
+ * @param array $data
1069
+ * @param bool $close
1070
+ * @param bool $closeParent
1071
+ */
1072
+ protected function _processFailure(Exception $e, $type) {
1073
+
1074
+ $errorMessage = $e->getMessage();
1075
+
1076
+ $transaction = $this->_getTransaction();
1077
+ if (empty($transaction)) {
1078
+ throw new Exception($this->_getHelper()
1079
+ ->__("Unable to load Transaction '{$this->getTransactionReference()}'"));
1080
+ }
1081
+ if ($transaction->getId() && (string)$transaction->getErrorMessage() == '') {
1082
+
1083
+ Mage::getModel('realex/transaction')
1084
+ ->load($transaction->getId())
1085
+ ->setErrorMessage($errorMessage)
1086
+ ->save();
1087
+ }
1088
+
1089
+ return $this;
1090
+ }
1091
+
1092
+ /**
1093
+ * To be removed
1094
+ *
1095
+ * @param $payment
1096
+ * @param $reference
1097
+ * @param array $data
1098
+ * @param bool $close
1099
+ * @param bool $closeParent
1100
+ */
1101
+ protected function _updatePaymentTransaction($payment, $reference, $data = array(), $close = false, $closeParent = false) {
1102
+ $payment
1103
+ ->setIsTransactionClosed($close)
1104
+ ->setShouldCloseParentTransaction($closeParent)
1105
+ ->setTransactionId($reference)
1106
+ ->setTransactionAdditionalInfo(
1107
+ Mage_Sales_Model_Order_Payment_Transaction::RAW_DETAILS,
1108
+ $data
1109
+ );
1110
+ }
1111
+
1112
+ protected function _registerTransaction() {
1113
+
1114
+ $this->_saveTransaction();
1115
+ }
1116
+
1117
+ protected function _processResponse() {
1118
+
1119
+ $this->_getResponse()->processResult();
1120
+ return $this;
1121
+ }
1122
+
1123
+ protected function _getResponse() {
1124
+
1125
+ return $this->_getType()->getResponse();
1126
+ }
1127
+
1128
+ protected function _setResponse($response) {
1129
+
1130
+ $this->_response = $response;
1131
+ return $this;
1132
+ }
1133
+
1134
+ /**
1135
+ * @return Mage_Core_Model_Abstract
1136
+ */
1137
+ protected function _getSession() {
1138
+ return Mage::getSingleton('checkout/session');
1139
+ }
1140
+
1141
+ public function getCardOwner(){
1142
+
1143
+ $payment = $this->_getPayment();
1144
+ return $payment->getData('cc_owner');
1145
+ }
1146
+
1147
+ }
app/code/community/Yoma/Realex/Model/Service/Direct.php ADDED
@@ -0,0 +1,50 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Service_Direct extends Yoma_Realex_Model_Service_Abstract{
21
+
22
+ /**
23
+ * Payment method processor.
24
+ *
25
+ * @var Yoma_Realex_Model_Payment_Abstract $_method
26
+ */
27
+ protected $_adapter = 'direct';
28
+ protected $_serviceCode = 'realexdirect';
29
+
30
+
31
+ protected function _registerTransaction(){
32
+
33
+ $this->_saveTransaction();
34
+ }
35
+
36
+ /**
37
+ * @return Mage_Core_Helper_Abstract
38
+ */
39
+ protected function _getHelper()
40
+ {
41
+ return Mage::helper('realex/direct');
42
+ }
43
+
44
+
45
+ public function getAdapter(){
46
+
47
+ return $this->_adapter;
48
+ }
49
+
50
+ }
app/code/community/Yoma/Realex/Model/Service/Redirect.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Service_Redirect extends Yoma_Realex_Model_Service_Abstract{
21
+
22
+ protected $_adapter = 'redirect';
23
+ protected $_serviceCode = 'realexredirect';
24
+
25
+ /**
26
+ * @return Mage_Core_Helper_Abstract
27
+ */
28
+ protected function _getHelper()
29
+ {
30
+ return Mage::helper('realex/redirect');
31
+ }
32
+
33
+ /**
34
+ * Set transaction state before call back
35
+ */
36
+ protected function _registerTransaction(){
37
+
38
+ $this->_saveTransaction();
39
+ $this->_getPayment()->setIsTransactionPending(true);
40
+ }
41
+
42
+ /**
43
+ * Save transaction
44
+ *
45
+ * @return $this|Yoma_Realex_Model_Service_Abstract
46
+ */
47
+ protected function _saveTransaction($errorMessage = false)
48
+ {
49
+ $transaction = Mage::getModel('realex/transaction')
50
+ ->setData(array(
51
+ 'service_code' => $this->getMethodInstance()->getCode(),
52
+ 'transaction_reference' => $this->getTransactionReference(),
53
+ 'payment_id' => $this->_getPayment()->getId(),
54
+ 'order_id' => $this->_getOrder()->getId(),
55
+ 'transaction_type' => $this->getTransactionType(),
56
+ 'additional_information' => $this->_method->getRegisterTransactionData(),
57
+ 'payment_amount' => $this->_getPayment()->getData('payment_amount'),
58
+ ))
59
+ ->save();
60
+
61
+ $this->_setTransaction($transaction);
62
+
63
+ return $this;
64
+ }
65
+
66
+ /**
67
+ * @todo replace redundant code
68
+ * @return $this
69
+ */
70
+ protected function _processResponse(){
71
+
72
+ $this->_getResponse()->processResult();
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ *
78
+ * * @todo replace redundant code
79
+ * @return string
80
+ */
81
+ public function getAdapter(){
82
+ return $this->_adapter;
83
+ }
84
+ }
app/code/community/Yoma/Realex/Model/Service/Token.php ADDED
@@ -0,0 +1,147 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ class Yoma_Realex_Model_Service_Token extends Yoma_Realex_Model_Service_Abstract
22
+ {
23
+
24
+ protected $_adapter = 'token';
25
+ protected $_serviceCode = 'realvault';
26
+
27
+ /**
28
+ * Fields that should be replaced in debug with '***'
29
+ *
30
+ * @var array
31
+ */
32
+ protected $_debugReplacePrivateDataKeys = array(
33
+ 'sha1hash', 'SHA1HASH','md5hash','MD5HASH','refundhash'
34
+ // 'sha1hash', 'SHA1HASH', 'card_number', 'card_cvn_number','md5hash','MD5HASH'
35
+ );
36
+
37
+ public function getAdapter()
38
+ {
39
+
40
+ return $this->_adapter;
41
+ }
42
+
43
+ protected function _getHelper()
44
+ {
45
+ return Mage::helper('realex');
46
+ }
47
+
48
+ /**
49
+ * Save transaction
50
+ * @TODO refactor service code call to mirror abstract method
51
+ *
52
+ * @param bool $errorMessage
53
+ * @return $this|Yoma_Realex_Model_Service_Abstract
54
+ */
55
+ protected function _saveTransaction($errorMessage = false)
56
+ {
57
+ $transaction = Mage::getModel('realex/transaction')
58
+ ->setData(array(
59
+ 'service_code' => $this->_serviceCode,
60
+ 'transaction_reference' => $this->getTransactionReference(),
61
+ 'payment_id' => $this->_getPayment()->getId(),
62
+ 'order_id' => $this->_getOrder()->getId(),
63
+ 'transaction_type' => $this->getTransactionType(),
64
+ 'additional_information' => $this->_method->getRegisterTransactionData(),
65
+ 'payment_amount' => $this->_getPayment()->getData('payment_amount'),
66
+ 'remembertoken' => $this->_getPayment()->getData('remembertoken'),
67
+ ));
68
+
69
+ $transaction->save();
70
+
71
+ $this->_setTransaction($transaction);
72
+
73
+ return $this;
74
+ }
75
+
76
+ /**
77
+ * @return string
78
+ */
79
+ public function getCode()
80
+ {
81
+ return 'realvault';
82
+ }
83
+
84
+ /**
85
+ * @param mixed $debugData
86
+ */
87
+ public function debugData($debugData)
88
+ {
89
+
90
+ if ($this->getMethodInstance()) {
91
+ $this->getMethodInstance()->debugData($debugData);
92
+ } else {
93
+ $logFile = 'payment_' . $this->getCode() . '.log';
94
+
95
+ if ($this->_getHelper()->getConfigData($this->getCode(), 'mode') == 'live') {
96
+ $debugData = $this->_filterData($debugData);
97
+ }
98
+ Realex_Log::log($debugData, NULL, $logFile);
99
+ }
100
+
101
+ }
102
+
103
+ /**
104
+ * @TODO refactor code call to mirror abstract method
105
+ * @param mixed $debugData
106
+ */
107
+ protected function _filterData($debugData)
108
+ {
109
+
110
+ if (is_array($debugData) && is_array($this->_debugReplacePrivateDataKeys)) {
111
+ foreach ($debugData as $key => $value) {
112
+ if (in_array($key, $this->_debugReplacePrivateDataKeys)) {
113
+ $temp = null;
114
+ for ($i = 0; $i < strlen($debugData[$key]); $i++) {
115
+ $temp .= '*';
116
+ }
117
+ $debugData[$key] = $temp;
118
+ } else {
119
+ if (is_array($debugData[$key])) {
120
+ $debugData[$key] = $this->_filterData($debugData[$key]);
121
+ }
122
+ }
123
+ }
124
+ }
125
+ return $debugData;
126
+ }
127
+
128
+ /**
129
+ * @return bool
130
+ */
131
+ public function getDebugFlag()
132
+ {
133
+ return true;
134
+ }
135
+
136
+ /**
137
+ *
138
+ * @return string
139
+ */
140
+ protected function _processResponse()
141
+ {
142
+
143
+ $this->_getResponse()->processResult();
144
+ return $this;
145
+
146
+ }
147
+ }
app/code/community/Yoma/Realex/Model/Session.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Session extends Mage_Core_Model_Session_Abstract
21
+ {
22
+ public function __construct()
23
+ {
24
+ $this->init('realex');
25
+ }
26
+
27
+ }
app/code/community/Yoma/Realex/Model/SubAccountProcessor.php ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_SubAccountProcessor
21
+ {
22
+
23
+ protected $_calculationTypes = array(
24
+ 'card_type' => '_stringCompare',
25
+ );
26
+
27
+ /*
28
+ *
29
+ * @param string $subAccount Default sub account value (to be used as fallback if no matches).
30
+ * @param array $rules Array of rules to attempt to match specific sub account values.
31
+ * @param array $filters Array of filters to match against each of the available rules.
32
+ * @return string
33
+ * @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
34
+ */
35
+ public function process($subAccount, $rules, $filters,$payment)
36
+ {
37
+ // loop through all provided rules trying to find a match
38
+ foreach ($rules as $_rule) {
39
+ // initialise matched filters with sub_account
40
+ $filtersMatched = array('sub_account' => true);
41
+
42
+ // loop through all required criteria
43
+ foreach ($filters as $_filterKey => $_filterValue) {
44
+ // skip any filters called sub_account
45
+ if ($_filterKey == 'sub_account') {
46
+ continue 2;
47
+ }
48
+
49
+ // does the rule have this filter defined
50
+ if (!array_key_exists($_filterKey, $_rule)) {
51
+ continue 2;
52
+ }
53
+
54
+ // does the rule have a sub_account defined (should always be true)
55
+ if (!array_key_exists('sub_account', $_rule)) {
56
+ continue 2;
57
+ }
58
+
59
+ // is the field type valid
60
+ if (!array_key_exists($_filterKey, $this->_calculationTypes)) {
61
+ continue 2;
62
+ }
63
+
64
+ // finally, call the calculation method to see if the filter value matches
65
+ $calculationMethod = $this->_calculationTypes[$_filterKey];
66
+ if (!$this->$calculationMethod($_rule[$_filterKey], $_filterValue)) {
67
+ continue 2;
68
+ }
69
+
70
+ // increment matches
71
+ $filtersMatched[$_filterKey] = true;
72
+ }
73
+
74
+ // check we matched all rules with the provided filters
75
+ if (count($_rule) == count($filtersMatched)) {
76
+ // we have a perfect match and dont need to examine any further rules
77
+ $subAccount = $_rule['sub_account'];
78
+ break;
79
+ }
80
+ }
81
+
82
+ $transport = new Varien_Object();
83
+ $transport->setSubAccount($subAccount);
84
+
85
+ Mage::dispatchEvent('realex_process_subaccount_after', array('payment'=> $payment,'transport'=>$transport));
86
+
87
+ return $transport->getSubAccount();
88
+ }
89
+
90
+ /**
91
+ * Determine whether the provided strings are the same.
92
+ *
93
+ * @param string $ruleValue
94
+ * @param string $filterValue
95
+ * @return bool
96
+ * @author Joseph McDermott <joseph.mcdermott@ampersandcommerce.com>
97
+ */
98
+ protected function _stringCompare($ruleValue, $filterValue)
99
+ {
100
+ return strcmp($ruleValue, $filterValue) === 0;
101
+ }
102
+ }
app/code/community/Yoma/Realex/Model/System/Config/Source/Storecard.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_System_Config_Source_Storecard {
21
+
22
+ /**
23
+ * Get card options to option array
24
+ *
25
+ * @return array
26
+ */
27
+
28
+ public function toOptionArray() {
29
+ $options = array(
30
+ array('value' => 0, 'label' => Mage::helper('adminhtml')->__('Always save card')),
31
+ array('value' => 1, 'label' => Mage::helper('adminhtml')->__('Offer to save card')),
32
+ );
33
+ return $options;
34
+ }
35
+ }
app/code/community/Yoma/Realex/Model/Token.php ADDED
@@ -0,0 +1,164 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Token extends Yoma_Realex_Model_Direct{
21
+
22
+ const PAYMENT_METHOD_CODE = 'realvault';
23
+
24
+ protected $_isCcTypeRequired = false;
25
+ protected $_canUseCheckout = false;
26
+ protected $_canUseForMultishipping = false;
27
+ protected $_code = self::PAYMENT_METHOD_CODE;
28
+ protected $_infoBlockType = 'realex/info_token';
29
+ protected $_formBlockType = 'realex/form_token';
30
+
31
+ /**
32
+ * @TODO refactor as no longer required
33
+ *
34
+ * @param Mage_Sales_Model_Quote $quote
35
+ * @param int|null $checksBitMask
36
+ * @return bool
37
+ */
38
+ public function isApplicableToQuote($quote, $checksBitMask)
39
+ {
40
+
41
+ if ($checksBitMask & self::CHECK_USE_FOR_COUNTRY) {
42
+ if (!$this->canUseForCountry($quote->getBillingAddress()->getCountry())) {
43
+ return false;
44
+ }
45
+ }
46
+ if ($checksBitMask & self::CHECK_USE_FOR_CURRENCY) {
47
+ if (!$this->canUseForCurrency($quote->getStore()->getBaseCurrencyCode())) {
48
+ return false;
49
+ }
50
+ }
51
+ if ($checksBitMask & self::CHECK_USE_CHECKOUT) {
52
+ return true;
53
+ }
54
+ if ($checksBitMask & self::CHECK_USE_FOR_MULTISHIPPING) {
55
+ if (!$this->canUseForMultishipping()) {
56
+ return true;
57
+ }
58
+ }
59
+ if ($checksBitMask & self::CHECK_USE_INTERNAL) {
60
+ if (!$this->canUseInternal()) {
61
+ return false;
62
+ }
63
+ }
64
+ if ($checksBitMask & self::CHECK_ORDER_TOTAL_MIN_MAX) {
65
+ $total = $quote->getBaseGrandTotal();
66
+ $minTotal = $this->getConfigData('min_order_total');
67
+ $maxTotal = $this->getConfigData('max_order_total');
68
+ if (!empty($minTotal) && $total < $minTotal || !empty($maxTotal) && $total > $maxTotal) {
69
+ return false;
70
+ }
71
+ }
72
+ if ($checksBitMask & self::CHECK_RECURRING_PROFILES) {
73
+ if (!$this->canManageRecurringProfiles() && $quote->hasRecurringItems()) {
74
+ return false;
75
+ }
76
+ }
77
+ if ($checksBitMask & self::CHECK_ZERO_TOTAL) {
78
+ $total = $quote->getBaseSubtotal() + $quote->getShippingAddress()->getBaseShippingAmount();
79
+ if ($total < 0.0001 && $this->getCode() != 'free'
80
+ && !($this->canManageRecurringProfiles() && $quote->hasRecurringItems())
81
+ ) {
82
+ return false;
83
+ }
84
+ }
85
+ return true;
86
+ }
87
+
88
+ /**
89
+ * Can be used in regular checkout
90
+ *
91
+ * @return bool
92
+ */
93
+ public function canUseCheckout()
94
+ {
95
+ if($this->_getHelper()->isCheckoutLoggedIn() && $this->getAvailableTokenCards()){
96
+ return true;
97
+ }
98
+
99
+ return $this->_canUseCheckout;
100
+ }
101
+
102
+ /**
103
+ * Can be used in multishipping checkout
104
+ *
105
+ * @return bool
106
+ */
107
+ public function canUseForMultishipping(){
108
+
109
+ if($this->_getHelper()->isCheckoutLoggedIn() && $this->getAvailableTokenCards()){
110
+ return true;
111
+ }
112
+
113
+ return $this->_canUseForMultishipping;
114
+ }
115
+
116
+ /**
117
+ * Check if token
118
+ *
119
+ * @param null string $methodCode
120
+ * @return bool
121
+ */
122
+ public function getAvailableTokenCards($methodCode = null)
123
+ {
124
+ $cards = Mage::getModel("realex/tokencard")->getCollection()
125
+ ->addActiveCardsByCustomerFilter(Mage::getSingleton('customer/session')->getCustomer())
126
+ ->load();
127
+ if(!$cards){
128
+ return false;
129
+ }
130
+ if($cards->getSize() > 0){
131
+ return true;
132
+ }
133
+
134
+ return false;
135
+ }
136
+
137
+ public function assignData($data)
138
+ {
139
+ if (!($data instanceof Varien_Object)) {
140
+ $data = new Varien_Object($data);
141
+ }
142
+ $info = $this->getInfoInstance();
143
+
144
+ $info->setRemembertoken((!is_null($data->getRemembertoken()) ? 1 : 0));
145
+
146
+ if(!is_null($data->getTokenCvv())){
147
+ $this->getRealexSession()->setTokenCvv($data->getTokenCvv());
148
+ }
149
+
150
+ $info->setCcType($data->getCcType())
151
+ ->setCcOwner($data->getCcOwner())
152
+ ->setCcLast4(substr($data->getCcNumber(), -4))
153
+ ->setCcNumber($data->getCcNumber())
154
+ ->setCcCid($data->getCcCid())
155
+ ->setCcExpMonth($data->getCcExpMonth())
156
+ ->setCcExpYear($data->getCcExpYear())
157
+ ->setCcSsIssue($data->getCcSsIssue())
158
+ ->setCcSsStartMonth($data->getCcSsStartMonth())
159
+ ->setCcSsStartYear($data->getCcSsStartYear())
160
+ ->setRealexTokenCcId($data->getRealexTokenCcId())
161
+ ;
162
+ return $this;
163
+ }
164
+ }
app/code/community/Yoma/Realex/Model/Tokencard.php ADDED
@@ -0,0 +1,148 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Tokencard extends Mage_Core_Model_Abstract {
21
+
22
+ protected function _construct() {
23
+
24
+ $this->_init('realex/tokencard');
25
+ }
26
+
27
+
28
+ /**
29
+ * Set default token
30
+ *
31
+ * @return Mage_Core_Model_Abstract
32
+ */
33
+ protected function _beforeSave() {
34
+ $card = $this->getCollection()
35
+ ->addCustomerFilter(Mage::helper('realex')->getCustomerQuoteId())
36
+ ->addFieldToFilter('is_default', (int) 1)
37
+ ->load()->getFirstItem();
38
+
39
+ if (!$card->getId()) {
40
+ $this->setIsDefault(1);
41
+ }
42
+
43
+ return parent::_beforeSave();
44
+ }
45
+
46
+ /**
47
+ * Get token by id
48
+ *
49
+ * @param null $card_id
50
+ * @return Mage_Core_Model_Abstract
51
+ */
52
+ public function getCardById($card_id = null) {
53
+ if((int) $card_id) {
54
+ $card = Mage::getModel('realex/tokencard')->load($card_id);
55
+ if($card->getCustomerId() == Mage::helper('realex')->getCustomerQuoteId()) {
56
+ return $card;
57
+ }
58
+ }
59
+ return;
60
+ }
61
+
62
+ /**
63
+ * Get default card
64
+ *
65
+ * @return Varien_Object
66
+ */
67
+ public function getDefaultCard() {
68
+ $card = $this->getCollection()
69
+ ->addCustomerFilter(Mage::helper('realex')->getCustomerQuoteId())
70
+ ->addFieldToFilter('is_default', (int) 1)
71
+ ->load()->getFirstItem();
72
+
73
+ if ($card->getId()) {
74
+ return $card;
75
+ }
76
+ return new Varien_Object;
77
+ }
78
+
79
+ /**
80
+ * Reset default card
81
+ */
82
+ public function resetCustomerDefault() {
83
+ $card = $this->getCollection()
84
+ ->addCustomerFilter(Mage::helper('realex')->getCustomerQuoteId())
85
+ ->addFieldToFilter('is_default', (int) 1)
86
+ ->load()->getFirstItem();
87
+
88
+ if ($card->getId()) {
89
+ $card->setIsDefault(0)
90
+ ->save();
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Set default token
96
+ *
97
+ * @param $value
98
+ * @return $this
99
+ */
100
+ public function setIsDefault($value) {
101
+ if ((int) $value == 1) {
102
+ # Reset current default card
103
+ Mage::getModel('realex/tokencard')->resetCustomerDefault();
104
+ }
105
+
106
+ $this->setData('is_default', $value);
107
+ return $this;
108
+ }
109
+
110
+ public function getLabel($withImage = true) {
111
+ //return Mage::helper('realex')->getCardLabel($this->getCardType(), $withImage);
112
+ return $this->getCardType();
113
+ }
114
+
115
+ public function getCcNumber() {
116
+ return '***********' . $this->getLastFour();
117
+ }
118
+
119
+ public function getExpireDate() {
120
+ return Mage::helper('realex')->getCardNiceDate($this->getExpiryDate());
121
+ }
122
+
123
+ public function loadByToken($token) {
124
+ $this->load($token, 'token');
125
+ return $this;
126
+ }
127
+
128
+ public function checkCardDefault() {
129
+ return $this->getIsDefault() ? true : false;
130
+ }
131
+
132
+ /**
133
+ * return count of cards nearing expiry date (1 month)
134
+ * @return int
135
+ */
136
+ public function getCardsExpiring() {
137
+ return $this->getCollection()
138
+ ->addFieldToFilter('status', (int) 1)
139
+ ->addFieldToFilter(
140
+ new Zend_Db_Expr("str_to_date(expiry_date, '%m%y')"),
141
+ array('
142
+ from' => date("Y-m-d H:i:s"),
143
+ 'to' => date("Y-m-d H:i:s", strtotime("+1 month"))
144
+ )
145
+ )->getSize();
146
+ }
147
+
148
+ }
app/code/community/Yoma/Realex/Model/Total/Creditmemo/Rebate.php ADDED
@@ -0,0 +1,71 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Total_Creditmemo_Rebate extends Mage_Sales_Model_Order_Creditmemo_Total_Abstract
21
+ {
22
+
23
+ /**
24
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
25
+ * @return $this|Mage_Sales_Model_Order_Creditmemo_Total_Abstract
26
+ */
27
+ public function collect(Mage_Sales_Model_Order_Creditmemo $creditmemo)
28
+ {
29
+ $data = mage::app()->getRequest()->getPost('creditmemo');
30
+ if (isset($data['rebate_positive'])) {
31
+ $this->setRebatePositive($creditmemo, $data['rebate_positive']);
32
+ }else{
33
+
34
+ }
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Allow positive amount on rebate
41
+ *
42
+ * @param Mage_Sales_Model_Order_Creditmemo $creditmemo
43
+ * @param string $amount
44
+ * @return $this
45
+ */
46
+ public function setRebatePositive($creditmemo, $amount){
47
+
48
+ $amount = trim($amount);
49
+ if (substr($amount, -1) == '%') {
50
+ $amount = (float) substr($amount, 0, -1);
51
+ $amount = $creditmemo->getGrandTotal() * $amount / 100;
52
+ }
53
+ $amount = $creditmemo->getOrder()->getStore()->roundPrice($amount);
54
+ $creditmemo->setData('base_rebate_positive', $amount);
55
+ $creditmemo->setBaseGrandTotal($creditmemo->getBaseGrandTotal() + $amount);
56
+
57
+ $storeRate = $creditmemo->getOrder()->getStoreToOrderRate();
58
+
59
+ $amount = $creditmemo->getOrder()->getStore()->roundPrice($amount*$storeRate);
60
+ $creditmemo->setData('rebate_positive', $amount);
61
+ $creditmemo->setGrandTotal($creditmemo->getGrandTotal() + $amount);
62
+
63
+ $creditmemo->getOrder()->addStatusHistoryComment(
64
+ Mage::helper('realex')->__('Rebate adjustment of: %s added to creditmemo', Mage::helper('core')->formatPrice($amount, true)))
65
+ ->setIsVisibleOnFront(false)
66
+ ->setIsCustomerNotified(false);
67
+
68
+ return $this;
69
+ }
70
+
71
+ }
app/code/community/Yoma/Realex/Model/Total/Invoice/Settle.php ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Total_Invoice_Settle extends Mage_Sales_Model_Order_Invoice_Total_Abstract
21
+ {
22
+
23
+ /**
24
+ * @param Mage_Sales_Model_Order_Invoice $invoice
25
+ * @return $this|Mage_Sales_Model_Order_Invoice_Total_Abstract
26
+ */
27
+ public function collect(Mage_Sales_Model_Order_Invoice $invoice)
28
+ {
29
+ $data = mage::app()->getRequest()->getPost('invoice');
30
+ if (isset($data['settle_positive'])) {
31
+ $this->setSettlePositive($invoice, $data['settle_positive']);
32
+ }else{
33
+
34
+ }
35
+
36
+ return $this;
37
+ }
38
+
39
+ /**
40
+ * Allow positive amount on invoice
41
+ *
42
+ * @param Mage_Sales_Model_Order_Invoice $invoice
43
+ * @param string $amount
44
+ * @return $this
45
+ */
46
+ public function setSettlePositive($invoice, $amount){
47
+
48
+ $amount = $invoice->getOrder()->getStore()->roundPrice($amount);
49
+ $invoice->setData('base_settle_positive', $amount);
50
+ //$invoice->setBaseGrandTotal($invoice->getBaseGrandTotal() + $amount);
51
+ $invoice->setBaseGrandTotal($amount);
52
+
53
+ $storeRate = $invoice->getOrder()->getStoreToOrderRate();
54
+
55
+ $amount = $invoice->getOrder()->getStore()->roundPrice($amount*$storeRate);
56
+ $invoice->setData('settle_positive', $amount);
57
+ //$invoice->setGrandTotal($invoice->getGrandTotal() + $amount);
58
+ $invoice->setGrandTotal($amount);
59
+
60
+ $invoice->getOrder()->addStatusHistoryComment(
61
+ Mage::helper('sales')->__('Settle for %s added to invoice.',Mage::helper('core')->formatPrice($invoice->getGrandTotal())))
62
+ ->setIsVisibleOnFront(false)
63
+ ->setIsCustomerNotified(false);
64
+
65
+ return $this;
66
+ }
67
+
68
+ /**
69
+ * @param Mage_Sales_Model_Order_Invoice $invoice
70
+ * @return $this
71
+ */
72
+ public function fetch(Mage_Sales_Model_Order_Invoice $invoice)
73
+ {
74
+
75
+ $invoice->addTotal(array(
76
+ 'code' => 'settle_positive',
77
+ 'title' => $this->helper('realex')->__('Settle Amount'),
78
+ 'value' => $invoice->getSettleAmount()
79
+ ));
80
+
81
+ return $this;
82
+ }
83
+
84
+ }
app/code/community/Yoma/Realex/Model/Transaction.php ADDED
@@ -0,0 +1,245 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Model_Transaction extends Mage_Core_Model_Abstract
21
+ {
22
+
23
+ protected $_obf = array('card_cvn','sha1hash','md5hash','SHA1HASH','MD5HASH');
24
+
25
+ protected function _construct()
26
+ {
27
+ $this->_init('realex/transaction');
28
+ }
29
+
30
+ /**
31
+ * Retrieve transaction by method and reference
32
+ *
33
+ * @param string $serviceCode
34
+ * @param string $transactionReference
35
+ * @param bool $error
36
+ * @return $this|bool
37
+ * @throws Exception
38
+ */
39
+ public function loadByServiceTransactionReference($serviceCode, $transactionReference, $error = true)
40
+ {
41
+ $collection = $this->getCollection()
42
+ ->addFieldToFilter('service_code', $serviceCode)
43
+ ->addFieldToFilter('transaction_reference', $transactionReference);
44
+
45
+ if ($collection->count() !== 1) {
46
+ if($error) {
47
+ throw new Exception($this->_getHelper()
48
+ ->__("Unable to load transaction with reference '{$transactionReference}'"));
49
+ }else{
50
+ return false;
51
+ }
52
+ }
53
+
54
+ $id = $collection->getFirstItem()->getId();
55
+ $this->load($id);
56
+
57
+ return $this;
58
+ }
59
+
60
+ /**
61
+ * Retrieve transaction by order
62
+ *
63
+ * @param int $orderId
64
+ * @return $this
65
+ * @throws Exception
66
+ */
67
+ public function loadByOrder($orderId)
68
+ {
69
+ $collection = $this->getCollection()
70
+ ->addFieldToFilter('order_id', $orderId);
71
+
72
+ if ($collection->count() !== 1) {
73
+ throw new Exception($this->_getHelper()
74
+ ->__("Unable to load transaction for order ID '{$orderId}'"));
75
+ }
76
+
77
+ $id = $collection->getFirstItem()->getId();
78
+ $this->load($id);
79
+
80
+ return $this;
81
+ }
82
+
83
+ /**
84
+ * Get transaction raw data
85
+ *
86
+ * @param string $key
87
+ * @return mixed|null
88
+ */
89
+ public function getAdditionalInformation($key = null)
90
+ {
91
+ $transactionData = $this->getData('additional_information');
92
+
93
+ if (is_null($key)) {
94
+ return $transactionData;
95
+ }
96
+
97
+ return array_key_exists($key, $transactionData) ? $transactionData[$key] : null;
98
+ }
99
+
100
+ /**
101
+ * Add transaction data
102
+ *
103
+ * @param string $key
104
+ * @param null $value
105
+ * @return $this
106
+ */
107
+ public function addAdditionalInformation($key, $value = null)
108
+ {
109
+ if (is_array($key)) {
110
+ foreach ($key as $_key => $_value) {
111
+ $this->addAdditionalInformation($_key, $_value);
112
+ }
113
+ }
114
+
115
+ $additionalInformation = $this->getData('additional_information');
116
+ $additionalInformation[$key] = $value;
117
+ $this->setData('additional_information', $additionalInformation);
118
+
119
+ return $this;
120
+ }
121
+
122
+ /**
123
+ * Unset data
124
+ *
125
+ * @param $key
126
+ * @return $this
127
+ */
128
+ public function unsAdditionalInformation($key)
129
+ {
130
+ $transactionData = $this->getData('additional_information');
131
+ if (!array_key_exists($key, $transactionData)) {
132
+ return $this;
133
+ }
134
+
135
+ unset($transactionData[$key]);
136
+ $this->setData('additional_information', $transactionData);
137
+
138
+ return $this;
139
+ }
140
+
141
+ protected function _beforeSave()
142
+ {
143
+ $additionalInformation = $this->getData('additional_information');
144
+ if (is_array($additionalInformation)) {
145
+ foreach($this->_obf as $key){
146
+ if(array_key_exists($key,$additionalInformation)){
147
+ unset($additionalInformation[$key]);
148
+ }
149
+ }
150
+ $this->setData('additional_information', serialize($additionalInformation));
151
+ }
152
+
153
+ $subscriptionData = $this->getData('subscription_data');
154
+ if (is_array($subscriptionData)) {
155
+ $this->setData('subscription_data', serialize($subscriptionData));
156
+ }
157
+
158
+ return parent::_beforeSave();
159
+ }
160
+
161
+ protected function _afterLoad()
162
+ {
163
+ $additionalInformation = $this->getData('additional_information');
164
+ if ($additionalInformation != '') {
165
+ $this->setData('additional_information', unserialize($additionalInformation));
166
+ }
167
+
168
+ $subscriptionData = $this->getData('subscription_data');
169
+ if ($subscriptionData != '') {
170
+ $this->setData('subscription_data', unserialize($subscriptionData));
171
+ }
172
+
173
+ return parent::_afterLoad();
174
+ }
175
+
176
+ protected function _getHelper(){
177
+ return mage::helper('realex');
178
+ }
179
+
180
+ public function getOrderPaymentObject($shouldLoad = true)
181
+ {
182
+ if (null === $this->_paymentObject) {
183
+ $payment = Mage::getModel('sales/order_payment')->load($this->getPaymentId());
184
+ if ($payment->getId()) {
185
+ $this->setOrderPaymentObject($payment);
186
+ }
187
+ }
188
+ return $this->_paymentObject;
189
+ }
190
+
191
+ /**
192
+ *Get order id
193
+ *
194
+ * @return mixed
195
+ */
196
+ public function getOrderId()
197
+ {
198
+ $orderId = $this->_getData('order_id');
199
+ if ($orderId) {
200
+ return $orderId;
201
+ }
202
+ if ($this->_paymentObject) {
203
+ return $this->_paymentObject->getOrder()
204
+ ? $this->_paymentObject->getOrder()->getId()
205
+ : $this->_paymentObject->getParentId();
206
+ }
207
+ }
208
+
209
+ /**
210
+ * Get Order
211
+ *
212
+ * @return mixed|null
213
+ */
214
+ public function getOrder()
215
+ {
216
+ if ($this->_order === null) {
217
+ $this->setOrder();
218
+ }
219
+
220
+ return $this->_order;
221
+ }
222
+
223
+ /*
224
+ * Set order
225
+ */
226
+ public function setOrder($order = null)
227
+ {
228
+ if (null === $order || $order === true) {
229
+ if (null !== $this->_paymentObject && $this->_paymentObject->getOrder()) {
230
+ $this->_order = $this->_paymentObject->getOrder();
231
+ } elseif ($this->getOrderId() && $order === null) {
232
+ $this->_order = Mage::getModel('sales/order')->load($this->getOrderId());
233
+ } else {
234
+ $this->_order = false;
235
+ }
236
+ } elseif (!$this->getId() || ($this->getOrderId() == $order->getId())) {
237
+ $this->_order = $order;
238
+ } else {
239
+ Mage::throwException(Mage::helper('realex')->__('Set order for existing transactions not allowed'));
240
+ }
241
+
242
+ return $this;
243
+ }
244
+
245
+ }
app/code/community/Yoma/Realex/controllers/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/controllers/Adminhtml/LogController.php ADDED
@@ -0,0 +1,110 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Adminhtml_LogController extends Mage_Adminhtml_Controller_Action
21
+ {
22
+
23
+ protected function _initAction()
24
+ {
25
+ $this->loadLayout()
26
+ ->_setActiveMenu('sales/realex/logs')
27
+ ->_addBreadcrumb($this->__('Sales'), $this->__('Sales'))
28
+ ->_addBreadcrumb($this->__('Logs'), $this->__('Logs'));
29
+ return $this;
30
+ }
31
+
32
+ public function indexAction()
33
+ {
34
+ $this->_title($this->__('Sales'))->_title($this->__('Realex'))->_title($this->__('Logs'));
35
+ $this->_initAction()->renderLayout();
36
+ }
37
+
38
+ /**
39
+ * Download log file
40
+ */
41
+ public function downloadFileAction()
42
+ {
43
+ $fileName = $this->getRequest()->getParam('f');
44
+ if(is_null($fileName)){
45
+ return;
46
+ }
47
+
48
+ $file = Mage::helper('realex')->getRealexLogDir() . DS . $fileName;
49
+
50
+ $this->_prepareDownloadResponse($fileName, file_get_contents($file), 'text/plain', filesize($file));
51
+ }
52
+
53
+ /**
54
+ * Tail log
55
+ *
56
+ * @return Zend_Controller_Response_Abstract
57
+ */
58
+ public function tailAction()
59
+ {
60
+ $r = $this->getRequest();
61
+
62
+ if(!$r->getParam('file')){
63
+ $this->getResponse()->setBody('<html><head><title></title></head><body><pre>'. Mage::helper('realex')->__('Please choose a file.') .'</pre></body></html>');
64
+ return;
65
+ }
66
+
67
+ $f = Mage::helper('realex')->getRealexLogDir() . DS . $r->getParam('file');
68
+
69
+ $numberOfLines = 200;
70
+ $handle = fopen($f, "r");
71
+ $linecounter = $numberOfLines;
72
+ $pos = -2;
73
+ $beginning = false;
74
+ $text = array();
75
+ while ($linecounter > 0) {
76
+ $t = " ";
77
+ while ($t != "\n") {
78
+ if(fseek($handle, $pos, SEEK_END) == -1) {
79
+ $beginning = true;
80
+ break;
81
+ }
82
+ $t = fgetc($handle);
83
+ $pos --;
84
+ }
85
+ $linecounter --;
86
+ if ($beginning) {
87
+ rewind($handle);
88
+ }
89
+ $text[$numberOfLines-$linecounter-1] = fgets($handle);
90
+ if ($beginning) break;
91
+ }
92
+ fclose ($handle);
93
+
94
+ $dlFile = '<a href="' . Mage::helper('adminhtml')->getUrl('realexAdmin/adminhtml_log/downloadFile', array('f'=>$r->getParam('file'))) . '">' . $this->__('Download file') . '</a>';
95
+
96
+ return $this->getResponse()->setBody('<html>
97
+ <head>
98
+ <title></title>
99
+ <!--<meta http-equiv="refresh" content="10">-->
100
+ </head>
101
+ <body>
102
+ <pre>' . $dlFile ."\r\n\n". strip_tags(implode('',$text)).'</pre>
103
+ </body>
104
+ </html>');
105
+
106
+
107
+
108
+ }
109
+
110
+ }
app/code/community/Yoma/Realex/controllers/Adminhtml/TokencardController.php ADDED
@@ -0,0 +1,154 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Adminhtml_TokencardController extends Mage_Adminhtml_Controller_Action
21
+ {
22
+ protected function _initAction()
23
+ {
24
+ $this->loadLayout()->_setActiveMenu("realex/tokencard")
25
+ ->_addBreadcrumb(Mage::helper("adminhtml")->__("Token Card Manager"),Mage::helper("adminhtml")->__("Token Card Manager"));
26
+ return $this;
27
+ }
28
+
29
+ public function indexAction()
30
+ {
31
+ $this->_title($this->__("Realex"));
32
+ $this->_title($this->__("Manager Token Card"));
33
+
34
+ $this->_initAction();
35
+ $this->renderLayout();
36
+ }
37
+
38
+ /**
39
+ * Edit token action
40
+ */
41
+ public function editAction()
42
+ {
43
+ $this->_title($this->__("Realex"));
44
+ $this->_title($this->__("Token Card"));
45
+ $this->_title($this->__("Edit Item"));
46
+
47
+ $id = $this->getRequest()->getParam("id");
48
+ $model = Mage::getModel("realex/tokencard")->load($id);
49
+ if ($model->getId()) {
50
+ Mage::register("tokencard_data", $model);
51
+ $this->loadLayout();
52
+ $this->_setActiveMenu("realex/tokencard");
53
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Tokencard Manager"), Mage::helper("adminhtml")->__("Tokencard Manager"));
54
+ $this->_addBreadcrumb(Mage::helper("adminhtml")->__("Tokencard Description"), Mage::helper("adminhtml")->__("Tokencard Description"));
55
+ $this->getLayout()->getBlock("head")->setCanLoadExtJs(true);
56
+ $this->_addContent($this->getLayout()->createBlock("realex/adminhtml_tokencard_edit"))->_addLeft($this->getLayout()->createBlock("realex/adminhtml_tokencard_edit_tabs"));
57
+ $this->renderLayout();
58
+ }
59
+ else {
60
+ Mage::getSingleton("adminhtml/session")->addError(Mage::helper("realex")->__("Item does not exist."));
61
+ $this->_redirect("*/*/");
62
+ }
63
+ }
64
+
65
+ /**
66
+ * Save token
67
+ */
68
+ public function saveAction()
69
+ {
70
+
71
+ $post_data=$this->getRequest()->getPost();
72
+ if ($post_data) {
73
+ try {
74
+
75
+ $card = Mage::getModel("realex/tokencard")->load($this->getRequest()->getParam("id"));
76
+ Mage::dispatchEvent('realex_edit_token', array('token'=> $card, 'details'=>$post_data));
77
+
78
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Tokencard was successfully saved"));
79
+ Mage::getSingleton("adminhtml/session")->setTokencardData(false);
80
+
81
+ if ($this->getRequest()->getParam("back")) {
82
+ $this->_redirect("*/*/edit", array("id" => $card->getId()));
83
+ return;
84
+ }
85
+ $this->_redirect("*/*/");
86
+ return;
87
+ }
88
+ catch (Exception $e) {
89
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
90
+ Mage::getSingleton("adminhtml/session")->setTokencardData($this->getRequest()->getPost());
91
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
92
+ return;
93
+ }
94
+
95
+ }
96
+ $this->_redirect("*/*/");
97
+ }
98
+
99
+ /**
100
+ * Delete token
101
+ */
102
+ public function deleteAction()
103
+ {
104
+ if( $this->getRequest()->getParam("id") > 0 ) {
105
+ try {
106
+ $model = Mage::getModel("realex/tokencard");
107
+ $model->setId($this->getRequest()->getParam("id"))->delete();
108
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item was successfully deleted"));
109
+ $this->_redirect("*/*/");
110
+ }
111
+ catch (Exception $e) {
112
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
113
+ $this->_redirect("*/*/edit", array("id" => $this->getRequest()->getParam("id")));
114
+ }
115
+ }
116
+ $this->_redirect("*/*/");
117
+ }
118
+
119
+
120
+ public function massRemoveAction()
121
+ {
122
+ try {
123
+ $ids = $this->getRequest()->getPost('ids', array());
124
+ foreach ($ids as $id) {
125
+ $card = Mage::getModel("realex/tokencard")->load($id);
126
+ Mage::dispatchEvent('realex_delete_token', array('token'=> $card));
127
+ }
128
+ Mage::getSingleton("adminhtml/session")->addSuccess(Mage::helper("adminhtml")->__("Item(s) was successfully removed"));
129
+ }
130
+ catch (Exception $e) {
131
+ Mage::getSingleton("adminhtml/session")->addError($e->getMessage());
132
+ }
133
+ $this->_redirect('*/*/');
134
+ }
135
+
136
+ /**
137
+ * Export order grid to CSV format
138
+ */
139
+ public function exportCsvAction()
140
+ {
141
+ $fileName = 'tokencard.csv';
142
+ $grid = $this->getLayout()->createBlock('realex/adminhtml_tokencard_grid');
143
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
144
+ }
145
+ /**
146
+ * Export order grid to Excel XML format
147
+ */
148
+ public function exportExcelAction()
149
+ {
150
+ $fileName = 'tokencard.xml';
151
+ $grid = $this->getLayout()->createBlock('realex/adminhtml_tokencard_grid');
152
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
153
+ }
154
+ }
app/code/community/Yoma/Realex/controllers/Adminhtml/TransactionController.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_Adminhtml_TransactionController extends Mage_Adminhtml_Controller_Action
21
+ {
22
+ protected function _initAction()
23
+ {
24
+ $this->loadLayout()->_setActiveMenu("realex/transaction")
25
+ ->_addBreadcrumb(Mage::helper("adminhtml")->__("Transactions"),Mage::helper("adminhtml")->__("Transactions"));
26
+ return $this;
27
+ }
28
+ public function indexAction()
29
+ {
30
+ $this->_title($this->__("Realex"));
31
+ $this->_title($this->__("Transactions"));
32
+
33
+ $this->_initAction();
34
+ $this->renderLayout();
35
+ }
36
+
37
+ public function viewAction()
38
+ {
39
+ $txn = $this->_initTransaction();
40
+ if (!$txn) {
41
+ return;
42
+ }
43
+ $this->_title($this->__('Realex'))
44
+ ->_title($this->__('Transactions'))
45
+ ->_title(sprintf("#%s", $txn->getEntityId()));
46
+
47
+ $this->loadLayout()
48
+ ->_setActiveMenu('realex/transaction')
49
+ ->renderLayout();
50
+ }
51
+
52
+ /**
53
+ * Initialize transaction
54
+ *
55
+ * @return Mage_Core_Model_Abstract
56
+ */
57
+ protected function _initTransaction()
58
+ {
59
+ $txn = Mage::getModel('realex/transaction')->load(
60
+ $this->getRequest()->getParam('txn_id')
61
+ );
62
+
63
+ if (!$txn->getId()) {
64
+ $this->_getSession()->addError($this->__('Wrong transaction ID specified.'));
65
+ $this->_redirect('*/*/');
66
+ $this->setFlag('', self::FLAG_NO_DISPATCH, true);
67
+ return false;
68
+ }
69
+ $orderId = $this->getRequest()->getParam('order_id');
70
+ if ($orderId) {
71
+ $txn->setOrderUrl(
72
+ $this->getUrl('*/sales_order/view', array('order_id' => $orderId))
73
+ );
74
+ }
75
+
76
+ Mage::register('transaction_data', $txn);
77
+ return $txn;
78
+ }
79
+
80
+ /**
81
+ * Export order grid to CSV format
82
+ */
83
+ public function exportCsvAction()
84
+ {
85
+ $fileName = 'transactions.csv';
86
+ $grid = $this->getLayout()->createBlock('realex/adminhtml_transaction_grid');
87
+ $this->_prepareDownloadResponse($fileName, $grid->getCsvFile());
88
+ }
89
+ /**
90
+ * Export order grid to Excel XML format
91
+ */
92
+ public function exportExcelAction()
93
+ {
94
+ $fileName = 'transactions.xml';
95
+ $grid = $this->getLayout()->createBlock('realex/adminhtml_transaction_grid');
96
+ $this->_prepareDownloadResponse($fileName, $grid->getExcelFile($fileName));
97
+ }
98
+
99
+ public function gridAction()
100
+ {
101
+ $this->loadLayout();
102
+ $this->getResponse()->setBody(
103
+ $this->getLayout()->createBlock('realex/adminhtml_transaction_grid')->toHtml()
104
+ );
105
+ }
106
+ }
app/code/community/Yoma/Realex/controllers/CardsController.php ADDED
@@ -0,0 +1,195 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_CardsController extends Mage_Core_Controller_Front_Action {
21
+
22
+
23
+ public function indexAction() {
24
+
25
+ if (!$customer_id = Mage::helper('realex/direct')->getCustomerId()) {
26
+ Mage::getSingleton('customer/session')->authenticate($customer_id);
27
+ return;
28
+ }
29
+
30
+ $this->loadLayout();
31
+ $this->_initLayoutMessages('catalog/session');
32
+ $this->_initLayoutMessages('customer/session');
33
+
34
+ if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) {
35
+ $navigationBlock->setActive('realex/cards');
36
+ }
37
+
38
+
39
+ if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
40
+ $block->setRefererUrl($this->_getRefererUrl());
41
+ }
42
+
43
+ $this->getLayout()->getBlock('head')
44
+ ->setTitle(Mage::helper('realex')->__('My Stored Cards'));
45
+ $this->renderLayout();
46
+ }
47
+
48
+ /**
49
+ * Set Default credit card
50
+ *
51
+ */
52
+ public function defaultAction() {
53
+
54
+ if ($this->getRequest()->isXmlHttpRequest()) {
55
+ $resp = array('st' => 'nok', 'text' => '');
56
+
57
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
58
+ $resp ['text'] = $this->__('Please login, you session expired.');
59
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
60
+ return;
61
+ }
62
+
63
+ if($card_id = (int) $this->getRequest()->getParam('card')) {
64
+ $card = Mage::getModel("realex/tokencard")->getCardById($card_id);
65
+
66
+ if ($card->getId()) {
67
+ if ($card->getCustomerId() != Mage::helper('realex/direct')->getCustomerId()) {
68
+ $resp ['text'] = $this->__('Invalid Card #');
69
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
70
+ return;
71
+ }
72
+
73
+ try {
74
+ Mage::getModel("realex/tokencard")->resetCustomerDefault();
75
+ $card->setIsDefault(1)->save();
76
+ $resp ['text'] = $this->__('Success!');
77
+ $resp ['st'] = 'ok';
78
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
79
+ return;
80
+ } catch (Exception $e) {
81
+ $resp ['text'] = $this->__($e->getMessage());
82
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
83
+ return;
84
+ }
85
+ }
86
+ } else {
87
+ $resp ['text'] = $this->__('The requested Card does not exist.');
88
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
89
+ return;
90
+ }
91
+ } else {
92
+
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Remove a stored credit card
98
+ *
99
+ */
100
+ public function deleteAction() {
101
+ if ($this->getRequest()->isXmlHttpRequest()) {
102
+ $resp = array('st' => 'nok', 'text' => '');
103
+
104
+ if (!Mage::getSingleton('customer/session')->authenticate($this)) {
105
+ $resp ['text'] = $this->__('Please login, you session expired.');
106
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
107
+ return;
108
+ }
109
+
110
+ if($card_id = (int) $this->getRequest()->getParam('card')) {
111
+ $card = Mage::getModel("realex/tokencard")->getCardById($card_id);
112
+ if ($card->getId()) {
113
+ if ($card->getCustomerId() != Mage::helper('realex/direct')->getCustomerId()) {
114
+ $resp ['text'] = $this->__('Invalid Card #');
115
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
116
+ return;
117
+ }
118
+
119
+ try {
120
+ Mage::dispatchEvent('realex_delete_token', array('token'=> $card));
121
+ $resp ['text'] = $this->__('Success!');
122
+ $resp ['st'] = 'ok';
123
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
124
+ return;
125
+ } catch (Exception $e) {
126
+ $resp ['text'] = $this->__($e->getMessage());
127
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
128
+ return;
129
+ }
130
+
131
+ } else {
132
+ $resp ['text'] = $this->__('The requested Card does not exist.');
133
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
134
+ return;
135
+ }
136
+
137
+ $resp ['text'] = $this->__('The requested Card does not exist.');
138
+ $this->getResponse()->setBody(Zend_Json::encode($resp));
139
+ return;
140
+ } else {
141
+
142
+ }
143
+ }
144
+ }
145
+
146
+
147
+ /**
148
+ * Edit Stored Credit Card
149
+ *
150
+ */
151
+ public function editAction() {
152
+
153
+ $url = Mage::getUrl('realexAdmin/cards/');
154
+ if($card_id = (int) $this->getRequest()->getParam('card')) {
155
+ if($card = Mage::getModel("realex/tokencard")->getCardById($card_id)) {
156
+
157
+ if ($this->getRequest()->isPost()){
158
+ try {
159
+ $expire_month = (int) $this->getRequest()->getParam('card_month');
160
+ $expire_year = (int) $this->getRequest()->getParam('card_year');
161
+ $data['expiry_date'] = sprintf("%02d",$expire_month).sprintf("%02d",$expire_year);
162
+ $data['ch_name'] = strip_tags($this->getRequest()->getParam('card_name'));
163
+ Mage::dispatchEvent('realex_edit_token', array('token'=> $card, 'details'=>$data));
164
+ Mage::getSingleton('core/session')->addSuccess('Card updated successfully');
165
+ } catch (Exception $e) {
166
+ Mage::getSingleton('core/session')->addError('Card update unsuccessful');
167
+ }
168
+ }
169
+
170
+ $this->loadLayout();
171
+ $this->_initLayoutMessages('catalog/session');
172
+ $this->_initLayoutMessages('customer/session');
173
+
174
+ if ($navigationBlock = $this->getLayout()->getBlock('customer_account_navigation')) {
175
+ $navigationBlock->setActive('realex/cards');
176
+ }
177
+
178
+
179
+ if ($block = $this->getLayout()->getBlock('customer.account.link.back')) {
180
+ $block->setRefererUrl($url);
181
+ }
182
+
183
+ $this->getLayout()
184
+ ->getBlock('head')
185
+ ->setTitle(Mage::helper('realex')->__('RealVault - Credit Cards'));
186
+ $this->renderLayout();
187
+ } else {
188
+
189
+ }
190
+ } else {
191
+
192
+ }
193
+ }
194
+
195
+ }
app/code/community/Yoma/Realex/controllers/Checkout/OnepageController.php ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ require_once('Mage/Checkout/controllers/OnepageController.php');
21
+ class Yoma_Realex_Checkout_OnepageController extends Mage_Checkout_OnepageController
22
+ {
23
+ /**
24
+ * Overide onestep checkout failure action
25
+ *
26
+ */
27
+ public function failureAction()
28
+ {
29
+
30
+ $lastOrderId = $this->getOnepage()->getCheckout()->getLastOrderId();
31
+ if (!$lastOrderId) {
32
+ return parent::failureAction();
33
+ }
34
+ // reorder last cart
35
+ try {
36
+ $transaction = Mage::getModel('realex/transaction')
37
+ ->loadByOrder($lastOrderId);
38
+ } catch (Exception $e) {
39
+ return parent::failureAction();
40
+ }
41
+
42
+ $helper = Mage::helper('realex/data');
43
+
44
+ $helper->reorder($lastOrderId);
45
+
46
+ return parent::failureAction();
47
+ }
48
+ }
app/code/community/Yoma/Realex/controllers/DirectController.php ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_DirectController extends Mage_Core_Controller_Front_Action {
21
+
22
+ /**
23
+ * Form Action
24
+ */
25
+ public function formAction(){
26
+
27
+ $formPost = $this->getLayout()->createBlock('realex/direct_form');
28
+
29
+ $this->getResponse()
30
+ ->clearHeaders()
31
+ ->setHeader('Content-Type', 'text/html')
32
+ ->setBody($formPost->toHtml());
33
+ }
34
+
35
+ /**
36
+ * iFame Action
37
+ */
38
+ public function iframeAction(){
39
+
40
+ $this->loadLayout();
41
+ $this->renderLayout();
42
+ }
43
+
44
+ /**
45
+ * 3d Secure callback
46
+ */
47
+ public function threedSecureCaptureAction(){
48
+
49
+ try {
50
+ $this->_getService()->callBack();
51
+ $url = mage::getUrl('checkout/onepage/success');
52
+ $success = true;
53
+ }catch(Exception $e){
54
+ $url = mage::getUrl('checkout/onepage/failure');
55
+ $success = false;
56
+ }
57
+
58
+ $this->getResponse()
59
+ ->setBody($this->getLayout()
60
+ ->createBlock('realex/redirect_result')
61
+ ->setResult($success)
62
+ ->setUrl($url)
63
+ ->toHtml())
64
+ ->sendResponse();
65
+ exit;
66
+
67
+ }
68
+
69
+ /*
70
+ * get service
71
+ */
72
+ protected function _getService(){
73
+ return mage::getModel('realex/service_direct');
74
+ }
75
+
76
+ /**
77
+ * Order failure action
78
+ */
79
+ public function onepageFailureOrderAction() {
80
+
81
+ try{
82
+ $this->_getService()->callDeny();
83
+ }catch(Exception $e){
84
+
85
+ Realex_Log::logException($e);
86
+ }
87
+ $url = mage::getUrl('checkout/onepage/failure');
88
+ $this->getResponse()
89
+ ->setBody($this->getLayout()
90
+ ->createBlock('realex/redirect_result')
91
+ ->setResult(false)
92
+ ->setUrl($url)
93
+ ->toHtml())
94
+ ->sendResponse();
95
+ exit;
96
+ }
97
+
98
+ }
app/code/community/Yoma/Realex/controllers/PaymentController.php ADDED
@@ -0,0 +1,22 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_PaymentController extends Mage_Core_Controller_Front_Action {
21
+
22
+ }
app/code/community/Yoma/Realex/controllers/RedirectController.php ADDED
@@ -0,0 +1,125 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_RedirectController extends Mage_Core_Controller_Front_Action {
21
+
22
+ public function getServerModel() {
23
+
24
+ return Mage :: getModel('realex/redirect');
25
+ }
26
+
27
+ /**
28
+ * Call back capture
29
+ */
30
+ public function captureAction(){
31
+
32
+ try {
33
+ $this->_getService()->callBack();
34
+ $url = mage::getUrl('checkout/onepage/success', array('token' => Mage::getSingleton('customer/session')->getTokenSaved()));
35
+ $success = true;
36
+ Mage::getSingleton('customer/session')->unsTokenSaved();
37
+ }catch(Exception $e){
38
+ Mage::logException($e);
39
+ $url = mage::getUrl('checkout/onepage/failure');
40
+ $success = false;
41
+ }
42
+
43
+ $this->getResponse()
44
+ ->setBody($this->getLayout()
45
+ ->createBlock('realex/redirect_result')
46
+ ->setResult($success)
47
+ ->setUrl($url)
48
+ ->toHtml())
49
+ ->sendResponse();
50
+ exit;
51
+ }
52
+
53
+ /**
54
+ * Call back authorize
55
+ */
56
+ public function authorizeAction(){
57
+
58
+ try {
59
+ $this->_getService()->callBack();
60
+ $url = mage::getUrl('checkout/onepage/success', array('token' => Mage::getSingleton('customer/session')->getTokenSaved()));
61
+ $success = true;
62
+ Mage::getSingleton('customer/session')->unsTokenSaved();
63
+ }catch(Exception $e){
64
+ Mage::logException($e);
65
+ $url = mage::getUrl('checkout/onepage/failure');
66
+ $success = false;
67
+ }
68
+
69
+ $this->getResponse()
70
+ ->setBody($this->getLayout()
71
+ ->createBlock('realex/redirect_result')
72
+ ->setResult($success)
73
+ ->setUrl($url)
74
+ ->toHtml())
75
+ ->sendResponse();
76
+ exit;
77
+ }
78
+
79
+ public function formAction(){
80
+
81
+ $formPost = $this->getLayout()->createBlock('realex/redirect_form');
82
+
83
+ $this->getResponse()
84
+ ->clearHeaders()
85
+ ->setHeader('Content-Type', 'text/html')
86
+ ->setBody($formPost->toHtml());
87
+ }
88
+
89
+ public function iframeAction(){
90
+
91
+ $this->loadLayout();
92
+ $this->renderLayout();
93
+ }
94
+
95
+ public function getIframeContent(){
96
+
97
+ $endpoint = 'https://hpp.sandbox.realexpayments.com/pay';
98
+ $data = mage::getSingleton('realex/session')->getTransactionData();
99
+ try {
100
+ $client = new Zend_Http_Client($endpoint);
101
+ $client->setMethod(Zend_Http_Client::POST);
102
+ $client->setConfig(array('strictredirects' => true));
103
+ $client->setParameterPost($data);
104
+ $response = $client->request();
105
+ return $response;
106
+ } catch(Exception $e){
107
+ throw $e;
108
+ }
109
+ }
110
+
111
+ protected function _getHelper()
112
+ {
113
+ return Mage::helper('realex/redirect');
114
+ }
115
+
116
+ protected function _getService(){
117
+ return mage::getModel('realex/service_redirect');
118
+ }
119
+
120
+ public function getOnepage()
121
+ {
122
+ return Mage::getSingleton('checkout/type_onepage');
123
+ }
124
+
125
+ }
app/code/community/Yoma/Realex/controllers/TokenController.php ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ class Yoma_Realex_TokenController extends Mage_Core_Controller_Front_Action {
21
+
22
+ public function formAction(){
23
+
24
+ $formPost = $this->getLayout()->createBlock('realex/direct_form');
25
+
26
+ $this->getResponse()
27
+ ->clearHeaders()
28
+ ->setHeader('Content-Type', 'text/html')
29
+ ->setBody($formPost->toHtml());
30
+ }
31
+
32
+ public function iframeAction(){
33
+
34
+ $this->loadLayout();
35
+ $this->renderLayout();
36
+ }
37
+
38
+ public function threedSecureCaptureAction(){
39
+
40
+ try {
41
+ $this->_getService()->callBack();
42
+ $url = mage::getUrl('checkout/onepage/success');
43
+ $success = true;
44
+ }catch(Exception $e){
45
+ $url = mage::getUrl('checkout/onepage/failure');
46
+ $success = false;
47
+ }
48
+
49
+ $this->getResponse()
50
+ ->setBody($this->getLayout()
51
+ ->createBlock('realex/redirect_result')
52
+ ->setResult($success)
53
+ ->setUrl($url)
54
+ ->toHtml())
55
+ ->sendResponse();
56
+ exit;
57
+
58
+ }
59
+
60
+ protected function _getService(){
61
+ return mage::getModel('realex/service_token');
62
+ }
63
+
64
+ public function onepageFailureOrderAction() {
65
+
66
+ try{
67
+ $this->_getService()->callDeny();
68
+ }catch(Exception $e){
69
+
70
+ Realex_Log::logException($e);
71
+ }
72
+
73
+ $url = mage::getUrl('checkout/onepage/failure');
74
+ $this->getResponse()
75
+ ->setBody($this->getLayout()
76
+ ->createBlock('realex/redirect_result')
77
+ ->setResult(false)
78
+ ->setUrl($url)
79
+ ->toHtml())
80
+ ->sendResponse();
81
+ exit;
82
+ }
83
+ }
app/code/community/Yoma/Realex/etc/adminhtml.xml ADDED
@@ -0,0 +1,84 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <menu>
24
+ <sales>
25
+ <depends>
26
+ <module>Yoma_Realex</module>
27
+ </depends>
28
+ <children>
29
+ <realex translate="title" module="realex">
30
+ <title>Realex Payments</title>
31
+ <sort_order>999</sort_order>
32
+ <children>
33
+ <logs translate="title" module="realex">
34
+ <title>Logs</title>
35
+ <sort_order>41</sort_order>
36
+ <action>realexAdmin/adminhtml_log</action>
37
+ </logs>
38
+ <tokencard translate="title" module="realex">
39
+ <title>Token Manager</title>
40
+ <sort_order>42</sort_order>
41
+ <action>realexAdmin/adminhtml_tokencard</action>
42
+ </tokencard>
43
+ <transaction translate="title" module="realex">
44
+ <title>Incomplete Transactions</title>
45
+ <sort_order>42</sort_order>
46
+ <action>realexAdmin/adminhtml_transaction</action>
47
+ </transaction>
48
+ </children>
49
+ </realex>
50
+ </children>
51
+ </sales>
52
+ </menu>
53
+ <acl>
54
+ <resources>
55
+ <admin>
56
+ <children>
57
+ <system>
58
+ <children>
59
+ <config>
60
+ <children>
61
+ <realex>
62
+ <title>Yoma Realex</title>
63
+ </realex>
64
+ </children>
65
+ </config>
66
+ </children>
67
+ </system>
68
+ <sales>
69
+ <children>
70
+ <realex>
71
+ <title>Realex Payments</title>
72
+ <children>
73
+ <logs translate="title">
74
+ <title>Magento log browser</title>
75
+ </logs>
76
+ </children>
77
+ </realex>
78
+ </children>
79
+ </sales>
80
+ </children>
81
+ </admin>
82
+ </resources>
83
+ </acl>
84
+ </config>
app/code/community/Yoma/Realex/etc/config.xml ADDED
@@ -0,0 +1,585 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <modules>
24
+ <Yoma_Realex>
25
+ <version>1.1.1</version>
26
+ </Yoma_Realex>
27
+ </modules>
28
+ <global>
29
+ <models>
30
+ <realex>
31
+ <class>Yoma_Realex_Model</class>
32
+ <resourceModel>realex_resource</resourceModel>
33
+ </realex>
34
+ <realex_resource>
35
+ <class>Yoma_Realex_Model_Resource</class>
36
+ <entities>
37
+ <transaction>
38
+ <table>realex_transaction</table>
39
+ </transaction>
40
+ <paymentInfo>
41
+ <table>realex_payment_info</table>
42
+ </paymentInfo>
43
+ <tokencard>
44
+ <table>realex_tokencard</table>
45
+ </tokencard>
46
+ </entities>
47
+ </realex_resource>
48
+ </models>
49
+ <resources>
50
+ <realex_setup>
51
+ <setup>
52
+ <module>Yoma_Realex</module>
53
+ </setup>
54
+ <connection>
55
+ <use>core_setup</use>
56
+ </connection>
57
+ </realex_setup>
58
+ <realex_write>
59
+ <connection>
60
+ <use>core_write</use>
61
+ </connection>
62
+ </realex_write>
63
+ <realex_read>
64
+ <connection>
65
+ <use>core_read</use>
66
+ </connection>
67
+ </realex_read>
68
+ </resources>
69
+ <helpers>
70
+ <realex>
71
+ <class>Yoma_Realex_Helper</class>
72
+ </realex>
73
+ </helpers>
74
+ <blocks>
75
+ <realex>
76
+ <class>Yoma_Realex_Block</class>
77
+ </realex>
78
+ <checkout>
79
+ <rewrite>
80
+ <onepage_success>Yoma_Realex_Block_Onepage_Success</onepage_success>
81
+ </rewrite>
82
+ </checkout>
83
+ </blocks>
84
+ <payment>
85
+ <cc>
86
+ <types>
87
+ <YOMA_DINERS_CLUB>
88
+ <code>YOMA_DINERS_CLUB</code>
89
+ <name>Diners Club</name>
90
+ <order>2009</order>
91
+ </YOMA_DINERS_CLUB>
92
+ <YOMA_MAESTRO>
93
+ <code>YOMA_MAESTRO</code>
94
+ <name>Maestro</name>
95
+ <order>2010</order>
96
+ </YOMA_MAESTRO>
97
+ </types>
98
+ </cc>
99
+ </payment>
100
+ <fieldsets>
101
+ <sales_convert_quote_payment>
102
+ <realex_token_cc_id>
103
+ <to_order_payment>*</to_order_payment>
104
+ </realex_token_cc_id>
105
+ <remembertoken>
106
+ <to_order_payment>*</to_order_payment>
107
+ </remembertoken>
108
+ </sales_convert_quote_payment>
109
+ </fieldsets>
110
+ <sales>
111
+ <order_invoice>
112
+ <totals>
113
+ <settle_positive>
114
+ <class>realex/total_invoice_settle</class>
115
+ <after>tax</after>
116
+ </settle_positive>
117
+ </totals>
118
+ </order_invoice>
119
+ <order_creditmemo>
120
+ <totals>
121
+ <rebate_positive>
122
+ <class>realex/total_creditmemo_rebate</class>
123
+ <after>tax</after>
124
+ </rebate_positive>
125
+ </totals>
126
+ </order_creditmemo>
127
+ </sales>
128
+ <events>
129
+ <realex_register_token>
130
+ <observers>
131
+ <realex>
132
+ <type>singleton</type>
133
+ <class>realex/observer_tokencard</class>
134
+ <method>saveCustomerCard</method>
135
+ </realex>
136
+ </observers>
137
+ </realex_register_token>
138
+ <realex_delete_token>
139
+ <observers>
140
+ <realex>
141
+ <type>singleton</type>
142
+ <class>realex/observer_tokencard</class>
143
+ <method>deleteCustomerCard</method>
144
+ </realex>
145
+ </observers>
146
+ </realex_delete_token>
147
+ <realex_edit_payer>
148
+ <observers>
149
+ <realex>
150
+ <type>singleton</type>
151
+ <class>realex/observer_tokencard</class>
152
+ <method>editPayer</method>
153
+ </realex>
154
+ </observers>
155
+ </realex_edit_payer>
156
+ <realex_edit_token>
157
+ <observers>
158
+ <realex>
159
+ <type>singleton</type>
160
+ <class>realex/observer_tokencard</class>
161
+ <method>editCustomerCard</method>
162
+ </realex>
163
+ </observers>
164
+ </realex_edit_token>
165
+ <!--
166
+ <sales_quote_payment_import_data_before>
167
+ <observers>
168
+ <realex>
169
+ <type>singleton</type>
170
+ <class>realex/observer_tokencard</class>
171
+ <method>setPaymentMethod</method>
172
+ </realex>
173
+ </observers>
174
+ </sales_quote_payment_import_data_before>
175
+ -->
176
+ <sales_model_service_quote_submit_failure>
177
+ <observers>
178
+ <realex>
179
+ <type>singleton</type>
180
+ <class>realex/observer</class>
181
+ <method>quoteSubmitFailure</method>
182
+ </realex>
183
+ </observers>
184
+ </sales_model_service_quote_submit_failure>
185
+ <!--
186
+ <payment_method_is_active>
187
+ <observers>
188
+ <realex>
189
+ <type>singleton</type>
190
+ <class>realex/observer_tokencard</class>
191
+ <method>checkPaymentMethod</method>
192
+ </realex>
193
+ </observers>
194
+ </payment_method_is_active>
195
+
196
+ <sales_order_payment_place_start>
197
+ <observers>
198
+ <realex>
199
+ <type>singleton</type>
200
+ <class>realex/observer_tokencard</class>
201
+ <method>setPaymentMethod</method>
202
+ </realex>
203
+ </observers>
204
+ </sales_order_payment_place_start>
205
+ -->
206
+ </events>
207
+ </global>
208
+ <crontab>
209
+ <jobs>
210
+ <realex_expiredcards>
211
+ <!--<schedule><cron_expr>0 1 * * *</cron_expr></schedule>-->
212
+ <schedule><cron_expr>0,15,30,45 * * * *</cron_expr></schedule>
213
+ <run><model>realex/observer_tokencard::alertExpiredCards</model></run>
214
+ </realex_expiredcards>
215
+ <realex_ordercleanup>
216
+ <schedule>
217
+ <cron_expr>*/5 * * * *</cron_expr>
218
+ </schedule>
219
+ <run>
220
+ <model>realex/observer_cron::orderCleanup</model>
221
+ </run>
222
+ </realex_ordercleanup>
223
+ </jobs>
224
+ </crontab>
225
+ <frontend>
226
+
227
+ <secure_url>
228
+ <realex>/realex/</realex>
229
+ </secure_url>
230
+ <routers>
231
+ <realex>
232
+ <use>standard</use>
233
+ <args>
234
+ <module>Yoma_Realex</module>
235
+ <frontName>realex</frontName>
236
+ </args>
237
+ </realex>
238
+ <checkout>
239
+ <args>
240
+ <modules>
241
+ <realex before="Mage_Checkout">Yoma_Realex_Checkout</realex>
242
+ </modules>
243
+ </args>
244
+ </checkout>
245
+ </routers>
246
+ <layout>
247
+ <updates>
248
+ <realex>
249
+ <file>realex/realex.xml</file>
250
+ </realex>
251
+ </updates>
252
+ </layout>
253
+ <translate>
254
+ <modules>
255
+ <Yoma_Realex>
256
+ <files>
257
+ <default>realex/Yoma_Realex.csv</default>
258
+ </files>
259
+ </Yoma_Realex>
260
+ </modules>
261
+ </translate>
262
+ </frontend>
263
+ <admin>
264
+ <routers>
265
+ <realex>
266
+ <use>admin</use>
267
+ <args>
268
+ <module>Yoma_Realex</module>
269
+ <frontName>realexAdmin</frontName>
270
+ </args>
271
+ </realex>
272
+ </routers>
273
+ </admin>
274
+ <adminhtml>
275
+ <events>
276
+ <payment_info_block_prepare_specific_information>
277
+ <observers>
278
+ <realex_payment_information>
279
+ <type>singleton</type>
280
+ <class>realex/observer</class>
281
+ <method>appendPaymentBlock</method>
282
+ </realex_payment_information>
283
+ </observers>
284
+ </payment_info_block_prepare_specific_information>
285
+ <customer_delete_before>
286
+ <observers>
287
+ <realex>
288
+ <type>singleton</type>
289
+ <class>realex/observer_tokencard</class>
290
+ <method>deleteCustomerCards</method>
291
+ </realex>
292
+ </observers>
293
+ </customer_delete_before>
294
+ </events>
295
+ <events>
296
+ <adminhtml_widget_container_html_before>
297
+ <observers>
298
+ <realex>
299
+ <class>realex/observer</class>
300
+ <type>singleton</type>
301
+ <method>orderViewBefore</method>
302
+ </realex>
303
+ </observers>
304
+ </adminhtml_widget_container_html_before>
305
+ </events>
306
+ <layout>
307
+ <updates>
308
+ <realex>
309
+ <file>realex/realex.xml</file>
310
+ </realex>
311
+ </updates>
312
+ </layout>
313
+ <translate>
314
+ <modules>
315
+ <Yoma_Realex>
316
+ <files>
317
+ <default>realex/Yoma_Realex_Adminhtml.csv</default>
318
+ </files>
319
+ </Yoma_Realex>
320
+ </modules>
321
+ </translate>
322
+ </adminhtml>
323
+ <default>
324
+ <payment>
325
+ <realex>
326
+ <logs>0</logs>
327
+ </realex>
328
+ <cleanup>
329
+ <cleanup_active>1</cleanup_active>
330
+ <cleanup_timeframe>24</cleanup_timeframe>
331
+ </cleanup>
332
+ <realexredirect>
333
+ <active>0</active>
334
+ <iframe>1</iframe>
335
+ <iframe_display>1</iframe_display>
336
+ <iframe_inline>0</iframe_inline>
337
+ <debug>0</debug>
338
+ <model>realex/redirect</model>
339
+ <title>Pay by Credit or Debit Card</title>
340
+ <allowspecific>0</allowspecific>
341
+ <mode>test</mode>
342
+ <payment_action>authorize_capture</payment_action>
343
+ <order_status>processing</order_status>
344
+ <!--<cctypes>AE,VI,MC</cctypes>-->
345
+ <purchase_description>Purchase of products ECOMMERCE</purchase_description>
346
+ <selected_description>
347
+ <![CDATA[Enter your credit card details after Order Review<br />]]></selected_description>
348
+ <live_url>https://hpp.realexpayments.com/pay</live_url>
349
+ <sandbox_url>https://hpp.sandbox.realexpayments.com/pay</sandbox_url>
350
+ <sub_account>internet</sub_account>
351
+ </realexredirect>
352
+ <realexdirect>
353
+ <active>0</active>
354
+ <iframe>1</iframe>
355
+ <iframe_display>1</iframe_display>
356
+ <debug>0</debug>
357
+ <model>realex/direct</model>
358
+ <title>Pay by Credit or Debit Card</title>
359
+ <allowspecific>0</allowspecific>
360
+ <mode>test</mode>
361
+ <payment_action>authorize_capture</payment_action>
362
+ <order_status>processing</order_status>
363
+ <!--<cctypes>AE,VI,MC</cctypes>-->
364
+ <purchase_description>Purchase of products ECOMMERCE</purchase_description>
365
+ <selected_description>
366
+ <![CDATA[Enter your credit card details after Order Review<br />]]></selected_description>
367
+ <live_url>https://epage.payandshop.com/epage-remote.cgi</live_url>
368
+ <threed_url>https://epage.payandshop.com/epage-3dsecure.cgi</threed_url>
369
+ <require_liability_shift>1</require_liability_shift>
370
+ <sub_account>internet</sub_account>
371
+ </realexdirect>
372
+ <realvault>
373
+ <active>0</active>
374
+ <model>realex/token</model>
375
+ <iframe>1</iframe>
376
+ <iframe_display>1</iframe_display>
377
+ <title>Pay with a stored card</title>
378
+ <payer_type>web</payer_type>
379
+ <payment_action>authorize_capture</payment_action>
380
+ <store_card>1</store_card>
381
+ <store_label>Store your card for next time?</store_label>
382
+ <auto_store_label>Your card details will be stored on our secure server.</auto_store_label>
383
+ <allow_delete>1</allow_delete>
384
+ <max_saved>3</max_saved>
385
+ <mode>test</mode>
386
+ <live_url>https://epage.payandshop.com/epage-remote.cgi</live_url>
387
+ <threed_url>https://epage.payandshop.com/epage-3dsecure.cgi</threed_url>
388
+ <require_liability_shift>1</require_liability_shift>
389
+ <sub_account>api</sub_account>
390
+ <require_cvv>1</require_cvv>
391
+ </realvault>
392
+ </payment>
393
+ </default>
394
+ <yoma_realex>
395
+ <currency_decimals>
396
+ <DEFAULT>2</DEFAULT>
397
+ <ADP>0</ADP>
398
+ <AFN>0</AFN>
399
+ <ALL>0</ALL>
400
+ <AMD>0</AMD>
401
+ <BHD>3</BHD>
402
+ <BIF>0</BIF>
403
+ <BYR>0</BYR>
404
+ <CLF>0</CLF>
405
+ <CLP>0</CLP>
406
+ <COP>0</COP>
407
+ <CRC>0</CRC>
408
+ <DJF>0</DJF>
409
+ <ESP>0</ESP>
410
+ <GNF>0</GNF>
411
+ <GYD>0</GYD>
412
+ <HUF>0</HUF>
413
+ <IDR>0</IDR>
414
+ <IQD>0</IQD>
415
+ <IRR>0</IRR>
416
+ <ISK>0</ISK>
417
+ <ITL>0</ITL>
418
+ <JOD>3</JOD>
419
+ <JPY>0</JPY>
420
+ <KMF>0</KMF>
421
+ <KPW>0</KPW>
422
+ <KRW>0</KRW>
423
+ <KWD>3</KWD>
424
+ <LAK>0</LAK>
425
+ <LBP>0</LBP>
426
+ <LUF>0</LUF>
427
+ <LYD>3</LYD>
428
+ <MGA>0</MGA>
429
+ <MGF>0</MGF>
430
+ <MMK>0</MMK>
431
+ <MNT>0</MNT>
432
+ <MRO>0</MRO>
433
+ <MUR>0</MUR>
434
+ <OMR>3</OMR>
435
+ <PKR>0</PKR>
436
+ <PYG>0</PYG>
437
+ <RSD>0</RSD>
438
+ <RWF>0</RWF>
439
+ <SLL>0</SLL>
440
+ <SOS>0</SOS>
441
+ <STD>0</STD>
442
+ <SYP>0</SYP>
443
+ <TMM>0</TMM>
444
+ <TND>3</TND>
445
+ <TRL>0</TRL>
446
+ <TZS>0</TZS>
447
+ <UGX>0</UGX>
448
+ <UZS>0</UZS>
449
+ <VND>0</VND>
450
+ <VUV>0</VUV>
451
+ <XAF>0</XAF>
452
+ <XOF>0</XOF>
453
+ <XPF>0</XPF>
454
+ <YER>0</YER>
455
+ <ZMK>0</ZMK>
456
+ <ZWD>0</ZWD>
457
+ </currency_decimals>
458
+ <mapping>
459
+ <realexredirect>
460
+ <out>
461
+ <authorize_capture>1</authorize_capture>
462
+ <authorize>0</authorize>
463
+ </out>
464
+ </realexredirect>
465
+ </mapping>
466
+ <!--
467
+ <messages>
468
+ <redirect>
469
+ <refund>
470
+ <request timestamp="" type="">
471
+ <merchantid></merchantid>
472
+ <account></account>
473
+ <orderid></orderid>
474
+ <pasref></pasref>
475
+ <authcode></authcode>
476
+ <amount></amount>
477
+ <sha1hash></sha1hash>
478
+ <refundhash></refundhash>
479
+ <autosettle></autosettle>
480
+ </request>
481
+ </refund>
482
+ <void>
483
+ <request timestamp="" type="">
484
+ <merchantid></merchantid>
485
+ <account></account>
486
+ <orderid></orderid>
487
+ <pasref></pasref>
488
+ <authcode></authcode>
489
+ <amount></amount>
490
+ <sha1hash></sha1hash>
491
+ <autosettle></autosettle>
492
+ </request>
493
+ </void>
494
+ </redirect>
495
+ <direct>
496
+ <capture>
497
+ <request timestamp="" type="">
498
+ <merchantid></merchantid>
499
+ <account></account>
500
+ <orderid></orderid>
501
+ <amount currency=""></amount>
502
+ <sha1hash></sha1hash>
503
+ <card>
504
+ <number></number>
505
+ <expdate></expdate>
506
+ <chname></chname>
507
+ <type></type>
508
+ <issueno></issueno>
509
+ <cvn>
510
+ <number></number>
511
+ <presind></presind>
512
+ </cvn>
513
+ </card>
514
+ <tssinfo>
515
+ <custnum></custnum>
516
+ <prodid></prodid>
517
+ <varref></varref>
518
+ <custipaddress></custipaddress>
519
+ <address type="billing">
520
+ <code></code>
521
+ <country></country>
522
+ </address>
523
+ <address type="shipping">
524
+ <code></code>
525
+ <country></country>
526
+ </address>
527
+ </tssinfo>
528
+ <autosettle flag=""></autosettle>
529
+ </request>
530
+ </capture>
531
+ <threedSecure>
532
+ <request timestamp="" type="">
533
+ <merchantid></merchantid>
534
+ <account></account>
535
+ <orderid></orderid>
536
+ <amount currency=""></amount>
537
+ <sha1hash></sha1hash>
538
+ <card>
539
+ <number></number>
540
+ <expdate></expdate>
541
+ <chname></chname>
542
+ <type></type>
543
+ <issueno></issueno>
544
+
545
+ </card>
546
+
547
+ <autosettle flag=""></autosettle>
548
+ </request>
549
+ </threedSecure>
550
+ </direct>
551
+ </messages>
552
+ -->
553
+ <!--
554
+ <urls>
555
+ <redirect>
556
+ <refund>
557
+ <out>https://epage.payandshop.com/epage-remote.cgi</out>
558
+ </refund>
559
+ <void>
560
+ <out>https://epage.payandshop.com/epage-remote.cgi</out>
561
+ </void>
562
+ <capture>
563
+ <out>https://hpp.sandbox.realexpayments.com/pay</out>
564
+ </capture>
565
+ </redirect>
566
+ <direct>
567
+ <capture>
568
+ <out>https://epage.payandshop.com/epage-remote.cgi</out>
569
+ </capture>
570
+ <threedSecure>
571
+ <out>https://epage.payandshop.com/epage-remote.cgi</out>
572
+ </threedSecure>
573
+ </direct>
574
+ </urls>
575
+ -->
576
+ <!--
577
+ <iframe>
578
+ <default>460x600</default>
579
+ <thredsecure>490x600</thredsecure>
580
+ <realvault>563x600</realvault>
581
+ <dcc>698x600</dcc>
582
+ </iframe>
583
+ -->
584
+ </yoma_realex>
585
+ </config>
app/code/community/Yoma/Realex/etc/system.xml ADDED
@@ -0,0 +1,718 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * Magento
5
+ *
6
+ * NOTICE OF LICENSE
7
+ *
8
+ * This source file is subject to the Open Software License (OSL 3.0)
9
+ * that is bundled with this package in the file LICENSE.txt.
10
+ * It is also available through the world-wide-web at this URL:
11
+ * http://opensource.org/licenses/osl-3.0.php
12
+ * If you did not receive a copy of the license and are unable to
13
+ * obtain it through the world-wide-web, please send an email
14
+ * to license@magentocommerce.com so we can send you a copy immediately.
15
+ *
16
+ * @category Yoma
17
+ * @package Yoma_Realex
18
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
19
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
20
+ */
21
+ -->
22
+ <config>
23
+ <sections>
24
+ <realex translate="label" module="realex">
25
+ <label>Realex Payments</label>
26
+ <tab>sales</tab>
27
+ <frontend_type>text</frontend_type>
28
+ <sort_order>345</sort_order>
29
+ <show_in_default>1</show_in_default>
30
+ <show_in_website>1</show_in_website>
31
+ <show_in_store>1</show_in_store>
32
+ <groups>
33
+ <realex translate="label comment" module="realex">
34
+ <label>Realex Payments Account Information [Global Settings]</label>
35
+ <sort_order>10</sort_order>
36
+ <show_in_default>1</show_in_default>
37
+ <show_in_website>1</show_in_website>
38
+ <show_in_store>1</show_in_store>
39
+ <fields>
40
+ <logs translate="label">
41
+ <label>Enable Logs</label>
42
+ <frontend_type>select</frontend_type>
43
+ <source_model>adminhtml/system_config_source_yesno</source_model>
44
+ <config_path>payment/realex/logs</config_path>
45
+ <comment><![CDATA[Location of the log files: "{{MagentoBaseDir}}/var/log/realex/"]]></comment>
46
+ <sort_order>20</sort_order>
47
+ <show_in_default>1</show_in_default>
48
+ <show_in_website>1</show_in_website>
49
+ <show_in_store>1</show_in_store>
50
+ </logs>
51
+ <secret translate="label">
52
+ <label>Shared Secret</label>
53
+ <frontend_type>password</frontend_type>
54
+ <config_path>payment/realex/secret</config_path>
55
+ <backend_model>adminhtml/system_config_backend_encrypted</backend_model>
56
+ <sort_order>60</sort_order>
57
+ <show_in_default>1</show_in_default>
58
+ <show_in_website>1</show_in_website>
59
+ <show_in_store>1</show_in_store>
60
+ </secret>
61
+ <vendor translate="label">
62
+ <label>Merchant ID</label>
63
+ <frontend_type>text</frontend_type>
64
+ <config_path>payment/realex/vendor</config_path>
65
+ <sort_order>50</sort_order>
66
+ <show_in_default>1</show_in_default>
67
+ <show_in_website>1</show_in_website>
68
+ <show_in_store>1</show_in_store>
69
+ </vendor>
70
+ <rebate_pass translate="label">
71
+ <label>Rebate Password</label>
72
+ <frontend_type>password</frontend_type>
73
+ <config_path>payment/realex/rebate_pass</config_path>
74
+ <sort_order>80</sort_order>
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
+ </rebate_pass>
79
+
80
+ </fields>
81
+ </realex>
82
+ <cleanup translate="label" module="realex">
83
+ <label>Order Clean-Up</label>
84
+ <sort_order>11</sort_order>
85
+ <show_in_default>1</show_in_default>
86
+ <show_in_website>0</show_in_website>
87
+ <show_in_store>0</show_in_store>
88
+ <fields>
89
+ <cleanup_active translate="label">
90
+ <label>Clean-Up Enabled</label>
91
+ <frontend_type>select</frontend_type>
92
+ <config_path>payment/cleanup/cleanup_active</config_path>
93
+ <source_model>adminhtml/system_config_source_yesno</source_model>
94
+ <sort_order>90</sort_order>
95
+ <show_in_default>1</show_in_default>
96
+ <show_in_website>1</show_in_website>
97
+ <show_in_store>0</show_in_store>
98
+ </cleanup_active>
99
+ <cleanup_timeframe translate="label comment">
100
+ <label>Order Timeframe</label>
101
+ <frontend_type>text</frontend_type>
102
+ <config_path>payment/cleanup/cleanup_timeframe</config_path>
103
+ <sort_order>91</sort_order>
104
+ <show_in_default>1</show_in_default>
105
+ <show_in_website>0</show_in_website>
106
+ <show_in_store>0</show_in_store>
107
+ <comment>This is the amount of time, in hours, to allow an order to be in the payment_review/on_hold state, before it is automatically cancelled. You must have Magento’s cron job scheduled on your server to use this service.</comment>
108
+ </cleanup_timeframe>
109
+ </fields>
110
+ </cleanup>
111
+ <realexredirect translate="label comment" module="realex">
112
+ <label>HPP (Hosted Payment Page)</label>
113
+ <sort_order>670</sort_order>
114
+ <show_in_default>1</show_in_default>
115
+ <show_in_website>1</show_in_website>
116
+ <show_in_store>1</show_in_store>
117
+ <fields>
118
+ <active translate="label">
119
+ <label>Enabled</label>
120
+ <frontend_type>select</frontend_type>
121
+ <config_path>payment/realexredirect/active</config_path>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>1</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>0</show_in_store>
127
+ </active>
128
+ <payment_action translate="label">
129
+ <label>Payment Action</label>
130
+ <frontend_type>select</frontend_type>
131
+ <config_path>payment/realexredirect/payment_action</config_path>
132
+ <source_model>realex/realex_source_paymentAction</source_model>
133
+ <sort_order>20</sort_order>
134
+ <show_in_default>1</show_in_default>
135
+ <show_in_website>1</show_in_website>
136
+ <show_in_store>0</show_in_store>
137
+ </payment_action>
138
+ <order_status translate="label">
139
+ <label>New order status</label>
140
+ <frontend_type>select</frontend_type>
141
+ <config_path>payment/realexredirect/order_status</config_path>
142
+ <source_model>realex/realex_source_status</source_model>
143
+ <sort_order>30</sort_order>
144
+ <show_in_default>1</show_in_default>
145
+ <show_in_website>1</show_in_website>
146
+ <show_in_store>0</show_in_store>
147
+ </order_status>
148
+ <title translate="label">
149
+ <label>Title</label>
150
+ <frontend_type>text</frontend_type>
151
+ <config_path>payment/realexredirect/title</config_path>
152
+ <sort_order>40</sort_order>
153
+ <show_in_default>1</show_in_default>
154
+ <show_in_website>1</show_in_website>
155
+ <show_in_store>0</show_in_store>
156
+ </title>
157
+ <mode translate="label">
158
+ <label>Mode</label>
159
+ <frontend_type>select</frontend_type>
160
+ <source_model>realex/realex_source_paymentMode</source_model>
161
+ <config_path>payment/realexredirect/mode</config_path>
162
+ <sort_order>50</sort_order>
163
+ <show_in_default>1</show_in_default>
164
+ <show_in_website>1</show_in_website>
165
+ <show_in_store>0</show_in_store>
166
+ </mode>
167
+ <live_url translate="label">
168
+ <label>Live URL</label>
169
+ <frontend_type>text</frontend_type>
170
+ <config_path>payment/realexredirect/live_url</config_path>
171
+ <sort_order>51</sort_order>
172
+ <show_in_default>1</show_in_default>
173
+ <show_in_website>1</show_in_website>
174
+ <show_in_store>0</show_in_store>
175
+ </live_url>
176
+ <sandbox_url translate="label">
177
+ <label>Sandbox URL</label>
178
+ <frontend_type>text</frontend_type>
179
+ <config_path>payment/realexredirect/sandbox_url</config_path>
180
+ <sort_order>52</sort_order>
181
+ <show_in_default>1</show_in_default>
182
+ <show_in_website>1</show_in_website>
183
+ <show_in_store>0</show_in_store>
184
+ </sandbox_url>
185
+ <iframe translate="label">
186
+ <label>Use iFrame</label>
187
+ <frontend_type>select</frontend_type>
188
+ <config_path>payment/realexredirect/iframe</config_path>
189
+ <source_model>adminhtml/system_config_source_yesno</source_model>
190
+ <sort_order>60</sort_order>
191
+ <show_in_default>1</show_in_default>
192
+ <show_in_website>1</show_in_website>
193
+ <show_in_store>0</show_in_store>
194
+ </iframe>
195
+ <iframe_size translate="label">
196
+ <label>iFrame Size</label>
197
+ <frontend_type>select</frontend_type>
198
+ <config_path>payment/realexredirect/iframe_size</config_path>
199
+ <source_model>realex/realex_source_iframeSize</source_model>
200
+ <sort_order>61</sort_order>
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
+ <depends>
205
+ <iframe>1</iframe>
206
+ </depends>
207
+ </iframe_size>
208
+ <iframe_display>
209
+ <label>Display iFrame on checkout page</label>
210
+ <comment><![CDATA[Set No for OSC Module]]></comment>
211
+ <frontend_type>select</frontend_type>
212
+ <config_path>payment/realexredirect/iframe_display</config_path>
213
+ <source_model>adminhtml/system_config_source_yesno</source_model>
214
+ <sort_order>62</sort_order>
215
+ <show_in_default>1</show_in_default>
216
+ <show_in_website>1</show_in_website>
217
+ <show_in_store>0</show_in_store>
218
+ <depends>
219
+ <iframe>1</iframe>
220
+ </depends>
221
+ </iframe_display>
222
+ <iframe_inline translate="label">
223
+ <label>Display iFrame Inline</label>
224
+ <frontend_type>select</frontend_type>
225
+ <config_path>payment/realexredirect/iframe_inline</config_path>
226
+ <source_model>adminhtml/system_config_source_yesno</source_model>
227
+ <sort_order>63</sort_order>
228
+ <show_in_default>1</show_in_default>
229
+ <show_in_website>1</show_in_website>
230
+ <show_in_store>0</show_in_store>
231
+ <depends>
232
+ <iframe_display>1</iframe_display>
233
+ </depends>
234
+ </iframe_inline>
235
+ <sub_account translate="label">
236
+ <label>Default Sub Account</label>
237
+ <frontend_type>text</frontend_type>
238
+ <config_path>payment/realexredirect/sub_account</config_path>
239
+ <sort_order>100</sort_order>
240
+ <show_in_default>1</show_in_default>
241
+ <show_in_website>1</show_in_website>
242
+ <show_in_store>0</show_in_store>
243
+ <comment><![CDATA[Leave this value blank to use the default sub account.]]></comment>
244
+ </sub_account>
245
+ <cctypes translate="label">
246
+ <label>Allowed Card Types</label>
247
+ <frontend_type>multiselect</frontend_type>
248
+ <source_model>realex/realex_source_cards</source_model>
249
+ <config_path>payment/realexredirect/cctypes</config_path>
250
+ <sort_order>120</sort_order>
251
+ <show_in_default>1</show_in_default>
252
+ <show_in_website>1</show_in_website>
253
+ <show_in_store>0</show_in_store>
254
+ </cctypes>
255
+ <allowspecific translate="label">
256
+ <label>Payment from applicable countries</label>
257
+ <frontend_type>allowspecific</frontend_type>
258
+ <config_path>payment/realexredirect/allowspecific</config_path>
259
+ <sort_order>211</sort_order>
260
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
261
+ <show_in_default>1</show_in_default>
262
+ <show_in_website>1</show_in_website>
263
+ <show_in_store>1</show_in_store>
264
+ </allowspecific>
265
+ <specificcountry translate="label">
266
+ <label>Payment from Specific countries</label>
267
+ <frontend_type>multiselect</frontend_type>
268
+ <config_path>payment/realexredirect/specificcountry</config_path>
269
+ <sort_order>212</sort_order>
270
+ <source_model>adminhtml/system_config_source_country</source_model>
271
+ <show_in_default>1</show_in_default>
272
+ <show_in_website>1</show_in_website>
273
+ <show_in_store>1</show_in_store>
274
+ </specificcountry>
275
+ <sort_order translate="label">
276
+ <label>Sort order</label>
277
+ <frontend_type>text</frontend_type>
278
+ <config_path>payment/realexredirect/sort_order</config_path>
279
+ <sort_order>250</sort_order>
280
+ <show_in_default>1</show_in_default>
281
+ <show_in_website>1</show_in_website>
282
+ <show_in_store>0</show_in_store>
283
+ </sort_order>
284
+ </fields>
285
+ </realexredirect>
286
+ <realexdirect translate="label comment" module="realex">
287
+ <label>API (Remote)</label>
288
+ <sort_order>670</sort_order>
289
+ <show_in_default>1</show_in_default>
290
+ <show_in_website>1</show_in_website>
291
+ <show_in_store>1</show_in_store>
292
+ <fields>
293
+ <active translate="label">
294
+ <label>Enabled</label>
295
+ <frontend_type>select</frontend_type>
296
+ <config_path>payment/realexdirect/active</config_path>
297
+ <source_model>adminhtml/system_config_source_yesno</source_model>
298
+ <sort_order>1</sort_order>
299
+ <show_in_default>1</show_in_default>
300
+ <show_in_website>1</show_in_website>
301
+ <show_in_store>0</show_in_store>
302
+ </active>
303
+ <payment_action translate="label">
304
+ <label>Payment Action</label>
305
+ <frontend_type>select</frontend_type>
306
+ <config_path>payment/realexdirect/payment_action</config_path>
307
+ <source_model>realex/realex_source_paymentAction</source_model>
308
+ <sort_order>20</sort_order>
309
+ <show_in_default>1</show_in_default>
310
+ <show_in_website>1</show_in_website>
311
+ <show_in_store>0</show_in_store>
312
+ </payment_action>
313
+ <order_status translate="label">
314
+ <label>New order status</label>
315
+ <frontend_type>select</frontend_type>
316
+ <config_path>payment/realexdirect/order_status</config_path>
317
+ <source_model>realex/realex_source_status</source_model>
318
+ <sort_order>30</sort_order>
319
+ <show_in_default>1</show_in_default>
320
+ <show_in_website>1</show_in_website>
321
+ <show_in_store>0</show_in_store>
322
+ </order_status>
323
+ <title translate="label">
324
+ <label>Title</label>
325
+ <frontend_type>text</frontend_type>
326
+ <config_path>payment/realexdirect/title</config_path>
327
+ <sort_order>40</sort_order>
328
+ <show_in_default>1</show_in_default>
329
+ <show_in_website>1</show_in_website>
330
+ <show_in_store>0</show_in_store>
331
+ </title>
332
+ <mode translate="label">
333
+ <label>Mode</label>
334
+ <frontend_type>select</frontend_type>
335
+ <source_model>realex/realex_source_paymentMode</source_model>
336
+ <config_path>payment/realexdirect/mode</config_path>
337
+ <sort_order>50</sort_order>
338
+ <show_in_default>1</show_in_default>
339
+ <show_in_website>1</show_in_website>
340
+ <show_in_store>0</show_in_store>
341
+ </mode>
342
+ <live_url translate="label">
343
+ <label>Live URL</label>
344
+ <frontend_type>text</frontend_type>
345
+ <config_path>payment/realexdirect/live_url</config_path>
346
+ <sort_order>51</sort_order>
347
+ <show_in_default>1</show_in_default>
348
+ <show_in_website>1</show_in_website>
349
+ <show_in_store>0</show_in_store>
350
+ </live_url>
351
+ <sub_account translate="label">
352
+ <label>Default Sub Account</label>
353
+ <frontend_type>text</frontend_type>
354
+ <config_path>payment/realexdirect/sub_account</config_path>
355
+ <sort_order>100</sort_order>
356
+ <show_in_default>1</show_in_default>
357
+ <show_in_website>1</show_in_website>
358
+ <show_in_store>0</show_in_store>
359
+ <comment><![CDATA[Leave this value blank to use the default sub account.]]></comment>
360
+ </sub_account>
361
+
362
+ <sub_account_rules translate="label comment">
363
+ <label>Sub Account Rules</label>
364
+ <frontend_model>realex/adminhtml_system_config_renderer_subAccount_direct</frontend_model>
365
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
366
+ <config_path>payment/realexdirect/sub_account_rules</config_path>
367
+ <sort_order>110</sort_order>
368
+ <show_in_default>1</show_in_default>
369
+ <show_in_website>1</show_in_website>
370
+ <show_in_store>1</show_in_store>
371
+ <comment><![CDATA[Custom sub account routing.]]></comment>
372
+ </sub_account_rules>
373
+
374
+ <cctypes translate="label">
375
+ <label>Allowed Card Types</label>
376
+ <frontend_type>multiselect</frontend_type>
377
+ <source_model>realex/realex_source_cards</source_model>
378
+ <config_path>payment/realexdirect/cctypes</config_path>
379
+ <sort_order>120</sort_order>
380
+ <show_in_default>1</show_in_default>
381
+ <show_in_website>1</show_in_website>
382
+ <show_in_store>0</show_in_store>
383
+ </cctypes>
384
+ <use_threed_secure translate="label">
385
+ <label>Use 3D Secure</label>
386
+ <frontend_type>select</frontend_type>
387
+ <source_model>adminhtml/system_config_source_yesno</source_model>
388
+ <config_path>payment/realexdirect/use_threed_secure</config_path>
389
+ <sort_order>121</sort_order>
390
+ <show_in_default>1</show_in_default>
391
+ <show_in_website>1</show_in_website>
392
+ <show_in_store>0</show_in_store>
393
+ </use_threed_secure>
394
+ <iframe translate="label">
395
+ <label>Use iframe</label>
396
+ <frontend_type>select</frontend_type>
397
+ <source_model>adminhtml/system_config_source_yesno</source_model>
398
+ <config_path>payment/realexdirect/iframe</config_path>
399
+ <sort_order>130</sort_order>
400
+ <show_in_default>1</show_in_default>
401
+ <show_in_website>1</show_in_website>
402
+ <show_in_store>0</show_in_store>
403
+ <depends>
404
+ <use_threed_secure>1</use_threed_secure>
405
+ </depends>
406
+ </iframe>
407
+ <iframe_display>
408
+ <label>Display iFrame on checkout page</label>
409
+ <frontend_type>select</frontend_type>
410
+ <comment><![CDATA[Set No for OSC Module]]></comment>
411
+ <config_path>payment/realexdirect/iframe_display</config_path>
412
+ <source_model>adminhtml/system_config_source_yesno</source_model>
413
+ <sort_order>131</sort_order>
414
+ <show_in_default>1</show_in_default>
415
+ <show_in_website>1</show_in_website>
416
+ <show_in_store>0</show_in_store>
417
+ <depends>
418
+ <iframe>1</iframe>
419
+ <use_threed_secure>1</use_threed_secure>
420
+ </depends>
421
+ </iframe_display>
422
+ <threed_url translate="label">
423
+ <label>3d Secure URL</label>
424
+ <frontend_type>text</frontend_type>
425
+ <config_path>payment/realexdirect/threed_url</config_path>
426
+ <sort_order>121</sort_order>
427
+ <show_in_default>1</show_in_default>
428
+ <show_in_website>1</show_in_website>
429
+ <show_in_store>0</show_in_store>
430
+ <depends>
431
+ <use_threed_secure>1</use_threed_secure>
432
+ </depends>
433
+ </threed_url>
434
+ <require_liability_shift translate="label">
435
+ <label>Require Liability Shift</label>
436
+ <frontend_type>select</frontend_type>
437
+ <config_path>payment/realexdirect/require_liability_shift</config_path>
438
+ <source_model>adminhtml/system_config_source_yesno</source_model>
439
+ <sort_order>140</sort_order>
440
+ <show_in_default>1</show_in_default>
441
+ <show_in_website>1</show_in_website>
442
+ <show_in_store>0</show_in_store>
443
+ <depends>
444
+ <use_threed_secure>1</use_threed_secure>
445
+ </depends>
446
+ <comment><![CDATA[By setting this to 'No' more transactions will be allowed, however you are more liable to fraud.]]></comment>
447
+ </require_liability_shift>
448
+ <allowspecific translate="label">
449
+ <label>Payment from applicable countries</label>
450
+ <frontend_type>allowspecific</frontend_type>
451
+ <config_path>payment/realexdirect/allowspecific</config_path>
452
+ <sort_order>211</sort_order>
453
+ <source_model>adminhtml/system_config_source_payment_allspecificcountries</source_model>
454
+ <show_in_default>1</show_in_default>
455
+ <show_in_website>1</show_in_website>
456
+ <show_in_store>1</show_in_store>
457
+ </allowspecific>
458
+ <specificcountry translate="label">
459
+ <label>Payment from Specific countries</label>
460
+ <frontend_type>multiselect</frontend_type>
461
+ <config_path>payment/realexdirect/specificcountry</config_path>
462
+ <sort_order>212</sort_order>
463
+ <source_model>adminhtml/system_config_source_country</source_model>
464
+ <show_in_default>1</show_in_default>
465
+ <show_in_website>1</show_in_website>
466
+ <show_in_store>1</show_in_store>
467
+ </specificcountry>
468
+ <sort_order translate="label">
469
+ <label>Sort order</label>
470
+ <frontend_type>text</frontend_type>
471
+ <config_path>payment/realexdirect/sort_order</config_path>
472
+ <sort_order>250</sort_order>
473
+ <show_in_default>1</show_in_default>
474
+ <show_in_website>1</show_in_website>
475
+ <show_in_store>0</show_in_store>
476
+ </sort_order>
477
+ </fields>
478
+ </realexdirect>
479
+
480
+ <realvault translate="label comment" module="realex">
481
+ <label>Tokenistation - RealVault</label>
482
+ <sort_order>1000</sort_order>
483
+ <show_in_default>1</show_in_default>
484
+ <show_in_website>1</show_in_website>
485
+ <show_in_store>1</show_in_store>
486
+ <fields>
487
+
488
+ <active translate="label">
489
+ <label>Enabled</label>
490
+ <frontend_type>select</frontend_type>
491
+ <config_path>payment/realvault/active</config_path>
492
+ <source_model>adminhtml/system_config_source_yesno</source_model>
493
+ <sort_order>1</sort_order>
494
+ <show_in_default>1</show_in_default>
495
+ <show_in_website>1</show_in_website>
496
+ <show_in_store>0</show_in_store>
497
+ </active>
498
+ <payment_action translate="label">
499
+ <label>Payment Action</label>
500
+ <frontend_type>select</frontend_type>
501
+ <config_path>payment/realvault/payment_action</config_path>
502
+ <source_model>realex/realex_source_paymentAction</source_model>
503
+ <sort_order>20</sort_order>
504
+ <show_in_default>1</show_in_default>
505
+ <show_in_website>1</show_in_website>
506
+ <show_in_store>0</show_in_store>
507
+ </payment_action>
508
+ <title translate="label">
509
+ <label>Title</label>
510
+ <frontend_type>text</frontend_type>
511
+ <config_path>payment/realvault/title</config_path>
512
+ <sort_order>3</sort_order>
513
+ <show_in_default>1</show_in_default>
514
+ <show_in_website>1</show_in_website>
515
+ <show_in_store>0</show_in_store>
516
+ </title>
517
+ <store_card translate="label">
518
+ <label>Store Card Option</label>
519
+ <frontend_type>select</frontend_type>
520
+ <comment>Supply the option on the frontend for users to store their card.</comment>
521
+ <config_path>payment/realvault/store_card</config_path>
522
+ <source_model>realex/system_config_source_storecard</source_model>
523
+ <sort_order>3</sort_order>
524
+ <show_in_default>1</show_in_default>
525
+ <show_in_website>1</show_in_website>
526
+ <show_in_store>0</show_in_store>
527
+ </store_card>
528
+
529
+ <store_label translate="label">
530
+ <label>Store Card Label</label>
531
+ <frontend_type>text</frontend_type>
532
+ <comment>If the store card option is set his label will be shown to the user on the frontend.</comment>
533
+ <sort_order>4</sort_order>
534
+ <config_path>payment/realvault/store_label</config_path>
535
+ <show_in_default>1</show_in_default>
536
+ <show_in_website>1</show_in_website>
537
+ <show_in_store>0</show_in_store>
538
+ <depends>
539
+ <store_card>1</store_card>
540
+ <active>1</active>
541
+ </depends>
542
+ <validate>required-entry</validate>
543
+ </store_label>
544
+
545
+ <auto_store_label translate="label">
546
+ <label>Always Store Card Label</label>
547
+ <frontend_type>text</frontend_type>
548
+ <sort_order>5</sort_order>
549
+ <config_path>payment/realvault/auto_store_label</config_path>
550
+ <show_in_default>1</show_in_default>
551
+ <show_in_website>1</show_in_website>
552
+ <show_in_store>0</show_in_store>
553
+ <depends>
554
+ <store_card>0</store_card>
555
+ </depends>
556
+ </auto_store_label>
557
+
558
+ <payer_type translate="label">
559
+ <label>Payer Type</label>
560
+ <frontend_type>text</frontend_type>
561
+ <comment>Realex Payments Payer Group</comment>
562
+ <sort_order>6</sort_order>
563
+ <config_path>payment/realvault/payer_type</config_path>
564
+ <show_in_default>1</show_in_default>
565
+ <show_in_website>1</show_in_website>
566
+ <show_in_store>0</show_in_store>
567
+ </payer_type>
568
+
569
+ <allow_delete translate="label">
570
+ <label>Allow Delete Cards</label>
571
+ <frontend_type>select</frontend_type>
572
+ <comment>Allow customers to delete their cards?</comment>
573
+ <sort_order>6</sort_order>
574
+ <config_path>payment/realvault/allow_delete</config_path>
575
+ <source_model>adminhtml/system_config_source_yesno</source_model>
576
+ <show_in_default>1</show_in_default>
577
+ <show_in_website>1</show_in_website>
578
+ <show_in_store>0</show_in_store>
579
+ <depends>
580
+ <active>1</active>
581
+ </depends>
582
+ </allow_delete>
583
+
584
+ <max_saved translate="label">
585
+ <label>Max Saved Cards Allowed</label>
586
+ <frontend_type>text</frontend_type>
587
+ <comment>Max saved cards per customer</comment>
588
+ <sort_order>6</sort_order>
589
+ <config_path>payment/realvault/max_saved</config_path>
590
+ <show_in_default>1</show_in_default>
591
+ <show_in_website>1</show_in_website>
592
+ <show_in_store>0</show_in_store>
593
+ <depends>
594
+ <active>1</active>
595
+ </depends>
596
+ </max_saved>
597
+ <require_cvv>
598
+ <label>Require Security Code</label>
599
+ <comment>Request Security Code on saved cards</comment>
600
+ <frontend_type>select</frontend_type>
601
+ <sort_order>7</sort_order>
602
+ <config_path>payment/realvault/require_cvv</config_path>
603
+ <source_model>adminhtml/system_config_source_yesno</source_model>
604
+ <show_in_default>1</show_in_default>
605
+ <show_in_website>1</show_in_website>
606
+ <show_in_store>0</show_in_store>
607
+ </require_cvv>
608
+ <mode translate="label">
609
+ <label>Mode</label>
610
+ <frontend_type>select</frontend_type>
611
+ <source_model>realex/realex_source_paymentMode</source_model>
612
+ <config_path>payment/realvault/mode</config_path>
613
+ <sort_order>50</sort_order>
614
+ <show_in_default>1</show_in_default>
615
+ <show_in_website>1</show_in_website>
616
+ <show_in_store>0</show_in_store>
617
+ </mode>
618
+ <live_url translate="label">
619
+ <label>Live URL</label>
620
+ <frontend_type>text</frontend_type>
621
+ <config_path>payment/realvault/live_url</config_path>
622
+ <sort_order>51</sort_order>
623
+ <show_in_default>1</show_in_default>
624
+ <show_in_website>1</show_in_website>
625
+ <show_in_store>0</show_in_store>
626
+ </live_url>
627
+ <sub_account translate="label">
628
+ <label>Default Sub Account</label>
629
+ <frontend_type>text</frontend_type>
630
+ <config_path>payment/realvault/sub_account</config_path>
631
+ <sort_order>100</sort_order>
632
+ <show_in_default>1</show_in_default>
633
+ <show_in_website>1</show_in_website>
634
+ <show_in_store>0</show_in_store>
635
+ <comment><![CDATA[Leave this value blank to use the default sub account.]]></comment>
636
+ </sub_account>
637
+ <sub_account_rules translate="label comment">
638
+ <label>Sub Account Rules</label>
639
+ <frontend_model>realex/adminhtml_system_config_renderer_subAccount_direct</frontend_model>
640
+ <backend_model>adminhtml/system_config_backend_serialized_array</backend_model>
641
+ <config_path>payment/realvault/sub_account_rules</config_path>
642
+ <sort_order>110</sort_order>
643
+ <show_in_default>1</show_in_default>
644
+ <show_in_website>1</show_in_website>
645
+ <show_in_store>1</show_in_store>
646
+ <comment><![CDATA[Custom sub account routing.]]></comment>
647
+ </sub_account_rules>
648
+ <use_threed_secure translate="label">
649
+ <label>Use 3D Secure</label>
650
+ <frontend_type>select</frontend_type>
651
+ <source_model>adminhtml/system_config_source_yesno</source_model>
652
+ <config_path>payment/realvault/use_threed_secure</config_path>
653
+ <sort_order>120</sort_order>
654
+ <show_in_default>1</show_in_default>
655
+ <show_in_website>1</show_in_website>
656
+ <show_in_store>0</show_in_store>
657
+ </use_threed_secure>
658
+ <iframe translate="label">
659
+ <label>Use iframe</label>
660
+ <frontend_type>select</frontend_type>
661
+ <source_model>adminhtml/system_config_source_yesno</source_model>
662
+ <config_path>payment/realvault/iframe</config_path>
663
+ <sort_order>130</sort_order>
664
+ <show_in_default>1</show_in_default>
665
+ <show_in_website>1</show_in_website>
666
+ <show_in_store>0</show_in_store>
667
+ <depends>
668
+ <use_threed_secure>1</use_threed_secure>
669
+ </depends>
670
+ </iframe>
671
+ <iframe_display>
672
+ <label>Display iFrame on checkout page</label>
673
+ <frontend_type>select</frontend_type>
674
+ <comment><![CDATA[Set No for OSC Module]]></comment>
675
+ <config_path>payment/realvault/iframe_display</config_path>
676
+ <source_model>adminhtml/system_config_source_yesno</source_model>
677
+ <sort_order>131</sort_order>
678
+ <show_in_default>1</show_in_default>
679
+ <show_in_website>1</show_in_website>
680
+ <show_in_store>0</show_in_store>
681
+ <depends>
682
+ <use_threed_secure>1</use_threed_secure>
683
+ <iframe>1</iframe>
684
+ </depends>
685
+ </iframe_display>
686
+ <threed_url translate="label">
687
+ <label>3d Secure URL</label>
688
+ <frontend_type>text</frontend_type>
689
+ <config_path>payment/realvault/threed_url</config_path>
690
+ <sort_order>121</sort_order>
691
+ <show_in_default>1</show_in_default>
692
+ <show_in_website>1</show_in_website>
693
+ <show_in_store>0</show_in_store>
694
+ <depends>
695
+ <use_threed_secure>1</use_threed_secure>
696
+ </depends>
697
+ </threed_url>
698
+ <require_liability_shift translate="label">
699
+ <label>Require Liability Shift</label>
700
+ <frontend_type>select</frontend_type>
701
+ <config_path>payment/realvault/require_liability_shift</config_path>
702
+ <source_model>adminhtml/system_config_source_yesno</source_model>
703
+ <sort_order>140</sort_order>
704
+ <show_in_default>1</show_in_default>
705
+ <show_in_website>1</show_in_website>
706
+ <show_in_store>0</show_in_store>
707
+ <depends>
708
+ <use_threed_secure>1</use_threed_secure>
709
+ </depends>
710
+ <comment><![CDATA[By setting this to 'No' more transactions will be allowed, however you are more liable to fraud.]]></comment>
711
+ </require_liability_shift>
712
+ </fields>
713
+ </realvault>
714
+ </groups>
715
+ </realex>
716
+
717
+ </sections>
718
+ </config>
app/code/community/Yoma/Realex/sql/.DS_Store ADDED
Binary file
app/code/community/Yoma/Realex/sql/realex_setup/mysql4-install-0.0.1.php ADDED
@@ -0,0 +1,158 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+
21
+ $installer = $this;
22
+
23
+ $setup = new Mage_Catalog_Model_Resource_Eav_Mysql4_Setup('core_setup');
24
+
25
+ $connection = $setup->getConnection();
26
+
27
+ $installer->startSetup();
28
+
29
+ /* install create realex/transaction table */
30
+ $installer->run("
31
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('realex/transaction')}` (
32
+ `entity_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
33
+ `created_at` datetime NOT NULL,
34
+ `updated_at` datetime NOT NULL,
35
+ `service_code` varchar(255) NOT NULL,
36
+ `transaction_reference` varchar(255) NOT NULL,
37
+ `payment_id` int(10) NOT NULL,
38
+ `order_id` int(10) NOT NULL,
39
+ `additional_information` text,
40
+ `transaction_type` varchar(20) DEFAULT NULL,
41
+ `payment_amount` decimal(12,4) DEFAULT NULL,
42
+ `error_message` text,
43
+ `remembertoken` int(11) DEFAULT NULL,
44
+ PRIMARY KEY (`entity_id`),
45
+ UNIQUE KEY `service_code` (`service_code`,`transaction_reference`),
46
+ KEY `transaction_reference` (`transaction_reference`),
47
+ KEY `payment_id` (`payment_id`),
48
+ KEY `order_id` (`order_id`)
49
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
50
+ ");
51
+
52
+ /* install 1-2 create realex/paymentInfo table */
53
+ $installer->run("
54
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('realex/paymentInfo')}` (
55
+ `entity_id` INT(10) UNSIGNED NOT NULL AUTO_INCREMENT,
56
+ `created_at` DATETIME NOT NULL,
57
+ `updated_at` DATETIME NOT NULL,
58
+ `payment_id` VARCHAR(255) NOT NULL,
59
+ `field` VARCHAR(255) NOT NULL,
60
+ `value` TEXT NOT NULL,
61
+ PRIMARY KEY (`entity_id`),
62
+ INDEX (`payment_id`)
63
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
64
+ ");
65
+
66
+ /* install 2-4 create realex/tokencard table */
67
+ $installer->run("
68
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('realex/tokencard')}` (
69
+ `id` int(10) unsigned NOT NULL auto_increment,
70
+ `customer_id` int(10) unsigned NOT NULL,
71
+ `visitor_session_id` varchar(255),
72
+ `token` varchar(38),
73
+ `status` varchar(15),
74
+ `card_type` varchar(255),
75
+ `last_four` varchar(4),
76
+ `expiry_date` varchar(4),
77
+ `status_detail` varchar(255),
78
+ `is_default` tinyint(1) unsigned NOT NULL default '0',
79
+ `payer_ref` varchar(200),
80
+ `ch_name` varchar(255),
81
+ `magento_card_type` varchar(200),
82
+ `payment_code` varchar(200),
83
+ PRIMARY KEY (`id`)
84
+ ) ENGINE=MYISAM DEFAULT CHARSET=utf8;
85
+ ");
86
+
87
+
88
+ /* install 4-5 create attributes to sales_flat_quote_payment */
89
+ try{
90
+ $connection->addColumn($this->getTable('sales_flat_quote_payment'), 'realex_token_cc_id', 'int(11)');
91
+ $setup->addAttribute('quote_payment', 'remembertoken', array());
92
+
93
+ }catch(Exception $ex){
94
+ mage::logException($ex);
95
+ }
96
+
97
+ try{
98
+ $connection->addColumn($this->getTable('sales_flat_quote_payment'), 'remembertoken', 'int(11)');
99
+ $setup->addAttribute('quote_payment', 'realex_token_cc_id', array());
100
+
101
+ }catch(Exception $ex){
102
+ mage::logException($ex);
103
+ }
104
+
105
+ try{
106
+ $connection->addColumn($this->getTable('sales_flat_order_payment'), 'realex_token_cc_id', 'int(11)');
107
+ $setup->addAttribute('order_payment', 'realex_token_cc_id', array());
108
+
109
+ }catch(Exception $ex){
110
+ mage::logException($ex);
111
+ }
112
+
113
+ try{
114
+ $connection->addColumn($this->getTable('sales_flat_order_payment'), 'remembertoken', 'int(11)');
115
+ $setup->addAttribute('order_payment', 'remembertoken', array());
116
+
117
+ }catch(Exception $ex){
118
+ mage::logException($ex);
119
+ }
120
+
121
+ try{
122
+ $installer->run("
123
+ ALTER TABLE sales_flat_invoice ADD COLUMN settle_positive DECIMAL(12,4) NULL;
124
+ ");
125
+
126
+ $installer->run("
127
+ ALTER TABLE sales_flat_invoice ADD COLUMN base_settle_positive DECIMAL(12,4) NULL;
128
+ ");
129
+
130
+ $installer->run("
131
+ ALTER TABLE sales_flat_creditmemo ADD COLUMN base_rebate_positive DECIMAL(12,4) NULL;
132
+ ALTER TABLE sales_flat_creditmemo ADD COLUMN rebate_positive DECIMAL(12,4) NULL;
133
+ ");
134
+
135
+ }catch(Exception $ex){
136
+ mage::logException($ex);
137
+ }
138
+
139
+ try{
140
+ $setup->addAttribute('customer', 'realex_payer_ref', array(
141
+ 'label' => 'RealVault Payer Reference',
142
+ 'type' => 'varchar',
143
+ 'input' => 'text',
144
+ 'global' => 1,
145
+ 'visible' => 1,
146
+ 'required' => 0,
147
+ 'user_defined' => 0,
148
+ 'default' => '',
149
+ 'visible_on_front' => 0,
150
+ 'source' => NULL,
151
+ 'comment' => 'Realex RealVault Payer Reference',
152
+ 'position' => 9999
153
+ ));
154
+ }catch(Exception $ex){
155
+ mage::logException($ex);
156
+ }
157
+
158
+ $installer->endSetup();
app/code/local/Yoma/RealexRewrite/Helper/Data.php ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <?php
2
+ class Yoma_RealexRewrite_Helper_Data extends Mage_Core_Helper_Abstract {
3
+
4
+ }
app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Creditmemo.php ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Yoma_RealexRewrite_Model_Sales_Order_Creditmemo extends Mage_Sales_Model_Order_Creditmemo{
3
+
4
+ /**
5
+ * Allow refund larger that original payment amount
6
+ *
7
+ * @return $this
8
+ * @throws Exception
9
+ * @throws Mage_Core_Exception
10
+ */
11
+ public function refund()
12
+ {
13
+ $this->setState(self::STATE_REFUNDED);
14
+ $orderRefund = Mage::app()->getStore()->roundPrice(
15
+ $this->getOrder()->getTotalRefunded()+$this->getGrandTotal()
16
+ );
17
+ $baseOrderRefund = Mage::app()->getStore()->roundPrice(
18
+ $this->getOrder()->getBaseTotalRefunded()+$this->getBaseGrandTotal()
19
+ );
20
+
21
+
22
+ $order = $this->getOrder();
23
+
24
+ if(!in_array($order->getPayment()->getMethod(),array('realexdirect','realexredirect','realvault'))) {
25
+
26
+ if ($baseOrderRefund > Mage::app()->getStore()->roundPrice($this->getOrder()->getBaseTotalPaid())) {
27
+
28
+ $baseAvailableRefund = $this->getOrder()->getBaseTotalPaid() - $this->getOrder()->getBaseTotalRefunded();
29
+
30
+ Mage::throwException(
31
+ Mage::helper('sales')->__('Maximum amount available to refund is %s', $this->getOrder()->formatBasePrice($baseAvailableRefund))
32
+ );
33
+ }
34
+ }
35
+
36
+
37
+ $order->setBaseTotalRefunded($baseOrderRefund);
38
+ $order->setTotalRefunded($orderRefund);
39
+
40
+ $order->setBaseSubtotalRefunded($order->getBaseSubtotalRefunded()+$this->getBaseSubtotal());
41
+ $order->setSubtotalRefunded($order->getSubtotalRefunded()+$this->getSubtotal());
42
+
43
+ $order->setBaseTaxRefunded($order->getBaseTaxRefunded()+$this->getBaseTaxAmount());
44
+ $order->setTaxRefunded($order->getTaxRefunded()+$this->getTaxAmount());
45
+ $order->setBaseHiddenTaxRefunded($order->getBaseHiddenTaxRefunded()+$this->getBaseHiddenTaxAmount());
46
+ $order->setHiddenTaxRefunded($order->getHiddenTaxRefunded()+$this->getHiddenTaxAmount());
47
+
48
+ $order->setBaseShippingRefunded($order->getBaseShippingRefunded()+$this->getBaseShippingAmount());
49
+ $order->setShippingRefunded($order->getShippingRefunded()+$this->getShippingAmount());
50
+
51
+ $order->setBaseShippingTaxRefunded($order->getBaseShippingTaxRefunded()+$this->getBaseShippingTaxAmount());
52
+ $order->setShippingTaxRefunded($order->getShippingTaxRefunded()+$this->getShippingTaxAmount());
53
+
54
+ $order->setAdjustmentPositive($order->getAdjustmentPositive()+$this->getAdjustmentPositive());
55
+ $order->setBaseAdjustmentPositive($order->getBaseAdjustmentPositive()+$this->getBaseAdjustmentPositive());
56
+
57
+ $order->setAdjustmentNegative($order->getAdjustmentNegative()+$this->getAdjustmentNegative());
58
+ $order->setBaseAdjustmentNegative($order->getBaseAdjustmentNegative()+$this->getBaseAdjustmentNegative());
59
+
60
+ $order->setDiscountRefunded($order->getDiscountRefunded()+$this->getDiscountAmount());
61
+ $order->setBaseDiscountRefunded($order->getBaseDiscountRefunded()+$this->getBaseDiscountAmount());
62
+
63
+ if ($this->getInvoice()) {
64
+ $this->getInvoice()->setIsUsedForRefund(true);
65
+ $this->getInvoice()->setBaseTotalRefunded(
66
+ $this->getInvoice()->getBaseTotalRefunded() + $this->getBaseGrandTotal()
67
+ );
68
+ $this->setInvoiceId($this->getInvoice()->getId());
69
+ }
70
+
71
+ if (!$this->getPaymentRefundDisallowed()) {
72
+ $order->getPayment()->refund($this);
73
+ }
74
+
75
+ Mage::dispatchEvent('sales_order_creditmemo_refund', array($this->_eventObject=>$this));
76
+ return $this;
77
+ }
78
+
79
+ }
app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Payment.php ADDED
@@ -0,0 +1,35 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Yoma_RealexRewrite_Model_Sales_Order_Payment extends Mage_Sales_Model_Order_Payment{
3
+
4
+ protected $_allowedMethods = array('realexdirect','realvault');
5
+
6
+ /**
7
+ * Lookup an authorization transaction using parent transaction id, if set
8
+ * @return Mage_Sales_Model_Order_Payment_Transaction|false
9
+ */
10
+ public function getAuthorizationTransaction()
11
+ {
12
+ if(in_array($this->getMethodInstance()->getCode(),$this->_allowedMethods)) {
13
+
14
+ if ($this->getParentTransactionId()) {
15
+ $txn = $this->_lookupTransaction($this->getParentTransactionId());
16
+ } else {
17
+ $txn = false;
18
+ }
19
+
20
+ if (!$txn) {
21
+ $txn = $this->_lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_AUTH);
22
+ }
23
+
24
+ if (!$txn) {
25
+ $txn = $this->_lookupTransaction(false, Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE);
26
+ }
27
+
28
+ return $txn;
29
+
30
+ }else{
31
+ return parent::getAuthorizationTransaction();
32
+ }
33
+ }
34
+
35
+ }
app/code/local/Yoma/RealexRewrite/Model/Sales/Order/Payment/Transaction.php ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Yoma_RealexRewrite_Model_Sales_Order_Payment_Transaction extends Mage_Sales_Model_Order_Payment_Transaction {
3
+
4
+ protected $_allowedMethods = array('realexdirect','realvault');
5
+
6
+ public function closeAuthorization($shouldSave = true, $dryRun = false) {
7
+ try {
8
+ $this->_verifyThisTransactionExists();
9
+ } catch (Exception $e) {
10
+ if ($dryRun) {
11
+ return false;
12
+ }
13
+ throw $e;
14
+ }
15
+ $authTransaction = false;
16
+ switch ($this->getTxnType()) {
17
+ case self::TYPE_VOID:
18
+ // break intentionally omitted
19
+ case self::TYPE_CAPTURE:
20
+ $authTransaction = $this->getParentTransaction();
21
+ if(in_array($this->getOrderPaymentObject()->getMethodInstance()->getCode(),$this->_allowedMethods)) {
22
+ $authTransaction = $this->getParentTransaction();
23
+ if(!$authTransaction){
24
+ $authTransaction = $this;
25
+ }
26
+ }
27
+ break;
28
+ case self::TYPE_AUTH:
29
+ $authTransaction = $this;
30
+ break;
31
+ // case self::TYPE_PAYMENT?
32
+ }
33
+ if ($authTransaction) {
34
+ if (!$dryRun) {
35
+ $authTransaction->close($shouldSave);
36
+ }
37
+ }
38
+
39
+ return $authTransaction;
40
+ }
41
+ }
app/code/local/Yoma/RealexRewrite/etc/config.xml ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yoma_RealexRewrite>
5
+ <version>1.1.0</version>
6
+ </Yoma_RealexRewrite>
7
+ </modules>
8
+ <global>
9
+ <models>
10
+ <sales>
11
+ <rewrite>
12
+ <order_payment>Yoma_RealexRewrite_Model_Sales_Order_Payment</order_payment>
13
+ <order_payment_transaction>Yoma_RealexRewrite_Model_Sales_Order_Payment_Transaction</order_payment_transaction>
14
+ <order_creditmemo>Yoma_RealexRewrite_Model_Sales_Order_Creditmemo</order_creditmemo>
15
+ </rewrite>
16
+ </sales>
17
+ </models>
18
+ <!--
19
+ <blocks>
20
+ <adminhtml>
21
+ <rewrite>
22
+ <sales_order_invoice_totals>Yoma_RealexRewrite_Block_Adminhtml_Sales_Order_Invoice_Settle</sales_order_invoice_totals>
23
+ <sales_order_creditmemo_totals>Yoma_RealexRewrite_Block_Adminhtml_Sales_Order_Creditmemo_Rebate</sales_order_creditmemo_totals>
24
+ </rewrite>
25
+ </adminhtml>
26
+ </blocks>
27
+ -->
28
+ <helpers>
29
+ <realexRewrite>
30
+ <class>Yoma_RealexRewrite_Helper</class>
31
+ </realexRewrite>
32
+ </helpers>
33
+ </global>
34
+ </config>
app/design/adminhtml/default/default/layout/realex/realex.xml ADDED
@@ -0,0 +1,77 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout>
3
+ <default>
4
+ <reference name="notifications">
5
+ <block type="realex/adminhtml_notifications" name="realex_notifications" template="realex/notifications.phtml"/>
6
+ </reference>
7
+ </default>
8
+ <realex_adminhtml_log_index>
9
+ <reference name="head">
10
+ <action method="addItem">
11
+ <type>skin_css</type>
12
+ <name>realex/css/realex.css</name>
13
+ </action>
14
+ <action method="addItem">
15
+ <type>skin_js</type>
16
+ <name>realex/js/realex.js</name>
17
+ </action>
18
+ </reference>
19
+ <reference name="content">
20
+ <block type="realex/adminhtml_sales_realex_logs"
21
+ name="realex.logs"
22
+ template="realex/sales/realex/logs.phtml">
23
+ </block>
24
+ </reference>
25
+ </realex_adminhtml_log_index>
26
+ <realex_adminhtml_tokencard_index>
27
+ <reference name="content">
28
+ <block type="realex/adminhtml_tokencard" name="tokencard" />
29
+ </reference>
30
+ </realex_adminhtml_tokencard_index>
31
+
32
+ <realex_adminhtml_transaction_index>
33
+ <reference name="content">
34
+ <block type="realex/adminhtml_transaction" name="transaction.grid.container" />
35
+ </reference>
36
+ </realex_adminhtml_transaction_index>
37
+
38
+ <realex_adminhtml_transaction_grid>
39
+ <block type="realex/adminhtml_transaction_grid" name="transaction.grid" output="toHtml"></block>
40
+ </realex_adminhtml_transaction_grid>
41
+ <realex_adminhtml_transaction_view>
42
+ <reference name="content">
43
+ <block type="realex/adminhtml_transaction_detail" name="transaction.detail" template="realex/sales/transaction/detail.phtml">
44
+ <block type="realex/adminhtml_transaction_detail_grid" name="transaction.detail.grid" as="detail_grid"/>
45
+ </block>
46
+ </reference>
47
+ </realex_adminhtml_transaction_view>
48
+
49
+ <adminhtml_customer_edit>
50
+ <reference name="customer_edit_tabs">
51
+ <action method="addTab">
52
+ <name>my_saved_cards</name>
53
+ <block>realex/adminhtml_customer_tab</block>
54
+ </action>
55
+ </reference>
56
+ </adminhtml_customer_edit>
57
+ <adminhtml_sales_order_invoice_new>
58
+ <reference name="head">
59
+ <action method="addJs"><script>realex/invoice.js</script></action>
60
+ </reference>
61
+ <reference name="invoice_totals">
62
+ <block type="realex/adminhtml_sales_order_invoice_Settle" name="adjustment_settle" template="realex/sales/order/invoice/totals/settle.phtml" />
63
+ </reference>
64
+ </adminhtml_sales_order_invoice_new>
65
+ <adminhtml_sales_order_invoice_view>
66
+ <reference name="invoice_totals">
67
+ <block type="realex/adminhtml_sales_order_invoice_Settle" name="adjustment_settle" template="realex/sales/order/invoice/totals/settled.phtml" />
68
+ </reference>
69
+ </adminhtml_sales_order_invoice_view>
70
+ <!--
71
+ <adminhtml_sales_order_creditmemo_new>
72
+ <reference name="creditmemo_totals">
73
+ <block type="realex/adminhtml_sales_order_creditmemo_rebate" name="adjustment_rebate" template="realex/sales/order/creditmemo/totals/rebate.phtml"/>
74
+ </reference>
75
+ </adminhtml_sales_order_creditmemo_new>
76
+ -->
77
+ </layout>
app/design/adminhtml/default/default/template/realex/customer/tab.phtml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Custom tab template
4
+ */
5
+ ?>
6
+ <div class="input-field">
7
+ <label for="custom_field">Custom Field</label>
8
+ <input type="text" class="input-text" name="custom_field" id="custom_field" />
9
+ </div>
app/design/adminhtml/default/default/template/realex/notifications.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <?php if ($message = $this->getMessage()) : ?>
2
+ <div class="notification-global"><?php echo $message ?></div>
3
+ <?php endif; ?>
app/design/adminhtml/default/default/template/realex/payment/info/payment-info.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php $paymentInfo = $this->getPaymentInfo(); ?>
2
+ <?php if (count($paymentInfo) > 0): ?>
3
+ <fieldset>
4
+ <?php foreach ($paymentInfo as $_label => $_value): ?>
5
+ <div class="realex_payment_info_item">
6
+ <h5><?php echo $this->__($_label); ?></h5>
7
+ <?php if (is_array($_value)): ?>
8
+ <table cellspacing="5">
9
+ <tbody>
10
+ <?php foreach ($_value as $__key => $__value): ?>
11
+ <tr>
12
+ <td><?php echo $__key; ?>:</td>
13
+ <td><?php echo $__value; ?></td>
14
+ </tr>
15
+ <?php endforeach; ?>
16
+ </tbody>
17
+ </table>
18
+ <?php else: ?>
19
+ <?php echo $_value; ?>
20
+ <?php endif; ?>
21
+ </div>
22
+ <?php endforeach; ?>
23
+ </fieldset>
24
+ <?php endif; ?>
app/design/adminhtml/default/default/template/realex/sales/order/creditmemo/totals/rebate.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <tr>
2
+ <td class="label"><?php echo $this->helper('realex')->__('Adjustment Rebate Amount') ?></td>
3
+ <td><input type="text" name="creditmemo[rebate_positive]" value="" class="input-text not-negative-amount" style="width:60px;text-align:right" id="rebate_positive"/></td>
4
+ </tr>
app/design/adminhtml/default/default/template/realex/sales/order/invoice/totals/settle.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <tr>
2
+ <td class="label"><?php echo $this->helper('realex')->__('Settle Amount') ?>&nbsp;<input id="settle-check" type="checkbox" name="settle" value="0"></td>
3
+ <td><input id="settle-amount" type="text" name="invoice[settle_positive]" value="" disabled="disabled" class="input-text not-negative-amount" style="width:60px;text-align:right;background-color: #AAAAAA" id="settle_positive"/></td>
4
+ </tr>
app/design/adminhtml/default/default/template/realex/sales/order/invoice/totals/settled.phtml ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ <tr>
2
+ <td class="label"><?php echo $this->helper('realex')->__('Settle Amount') ?></td>
3
+ <td><span class="price"><?php echo Mage::helper('core')->formatPrice($this->getSettleAmount(), true);?></span></td>
4
+ </tr>
app/design/adminhtml/default/default/template/realex/sales/realex/logs.phtml ADDED
@@ -0,0 +1,7 @@
 
 
 
 
 
 
 
1
+ <div id="realex-log-view-cont">
2
+ <?php echo $this->getLogFilesSelect(); ?>
3
+
4
+ <iframe id="realex-log-view" src="<?php echo $this->getTailUrl(); ?>">
5
+ <p><?php echo $this->__('Your browser does not support iframes.'); ?></p>
6
+ </iframe>
7
+ </div>
app/design/adminhtml/default/default/template/realex/sales/transaction/detail.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ <div class="content-header">
3
+ <table cellspacing="0">
4
+ <tr>
5
+ <td style="<?php echo $this->getHeaderWidth() ?>"><?php echo $this->getHeaderHtml() ?></td>
6
+ <td class="form-buttons"><?php echo $this->getButtonsHtml() ?></td>
7
+ </tr>
8
+ </table>
9
+ </div>
10
+
11
+ <div class="entry-edit">
12
+ <div class="entry-edit">
13
+ <div class="entry-edit-head">
14
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Transaction Data'); ?></h4>
15
+ </div>
16
+ <div id="log_details_fieldset" class="log-details">
17
+ <table cellspacing="0" class="log-info table">
18
+ <col width="25%" />
19
+ <col />
20
+ <tbody>
21
+ <tr>
22
+ <th><?php echo $this->__('Transaction ID'); ?></th>
23
+ <td><?php echo $this->getTxnIdHtml() ?></td>
24
+ </tr>
25
+ <tr>
26
+ <th><?php echo $this->__('Order ID'); ?></th>
27
+ <td>
28
+ <a href="<?php echo $this->getOrderIdUrlHtml(); ?>">
29
+ <?php echo $this->getOrderIncrementIdHtml() ?>
30
+ </a>
31
+ </td>
32
+ </tr>
33
+ <tr>
34
+ <th><?php echo $this->__('Transaction Type'); ?></th>
35
+ <td><?php echo $this->getTxnTypeHtml() ?></td>
36
+ </tr>
37
+ <tr>
38
+ <th><?php echo $this->__('Created At'); ?></th>
39
+ <td><?php echo $this->getCreatedAtHtml(); ?></td>
40
+ </tr>
41
+ </tbody>
42
+ </table>
43
+ </div>
44
+ </div>
45
+ </div>
46
+
47
+ <div class="entry-edit">
48
+ <div class="entry-edit">
49
+ <div class="entry-edit-head">
50
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->__('Transaction Details'); ?></h4>
51
+ </div>
52
+ <div class="log-details-grid">
53
+ <?php echo $this->getChildHtml('detail_grid') ?>
54
+ </div>
55
+ </div>
56
+ </div>
app/design/frontend/base/default/layout/realex/realex.xml ADDED
@@ -0,0 +1,211 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <layout version="0.1.0">
3
+ <default>
4
+ <reference name="head">
5
+ <action method="addJs"><script>realex/validation.js</script></action>
6
+ </reference>
7
+ </default>
8
+
9
+ <checkout_onepage_index>
10
+ <reference name="head">
11
+ <action method="addItem">
12
+ <type>skin_css</type>
13
+ <name>realex/css/realex.css</name>
14
+ </action>
15
+ <action method="addItem">
16
+ <type>skin_js</type>
17
+ <name>realex/js/realex.js</name>
18
+ </action>
19
+ <action method="addItem">
20
+ <type>js</type>
21
+ <name>realex/livepipe/livepipe.js</name>
22
+ </action>
23
+ <action method="addItem">
24
+ <type>js</type>
25
+ <name>realex/livepipe/window.js</name>
26
+ </action>
27
+ <action method="addItem">
28
+ <type>skin_js</type>
29
+ <name>realex/js/checkout.js</name>
30
+ </action>
31
+ </reference>
32
+ <reference name="content">
33
+ <block type="realex/config" name="realex_config"/>
34
+ </reference>
35
+ </checkout_onepage_index>
36
+
37
+ <onestepcheckout_index_index>
38
+ <reference name="head">
39
+ <action method="addItem">
40
+ <type>skin_css</type>
41
+ <name>realex/css/realex.css</name>
42
+ </action>
43
+ <action method="addItem">
44
+ <type>skin_js</type>
45
+ <name>realex/js/realex.js</name>
46
+ </action>
47
+ <action method="addItem">
48
+ <type>js</type>
49
+ <name>realex/livepipe/livepipe.js</name>
50
+ </action>
51
+ <action method="addItem">
52
+ <type>js</type>
53
+ <name>realex/livepipe/window.js</name>
54
+ </action>
55
+ <action method="addItem">
56
+ <type>skin_js</type>
57
+ <name>realex/js/checkout.js</name>
58
+ </action>
59
+ </reference>
60
+ <reference name="content">
61
+ <block type="realex/config" name="realex_config"/>
62
+ </reference>
63
+ </onestepcheckout_index_index>
64
+
65
+ <checkout_multishipping_billing>
66
+ <reference name="head">
67
+ <action method="addItem">
68
+ <type>skin_css</type>
69
+ <name>realex/css/realex.css</name>
70
+ </action>
71
+ <action method="addItem">
72
+ <type>skin_js</type>
73
+ <name>realex/js/realex.js</name>
74
+ </action>
75
+ <action method="addItem">
76
+ <type>skin_js</type>
77
+ <name>realex/js/checkout.js</name>
78
+ </action>
79
+ </reference>
80
+ </checkout_multishipping_billing>
81
+
82
+ <realex_redirect_form>
83
+ <reference name="content">
84
+ <block type="realex/redirect_form" name="realex_redirect_form"></block>
85
+ </reference>
86
+ </realex_redirect_form>
87
+
88
+ <realex_redirect_iframe>
89
+ <reference name="head">
90
+ <action method="addItem">
91
+ <type>js</type>
92
+ <name>realex/livepipe/livepipe.js</name>
93
+ </action>
94
+ <action method="addItem">
95
+ <type>js</type>
96
+ <name>realex/livepipe/window.js</name>
97
+ </action>
98
+ <action method="addItem">
99
+ <type>skin_css</type>
100
+ <name>realex/css/realex.css</name>
101
+ </action>
102
+ <action method="addItem">
103
+ <type>skin_js</type>
104
+ <name>realex/js/iframe.js</name>
105
+ </action>
106
+ </reference>
107
+ <reference name="content">
108
+ <block type="realex/redirect_frame" name="realex_redirect_frame"></block>
109
+ </reference>
110
+ </realex_redirect_iframe>
111
+
112
+ <realex_direct_iframe>
113
+ <reference name="head">
114
+ <action method="addItem">
115
+ <type>js</type>
116
+ <name>realex/livepipe/livepipe.js</name>
117
+ </action>
118
+ <action method="addItem">
119
+ <type>js</type>
120
+ <name>realex/livepipe/window.js</name>
121
+ </action>
122
+ <action method="addItem">
123
+ <type>skin_css</type>
124
+ <name>realex/css/realex.css</name>
125
+ </action>
126
+ <action method="addItem">
127
+ <type>skin_js</type>
128
+ <name>realex/js/iframe.js</name>
129
+ </action>
130
+ </reference>
131
+ <reference name="content">
132
+ <block type="realex/direct_frame" name="realex_direct_frame"></block>
133
+ </reference>
134
+ </realex_direct_iframe>
135
+
136
+ <realex_token_iframe>
137
+ <reference name="head">
138
+ <action method="addItem">
139
+ <type>js</type>
140
+ <name>realex/livepipe/livepipe.js</name>
141
+ </action>
142
+ <action method="addItem">
143
+ <type>js</type>
144
+ <name>realex/livepipe/window.js</name>
145
+ </action>
146
+ <action method="addItem">
147
+ <type>skin_css</type>
148
+ <name>realex/css/realex.css</name>
149
+ </action>
150
+ <action method="addItem">
151
+ <type>skin_js</type>
152
+ <name>realex/js/iframe.js</name>
153
+ </action>
154
+ </reference>
155
+ <reference name="content">
156
+ <block type="realex/direct_frame" name="realex_direct_frame"></block>
157
+ </reference>
158
+ </realex_token_iframe>
159
+
160
+ <customer_account>
161
+ <reference name="customer_account_navigation">
162
+ <action method="addLink" ifconfig="payment/realvault/active" translate="label" module="realex">
163
+ <name>realexcards</name>
164
+ <path>realex/cards/</path>
165
+ <label>My Stored Cards</label>
166
+ </action>
167
+ </reference>
168
+ </customer_account>
169
+
170
+ <realex_cards_index translate="label">
171
+ <label>Customer My Account Realex Cards</label>
172
+ <update handle="customer_account"/>
173
+ <reference name="head">
174
+ <action method="addItem">
175
+ <type>skin_js</type>
176
+ <name>realex/js/customer.js</name>
177
+ </action>
178
+ </reference>
179
+ <reference name="my.account.wrapper">
180
+ <block type="realex/customer_account_cards" name="realexcards" template="realex/customer/cards.phtml" />
181
+ <block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
182
+ </reference>
183
+ </realex_cards_index>
184
+
185
+ <realex_cards_edit translate="label">
186
+ <label>Edit My Cards</label>
187
+ <update handle="customer_account"/>
188
+ <reference name="head">
189
+ <action method="addItem">
190
+ <type>skin_js</type>
191
+ <name>realex/js/customer.js</name>
192
+ </action>
193
+ </reference>
194
+ <reference name="my.account.wrapper">
195
+ <block type="realex/customer_account_cards_edit" name="realexedit" template="realex/customer/cards/edit.phtml" />
196
+ <block type="customer/account_dashboard" name="customer.account.link.back" template="customer/account/link/back.phtml"/>
197
+ </reference>
198
+ </realex_cards_edit>
199
+
200
+ <checkout_onepage_success translate="label">
201
+ <label>One Page Checkout Success</label>
202
+ <reference name="root">
203
+ <action method="setTemplate"><template>page/2columns-right.phtml</template></action>
204
+ </reference>
205
+ <reference name="content">
206
+ <reference name="checkout.success">
207
+ <action method="setTemplate"><template>realex/onepage/success.phtml</template></action>
208
+ </reference>
209
+ </reference>
210
+ </checkout_onepage_success>
211
+ </layout>
app/design/frontend/base/default/template/realex/customer/cards.phtml ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $cards = $this->getCustomerCards(); ?>
23
+ <div class="page-title">
24
+ <h1>My Stored Cards</h1>
25
+ </div>
26
+ <?php echo $this->getMessagesBlock()->getGroupedHtml(); ?>
27
+ <table class="data-table" id="realex-card-table">
28
+ <thead>
29
+ <tr>
30
+ <th><?php echo $this->helper('realex')->__('Type') ?></th>
31
+ <th><?php echo $this->helper('realex')->__('Number') ?></th>
32
+ <th><?php echo $this->helper('realex')->__('Exp. Date') ?></th>
33
+ <th class="a-center"><?php echo $this->helper('realex')->__('Default') ?></th>
34
+ <th class="a-center" colspan="2"><?php echo $this->helper('realex')->__('Actions') ?></th>
35
+ </tr>
36
+ </thead>
37
+
38
+ <tbody>
39
+ <?php if($cards->getSize()): ?>
40
+ <?php foreach($cards as $card): ?>
41
+ <tr>
42
+ <td><?php echo $this->getCcTypeName($card->getMagentoCardType(),$card->getPaymentCode()); ?></td>
43
+ <td><?php echo $card->getCcNumber(); ?></td>
44
+ <td><?php echo $card->getExpireDate(); ?></td>
45
+ <td class="a-center">
46
+ <input onclick="setDefault(this);" type="radio" name="tokencard_def" value="<?php echo $card->getId(); ?>"<?php if($card->checkCardDefault()): ?> checked="checked"<?php endif; ?> />
47
+ </td>
48
+ <td class="a-center">
49
+ <a href="<?php echo $this->getUrl('realex/cards/edit/', array('card'=>$card->getId())) ?>"><?php echo $this->helper('realex')->__('Edit') ?></a>
50
+ </td>
51
+ <td class="a-center">
52
+ <?php if($this->canDeleteCards()):?>
53
+ <a onclick="if(confirm('<?php echo $this->helper('realex')->__('Are you sure?'); ?>')){removeCard(this); return false; }else{return false;}" href="<?php echo $this->getUrl('realex/cards/delete/', array('card'=>$card->getId())) ?>"><?php echo $this->helper('realex')->__('Remove') ?></a>
54
+ <?php endif; ?>
55
+ </td>
56
+ </tr>
57
+ <?php endforeach; ?>
58
+ <?php else: ?>
59
+ <tr>
60
+ <td colspan="5" class="a-center"><p><?php echo $this->helper('realex')->__('You have no cards yet.') ?></p></td>
61
+ </tr>
62
+ <?php endif; ?>
63
+ </tbody>
64
+ </table>
65
+
66
+ <script type="text/javascript">decorateTable('realex-card-table');</script>
app/design/frontend/base/default/template/realex/customer/cards/edit.phtml ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $card = $this->getCustomerCard();
23
+ $_code = 'realvault';
24
+ ?>
25
+ <div class="page-title">
26
+ <h1>Edit My Stored Cards</h1>
27
+ </div>
28
+ <form id="frmRegCard" action="<?php echo $this->getUrl('realex/cards/edit', array('card'=>$card->getId())); ?>" method="post">
29
+
30
+ <ul class="form-list sp-methods" id="payment_form_<?php echo $_code ?>">
31
+ <li>
32
+ <label for="<?php echo $_code ?>_name" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
33
+ <div class="input-box">
34
+ <input type="text" name="card_name" id="<?php echo $_code ?>_name" class="input-text required-entry" value="<?php echo $card->getChName(); ?>"/>
35
+ </div>
36
+ </li>
37
+
38
+ <li>
39
+ <label for="<?php echo $_code ?>_expiration" class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
40
+ <div class="input-box">
41
+ <div class="v-fix">
42
+ <select id="<?php echo $_code ?>_expiration" class="month required-entry" name="card_month">
43
+ <?php echo $this->getMonthOptions(); ?>
44
+ </select>
45
+ </div>
46
+ <div class="v-fix">
47
+ <select id="<?php echo $_code ?>_expiration_year" class="year required-entry" name="card_year">
48
+ <?php echo $this->getYearOptions(); ?>
49
+ </select>
50
+ </div>
51
+ </div>
52
+ </li>
53
+
54
+ <li id="<?php echo $_code ?>_cc_post">
55
+ <div class="input-box">
56
+ <div class="v-fix">
57
+ <button type="submit" class="button" title="<?php echo $this->__('Update Card'); ?>">
58
+ <span>
59
+ <span>
60
+ <?php echo $this->__('Update Card'); ?>
61
+ </span>
62
+ </span>
63
+ </button>
64
+ </div>
65
+ </div>
66
+ </li>
67
+ </ul>
68
+
69
+ </form>
app/design/frontend/base/default/template/realex/onepage/success.phtml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+
22
+ <div class="page-title">
23
+ <h1><?php echo $this->__('Your order has been received.') ?></h1>
24
+ </div>
25
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
26
+ <h2 class="sub-title"><?php echo $this->__('Thank you for your purchase!') ?></h2>
27
+
28
+ <?php if ($this->getOrderId()):?>
29
+ <?php if ($this->getCanViewOrder()) :?>
30
+ <p><?php echo $this->__('Your order # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getViewOrderUrl()), $this->escapeHtml($this->getOrderId()))) ?></p>
31
+ <?php else :?>
32
+ <p><?php echo $this->__('Your order # is: %s.', $this->escapeHtml($this->getOrderId())) ?></p>
33
+ <?php endif;?>
34
+ <p><?php echo $this->__('You will receive an order confirmation email with details of your order and a link to track its progress.') ?></p>
35
+ <?php if($this->getRememberToken($this->getOrderId())):?>
36
+ <p>Card details successfully and securely stored.</p>
37
+ <?php endif; ?>
38
+ <?php if ($this->getCanViewOrder() && $this->getCanPrintOrder()) :?>
39
+ <p>
40
+ <?php echo $this->__('Click <a href="%s" onclick="this.target=\'_blank\'">here to print</a> a copy of your order confirmation.', $this->getPrintUrl()) ?>
41
+ <?php echo $this->getChildHtml() ?>
42
+ </p>
43
+ <?php endif;?>
44
+ <?php endif;?>
45
+
46
+ <?php if ($this->getAgreementRefId()): ?>
47
+ <p><?php echo $this->__('Your billing agreement # is: %s.', sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getAgreementUrl()), $this->escapeHtml($this->getAgreementRefId())))?></p>
48
+ <?php endif;?>
49
+
50
+ <?php if ($profiles = $this->getRecurringProfiles()):?>
51
+ <p><?php echo $this->__('Your recurring payment profiles:'); ?></p>
52
+ <ul class="disc">
53
+ <?php foreach($profiles as $profile):?>
54
+ <?php $profileIdHtml = ($this->getCanViewProfiles() ? sprintf('<a href="%s">%s</a>', $this->escapeHtml($this->getProfileUrl($profile)), $this->escapeHtml($this->getObjectData($profile, 'reference_id'))) : $this->escapeHtml($this->getObjectData($profile, 'reference_id')));?>
55
+ <li><?php echo $this->__('Payment profile # %s: "%s".', $profileIdHtml, $this->escapeHtml($this->getObjectData($profile, 'schedule_description')))?></li>
56
+ <?php endforeach;?>
57
+ </ul>
58
+ <?php endif;?>
59
+
60
+ <div class="buttons-set">
61
+ <button type="button" class="button" title="<?php echo $this->__('Continue Shopping') ?>" onclick="window.location='<?php echo $this->getUrl() ?>'"><span><span><?php echo $this->__('Continue Shopping') ?></span></span></button>
62
+ </div>
app/design/frontend/base/default/template/realex/payment/config.phtml ADDED
@@ -0,0 +1,3 @@
 
 
 
1
+ <script>
2
+ var realexConfig = JSON.parse('<?php echo json_encode($this->getConfig()) ?>');
3
+ </script>
app/design/frontend/base/default/template/realex/payment/direct/form.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <!DOCTYPE html>
22
+ <html>
23
+ <head>
24
+ <meta charset="UTF-8" content="IE=edge" http-equiv="X-UA-Compatible">
25
+ <meta charset="UTF-8" content="IE=9" http-equiv="X-UA-Compatible">
26
+ <meta charset="UTF-8" content="IE=8" http-equiv="X-UA-Compatible">
27
+ </head>
28
+ <body>
29
+ <div>
30
+ <?php $data = $this->getMessageData()?>
31
+ <?php $redirectUrl = $this->getTermUrl();?>
32
+ <?php if ($redirectUrl != ''):?>
33
+ <form action="<?php echo $redirectUrl; ?>" name="realexform" id="realexform" method="POST" style="width:100%; text-align:center;">
34
+ <?php foreach ($data as $_fieldName => $_value): ?>
35
+ <input type="hidden" name="<?php echo $_fieldName; ?>" value="<?php echo $_value ?>" >
36
+ <?php endforeach; ?>
37
+ <input type="submit" value="<?php echo $this->__('Please click here if you are not automatically redirected after a few seconds...'); ?>" >
38
+ </form>
39
+ <script type="text/javascript">
40
+ function postTransaction() {
41
+ document.realexform.submit();
42
+ }
43
+ if (window.addEventListener) {
44
+ window.addEventListener('load', postTransaction, false);
45
+ }else if (window.attachEvent){
46
+ window.attachEvent('onload', postTransaction);
47
+ }else {
48
+ window.onload = postTransaction;
49
+ }
50
+ </script>
51
+ <?php else: ?>
52
+ <p><?php echo $this->__($this->getNoRedirectUrlMessage()) ?></p>
53
+ <?php endif; ?>
54
+ </div>
55
+ </body></html>
app/design/frontend/base/default/template/realex/payment/direct/frame.phtml ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $iframeSize = $this->getIframeSize();
23
+ ?>
24
+ <script>
25
+ var realexIframe = new Iframe(
26
+ '<?php echo $this->getFailUrl() ?>',
27
+ '<?php echo $this->getRedirectUrl() ?>',
28
+ '<?php echo Mage::helper("core/url")->getCurrentUrl() ?>',
29
+ '<?php echo $iframeSize[0] ?>',
30
+ '<?php echo $iframeSize[1] ?>'
31
+ );
32
+ realexIframe.show();
33
+ </script>
app/design/frontend/base/default/template/realex/payment/form/direct.phtml ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+ $tokenCards = $this->getTokenCards();
24
+ $cTokens = ($tokenCards->getSize()>0 && $this->canUseToken());
25
+ $realexStyle = ($cTokens ? ' style=""' : '');
26
+ $realexValidation = ($cTokens ? ' realex-required-entry ' : ' realex-required-entry ');
27
+ ?>
28
+
29
+ <ul class="form-list paymentrealex" id="payment_form_<?php echo $_code ?>" style="display:none;">
30
+
31
+ <li<?php echo $realexStyle; ?>>
32
+ <label for="<?php echo $_code ?>_cc_owner" class="required"><em>*</em><?php echo $this->__('Name on Card') ?></label>
33
+ <div class="input-box">
34
+ <input type="text" title="<?php echo $this->__('Name on Card') ?>" class="input-text required-entry" id="<?php echo $_code ?>_cc_owner" name="payment[cc_owner]" value="<?php echo $this->htmlEscape($this->getInfoData('cc_owner')) ?>" />
35
+ </div>
36
+ </li>
37
+ <li<?php echo $realexStyle; ?>>
38
+ <label for="<?php echo $_code ?>_cc_type"
39
+ class="required"><em>*</em><?php echo $this->__('Card Type') ?></label>
40
+
41
+ <div class="input-box">
42
+ <select id="<?php echo $_code ?>_cc_type" name="payment[cc_type]"
43
+ class="required-entry validate-cc-type-select">
44
+ <option value=""><?php echo $this->__('--Please Select--') ?></option>
45
+ <?php $_ccType = $this->getInfoData('cc_type') ?>
46
+ <?php foreach ($this->getCcAvailableTypes() as $_typeCode => $_typeName): ?>
47
+ <option
48
+ value="<?php echo $_typeCode ?>"<?php if ($_typeCode == $_ccType): ?> selected="selected"<?php endif ?>><?php echo $_typeName ?></option>
49
+ <?php endforeach ?>
50
+ </select>
51
+ </div>
52
+ </li>
53
+ <li<?php echo $realexStyle; ?>>
54
+ <label for="<?php echo $_code ?>_cc_number"
55
+ class="required"><em>*</em><?php echo $this->__('Card Number') ?></label>
56
+
57
+ <div class="input-box">
58
+ <input type="text" id="<?php echo $_code ?>_cc_number" name="payment[cc_number]"
59
+ title="<?php echo $this->__('Card Number') ?>"
60
+ class="input-text validate-cc-number validate-cc-type" value=""/>
61
+ </div>
62
+ </li>
63
+ <li id="<?php echo $_code ?>_cc_type_exp_div"<?php echo $realexStyle; ?>>
64
+ <label for="<?php echo $_code ?>_expiration"
65
+ class="required"><em>*</em><?php echo $this->__('Expiration Date') ?></label>
66
+
67
+ <div class="input-box">
68
+ <div class="v-fix">
69
+ <select id="<?php echo $_code ?>_expiration" name="payment[cc_exp_month]"
70
+ class="month validate-cc-exp required-entry">
71
+ <?php $_ccExpMonth = $this->getInfoData('cc_exp_month') ?>
72
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
73
+ <option
74
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpMonth): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
75
+ <?php endforeach ?>
76
+ </select>
77
+ </div>
78
+ <div class="v-fix">
79
+ <?php $_ccExpYear = $this->getInfoData('cc_exp_year') ?>
80
+ <select id="<?php echo $_code ?>_expiration_yr" name="payment[cc_exp_year]"
81
+ class="year required-entry">
82
+ <?php foreach ($this->getCcYears() as $k => $v): ?>
83
+ <option
84
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $_ccExpYear): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
85
+ <?php endforeach ?>
86
+ </select>
87
+ </div>
88
+ </div>
89
+ </li>
90
+ <?php //echo $this->getChildHtml() ?>
91
+ <?php if ($this->hasVerification()): ?>
92
+ <li id="<?php echo $_code ?>_cc_type_cvv_div"<?php echo $realexStyle; ?>>
93
+ <label for="<?php echo $_code ?>_cc_cid"
94
+ class="required"><em>*</em><?php echo $this->__('Security Code') ?></label>
95
+
96
+ <div class="input-box">
97
+ <div class="v-fix">
98
+ <input type="text" title="<?php echo $this->__('Card Verification Number') ?>"
99
+ class="input-text cvv required-entry validate-cc-cvn" id="<?php echo $_code ?>_cc_cid"
100
+ name="payment[cc_cid]" value=""/>
101
+ </div>
102
+ <a href="#" class="cvv-what-is-this"><?php echo $this->__('What is this?') ?></a>
103
+ </div>
104
+ </li>
105
+ <?php endif; ?>
106
+ <?php if($this->canUseToken() && $this->canAddToken($tokenCards)): ?>
107
+
108
+ <?php if($this->alwaysSave()): ?>
109
+ <li<?php echo $realexStyle; ?>>
110
+ <label for="<?php echo $_code ?>_remembertoken-<?php echo $_code; ?>"><?php echo mage::helper('realex')->getConfigData('realvault','auto_store_label'); ?></label>
111
+ <input type="hidden" name="payment[remembertoken]" value="1" id="<?php echo $_code ?>_remembertoken" />
112
+ </li>
113
+ <?php else: ?>
114
+ <li<?php echo $realexStyle; ?>>
115
+ <label for="<?php echo $_code ?>_remembertoken-<?php echo $_code; ?>"><?php echo mage::helper('realex')->getConfigData('realvault','store_label'); ?></label>&nbsp;
116
+ <input checked="checked" type="checkbox" name="payment[remembertoken]" value="1" id="<?php echo $_code ?>_remembertoken" />
117
+ </li>
118
+ <?php endif; ?>
119
+
120
+ <?php endif; ?>
121
+ <?php if ($this->hasSsCardType()): ?>
122
+ <li id="<?php echo $_code ?>_cc_type_ss_div"<?php echo $realexStyle; ?>>
123
+ <ul class="inner-form">
124
+ <li class="form-alt"><label for="<?php echo $_code ?>_cc_issue"
125
+ class="required"><em>*</em><?php echo $this->__('Switch/Solo/Maestro Only') ?>
126
+ </label></li>
127
+ <li>
128
+ <label for="<?php echo $_code ?>_cc_issue"><?php echo $this->__('Issue Number') ?>:</label>
129
+ <span class="input-box">
130
+ <input type="text" title="<?php echo $this->__('Issue Number') ?>"
131
+ class="input-text validate-cc-ukss cvv" id="<?php echo $_code ?>_cc_issue"
132
+ name="payment[cc_ss_issue]" value=""/>
133
+ </span>
134
+ </li>
135
+
136
+ <li>
137
+ <label for="<?php echo $_code ?>_start_month"><?php echo $this->__('Start Date') ?>:</label>
138
+
139
+ <div class="input-box">
140
+ <div class="v-fix">
141
+ <select id="<?php echo $_code ?>_start_month" name="payment[cc_ss_start_month]"
142
+ class="validate-cc-ukss month">
143
+ <?php foreach ($this->getCcMonths() as $k => $v): ?>
144
+ <option
145
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData('cc_ss_start_month')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
146
+ <?php endforeach ?>
147
+ </select>
148
+ </div>
149
+ <div class="v-fix">
150
+ <select id="<?php echo $_code ?>_start_year" name="payment[cc_ss_start_year]"
151
+ class="validate-cc-ukss year">
152
+ <?php foreach ($this->getSsStartYears() as $k => $v): ?>
153
+ <option
154
+ value="<?php echo $k ? $k : '' ?>"<?php if ($k == $this->getInfoData('cc_ss_start_year')): ?> selected="selected"<?php endif ?>><?php echo $v ?></option>
155
+ <?php endforeach ?>
156
+ </select>
157
+ </div>
158
+ </div>
159
+ </li>
160
+ <li class="adv-container">&nbsp;</li>
161
+ </ul>
162
+ <script type="text/javascript">
163
+ //<![CDATA[
164
+ var SSChecked<?php echo $_code ?> = function () {
165
+ var elm = $('<?php echo $_code ?>_cc_type');
166
+ if (['SS', 'SM', 'SO'].indexOf(elm.value) != -1) {
167
+ $('<?php echo $_code ?>_cc_type_ss_div').show();
168
+ } else {
169
+ $('<?php echo $_code ?>_cc_type_ss_div').hide();
170
+ }
171
+ };
172
+
173
+ Event.observe($('<?php echo $_code ?>_cc_type'), 'change', SSChecked<?php echo $_code ?>);
174
+ SSChecked<?php echo $_code ?>();
175
+ //]]>
176
+ </script>
177
+ </li>
178
+ <?php endif; ?>
179
+ </ul>
app/design/frontend/base/default/template/realex/payment/form/redirect.phtml ADDED
@@ -0,0 +1,49 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $_code = $this->getMethodCode();
23
+
24
+ $tokenCards = $this->getTokenCards();
25
+ $cTokens = ($tokenCards->getSize()>0 && $this->canUseToken());
26
+ $realexStyle = ($cTokens ? ' style=""' : '');
27
+ $realexValidation = ($cTokens ? ' realex-required-entry ' : ' realex-required-entry ');
28
+ ?>
29
+
30
+ <ul class="form-list paymentrealex" id="payment_form_<?php echo $_code ?>" style="display:none;">
31
+
32
+ <?php if($this->canUseToken() && $this->canAddToken($tokenCards)): ?>
33
+
34
+ <?php if($this->alwaysSave()): ?>
35
+ <li<?php echo $realexStyle; ?>>
36
+ <label for="remembertoken-<?php echo $_code; ?>"><?php echo $this->__(mage::helper('realex')->getConfigData('realvault','auto_store_label')); ?></label>
37
+ <input type="hidden" name="payment[remembertoken]" value="1" id="remembertoken-<?php echo $_code; ?>" />
38
+ </li>
39
+ <?php else: ?>
40
+ <li<?php echo $realexStyle; ?>>
41
+ <label for="remembertoken-<?php echo $_code; ?>"><?php echo $this->__(mage::helper('realex')->getConfigData('realvault','store_label')); ?></label>&nbsp;
42
+ <input checked="checked" type="checkbox" name="payment[remembertoken]" value="1" id="remembertoken-<?php echo $_code; ?>" />
43
+ </li>
44
+ <?php endif; ?>
45
+
46
+ <?php endif; ?>
47
+ </ul>
48
+
49
+ </ul>
app/design/frontend/base/default/template/realex/payment/form/token.phtml ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php
22
+ $code = $this->getPaymentMethodCode();
23
+ $tokenCards = $this->getAvailableTokenCards();
24
+ $cTokens = ($tokenCards->getSize()>0 && $this->canUseTokens());
25
+ if($cTokens > 0):
26
+ $defToken = $this->helper('realex')->getDefaultToken();
27
+ ?>
28
+ <ul class="form-list tokenrealex" id="payment_form_<?php echo $code; ?>" style="display:none;">
29
+ <?php
30
+ foreach($tokenCards as $_tcard):
31
+ $radioId = $code . '_tokencard_' . $_tcard->getId();
32
+ //$isDef = $_tcard->getId() == $defToken->getId();
33
+ $isDef = false;
34
+ ?>
35
+ <li class="tokencard-radio control">
36
+ <input<?php if($isDef): ?> checked="checked"<?php endif; ?> type="radio" id="<?php echo $radioId; ?>" name="payment[realex_token_cc_id]" title="<?php echo $this->__('Credit Card Number') ?>" class="input-radio" value="<?php echo $_tcard->getId(); ?>" onclick="switchToken(this);" />
37
+ <span class="token-icon token-icon-<?php echo strtolower($_tcard->getMagentoCardType()); ?>"><?php echo $_tcard->getCardType(); ?></span>
38
+ <label class="token" for="<?php echo $radioId; ?>"><?php echo $this->__('%s, Exp. %s', $_tcard->getCcNumber(), $_tcard->getExpireDate()); ?></label>
39
+ <?php if($this->requireTokenCvv()):?>
40
+ <div class="tokencvv"<?php if(!$isDef): ?> style="display:none"<?php endif; ?>>
41
+ <label class="required" for="<?php echo $code ?>_token_cvv_<?php echo $_tcard->getId(); ?>"><em>*</em><?php echo $this->__('Security Code'); ?></label>
42
+ <input<?php if(!$isDef): ?> disabled="disabled"<?php endif; ?> type="text" id="<?php echo $code ?>_token_cvv_<?php echo $_tcard->getId(); ?>" name="payment[token_cvv]" title="<?php echo $this->__('Credit Card Security Code') ?>" class="input-text required-entry validate-digits cvv tokencvv validate-realex-cvn" onfocus="tokenRadioCheck('<?php echo $radioId; ?>', this);" />
43
+ <input<?php if(!$isDef): ?> disabled="disabled"<?php endif; ?> type="hidden" id="<?php echo $code ?>_cc_type_<?php echo $_tcard->getId(); ?>" name="payment[cc_type]" value="<?php echo $_tcard->getCardType();//echo $this->getMagentoCardType($_tcard) ?>" class="tokencctype"/>
44
+ </div>
45
+ <?php endif; ?>
46
+ <!--<img width="35" src="<?php // echo $this->helper('realex')->getCcImage($this->helper('realex')->getCardLabel($_tcard->getCardType(), false)); ?>" />-->&nbsp;&nbsp;&nbsp;
47
+ </li>
48
+ <?php endforeach; ?>
49
+ </ul>
50
+
51
+ <?php else: ?>
52
+ <ul class="form-list tokenrealex" id="payment_form_<?php echo $code; ?>">
53
+ <li>No Cards Stored</li>
54
+ </ul>
55
+ <?php endif; ?>
app/design/frontend/base/default/template/realex/payment/info/redirect.phtml ADDED
File without changes
app/design/frontend/base/default/template/realex/payment/redirect/form.phtml ADDED
@@ -0,0 +1,56 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+
22
+ <!DOCTYPE html>
23
+ <html>
24
+ <head>
25
+ <meta charset="UTF-8" content="IE=edge" http-equiv="X-UA-Compatible">
26
+ <meta charset="UTF-8" content="IE=9" http-equiv="X-UA-Compatible">
27
+ <meta charset="UTF-8" content="IE=8" http-equiv="X-UA-Compatible">
28
+ </head>
29
+ <body>
30
+ <div>
31
+ <?php $data = $this->getMessageData()?>
32
+ <?php $redirectUrl = $this->getRedirectUrl();?>
33
+ <?php if ($redirectUrl != ''):?>
34
+ <form action="<?php echo $redirectUrl; ?>" name="realexform" id="realexform" method="POST" style="width:100%; text-align:center;">
35
+ <?php foreach ($data as $_fieldName => $_value): ?>
36
+ <input type="hidden" name="<?php echo $_fieldName; ?>" value="<?php echo $_value ?>" >
37
+ <?php endforeach; ?>
38
+ <input type="submit" value="<?php echo $this->__('Please click here if you are not automatically redirected after a few seconds...'); ?>" >
39
+ </form>
40
+ <script type="text/javascript">
41
+ function postTransaction() {
42
+ document.realexform.submit();
43
+ }
44
+ if (window.addEventListener) {
45
+ window.addEventListener('load', postTransaction, false);
46
+ }else if (window.attachEvent){
47
+ window.attachEvent('onload', postTransaction);
48
+ }else {
49
+ window.onload = postTransaction;
50
+ }
51
+ </script>
52
+ <?php else: ?>
53
+ <p><?php echo $this->__($this->getNoRedirectUrlMessage()) ?></p>
54
+ <?php endif; ?>
55
+ </div>
56
+ </body></html>
app/design/frontend/base/default/template/realex/payment/redirect/frame.phtml ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php $iframeSize = $this->getIframeSize() ?>
22
+ <script>
23
+ var realexIframe = new Iframe(
24
+ '<?php echo $this->getFailUrl() ?>',
25
+ '<?php echo $this->getRedirectUrl() ?>',
26
+ '<?php echo Mage::helper("core/url")->getCurrentUrl() ?>',
27
+ '<?php echo $iframeSize[0] ?>',
28
+ '<?php echo $iframeSize[1] ?>'
29
+ );
30
+ realexIframe.show();
31
+ </script>
app/design/frontend/base/default/template/realex/payment/redirect/result.phtml ADDED
@@ -0,0 +1,28 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ ?>
21
+ <?php $result = $this->getResult(); ?>
22
+ <script type="text/javascript">
23
+ window.parent.postMessage('1','*');
24
+ window.top.location.href="<?php echo $this->getData('url') ?>";
25
+ </script>
26
+ <p style="text-align:center">
27
+ <input type="submit" value="<?php echo $this->__('Please click here if you are not automatically redirected after a few seconds...'); ?>" onClick="window.top.location.href='<?php echo $this->getData('url') ?>';">
28
+ </p>
app/etc/modules/Yoma_Realex.xml ADDED
@@ -0,0 +1,9 @@
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yoma_Realex>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Yoma_Realex>
8
+ </modules>
9
+ </config>
app/etc/modules/Yoma_RealexRewrite.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Yoma_RealexRewrite>
5
+ <active>true</active>
6
+ <codePool>local</codePool>
7
+ <depends>
8
+ <Yoma_Realex />
9
+ </depends>
10
+ </Yoma_RealexRewrite>
11
+ </modules>
12
+ </config>
app/locale/en_GB/realex/Yoma_Realex.csv ADDED
@@ -0,0 +1,4 @@
 
 
 
 
1
+ "Credit Card Type","Card Type"
2
+ "Credit Card Number","Card Number"
3
+ "Your credit card will be charged for","Your card will be charged for"
4
+ "An error occurred in the process of payment", "The payment was unsuccessful at this time. Please try again or contact us for more information."
app/locale/en_GB/realex/Yoma_Realex_Adminhtml.csv ADDED
@@ -0,0 +1,2 @@
 
 
1
+ "Credit Card Type","Card Type"
2
+ "Credit Card Number","Card Number"
js/realex/invoice.js ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ document.observe("dom:loaded", function() {
21
+
22
+ var settleAmount = $('settle-amount');
23
+ if($('settle-check')) {
24
+ $('settle-check').checked = false;
25
+ $('settle-check').observe('click', function (e) {
26
+ if (this.checked) {
27
+ settleAmount.disabled = false;
28
+ settleAmount.setStyle({
29
+ backgroundColor: 'white',
30
+ color: 'black'
31
+ });
32
+ return true;
33
+ }
34
+ settleAmount.disabled = true;
35
+ settleAmount.setStyle({
36
+ backgroundColor: '#AAAAAA',
37
+ color: 'graytext'
38
+ });
39
+
40
+ });
41
+ }
42
+
43
+ });
js/realex/livepipe/contextmenu.js ADDED
@@ -0,0 +1,185 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/contextmenu
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global window, document, Prototype, Class, Event, $, $A, $R, Control, $value */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.ContextMenu requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.ContextMenu requires Object.Event to be loaded."; }
16
+
17
+ Control.ContextMenu = Class.create({
18
+ initialize: function(container,options){
19
+ Control.ContextMenu.load();
20
+ this.options = Object.extend({
21
+ leftClick: false,
22
+ disableOnShiftKey: true,
23
+ disableOnAltKey: true,
24
+ selectedClassName: 'selected',
25
+ activatedClassName: 'activated',
26
+ animation: true,
27
+ animationCycles: 2,
28
+ animationLength: 300,
29
+ delayCallback: true
30
+ },options || {});
31
+ this.activated = false;
32
+ this.items = this.options.items || [];
33
+ this.container = $(container);
34
+ this.container.observe(this.options.leftClick ? 'click' : (Prototype.Browser.Opera ? 'click' : 'contextmenu'),function(event){
35
+ if(!Control.ContextMenu.enabled || Prototype.Browser.Opera && !event.ctrlKey) {
36
+ return; }
37
+ this.open(event);
38
+ }.bindAsEventListener(this));
39
+ },
40
+ open: function(event){
41
+ if(Control.ContextMenu.current && !Control.ContextMenu.current.close()) {
42
+ return; }
43
+ if(this.notify('beforeOpen',event) === false) {
44
+ return false; }
45
+ this.buildMenu();
46
+ if(this.items.length === 0){
47
+ this.close(event);
48
+ return false;
49
+ }
50
+ this.clicked = Event.element(event);
51
+ Control.ContextMenu.current = this;
52
+ Control.ContextMenu.positionContainer(event);
53
+ Control.ContextMenu.container.show();
54
+ if(this.notify('afterOpen',event) === false) {
55
+ return false; }
56
+ event.stop();
57
+ return true;
58
+ },
59
+ close: function(event){
60
+ if(event) {
61
+ event.stop(); }
62
+ if(this.notify('beforeClose') === false) {
63
+ return false; }
64
+ Control.ContextMenu.current = false;
65
+ this.activated = false;
66
+ Control.ContextMenu.container.removeClassName(this.options.activatedClassName);
67
+ Control.ContextMenu.container.select('li').invoke('stopObserving');
68
+ Control.ContextMenu.container.hide();
69
+ Control.ContextMenu.container.update('');
70
+ if(this.notify('afterClose') === false) {
71
+ return false; }
72
+ return true;
73
+ },
74
+ buildMenu: function(){
75
+ var list = document.createElement('ul');
76
+ Control.ContextMenu.container.appendChild(list);
77
+ this.items.each(function(item){
78
+ if(!(!item.condition || item.condition && item.condition() !== false)) {
79
+ return; }
80
+ var item_container = $(document.createElement('li'));
81
+ item_container.update($value(item.label));
82
+ list.appendChild(item_container);
83
+ item_container[$value(item.enabled) ? 'removeClassName' : 'addClassName']('disabled');
84
+ item_container.observe('mousedown',function(event,item){
85
+ if(!$value(item.enabled)) {
86
+ return event.stop(); }
87
+ this.activated = $value(item.label);
88
+ }.bindAsEventListener(this,item));
89
+ item_container.observe('click',this.selectMenuItem.bindAsEventListener(this,item,item_container));
90
+ item_container.observe('contextmenu',this.selectMenuItem.bindAsEventListener(this,item,item_container));
91
+ }.bind(this));
92
+ },
93
+ addItem: function(params){
94
+ if (!('enabled' in params)) { params.enabled = true; }
95
+ this.items.push(params);
96
+ return this;
97
+ },
98
+ destroy: function(){
99
+ this.container.stopObserving(Prototype.Browser.Opera || this.options.leftClick ? 'click' : 'contextmenu');
100
+ this.items = [];
101
+ },
102
+ selectMenuItem: function(event,item,item_container){
103
+ if(!$value(item.enabled)) {
104
+ return event.stop(); }
105
+ if(!this.activated || this.activated == $value(item.label)){
106
+ if(this.options.animation){
107
+ Control.ContextMenu.container.addClassName(this.options.activatedClassName);
108
+ $A($R(0,this.options.animationCycles * 2)).each(function(i){
109
+ window.setTimeout(function(){
110
+ item_container.toggleClassName(this.options.selectedClassName);
111
+ }.bind(this),i * parseInt(this.options.animationLength / (this.options.animationCycles * 2), 10));
112
+ }.bind(this));
113
+ window.setTimeout(function(){
114
+ if(this.close() && this.options.delayCallback) {
115
+ item.callback(this.clicked); }
116
+ }.bind(this),this.options.animationLength);
117
+ if(!this.options.delayCallback) {
118
+ item.callback(this.clicked); }
119
+ }else if(this.close()) {
120
+ item.callback(this.clicked); }
121
+ }
122
+ event.stop();
123
+ return false;
124
+ }
125
+ });
126
+ Object.extend(Control.ContextMenu,{
127
+ loaded: false,
128
+ capture_all: false,
129
+ menus: [],
130
+ current: false,
131
+ enabled: false,
132
+ offset: 4,
133
+ load: function(capture_all){
134
+ if(Control.ContextMenu.loaded) {
135
+ return; }
136
+ Control.ContextMenu.loaded = true;
137
+ if(typeof(capture_all) == 'undefined') {
138
+ capture_all = false; }
139
+ Control.ContextMenu.capture_all = capture_all;
140
+ Control.ContextMenu.container = $(document.createElement('div'));
141
+ Control.ContextMenu.container.id = 'control_contextmenu';
142
+ Control.ContextMenu.container.style.position = 'absolute';
143
+ Control.ContextMenu.container.style.zIndex = 99999;
144
+ Control.ContextMenu.container.hide();
145
+ document.body.appendChild(Control.ContextMenu.container);
146
+ Control.ContextMenu.enable();
147
+ },
148
+ enable: function(){
149
+ Control.ContextMenu.enabled = true;
150
+ Event.observe(document.body,'click',Control.ContextMenu.onClick);
151
+ if(Control.ContextMenu.capture_all) {
152
+ Event.observe(document.body,'contextmenu',Control.ContextMenu.onContextMenu); }
153
+ },
154
+ disable: function(){
155
+ Event.stopObserving(document.body,'click',Control.ContextMenu.onClick);
156
+ if(Control.ContextMenu.capture_all) {
157
+ Event.stopObserving(document.body,'contextmenu',Control.ContextMenu.onContextMenu); }
158
+ },
159
+ onContextMenu: function(event){
160
+ event.stop();
161
+ return false;
162
+ },
163
+ onClick: function(){
164
+ if(Control.ContextMenu.current) {
165
+ Control.ContextMenu.current.close(); }
166
+ },
167
+ positionContainer: function(event){
168
+ var dimensions = Control.ContextMenu.container.getDimensions();
169
+ var top = Event.pointerY(event);
170
+ var left = Event.pointerX(event);
171
+ var bottom = dimensions.height + top;
172
+ var right = dimensions.width + left;
173
+ var viewport_dimensions = document.viewport.getDimensions();
174
+ var viewport_scroll_offsets = document.viewport.getScrollOffsets();
175
+ if(bottom > viewport_dimensions.height + viewport_scroll_offsets.top) {
176
+ top -= bottom - ((viewport_dimensions.height + viewport_scroll_offsets.top) - Control.ContextMenu.offset); }
177
+ if(right > viewport_dimensions.width + viewport_scroll_offsets.left) {
178
+ left -= right - ((viewport_dimensions.width + viewport_scroll_offsets.left) - Control.ContextMenu.offset); }
179
+ Control.ContextMenu.container.setStyle({
180
+ top: top + 'px',
181
+ left: left + 'px'
182
+ });
183
+ }
184
+ });
185
+ Object.Event.extend(Control.ContextMenu);
js/realex/livepipe/cookie.js ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/controls/hotkey/
7
+ * @attribution http://www.quirksmode.org/js/cookies.html
8
+ */
9
+
10
+ /*global document, Prototype, $A */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Cookie requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Cookie requires Object.Event to be loaded."; }
16
+
17
+ var Cookie = {
18
+ build: function() {
19
+ return $A(arguments).compact().join("; ");
20
+ },
21
+ secondsFromNow: function(seconds) {
22
+ var d = new Date();
23
+ d.setTime(d.getTime() + (seconds * 1000));
24
+ return d.toGMTString();
25
+ },
26
+ set: function(name,value,seconds){
27
+ Cookie.notify('set',name,value);
28
+ var expiry = seconds ? 'expires=' + Cookie.secondsFromNow(seconds) : null;
29
+ document.cookie = Cookie.build(name + "=" + value, expiry, "path=/");
30
+ },
31
+ get: function(name){
32
+ Cookie.notify('get',name);
33
+ var valueMatch = new RegExp(name + "=([^;]+)").exec(document.cookie);
34
+ return valueMatch ? valueMatch[1] : null;
35
+ },
36
+ unset: function(name){
37
+ Cookie.notify('unset',name);
38
+ Cookie.set(name,'',-1);
39
+ }
40
+ };
41
+ Object.Event.extend(Cookie);
js/realex/livepipe/event_behavior.js ADDED
@@ -0,0 +1,298 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/extra/event_behavior
7
+ * @require prototype.js, livepipe.js
8
+ * @attribution http://www.adamlogic.com/2007/03/20/3_metaprogramming-javascript-presentation
9
+ */
10
+
11
+ /*global Prototype, Class, Event, Try, $, $A, $H */
12
+
13
+ if(typeof(Prototype) == "undefined") {
14
+ throw "Event.Behavior requires Prototype to be loaded."; }
15
+ if(typeof(Object.Event) == "undefined") {
16
+ throw "Event.Behavior requires Object.Event to be loaded."; }
17
+
18
+ Event.Behavior = {
19
+ addVerbs: function(verbs){
20
+ var v;
21
+ for (var name in verbs) { if (verbs.hasOwnProperty(name)) {
22
+ v = new Event.Behavior.Verb(verbs[name]);
23
+ Event.Behavior.Verbs[name] = v;
24
+ Event.Behavior[name.underscore()] = Event.Behavior[name] = v.getCallbackForStack.bind(v);
25
+ }}
26
+ },
27
+ addEvents: function(events){
28
+ $H(events).each(function(event_type){
29
+ Event.Behavior.Adjective.prototype[event_type.key.underscore()] = Event.Behavior.Adjective.prototype[event_type.key] = function(){
30
+ this.nextConditionType = 'and';
31
+ this.events.push(event_type.value);
32
+ this.attachObserver(false);
33
+ return this;
34
+ };
35
+ });
36
+ },
37
+ invokeElementMethod: function(element,action,args){
38
+ if(typeof(element) == 'function'){
39
+ return $A(element()).each(function(e){
40
+ if(typeof(args[0]) == 'function'){
41
+ return $A(args[0]).each(function(a){
42
+ return $(e)[action].apply($(e),(a ? [a] : []));
43
+ });
44
+ }else {
45
+ return $(e)[action].apply($(e),args || []); }
46
+ });
47
+ }else {
48
+ return $(element)[action].apply($(element),args || []); }
49
+ }
50
+ };
51
+
52
+ Event.Behavior.Verbs = $H({});
53
+
54
+ Event.Behavior.Verb = Class.create();
55
+ Object.extend(Event.Behavior.Verb.prototype,{
56
+ originalAction: false,
57
+ execute: false,
58
+ executeOpposite: false,
59
+ target: false,
60
+ initialize: function(action){
61
+ this.originalAction = action;
62
+ this.execute = function(action,target,argument){
63
+ return (argument) ? action(target,argument) : action(target);
64
+ }.bind(this,action);
65
+ },
66
+ setOpposite: function(opposite_verb){
67
+ var opposite_action = opposite_verb.originalAction;
68
+ this.executeOpposite = function(opposite_action,target,argument){
69
+ return (argument) ? opposite_action(target,argument) :
70
+ opposite_action(target);
71
+ }.bind(this,opposite_action);
72
+ },
73
+ getCallbackForStack: function(argument){
74
+ return new Event.Behavior.Noun(this,argument);
75
+ }
76
+ });
77
+
78
+ Event.Behavior.addVerbs({
79
+ call: function(callback){
80
+ callback();
81
+ },
82
+ show: function(element){
83
+ return Event.Behavior.invokeElementMethod(element,'show');
84
+ },
85
+ hide: function(element){
86
+ return Event.Behavior.invokeElementMethod(element,'hide');
87
+ },
88
+ remove: function(element){
89
+ return Event.Behavior.invokeElementMethod(element,'remove');
90
+ },
91
+ setStyle: function(element,styles){
92
+ return Event.Behavior.invokeElementMethod(element,'setStyle',[(typeof(styles) == 'function' ? styles() : styles)]);
93
+ },
94
+ addClassName: function(element,class_name){
95
+ return Event.Behavior.invokeElementMethod(element,'addClassName',[(typeof(class_name) == 'function' ? class_name() : class_name)]);
96
+ },
97
+ removeClassName: function(element,class_name){
98
+ return Event.Behavior.invokeElementMethod(element,'removeClassName',[(typeof(class_name) == 'function' ? class_name() : class_name)]);
99
+ },
100
+ setClassName: function(element,class_name){
101
+ var c = (typeof(class_name) == 'function') ? class_name() : class_name;
102
+ if(typeof(element) == 'function'){
103
+ return $A(element()).each(function(e){
104
+ $(e).className = c;
105
+ });
106
+ }else {
107
+ c = $(element).className;
108
+ return c;
109
+ }
110
+ },
111
+ update: function(content,element){
112
+ return Event.Behavior.invokeElementMethod(element,'update',[(typeof(content) == 'function' ? content() : content)]);
113
+ },
114
+ replace: function(content,element){
115
+ return Event.Behavior.invokeElementMethod(element,'replace',[(typeof(content) == 'function' ? content() : content)]);
116
+ }
117
+ });
118
+ Event.Behavior.Verbs.show.setOpposite(Event.Behavior.Verbs.hide);
119
+ Event.Behavior.Verbs.hide.setOpposite(Event.Behavior.Verbs.show);
120
+ Event.Behavior.Verbs.addClassName.setOpposite(Event.Behavior.Verbs.removeClassName);
121
+ Event.Behavior.Verbs.removeClassName.setOpposite(Event.Behavior.Verbs.addClassName);
122
+
123
+ Event.Behavior.Noun = Class.create();
124
+ Object.extend(Event.Behavior.Noun.prototype,{
125
+ verbs: false,
126
+ verb: false,
127
+ argument: false,
128
+ subject: false,
129
+ target: false,
130
+ initialize: function(verb,argument){
131
+ //this.verbs = $A([]);
132
+ this.verb = verb;
133
+ this.argument = argument;
134
+ },
135
+ execute: function(){
136
+ return (this.target) ? this.verb.execute(this.target,this.argument) :
137
+ this.verb.execute(this.argument);
138
+ },
139
+ executeOpposite: function(){
140
+ return (this.target) ?
141
+ this.verb.executeOpposite(this.target,this.argument) :
142
+ this.verb.executeOpposite(this.argument);
143
+ },
144
+ when: function(subject){
145
+ this.subject = subject;
146
+ return new Event.Behavior.Adjective(this);
147
+ },
148
+ getValue: function(){
149
+ return Try.these(
150
+ function(){return $(this.subject).getValue();}.bind(this),
151
+ function(){return $(this.subject).options[$(this.subject).options.selectedIndex].value;}.bind(this),
152
+ function(){return $(this.subject).value;}.bind(this),
153
+ function(){return $(this.subject).innerHTML;}.bind(this)
154
+ );
155
+ },
156
+ containsValue: function(match){
157
+ var value = this.getValue();
158
+ if(typeof(match) == 'function'){
159
+ return $A(match()).include(value);
160
+ }else {
161
+ return value.match(match); }
162
+ },
163
+ setTarget: function(target){
164
+ this.target = target;
165
+ return this;
166
+ },
167
+ and: function(){
168
+
169
+ }
170
+ });
171
+ Event.Behavior.Noun.prototype._with = Event.Behavior.Noun.prototype.setTarget;
172
+ Event.Behavior.Noun.prototype.on = Event.Behavior.Noun.prototype.setTarget;
173
+ Event.Behavior.Noun.prototype.of = Event.Behavior.Noun.prototype.setTarget;
174
+ Event.Behavior.Noun.prototype.to = Event.Behavior.Noun.prototype.setTarget;
175
+ Event.Behavior.Noun.prototype.from = Event.Behavior.Noun.prototype.setTarget;
176
+
177
+ Event.Behavior.Adjective = Class.create();
178
+ Object.extend(Event.Behavior.Adjective.prototype,{
179
+ noun: false,
180
+ lastConditionName: '',
181
+ nextConditionType: 'and',
182
+ conditions: $A([]),
183
+ events: $A([]),
184
+ attached: false,
185
+ initialize: function(noun){
186
+ this.conditions = $A([]);
187
+ this.events = $A([]);
188
+ this.noun = noun;
189
+ },
190
+ attachObserver: function(execute_on_load){
191
+ if(this.attached){
192
+ //this may call things multiple times, but is the only way to gaurentee correct state on startup
193
+ if(execute_on_load) {
194
+ this.execute(); }
195
+ return;
196
+ }
197
+ this.attached = true;
198
+ if(typeof(this.noun.subject) == 'function'){
199
+ $A(this.noun.subject()).each(function(subject){
200
+ (this.events.length > 0 ? this.events : $A(['change'])).each(function(event_name){
201
+ (subject.observe ? subject : $(subject)).observe(event_name,function(){
202
+ this.execute();
203
+ }.bind(this));
204
+ }.bind(this));
205
+ }.bind(this));
206
+ }else{
207
+ (this.events.length > 0 ? this.events : $A(['change'])).each(function(event_name){
208
+ $(this.noun.subject).observe(event_name,function(){
209
+ this.execute();
210
+ }.bind(this));
211
+ }.bind(this));
212
+ }
213
+ if(execute_on_load) { this.execute(); }
214
+ },
215
+ execute: function(){
216
+ if(this.match()) { return this.noun.execute(); }
217
+ else if(this.noun.verb.executeOpposite) { this.noun.executeOpposite(); }
218
+ },
219
+ attachCondition: function(callback){
220
+ this.conditions.push([this.nextConditionType,callback.bind(this)]);
221
+ },
222
+ match: function(){
223
+ if(this.conditions.length === 0) { return true; }
224
+ else {
225
+ return this.conditions.inject(false, function (bool,condition) {
226
+ return (condition[0] === 'or') ?
227
+ (bool && condition[1]()) : (bool || condition[1]());
228
+ });
229
+ }
230
+ },
231
+ //conditions
232
+ is: function(item){
233
+ this.lastConditionName = 'is';
234
+ this.attachCondition(function(item){
235
+ return (typeof(item) == 'function' ? item() : item) == this.noun.getValue();
236
+ }.bind(this,item));
237
+ this.attachObserver(true);
238
+ return this;
239
+ },
240
+ isNot: function(item){
241
+ this.lastConditionName = 'isNot';
242
+ this.attachCondition(function(item){
243
+ return (typeof(item) == 'function' ? item() : item) != this.noun.getValue();
244
+ }.bind(this,item));
245
+ this.attachObserver(true);
246
+ return this;
247
+ },
248
+ contains: function(item){
249
+ this.lastConditionName = 'contains';
250
+ this.attachCondition(function(item){
251
+ return this.noun.containsValue(item);
252
+ }.bind(this,item));
253
+ this.attachObserver(true);
254
+ return this;
255
+ },
256
+ within: function(item){
257
+ this.lastConditionName = 'within';
258
+ this.attachCondition(function(item){
259
+
260
+ }.bind(this,item));
261
+ this.attachObserver(true);
262
+ return this;
263
+ },
264
+ //events
265
+ change: function(){
266
+ this.nextConditionType = 'and';
267
+ this.attachObserver(true);
268
+ return this;
269
+ },
270
+ and: function(condition){
271
+ this.attached = false;
272
+ this.nextConditionType = 'and';
273
+ if(condition) { this[this.lastConditionName](condition); }
274
+ return this;
275
+ },
276
+ or: function(condition){
277
+ this.attached = false;
278
+ this.nextConditionType = 'or';
279
+ if(condition) { this[this.lastConditionName](condition); }
280
+ return this;
281
+ }
282
+ });
283
+
284
+ Event.Behavior.addEvents({
285
+ losesFocus: 'blur',
286
+ gainsFocus: 'focus',
287
+ isClicked: 'click',
288
+ isDoubleClicked: 'dblclick',
289
+ keyPressed: 'keypress'
290
+ });
291
+
292
+ Event.Behavior.Adjective.prototype.is_not = Event.Behavior.Adjective.prototype.isNot;
293
+ Event.Behavior.Adjective.prototype.include = Event.Behavior.Adjective.prototype.contains;
294
+ Event.Behavior.Adjective.prototype.includes = Event.Behavior.Adjective.prototype.contains;
295
+ Event.Behavior.Adjective.prototype.are = Event.Behavior.Adjective.prototype.is;
296
+ Event.Behavior.Adjective.prototype.areNot = Event.Behavior.Adjective.prototype.isNot;
297
+ Event.Behavior.Adjective.prototype.are_not = Event.Behavior.Adjective.prototype.isNot;
298
+ Event.Behavior.Adjective.prototype.changes = Event.Behavior.Adjective.prototype.change;
js/realex/livepipe/hotkey.js ADDED
@@ -0,0 +1,74 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/extra/hotkey
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global document, Prototype, Class, Event, $ */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "HotKey requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "HotKey requires Object.Event to be loaded."; }
16
+
17
+ var HotKey = Class.create({
18
+ initialize: function(letter,callback,options){
19
+ letter = letter.toUpperCase();
20
+ HotKey.hotkeys.push(this);
21
+ this.options = Object.extend({
22
+ element: false,
23
+ shiftKey: false,
24
+ altKey: false,
25
+ ctrlKey: true,
26
+ bubbleEvent : true,
27
+ fireOnce : false // Keep repeating event while key is pressed?
28
+ },options || {});
29
+ this.letter = letter;
30
+
31
+ // All custom hotkey events should stop after their custom actions.
32
+ this.callback = function (event) {
33
+ if (!(this.options.fireOnce && this.fired) && Object.isFunction(callback)) {
34
+ callback(event);
35
+ }
36
+ if (!this.options.bubbleEvent) { event.stop(); }
37
+ this.fired = true;
38
+ };
39
+
40
+ this.element = $(this.options.element || document);
41
+ this.handler = function(event){
42
+ if(!event || (
43
+ (Event['KEY_' + this.letter] || this.letter.charCodeAt(0)) == event.keyCode &&
44
+ ((!this.options.shiftKey || (this.options.shiftKey && event.shiftKey)) &&
45
+ (!this.options.altKey || (this.options.altKey && event.altKey)) &&
46
+ (!this.options.ctrlKey || (this.options.ctrlKey && event.ctrlKey))
47
+ )
48
+ )){
49
+ if(this.notify('beforeCallback',event) === false) {
50
+ return; }
51
+ this.callback(event);
52
+ this.notify('afterCallback',event);
53
+ }
54
+ }.bind(this);
55
+ this.enable();
56
+ },
57
+ trigger: function(){
58
+ this.handler();
59
+ },
60
+ enable: function(){
61
+ this.element.observe('keydown',this.handler);
62
+ },
63
+ disable: function(){
64
+ this.element.stopObserving('keydown',this.handler);
65
+ },
66
+ destroy: function(){
67
+ this.disable();
68
+ HotKey.hotkeys = HotKey.hotkeys.without(this);
69
+ }
70
+ });
71
+ Object.extend(HotKey,{
72
+ hotkeys: []
73
+ });
74
+ Object.Event.extend(HotKey);
js/realex/livepipe/livepipe.js ADDED
@@ -0,0 +1,181 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/core
7
+ * @require prototype.js
8
+ */
9
+
10
+ if(typeof(Control) == 'undefined')
11
+ Control = {};
12
+
13
+ var $proc = function(proc){
14
+ return typeof(proc) == 'function' ? proc : function(){return proc};
15
+ };
16
+
17
+ var $value = function(value){
18
+ return typeof(value) == 'function' ? value() : value;
19
+ };
20
+
21
+ Object.Event = {
22
+ extend: function(object){
23
+ object._objectEventSetup = function(event_name){
24
+ this._observers = this._observers || {};
25
+ this._observers[event_name] = this._observers[event_name] || [];
26
+ };
27
+ object.observe = function(event_name,observer){
28
+ if(typeof(event_name) == 'string' && typeof(observer) != 'undefined'){
29
+ this._objectEventSetup(event_name);
30
+ if(!this._observers[event_name].include(observer))
31
+ this._observers[event_name].push(observer);
32
+ }else
33
+ for(var e in event_name)
34
+ this.observe(e,event_name[e]);
35
+ };
36
+ object.stopObserving = function(event_name,observer){
37
+ this._objectEventSetup(event_name);
38
+ if(event_name && observer)
39
+ this._observers[event_name] = this._observers[event_name].without(observer);
40
+ else if(event_name)
41
+ this._observers[event_name] = [];
42
+ else
43
+ this._observers = {};
44
+ };
45
+ object.observeOnce = function(event_name,outer_observer){
46
+ var inner_observer = function(){
47
+ outer_observer.apply(this,arguments);
48
+ this.stopObserving(event_name,inner_observer);
49
+ }.bind(this);
50
+ this._objectEventSetup(event_name);
51
+ this._observers[event_name].push(inner_observer);
52
+ };
53
+ object.notify = function(event_name){
54
+ this._objectEventSetup(event_name);
55
+ var collected_return_values = [];
56
+ var args = $A(arguments).slice(1);
57
+ try{
58
+ for(var i = 0; i < this._observers[event_name].length; ++i)
59
+ collected_return_values.push(this._observers[event_name][i].apply(this,args) || null);
60
+ }catch(e){
61
+ if(e == $break)
62
+ return false;
63
+ else
64
+ throw e;
65
+ }
66
+ return collected_return_values;
67
+ };
68
+ if(object.prototype){
69
+ object.prototype._objectEventSetup = object._objectEventSetup;
70
+ object.prototype.observe = object.observe;
71
+ object.prototype.stopObserving = object.stopObserving;
72
+ object.prototype.observeOnce = object.observeOnce;
73
+ object.prototype.notify = function(event_name){
74
+ if(object.notify){
75
+ var args = $A(arguments).slice(1);
76
+ args.unshift(this);
77
+ args.unshift(event_name);
78
+ object.notify.apply(object,args);
79
+ }
80
+ this._objectEventSetup(event_name);
81
+ var args = $A(arguments).slice(1);
82
+ var collected_return_values = [];
83
+ try{
84
+ if(this.options && this.options[event_name] && typeof(this.options[event_name]) == 'function')
85
+ collected_return_values.push(this.options[event_name].apply(this,args) || null);
86
+ var callbacks_copy = this._observers[event_name]; // since original array will be modified after observeOnce calls
87
+ for(var i = 0; i < callbacks_copy.length; ++i)
88
+ collected_return_values.push(callbacks_copy[i].apply(this,args) || null);
89
+ }catch(e){
90
+ if(e == $break)
91
+ return false;
92
+ else
93
+ throw e;
94
+ }
95
+ return collected_return_values;
96
+ };
97
+ }
98
+ }
99
+ };
100
+
101
+ /* Begin Core Extensions */
102
+
103
+ //Element.observeOnce
104
+ Element.addMethods({
105
+ observeOnce: function(element,event_name,outer_callback){
106
+ var inner_callback = function(){
107
+ outer_callback.apply(this,arguments);
108
+ Element.stopObserving(element,event_name,inner_callback);
109
+ };
110
+ Element.observe(element,event_name,inner_callback);
111
+ }
112
+ });
113
+
114
+ //mouse:wheel
115
+ (function(){
116
+ function wheel(event){
117
+ var delta, element, custom_event;
118
+ // normalize the delta
119
+ if (event.wheelDelta) { // IE & Opera
120
+ delta = event.wheelDelta / 120;
121
+ } else if (event.detail) { // W3C
122
+ delta =- event.detail / 3;
123
+ }
124
+ if (!delta) { return; }
125
+ element = Event.extend(event).target;
126
+ element = Element.extend(element.nodeType === Node.TEXT_NODE ? element.parentNode : element);
127
+ custom_event = element.fire('mouse:wheel',{ delta: delta });
128
+ if (custom_event.stopped) {
129
+ Event.stop(event);
130
+ return false;
131
+ }
132
+ }
133
+ document.observe('mousewheel',wheel);
134
+ document.observe('DOMMouseScroll',wheel);
135
+ })();
136
+
137
+ /* End Core Extensions */
138
+
139
+ //from PrototypeUI
140
+ var IframeShim = Class.create({
141
+ initialize: function() {
142
+ this.element = new Element('iframe',{
143
+ style: 'position:absolute;filter:progid:DXImageTransform.Microsoft.Alpha(opacity=0);display:none',
144
+ src: 'javascript:void(0);',
145
+ frameborder: 0
146
+ });
147
+ $(document.body).insert(this.element);
148
+ },
149
+ hide: function() {
150
+ this.element.hide();
151
+ return this;
152
+ },
153
+ show: function() {
154
+ this.element.show();
155
+ return this;
156
+ },
157
+ positionUnder: function(element) {
158
+ var element = $(element);
159
+ var offset = element.cumulativeOffset();
160
+ var dimensions = element.getDimensions();
161
+ this.element.setStyle({
162
+ left: offset[0] + 'px',
163
+ top: offset[1] + 'px',
164
+ width: dimensions.width + 'px',
165
+ height: dimensions.height + 'px',
166
+ zIndex: element.getStyle('zIndex') - 1
167
+ }).show();
168
+ return this;
169
+ },
170
+ setBounds: function(bounds) {
171
+ for(prop in bounds)
172
+ bounds[prop] += 'px';
173
+ this.element.setStyle(bounds);
174
+ return this;
175
+ },
176
+ destroy: function() {
177
+ if(this.element)
178
+ this.element.remove();
179
+ return this;
180
+ }
181
+ });
js/realex/livepipe/progressbar.js ADDED
@@ -0,0 +1,102 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/progressbar
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global document, Prototype, Ajax, Class, PeriodicalExecuter, $, $A, Control */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.ProgressBar requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.ProgressBar requires Object.Event to be loaded."; }
16
+
17
+ Control.ProgressBar = Class.create({
18
+ initialize: function(container,options){
19
+ this.progress = 0;
20
+ this.executer = false;
21
+ this.active = false;
22
+ this.poller = false;
23
+ this.container = $(container);
24
+ this.containerWidth = this.container.getDimensions().width - (parseInt(this.container.getStyle('border-right-width').replace(/px/,''), 10) + parseInt(this.container.getStyle('border-left-width').replace(/px/,''), 10));
25
+ this.progressContainer = $(document.createElement('div'));
26
+ this.progressContainer.setStyle({
27
+ width: this.containerWidth + 'px',
28
+ height: '100%',
29
+ position: 'absolute',
30
+ top: '0px',
31
+ right: '0px'
32
+ });
33
+ this.container.appendChild(this.progressContainer);
34
+ this.options = {
35
+ afterChange: Prototype.emptyFunction,
36
+ interval: 0.25,
37
+ step: 1,
38
+ classNames: {
39
+ active: 'progress_bar_active',
40
+ inactive: 'progress_bar_inactive'
41
+ }
42
+ };
43
+ Object.extend(this.options,options || {});
44
+ this.container.addClassName(this.options.classNames.inactive);
45
+ this.active = false;
46
+ },
47
+ setProgress: function(value){
48
+ this.progress = value;
49
+ this.draw();
50
+ if(this.progress >= 100) {
51
+ this.stop(false); }
52
+ this.notify('afterChange',this.progress,this.active);
53
+ },
54
+ poll: function (url, interval, ajaxOptions){
55
+ // Extend the passed ajax options and success callback with our own.
56
+ ajaxOptions = ajaxOptions || {};
57
+ var success = ajaxOptions.onSuccess || Prototype.emptyFunction;
58
+ ajaxOptions.onSuccess = success.wrap(function (callOriginal, request) {
59
+ this.setProgress(parseInt(request.responseText, 10));
60
+ if(!this.active) { this.poller.stop(); }
61
+ callOriginal(request);
62
+ }).bind(this);
63
+
64
+ this.active = true;
65
+ this.poller = new PeriodicalExecuter(function(){
66
+ var a = new Ajax.Request(url, ajaxOptions);
67
+ }.bind(this),interval || 3);
68
+ },
69
+ start: function(){
70
+ this.active = true;
71
+ this.container.removeClassName(this.options.classNames.inactive);
72
+ this.container.addClassName(this.options.classNames.active);
73
+ this.executer = new PeriodicalExecuter(this.step.bind(this,this.options.step),this.options.interval);
74
+ },
75
+ stop: function(reset){
76
+ this.active = false;
77
+ if(this.executer) {
78
+ this.executer.stop(); }
79
+ this.container.removeClassName(this.options.classNames.active);
80
+ this.container.addClassName(this.options.classNames.inactive);
81
+ if (typeof reset === 'undefined' || reset === true) {
82
+ this.reset(); }
83
+ },
84
+ step: function(amount){
85
+ this.active = true;
86
+ this.setProgress(Math.min(100,this.progress + amount));
87
+ },
88
+ reset: function(){
89
+ this.active = false;
90
+ this.setProgress(0);
91
+ },
92
+ draw: function(){
93
+ this.progressContainer.setStyle({
94
+ width: (this.containerWidth - Math.floor((parseInt(this.progress, 10) / 100) * this.containerWidth)) + 'px'
95
+ });
96
+ },
97
+ notify: function(event_name){
98
+ if(this.options[event_name]) {
99
+ return [this.options[event_name].apply(this.options[event_name],$A(arguments).slice(1))]; }
100
+ }
101
+ });
102
+ Object.Event.extend(Control.ProgressBar);
js/realex/livepipe/rating.js ADDED
@@ -0,0 +1,156 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/rating
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global document, Prototype, Ajax, Class, Event, $, $A, $F, $R, $break, Control */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.Rating requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.Rating requires Object.Event to be loaded."; }
16
+
17
+ Control.Rating = Class.create({
18
+ initialize: function(container,options){
19
+ Control.Rating.instances.push(this);
20
+ this.value = false;
21
+ this.links = [];
22
+ this.container = $(container);
23
+ this.container.update('');
24
+ this.options = {
25
+ min: 1,
26
+ max: 5,
27
+ rated: false,
28
+ input: false,
29
+ reverse: false,
30
+ capture: true,
31
+ multiple: false,
32
+ classNames: {
33
+ off: 'rating_off',
34
+ half: 'rating_half',
35
+ on: 'rating_on',
36
+ selected: 'rating_selected'
37
+ },
38
+ updateUrl: false,
39
+ updateParameterName: 'value',
40
+ updateOptions : {},
41
+ afterChange: Prototype.emptyFunction
42
+ };
43
+ Object.extend(this.options,options || {});
44
+ if(this.options.value){
45
+ this.value = this.options.value;
46
+ delete this.options.value;
47
+ }
48
+ if(this.options.input){
49
+ this.options.input = $(this.options.input);
50
+ this.options.input.observe('change',function(input){
51
+ this.setValueFromInput(input);
52
+ }.bind(this,this.options.input));
53
+ this.setValueFromInput(this.options.input,true);
54
+ }
55
+ var range = $R(this.options.min,this.options.max);
56
+ (this.options.reverse ? $A(range).reverse() : range).each(function(i){
57
+ var link = this.buildLink(i);
58
+ this.container.appendChild(link);
59
+ this.links.push(link);
60
+ }.bind(this));
61
+ this.setValue(this.value || this.options.min - 1,false,true);
62
+ },
63
+ buildLink: function(rating){
64
+ var link = $(document.createElement('a'));
65
+ link.value = rating;
66
+ if(this.options.multiple || (!this.options.rated && !this.options.multiple)){
67
+ link.href = '';
68
+ link.onmouseover = this.mouseOver.bind(this,link);
69
+ link.onmouseout = this.mouseOut.bind(this,link);
70
+ link.onclick = this.click.bindAsEventListener(this,link);
71
+ }else{
72
+ link.style.cursor = 'default';
73
+ link.observe('click',function(event){
74
+ Event.stop(event);
75
+ return false;
76
+ }.bindAsEventListener(this));
77
+ }
78
+ link.addClassName(this.options.classNames.off);
79
+ return link;
80
+ },
81
+ disable: function(){
82
+ this.links.each(function(link){
83
+ link.onmouseover = Prototype.emptyFunction;
84
+ link.onmouseout = Prototype.emptyFunction;
85
+ link.onclick = Prototype.emptyFunction;
86
+ link.observe('click',function(event){
87
+ Event.stop(event);
88
+ return false;
89
+ }.bindAsEventListener(this));
90
+ link.style.cursor = 'default';
91
+ }.bind(this));
92
+ },
93
+ setValueFromInput: function(input,prevent_callbacks){
94
+ this.setValue($F(input),true,prevent_callbacks);
95
+ },
96
+ setValue: function(value,force_selected,prevent_callbacks){
97
+ this.value = value;
98
+ if(this.options.input){
99
+ if(this.options.input.options){
100
+ $A(this.options.input.options).each(function(option,i){
101
+ if(option.value == this.value){
102
+ this.options.input.options.selectedIndex = i;
103
+ throw $break;
104
+ }
105
+ }.bind(this));
106
+ }else {
107
+ this.options.input.value = this.value; }
108
+ }
109
+ this.render(this.value,force_selected);
110
+ if(!prevent_callbacks){
111
+ if(this.options.updateUrl){
112
+ var params = {}, a;
113
+ params[this.options.updateParameterName] = this.value;
114
+ a = new Ajax.Request(this.options.updateUrl, Object.extend(
115
+ this.options.updateOptions, { parameters : params }
116
+ ));
117
+ }
118
+ this.notify('afterChange',this.value);
119
+ }
120
+ },
121
+ render: function(rating,force_selected){
122
+ (this.options.reverse ? this.links.reverse() : this.links).each(function(link,i){
123
+ if(link.value <= Math.ceil(rating)){
124
+ link.className = this.options.classNames[link.value <= rating ? 'on' : 'half'];
125
+ if(this.options.rated || force_selected) {
126
+ link.addClassName(this.options.classNames.selected); }
127
+ }else {
128
+ link.className = this.options.classNames.off; }
129
+ }.bind(this));
130
+ },
131
+ mouseOver: function(link){
132
+ this.render(link.value,true);
133
+ },
134
+ mouseOut: function(link){
135
+ this.render(this.value);
136
+ },
137
+ click: function(event,link){
138
+ this.options.rated = true;
139
+ this.setValue((link.value ? link.value : link),true);
140
+ if(!this.options.multiple) {
141
+ this.disable(); }
142
+ if(this.options.capture){
143
+ Event.stop(event);
144
+ return false;
145
+ }
146
+ }
147
+ });
148
+ Object.extend(Control.Rating,{
149
+ instances: [],
150
+ findByElementId: function(id){
151
+ return Control.Rating.instances.find(function(instance){
152
+ return (instance.container.id && instance.container.id == id);
153
+ });
154
+ }
155
+ });
156
+ Object.Event.extend(Control.Rating);
js/realex/livepipe/resizable.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ // script.aculo.us Resizables.js
3
+
4
+ // Copyright(c) 2007 - Orr Siloni, Comet Information Systems http://www.comet.co.il/en/
5
+ //
6
+ // Resizable.js is freely distributable under the terms of an MIT-style license.
7
+ // For details, see the script.aculo.us web site: http://script.aculo.us/
8
+
9
+ var Resizables = {
10
+ instances: [],
11
+ observers: [],
12
+
13
+ register: function(resizable) {
14
+ if(this.instances.length == 0) {
15
+ this.eventMouseUp = this.endResize.bindAsEventListener(this);
16
+ this.eventMouseMove = this.updateResize.bindAsEventListener(this);
17
+
18
+ Event.observe(document, "mouseup", this.eventMouseUp);
19
+ Event.observe(document, "mousemove", this.eventMouseMove);
20
+ }
21
+ this.instances.push(resizable);
22
+ },
23
+
24
+ unregister: function(resizable) {
25
+ this.instances = this.instances.reject(function(d) { return d==resizable });
26
+ if(this.instances.length == 0) {
27
+ Event.stopObserving(document, "mouseup", this.eventMouseUp);
28
+ Event.stopObserving(document, "mousemove", this.eventMouseMove);
29
+ }
30
+ },
31
+
32
+ activate: function(resizable) {
33
+ if(resizable.options.delay) {
34
+ this._timeout = setTimeout(function() {
35
+ Resizables._timeout = null;
36
+ Resizables.activeResizable = resizable;
37
+ }.bind(this), resizable.options.delay);
38
+ } else {
39
+ this.activeResizable = resizable;
40
+ }
41
+ },
42
+
43
+ deactivate: function() {
44
+ this.activeResizable = null;
45
+ },
46
+
47
+ updateResize: function(event) {
48
+ if(!this.activeResizable) return;
49
+ var pointer = [Event.pointerX(event), Event.pointerY(event)];
50
+ // Mozilla-based browsers fire successive mousemove events with
51
+ // the same coordinates, prevent needless redrawing (moz bug?)
52
+ if(this._lastPointer && (this._lastPointer.inspect() == pointer.inspect())) return;
53
+ this._lastPointer = pointer;
54
+
55
+ this.activeResizable.updateResize(event, pointer);
56
+ },
57
+
58
+ endResize: function(event) {
59
+ if(this._timeout) {
60
+ clearTimeout(this._timeout);
61
+ this._timeout = null;
62
+ }
63
+ if(!this.activeResizable) return;
64
+ this._lastPointer = null;
65
+ this.activeResizable.endResize(event);
66
+ this.activeResizable = null;
67
+ },
68
+
69
+ addObserver: function(observer) {
70
+ this.observers.push(observer);
71
+ this._cacheObserverCallbacks();
72
+ },
73
+
74
+ removeObserver: function(element) { // element instead of observer fixes mem leaks
75
+ this.observers = this.observers.reject( function(o) { return o.element==element });
76
+ this._cacheObserverCallbacks();
77
+ },
78
+
79
+ notify: function(eventName, resizable, event) { // 'onStart', 'onEnd', 'onResize'
80
+ if(this[eventName+'Count'] > 0)
81
+ this.observers.each( function(o) {
82
+ if(o[eventName]) o[eventName](eventName, resizable, event);
83
+ });
84
+ if(resizable.options[eventName]) resizable.options[eventName](resizable, event);
85
+ },
86
+
87
+ _cacheObserverCallbacks: function() {
88
+ ['onStart','onEnd','onResize'].each( function(eventName) {
89
+ Resizables[eventName+'Count'] = Resizables.observers.select(
90
+ function(o) { return o[eventName]; }
91
+ ).length;
92
+ });
93
+ }
94
+ }
95
+
96
+ var Resizable = Class.create();
97
+ Resizable._resizing = {};
98
+
99
+ Resizable.prototype = {
100
+ initialize: function(element){
101
+ var defaults = {
102
+ handle: false,
103
+ snap: false, // false, or xy or [x,y] or function(x,y){ return [x,y] }
104
+ delay: 0,
105
+ minHeight: false,
106
+ minwidth: false,
107
+ maxHeight: false,
108
+ maxWidth: false
109
+ }
110
+
111
+ this.element = $(element);
112
+
113
+ var options = Object.extend(defaults, arguments[1] || {});
114
+ if(options.handle && typeof options.handle == 'string')
115
+ this.handle = $(options.handle);
116
+ else if(options.handle)
117
+ this.handle = options.handle;
118
+
119
+ if(!this.handle) this.handle = this.element;
120
+
121
+ this.options = options;
122
+ this.dragging = false;
123
+
124
+ this.eventMouseDown = this.initResize.bindAsEventListener(this);
125
+ Event.observe(this.handle, "mousedown", this.eventMouseDown);
126
+
127
+ Resizables.register(this);
128
+ },
129
+
130
+ destroy: function() {
131
+ Event.stopObserving(this.handle, "mousedown", this.eventMouseDown);
132
+ },
133
+
134
+ currentDelta: function() {
135
+ return([
136
+ parseInt(Element.getStyle(this.element,'width') || '0'),
137
+ parseInt(Element.getStyle(this.element,'height') || '0')]);
138
+ },
139
+
140
+ initResize: function(event) {
141
+ if(typeof Resizable._resizing[this.element] != 'undefined' &&
142
+ Resizable._resizing[this.element]) return;
143
+ if(Event.isLeftClick(event)) {
144
+ // abort on form elements, fixes a Firefox issue
145
+ var src = Event.element(event);
146
+ if((tag_name = src.tagName.toUpperCase()) && (
147
+ tag_name=='INPUT' || tag_name=='SELECT' || tag_name=='OPTION' ||
148
+ tag_name=='BUTTON' || tag_name=='TEXTAREA')) return;
149
+
150
+ this.pointer = [Event.pointerX(event), Event.pointerY(event)];
151
+ this.size = [parseInt(this.element.getStyle('width')) || 0, parseInt(this.element.getStyle('height')) || 0];
152
+
153
+ Resizables.activate(this);
154
+ Event.stop(event);
155
+ }
156
+ },
157
+
158
+ startResize: function(event) {
159
+ this.resizing = true;
160
+ if(this.options.zindex) {
161
+ this.originalZ = parseInt(Element.getStyle(this.element,'z-index') || 0);
162
+ this.element.style.zIndex = this.options.zindex;
163
+ }
164
+ Resizables.notify('onStart', this, event);
165
+ Resizable._resizing[this.element] = true;
166
+ },
167
+
168
+ updateResize: function(event, pointer) {
169
+ if(!this.resizing) this.startResize(event);
170
+
171
+ Resizables.notify('onResize', this, event);
172
+
173
+ this.draw(pointer);
174
+ if(this.options.change) this.options.change(this);
175
+
176
+ // fix AppleWebKit rendering
177
+ if(Prototype.Browser.WebKit) window.scrollBy(0,0);
178
+ Event.stop(event);
179
+ },
180
+
181
+ finishResize: function(event, success) {
182
+ this.resizing = false;
183
+ Resizables.notify('onEnd', this, event);
184
+ if(this.options.zindex) this.element.style.zIndex = this.originalZ;
185
+ Resizable._resizing[this.element] = false;
186
+ Resizables.deactivate(this);
187
+ },
188
+
189
+ endResize: function(event) {
190
+ if(!this.resizing) return;
191
+ this.finishResize(event, true);
192
+ Event.stop(event);
193
+ },
194
+
195
+ draw: function(point) {
196
+ var p = [0,1].map(function(i){
197
+ return (this.size[i] + point[i] - this.pointer[i]);
198
+ }.bind(this));
199
+
200
+ if(this.options.snap) {
201
+ if(typeof this.options.snap == 'function') {
202
+ p = this.options.snap(p[0],p[1],this);
203
+ } else {
204
+ if(this.options.snap instanceof Array) {
205
+ p = p.map( function(v, i) {
206
+ return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
207
+ } else {
208
+ p = p.map( function(v) {
209
+ return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
210
+ }
211
+ }}
212
+
213
+ var minWidth = (typeof(this.options.minWidth) == 'function') ? this.options.minWidth(this.element) : this.options.minWidth;
214
+ var maxWidth = (typeof(this.options.maxWidth) == 'function') ? this.options.maxWidth(this.element) : this.options.maxWidth;
215
+ var minHeight = (typeof(this.options.minHeight) == 'function') ? this.options.minHeight(this.element) : this.options.minHeight;
216
+ var maxHeight = (typeof(this.options.maxHeight) == 'function') ? this.options.maxHeight(this.element) : this.options.maxHeight;
217
+
218
+ if (minWidth && p[0] <= minWidth) p[0] = minWidth;
219
+ if (maxWidth && p[0] >= maxWidth) p[0] = maxWidth;
220
+ if (minHeight && p[1] <= minHeight) p[1] = minHeight;
221
+ if (maxHeight && p[1] >= maxHeight) p[1] = maxHeight;
222
+
223
+ var style = this.element.style;
224
+ if((!this.options.constraint) || (this.options.constraint=='horizontal')){
225
+ style.width = p[0] + "px";
226
+ }
227
+ if((!this.options.constraint) || (this.options.constraint=='vertical')){
228
+ style.height = p[1] + "px";
229
+ }
230
+
231
+ if(style.visibility=="hidden") style.visibility = ""; // fix gecko rendering
232
+ }
233
+ };
js/realex/livepipe/scrollbar.js ADDED
@@ -0,0 +1,227 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/scrollbar
7
+ * @require prototype.js, slider.js, livepipe.js
8
+ */
9
+
10
+ if(typeof(Prototype) == "undefined")
11
+ throw "Control.ScrollBar requires Prototype to be loaded.";
12
+ if(typeof(Control.Slider) == "undefined")
13
+ throw "Control.ScrollBar requires Control.Slider to be loaded.";
14
+ if(typeof(Object.Event) == "undefined")
15
+ throw "Control.ScrollBar requires Object.Event to be loaded.";
16
+
17
+ Control.ScrollBar = Class.create({
18
+ initialize: function(container,track,options){
19
+ Control.ScrollBar.instances.push(this);
20
+ this.enabled = false;
21
+ this.notificationTimeout = false;
22
+ this.container = $(container);
23
+ this.boundMouseWheelEvent = this.onMouseWheel.bindAsEventListener(this);
24
+ this.boundResizeObserver = this.onWindowResize.bind(this);
25
+ this.track = $(track);
26
+ this.handle = this.track.firstDescendant();
27
+ this.options = Object.extend({
28
+ active_class_name: 'scrolling',
29
+ apply_active_class_name_to: this.container,
30
+ notification_timeout_length: 125,
31
+ handle_minimum_length: 25,
32
+ scroll_to_smoothing: 0.01,
33
+ scroll_to_steps: 15,
34
+ scroll_to_precision: 100,
35
+ proportional: true,
36
+ custom_event: null,
37
+ custom_event_handler: null,
38
+ scroll_axis: 'vertical',
39
+ /**
40
+ * If this value is larger than 0 (e.g. 50), one mouse wheel event will scroll the page
41
+ * by the given number of pixels (default behaviour in any program). If it is lower than 0,
42
+ * the scrollbar's default behaviour will be used (scrolls down 1/20 of the page, no matter
43
+ * how long it is). Initialization with e.g.:
44
+ * new Control.ScrollBar(
45
+ document.getElementById('scrollbar_content'),
46
+ document.getElementById('scrollbar_track'),
47
+ { fixed_scroll_distance: 50 });
48
+ */
49
+ fixed_scroll_distance: -1,
50
+ slider_options: {}
51
+ },options || {});
52
+ this.slider = new Control.Slider(this.handle,this.track,Object.extend({
53
+ axis: this.options.scroll_axis,
54
+ onSlide: this.onChange.bind(this),
55
+ onChange: this.onChange.bind(this)
56
+ },this.options.slider_options));
57
+ this.recalculateLayout();
58
+ Event.observe(window,'resize',this.boundResizeObserver);
59
+ if (this.options.custom_event) {
60
+ if (Object.isFunction(this.options.custom_event_handler)) {
61
+ this.container.observe(this.options.custom_event, this.options.custom_event_handler);
62
+ } else {
63
+ this.container.observe(this.options.custom_event, this.boundResizeObserver);
64
+ }
65
+ }
66
+ this.handle.observe('mousedown',function(){
67
+ if(this.auto_sliding_executer)
68
+ this.auto_sliding_executer.stop();
69
+ }.bind(this));
70
+ },
71
+ destroy: function(){
72
+ Event.stopObserving(window,'resize',this.boundResizeObserver);
73
+ if(this.options.active_class_name)
74
+ $(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name);
75
+ if (this.options.custom_event) {
76
+ this.container.stopObserving(this.options.custom_event);
77
+ }
78
+ },
79
+ scrollLength: function(){
80
+ return (this.options.scroll_axis == 'vertical') ? this.container.scrollHeight : this.container.scrollWidth;
81
+ },
82
+ offsetLength: function(){
83
+ return (this.options.scroll_axis == 'vertical') ? this.container.offsetHeight : this.container.offsetWidth;
84
+ },
85
+ enable: function(){
86
+ this.enabled = true;
87
+ this.container.observe('mouse:wheel',this.boundMouseWheelEvent);
88
+ this.slider.setEnabled();
89
+ this.track.show();
90
+ if(this.options.active_class_name)
91
+ $(this.options.apply_active_class_name_to).addClassName(this.options.active_class_name);
92
+ this.notify('enabled');
93
+ },
94
+ disable: function(){
95
+ this.enabled = false;
96
+ this.container.stopObserving('mouse:wheel',this.boundMouseWheelEvent);
97
+ this.slider.setDisabled();
98
+ this.track.hide();
99
+ if(this.options.active_class_name)
100
+ $(this.options.apply_active_class_name_to).removeClassName(this.options.active_class_name);
101
+ this.notify('disabled');
102
+ this.reset();
103
+ },
104
+ reset: function(){
105
+ this.slider.setValue(0);
106
+ },
107
+ recalculateLayout: function(){
108
+ if(this.scrollLength() <= this.offsetLength())
109
+ this.disable();
110
+ else{
111
+ this.enable();
112
+ this.slider.trackLength = this.slider.maximumOffset() - this.slider.minimumOffset();
113
+ if(this.options.proportional){
114
+ this.slider.handleLength = Math.max(this.offsetLength() * (this.offsetLength() / this.scrollLength()),this.options.handle_minimum_length);
115
+ if (this.options.scroll_axis == 'vertical')
116
+ this.handle.style.height = this.slider.handleLength + 'px';
117
+ else
118
+ this.handle.style.width = this.slider.handleLength + 'px';
119
+ }
120
+ this.scrollBy(0);
121
+ }
122
+ },
123
+ onWindowResize: function(){
124
+ this.recalculateLayout();
125
+ this.scrollBy(0);
126
+ },
127
+ onMouseWheel: function(event){
128
+ if(this.auto_sliding_executer) {
129
+ this.auto_sliding_executer.stop();
130
+ }
131
+ if (this.options.fixed_scroll_distance > 0) {
132
+ // Move the content by the given number of pixels each wheel event
133
+ this.slider.setValueBy(-(this.options.fixed_scroll_distance * event.memo.delta / (this.scrollLength()-this.slider.trackLength)));
134
+ } else {
135
+ // Move the content by 1/20 of the page
136
+ this.slider.setValueBy(-(event.memo.delta / 20));
137
+ }
138
+ event.stop();
139
+ return false;
140
+ },
141
+ onChange: function(value){
142
+ var scroll_pos = Math.round(value / this.slider.maximum * (this.scrollLength() - this.offsetLength()));
143
+ if (this.options.scroll_axis == 'vertical')
144
+ this.container.scrollTop = scroll_pos;
145
+ else
146
+ this.container.scrollLeft = scroll_pos;
147
+ if(this.notification_timeout)
148
+ window.clearTimeout(this.notificationTimeout);
149
+ this.notificationTimeout = window.setTimeout(function(){
150
+ this.notify('change',value);
151
+ }.bind(this),this.options.notification_timeout_length);
152
+ },
153
+ getCurrentMaximumDelta: function(){
154
+ return this.slider.maximum * (this.scrollLength() - this.offsetLength());
155
+ },
156
+ getContainerOffset: function(element) {
157
+ var offset = element.positionedOffset();
158
+ while (element.getOffsetParent() != this.container)
159
+ {
160
+ element = element.getOffsetParent();
161
+ offset[0] += element.positionedOffset()[0];
162
+ offset[1] += element.positionedOffset()[1];
163
+ offset.top += element.positionedOffset().top;
164
+ offset.left += element.positionedOffset().left;
165
+ }
166
+ return offset;
167
+ },
168
+ getDeltaToElement: function(element){
169
+
170
+ if (this.options.scroll_axis == 'vertical')
171
+ return this.slider.maximum * ((this.getContainerOffset(element).top + (element.getHeight() / 2)) - (this.container.getHeight() / 2));
172
+ else
173
+ return this.slider.maximum * ((this.getContainerOffset(element).left + (element.getWidth() / 2)) - (this.container.getWidth() / 2));
174
+ },
175
+ scrollTo: function(y,animate){
176
+ var precision = this.options.scroll_to_precision,
177
+ current_maximum_delta = this.getCurrentMaximumDelta();
178
+ if (precision == 'auto')
179
+ precision = Math.pow(10, Math.ceil(Math.log(current_maximum_delta)/Math.log(10)));
180
+ if(y == 'top')
181
+ y = 0;
182
+ else if(y == 'bottom')
183
+ y = current_maximum_delta;
184
+ else if(typeof(y) != "number")
185
+ y = this.getDeltaToElement($(y));
186
+ if(this.enabled){
187
+ y = Math.max(0,Math.min(y,current_maximum_delta));
188
+ if(this.auto_sliding_executer)
189
+ this.auto_sliding_executer.stop();
190
+ var target_value = y / current_maximum_delta;
191
+ var original_slider_value = this.slider.value;
192
+ var delta = (target_value - original_slider_value) * current_maximum_delta;
193
+ if(animate){
194
+ this.auto_sliding_executer = new PeriodicalExecuter(function(){
195
+ if(Math.round(this.slider.value * precision) / precision < Math.round(target_value * precision) / precision || Math.round(this.slider.value * precision) / precision > Math.round(target_value * precision) / precision){
196
+ this.scrollBy(delta / this.options.scroll_to_steps);
197
+ }else{
198
+ this.auto_sliding_executer.stop();
199
+ this.auto_sliding_executer = null;
200
+ if(typeof(animate) == "function")
201
+ animate();
202
+ }
203
+ }.bind(this),this.options.scroll_to_smoothing);
204
+ }else
205
+ this.scrollBy(delta);
206
+ }else if(typeof(animate) == "function")
207
+ animate();
208
+ },
209
+ scrollBy: function(y){
210
+ if(!this.enabled)
211
+ return false;
212
+ this.slider.setValueBy(y / (this.getCurrentMaximumDelta() == 0 ? 1 : this.getCurrentMaximumDelta()) );
213
+ }
214
+ });
215
+ Object.extend(Control.ScrollBar,
216
+ {
217
+ instances: [],
218
+
219
+ findByElementId: function(id)
220
+ {
221
+ return Control.ScrollBar.instances.find(function(instance)
222
+ {
223
+ return (instance.container.id && instance.container.id == id);
224
+ });
225
+ }
226
+ });
227
+ Object.Event.extend(Control.ScrollBar);
js/realex/livepipe/selection.js ADDED
@@ -0,0 +1,459 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/selection
7
+ * @require prototype.js, effects.js, draggable.js, livepipe.js
8
+ */
9
+
10
+ /*global window, document, Prototype, Element, Event, $, $$, $break, Control, Draggable */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.Selection requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.Selection requires Object.Event to be loaded."; }
16
+
17
+ Control.Selection = {
18
+ options: {
19
+ resize_layout_timeout: 125,
20
+ selected: Prototype.emptyFunction,
21
+ deselected: Prototype.emptyFunction,
22
+ change: Prototype.emptyFunction,
23
+ selection_id: 'control_selection',
24
+ selection_style: {
25
+ zIndex: 999,
26
+ cursor: 'default',
27
+ border: '1px dotted #000'
28
+ },
29
+ filter: function(element){
30
+ return true;
31
+ },
32
+ drag_proxy: false,
33
+ drag_proxy_threshold: 1,
34
+ drag_proxy_options: {}
35
+ },
36
+ selectableElements: [],
37
+ elements: [],
38
+ selectableObjects: [],
39
+ objects: [],
40
+ active: false,
41
+ container: false,
42
+ resizeTimeout: false,
43
+ load: function(options){
44
+ Control.Selection.options = Object.extend(Control.Selection.options,options || {});
45
+ Control.Selection.selection_div = $(document.createElement('div'));
46
+ Control.Selection.selection_div.id = Control.Selection.options.selection_id;
47
+ Control.Selection.selection_div.style.display = 'none';
48
+ Control.Selection.selection_div.setStyle(Control.Selection.options.selection_style);
49
+ Control.Selection.border_width = parseInt(Control.Selection.selection_div.getStyle('border-top-width'), 10) * 2;
50
+ Control.Selection.container = Prototype.Browser.IE ? window.container : window;
51
+ $(document.body).insert(Control.Selection.selection_div);
52
+ Control.Selection.enable();
53
+ if(Control.Selection.options.drag_proxy && typeof(Draggable) != 'undefined') {
54
+ Control.Selection.DragProxy.load(); }
55
+ Event.observe(window,'resize',function(){
56
+ if(Control.Selection.resizeTimeout) {
57
+ window.clearTimeout(Control.Selection.resizeTimeout); }
58
+ Control.Selection.resizeTimeout = window.setTimeout(Control.Selection.recalculateLayout,Control.Selection.options.resize_layout_timeout);
59
+ });
60
+ if(Prototype.Browser.IE){
61
+ var body = $$('body').first();
62
+ body.observe('mouseleave',Control.Selection.stop);
63
+ body.observe('mouseup',Control.Selection.stop);
64
+ }
65
+ },
66
+ enable: function(){
67
+ if(Prototype.Browser.IE){
68
+ document.onselectstart = function(){
69
+ return false;
70
+ };
71
+ }
72
+ Event.observe(Control.Selection.container,'mousedown',Control.Selection.start);
73
+ Event.observe(Control.Selection.container,'mouseup',Control.Selection.stop);
74
+ },
75
+ disable: function(){
76
+ if(Prototype.Browser.IE){
77
+ document.onselectstart = function(){
78
+ return true;
79
+ };
80
+ }
81
+ Event.stopObserving(Control.Selection.container,'mousedown',Control.Selection.start);
82
+ Event.stopObserving(Control.Selection.container,'mouseup',Control.Selection.stop);
83
+ },
84
+ recalculateLayout: function(){
85
+ Control.Selection.selectableElements.each(function(element){
86
+ var dimensions = element.getDimensions();
87
+ var offset = element.cumulativeOffset();
88
+ var scroll_offset = element.cumulativeScrollOffset();
89
+ if(!element._control_selection) {
90
+ element._control_selection = {}; }
91
+ element._control_selection.top = offset[1] - scroll_offset[1];
92
+ element._control_selection.left = offset[0] - scroll_offset[0];
93
+ element._control_selection.width = dimensions.width;
94
+ element._control_selection.height = dimensions.height;
95
+ });
96
+ },
97
+ addSelectable: function(element,object,activation_targets,activation_target_callback){
98
+ element = $(element);
99
+ if(activation_targets) {
100
+ activation_targets = activation_targets.each ? activation_targets : [activation_targets]; }
101
+ var dimensions = element.getDimensions();
102
+ var offset = Element.cumulativeOffset(element);
103
+ element._control_selection = {
104
+ activation_targets: activation_targets,
105
+ is_selected: false,
106
+ top: offset[1],
107
+ left: offset[0],
108
+ width: dimensions.width,
109
+ height: dimensions.height,
110
+ activationTargetMouseMove: function(){
111
+ Control.Selection.notify('activationTargetMouseMove',element);
112
+ if(activation_targets){
113
+ activation_targets.each(function(activation_target){
114
+ activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);
115
+ });
116
+ }
117
+ Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);
118
+ },
119
+ activationTargetMouseDown: function(event){
120
+ if(!Control.Selection.elements.include(element)) {
121
+ Control.Selection.select(element); }
122
+ Control.Selection.DragProxy.start(event);
123
+ Control.Selection.DragProxy.container.hide();
124
+ if(activation_targets){
125
+ activation_targets.each(function(activation_target){
126
+ activation_target.observe('mousemove',element._control_selection.activationTargetMouseMove);
127
+ });
128
+ }
129
+ Control.Selection.DragProxy.container.observe('mousemove',element._control_selection.activationTargetMouseMove);
130
+ },
131
+ activationTargetClick: function(){
132
+ Control.Selection.select(element);
133
+ if(typeof(activation_target_callback) == "function") {
134
+ activation_target_callback(); }
135
+ if(activation_targets){
136
+ activation_targets.each(function(activation_target){
137
+ activation_target.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);
138
+ });
139
+ }
140
+ Control.Selection.DragProxy.container.stopObserving('mousemove',element._control_selection.activationTargetMouseMove);
141
+ }
142
+ };
143
+ element.onselectstart = function(){
144
+ return false;
145
+ };
146
+ element.unselectable = 'on';
147
+ element.style.MozUserSelect = 'none';
148
+ if(activation_targets){
149
+ activation_targets.each(function(activation_target){
150
+ activation_target.observe('mousedown',element._control_selection.activationTargetMouseDown);
151
+ activation_target.observe('click',element._control_selection.activationTargetClick);
152
+ });
153
+ }
154
+ Control.Selection.selectableElements.push(element);
155
+ Control.Selection.selectableObjects.push(object);
156
+ },
157
+ removeSelectable: function(element){
158
+ element = $(element);
159
+ if(element._control_selection.activation_targets){
160
+ element._control_selection.activation_targets.each(function(activation_target){
161
+ activation_target.stopObserving('mousedown',element._control_selection.activationTargetMouseDown);
162
+ });
163
+ element._control_selection.activation_targets.each(function(activation_target){
164
+ activation_target.stopObserving('click',element._control_selection.activationTargetClick);
165
+ });
166
+ }
167
+ element._control_selection = null;
168
+ element.onselectstart = function() {
169
+ return true;
170
+ };
171
+ element.unselectable = 'off';
172
+ element.style.MozUserSelect = '';
173
+ var position = 0;
174
+ Control.Selection.selectableElements.each(function(selectable_element,i){
175
+ if(selectable_element == element){
176
+ position = i;
177
+ throw $break;
178
+ }
179
+ });
180
+ Control.Selection.selectableElements = Control.Selection.selectableElements.without(element);
181
+ Control.Selection.selectableObjects = Control.Selection.selectableObjects.slice(0,position).concat(Control.Selection.selectableObjects.slice(position + 1));
182
+ },
183
+ select: function(selected_elements){
184
+ if(typeof(selected_elements) == "undefined" || !selected_elements) {
185
+ selected_elements = []; }
186
+ if(!selected_elements.each && !selected_elements._each) {
187
+ selected_elements = [selected_elements]; }
188
+ //comparing the arrays directly wouldn't equate to true in safari so we need to compare each item
189
+ var selected_items_have_changed = !(Control.Selection.elements.length == selected_elements.length && Control.Selection.elements.all(function(item,i){
190
+ return selected_elements[i] == item;
191
+ }));
192
+ if(!selected_items_have_changed) {
193
+ return; }
194
+ var selected_objects_indexed_by_element = {};
195
+ var selected_objects = selected_elements.collect(function(selected_element){
196
+ var selected_object = Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(selected_element)];
197
+ selected_objects_indexed_by_element[selected_element] = selected_object;
198
+ return selected_object;
199
+ });
200
+ if(Control.Selection.elements.length === 0 && selected_elements.length !== 0){
201
+ selected_elements.each(function(element){
202
+ Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);
203
+ });
204
+ }else{
205
+ Control.Selection.elements.each(function(element){
206
+ if(!selected_elements.include(element)){
207
+ Control.Selection.notify('deselected',element,selected_objects_indexed_by_element[element]);
208
+ }
209
+ });
210
+ selected_elements.each(function(element){
211
+ if(!Control.Selection.elements.include(element)){
212
+ Control.Selection.notify('selected',element,selected_objects_indexed_by_element[element]);
213
+ }
214
+ });
215
+ }
216
+ Control.Selection.elements = selected_elements;
217
+ Control.Selection.objects = selected_objects;
218
+ Control.Selection.notify('change',Control.Selection.elements,Control.Selection.objects);
219
+ },
220
+ deselect: function(){
221
+ if(Control.Selection.notify('deselect') === false) {
222
+ return false; }
223
+ Control.Selection.elements.each(function(element){
224
+ Control.Selection.notify('deselected',element,Control.Selection.selectableObjects[Control.Selection.selectableElements.indexOf(element)]);
225
+ });
226
+ Control.Selection.objects = [];
227
+ Control.Selection.elements = [];
228
+ Control.Selection.notify('change',Control.Selection.objects,Control.Selection.elements);
229
+ return true;
230
+ },
231
+ //private
232
+ start: function(event){
233
+ if(!event.isLeftClick() || Control.Selection.notify('start',event) === false) {
234
+ return false; }
235
+ if(!event.shiftKey && !event.altKey) {
236
+ Control.Selection.deselect(); }
237
+ Event.observe(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);
238
+ Event.stop(event);
239
+ return false;
240
+ },
241
+ stop: function(){
242
+ Event.stopObserving(Control.Selection.container,'mousemove',Control.Selection.onMouseMove);
243
+ Control.Selection.active = false;
244
+ Control.Selection.selection_div.setStyle({
245
+ display: 'none',
246
+ top: null,
247
+ left: null,
248
+ width: null,
249
+ height: null
250
+ });
251
+ Control.Selection.start_mouse_coordinates = {};
252
+ Control.Selection.current_mouse_coordinates = {};
253
+ },
254
+ mouseCoordinatesFromEvent: function(event){
255
+ return {
256
+ x: Event.pointerX(event),
257
+ y: Event.pointerY(event)
258
+ };
259
+ },
260
+ onClick: function(event,element,source){
261
+ var selection = [];
262
+ if(event.shiftKey){
263
+ selection = Control.Selection.elements.clone();
264
+ if(!selection.include(element)) {
265
+ selection.push(element); }
266
+ }else if(event.altKey){
267
+ selection = Control.Selection.elements.clone();
268
+ if(selection.include(element)) {
269
+ selection = selection.without(element); }
270
+ }else{
271
+ selection = [element];
272
+ }
273
+ Control.Selection.select(selection);
274
+ if(source == 'click') {
275
+ Event.stop(event); }
276
+ },
277
+ onMouseMove: function(event){
278
+ if(!Control.Selection.active){
279
+ Control.Selection.active = true;
280
+ Control.Selection.start_mouse_coordinates = Control.Selection.mouseCoordinatesFromEvent(event);
281
+ }else{
282
+ Control.Selection.current_mouse_coordinates = Control.Selection.mouseCoordinatesFromEvent(event);
283
+ Control.Selection.drawSelectionDiv();
284
+ var current_selection = Control.Selection.selectableElements.findAll(function(element){
285
+ return Control.Selection.options.filter(element) && Control.Selection.elementWithinSelection(element);
286
+ });
287
+ if(event.shiftKey && !event.altKey){
288
+ Control.Selection.elements.each(function(element){
289
+ if(!current_selection.include(element)) {
290
+ current_selection.push(element); }
291
+ });
292
+ }else if(event.altKey && !event.shiftKey){
293
+ current_selection = Control.Selection.elements.findAll(function(element){
294
+ return !current_selection.include(element);
295
+ });
296
+ }
297
+ Control.Selection.select(current_selection);
298
+ }
299
+ },
300
+ drawSelectionDiv: function(){
301
+ if(Control.Selection.start_mouse_coordinates == Control.Selection.current_mouse_coordinates){
302
+ Control.Selection.selection_div.style.display = 'none';
303
+ }else{
304
+ Control.Selection.viewport = document.viewport.getDimensions();
305
+ Control.Selection.selection_div.style.position = 'absolute';
306
+ Control.Selection.current_direction = (Control.Selection.start_mouse_coordinates.y > Control.Selection.current_mouse_coordinates.y ? 'N' : 'S') + (Control.Selection.start_mouse_coordinates.x < Control.Selection.current_mouse_coordinates.x ? 'E' : 'W');
307
+ Control.Selection.selection_div.setStyle(Control.Selection['dimensionsFor' + Control.Selection.current_direction]());
308
+ Control.Selection.selection_div.style.display = 'block';
309
+ }
310
+ },
311
+ dimensionsForNW: function(){
312
+ return {
313
+ top: (Control.Selection.start_mouse_coordinates.y - (Control.Selection.start_mouse_coordinates.y - Control.Selection.current_mouse_coordinates.y)) + 'px',
314
+ left: (Control.Selection.start_mouse_coordinates.x - (Control.Selection.start_mouse_coordinates.x - Control.Selection.current_mouse_coordinates.x)) + 'px',
315
+ width: (Control.Selection.start_mouse_coordinates.x - Control.Selection.current_mouse_coordinates.x) + 'px',
316
+ height: (Control.Selection.start_mouse_coordinates.y - Control.Selection.current_mouse_coordinates.y) + 'px'
317
+ };
318
+ },
319
+ dimensionsForNE: function(){
320
+ return {
321
+ top: (Control.Selection.start_mouse_coordinates.y - (Control.Selection.start_mouse_coordinates.y - Control.Selection.current_mouse_coordinates.y)) + 'px',
322
+ left: Control.Selection.start_mouse_coordinates.x + 'px',
323
+ width: Math.min((Control.Selection.viewport.width - Control.Selection.start_mouse_coordinates.x) - Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x - Control.Selection.start_mouse_coordinates.x) + 'px',
324
+ height: (Control.Selection.start_mouse_coordinates.y - Control.Selection.current_mouse_coordinates.y) + 'px'
325
+ };
326
+ },
327
+ dimensionsForSE: function(){
328
+ return {
329
+ top: Control.Selection.start_mouse_coordinates.y + 'px',
330
+ left: Control.Selection.start_mouse_coordinates.x + 'px',
331
+ width: Math.min((Control.Selection.viewport.width - Control.Selection.start_mouse_coordinates.x) - Control.Selection.border_width,Control.Selection.current_mouse_coordinates.x - Control.Selection.start_mouse_coordinates.x) + 'px',
332
+ height: Math.min((Control.Selection.viewport.height - Control.Selection.start_mouse_coordinates.y) - Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y - Control.Selection.start_mouse_coordinates.y) + 'px'
333
+ };
334
+ },
335
+ dimensionsForSW: function(){
336
+ return {
337
+ top: Control.Selection.start_mouse_coordinates.y + 'px',
338
+ left: (Control.Selection.start_mouse_coordinates.x - (Control.Selection.start_mouse_coordinates.x - Control.Selection.current_mouse_coordinates.x)) + 'px',
339
+ width: (Control.Selection.start_mouse_coordinates.x - Control.Selection.current_mouse_coordinates.x) + 'px',
340
+ height: Math.min((Control.Selection.viewport.height - Control.Selection.start_mouse_coordinates.y) - Control.Selection.border_width,Control.Selection.current_mouse_coordinates.y - Control.Selection.start_mouse_coordinates.y) + 'px'
341
+ };
342
+ },
343
+ inBoundsForNW: function(element,selection){
344
+ return (
345
+ ((element.left > selection.left || element.right > selection.left) && selection.right > element.left) &&
346
+ ((element.top > selection.top || element.bottom > selection.top) && selection.bottom > element.top)
347
+ );
348
+ },
349
+ inBoundsForNE: function(element,selection){
350
+ return (
351
+ ((element.left < selection.right || element.left < selection.right) && selection.left < element.right) &&
352
+ ((element.top > selection.top || element.bottom > selection.top) && selection.bottom > element.top)
353
+ );
354
+ },
355
+ inBoundsForSE: function(element,selection){
356
+ return (
357
+ ((element.left < selection.right || element.left < selection.right) && selection.left < element.right) &&
358
+ ((element.bottom < selection.bottom || element.top < selection.bottom) && selection.top < element.bottom)
359
+ );
360
+ },
361
+ inBoundsForSW: function(element,selection){
362
+ return (
363
+ ((element.left > selection.left || element.right > selection.left) && selection.right > element.left) &&
364
+ ((element.bottom < selection.bottom || element.top < selection.bottom) && selection.top < element.bottom)
365
+ );
366
+ },
367
+ elementWithinSelection: function(element){
368
+ if(Control.Selection['inBoundsFor' + Control.Selection.current_direction]({
369
+ top: element._control_selection.top,
370
+ left: element._control_selection.left,
371
+ bottom: element._control_selection.top + element._control_selection.height,
372
+ right: element._control_selection.left + element._control_selection.width
373
+ },{
374
+ top: parseInt(Control.Selection.selection_div.style.top, 10),
375
+ left: parseInt(Control.Selection.selection_div.style.left, 10),
376
+ bottom: parseInt(Control.Selection.selection_div.style.top, 10) + parseInt(Control.Selection.selection_div.style.height, 10),
377
+ right: parseInt(Control.Selection.selection_div.style.left, 10) + parseInt(Control.Selection.selection_div.style.width, 10)
378
+ })){
379
+ element._control_selection.is_selected = true;
380
+ return true;
381
+ }else{
382
+ element._control_selection.is_selected = false;
383
+ return false;
384
+ }
385
+ },
386
+ DragProxy: {
387
+ active: false,
388
+ xorigin: 0,
389
+ yorigin: 0,
390
+ load: function(){
391
+ Control.Selection.DragProxy.container = $(document.createElement('div'));
392
+ Control.Selection.DragProxy.container.id = 'control_selection_drag_proxy';
393
+ Control.Selection.DragProxy.container.setStyle({
394
+ position: 'absolute',
395
+ top: '1px',
396
+ left: '1px',
397
+ zIndex: 99999
398
+ });
399
+ Control.Selection.DragProxy.container.hide();
400
+ document.body.appendChild(Control.Selection.DragProxy.container);
401
+ Control.Selection.observe('selected',Control.Selection.DragProxy.selected);
402
+ Control.Selection.observe('deselected',Control.Selection.DragProxy.deselected);
403
+ },
404
+ start: function(event){
405
+ if(event.isRightClick()){
406
+ Control.Selection.DragProxy.container.hide();
407
+ return;
408
+ }
409
+ if(Control.Selection.DragProxy.xorigin == Event.pointerX(event) && Control.Selection.DragProxy.yorigin == Event.pointerY(event)) {
410
+ return; }
411
+ Control.Selection.DragProxy.active = true;
412
+ Control.Selection.DragProxy.container.setStyle({
413
+ position: 'absolute',
414
+ top: Event.pointerY(event) + 'px',
415
+ left: Event.pointerX(event) + 'px'
416
+ });
417
+ Control.Selection.DragProxy.container.observe('mouseup',Control.Selection.DragProxy.onMouseUp);
418
+ Control.Selection.DragProxy.container.show();
419
+ Control.Selection.DragProxy.container._draggable = new Draggable(Control.Selection.DragProxy.container,Object.extend({
420
+ onEnd: Control.Selection.DragProxy.stop
421
+ },Control.Selection.options.drag_proxy_options));
422
+ Control.Selection.DragProxy.container._draggable.eventMouseDown(event);
423
+ Control.Selection.DragProxy.notify('start',Control.Selection.DragProxy.container,Control.Selection.elements);
424
+ },
425
+ stop: function(){
426
+ window.setTimeout(function(){
427
+ Control.Selection.DragProxy.active = false;
428
+ Control.Selection.DragProxy.container.hide();
429
+ if(Control.Selection.DragProxy.container._draggable){
430
+ Control.Selection.DragProxy.container._draggable.destroy();
431
+ Control.Selection.DragProxy.container._draggable = null;
432
+ }
433
+ Control.Selection.DragProxy.notify('stop');
434
+ },1);
435
+ },
436
+ onClick: function(event){
437
+ Control.Selection.DragProxy.xorigin = Event.pointerX(event);
438
+ Control.Selection.DragProxy.yorigin = Event.pointerY(event);
439
+ if(event.isRightClick()) {
440
+ Control.Selection.DragProxy.container.hide(); }
441
+ if(Control.Selection.elements.length >= Control.Selection.options.drag_proxy_threshold && !(event.shiftKey || event.altKey) && (Control.Selection.DragProxy.xorigin != Event.pointerX(event) || Control.Selection.DragProxy.yorigin != Event.pointerY(event))){
442
+ Control.Selection.DragProxy.start(event);
443
+ Event.stop(event);
444
+ }
445
+ },
446
+ onMouseUp: function(event){
447
+ Control.Selection.DragProxy.stop();
448
+ Control.Selection.DragProxy.container.stopObserving('mouseup',Control.Selection.DragProxy.onMouseUp);
449
+ },
450
+ selected: function(element){
451
+ element.observe('mousedown',Control.Selection.DragProxy.onClick);
452
+ },
453
+ deselected: function(element){
454
+ element.stopObserving('mousedown',Control.Selection.DragProxy.onClick);
455
+ }
456
+ }
457
+ };
458
+ Object.Event.extend(Control.Selection);
459
+ Object.Event.extend(Control.Selection.DragProxy);
js/realex/livepipe/selectmultiple.js ADDED
@@ -0,0 +1,155 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/rating
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global Prototype, Class, Option, $, $A, Control, $break, */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.SelectMultiple requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.SelectMultiple requires Object.Event to be loaded."; }
16
+
17
+ Control.SelectMultiple = Class.create({
18
+ select: false,
19
+ container: false,
20
+ numberOfCheckedBoxes: 0,
21
+ checkboxes: [],
22
+ hasExtraOption: false,
23
+ initialize: function(select,container,options){
24
+ this.options = {
25
+ checkboxSelector: 'input[type=checkbox]',
26
+ nameSelector: 'span.name',
27
+ labelSeparator: ', ',
28
+ valueSeparator: ',',
29
+ afterChange: Prototype.emptyFunction,
30
+ overflowString: function(str){
31
+ return str.truncate();
32
+ },
33
+ overflowLength: 30
34
+ };
35
+ Object.extend(this.options,options || {});
36
+ this.select = $(select);
37
+ this.container = $(container);
38
+ this.checkboxes = (typeof(this.options.checkboxSelector) == 'function') ?
39
+ this.options.checkboxSelector.bind(this)() :
40
+ this.container.getElementsBySelector(this.options.checkboxSelector);
41
+ var value_was_set = false;
42
+ if(this.options.value){
43
+ value_was_set = true;
44
+ this.setValue(this.options.value);
45
+ delete this.options.value;
46
+ }
47
+ this.hasExtraOption = false;
48
+ this.checkboxes.each(function(checkbox){
49
+ checkbox.observe('click',this.checkboxOnClick.bind(this,checkbox));
50
+ }.bind(this));
51
+ this.select.observe('change',this.selectOnChange.bind(this));
52
+ this.countAndCheckCheckBoxes();
53
+ if(!value_was_set) {
54
+ this.scanCheckBoxes(); }
55
+ this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);
56
+ },
57
+ countAndCheckCheckBoxes: function(){
58
+ this.numberOfCheckedBoxes = this.checkboxes.inject(0,function(number,checkbox){
59
+ checkbox.checked = (this.select.options[this.select.options.selectedIndex].value == checkbox.value);
60
+ var value_string = this.select.options[this.select.options.selectedIndex].value;
61
+ var value_collection = $A(value_string.split ? value_string.split(this.options.valueSeparator) : value_string);
62
+ var should_check = value_collection.any(function(value) {
63
+ if (!should_check && checkbox.value == value) {
64
+ return true; }
65
+ }.bind(this));
66
+ checkbox.checked = should_check;
67
+ if(checkbox.checked) {
68
+ ++number; }
69
+ return number;
70
+ }.bind(this));
71
+ },
72
+ setValue: function(value_string){
73
+ this.numberOfCheckedBoxes = 0;
74
+ var value_collection = $A(value_string.split ? value_string.split(this.options.valueSeparator) : value_string);
75
+ this.checkboxes.each(function(checkbox){
76
+ checkbox.checked = false;
77
+ value_collection.each(function(value){
78
+ if(checkbox.value == value){
79
+ ++this.numberOfCheckedBoxes;
80
+ checkbox.checked = true;
81
+ }
82
+ }.bind(this));
83
+ }.bind(this));
84
+ this.scanCheckBoxes();
85
+ },
86
+ selectOnChange: function(){
87
+ this.removeExtraOption();
88
+ this.countAndCheckCheckBoxes();
89
+ this.notify('afterChange',this.select.options[this.select.options.selectedIndex].value);
90
+ },
91
+ checkboxOnClick: function(checkbox){
92
+ this.numberOfCheckedBoxes = this.checkboxes.findAll(function (c) {
93
+ return c.checked;
94
+ }).length;
95
+ this.scanCheckBoxes();
96
+ this.notify('afterChange', this.numberOfCheckedBoxes === 0 ? "" :
97
+ this.select.options[this.select.options.selectedIndex].value);
98
+ },
99
+ scanCheckBoxes: function(){
100
+ switch(this.numberOfCheckedBoxes){
101
+ case 1:
102
+ this.checkboxes.each(function(checkbox){
103
+ if(checkbox.checked){
104
+ $A(this.select.options).each(function(option,i){
105
+ if(option.value == checkbox.value){
106
+ this.select.options.selectedIndex = i;
107
+ throw $break;
108
+ }
109
+ }.bind(this));
110
+ throw $break;
111
+ }
112
+ }.bind(this));
113
+ break;
114
+ case 0:
115
+ this.removeExtraOption();
116
+ break;
117
+ default:
118
+ this.addExtraOption();
119
+ break;
120
+ }
121
+ },
122
+ getLabelForExtraOption: function(){
123
+ var label = (typeof(this.options.nameSelector) == 'function' ?
124
+ this.options.nameSelector.bind(this)() :
125
+ this.container.getElementsBySelector(this.options.nameSelector).inject([],function(labels,name_element,i){
126
+ if(this.checkboxes[i].checked) {
127
+ labels.push(name_element.innerHTML); }
128
+ return labels;
129
+ }.bind(this))
130
+ ).join(this.options.labelSeparator);
131
+ return (label.length >= this.options.overflowLength && this.options.overflowLength > 0) ?
132
+ (typeof(this.options.overflowString) == 'function' ? this.options.overflowString(label) : this.options.overflowString) :
133
+ label;
134
+ },
135
+ getValueForExtraOption: function(){
136
+ return this.checkboxes.inject([],function(values,checkbox){
137
+ if(checkbox.checked) {
138
+ values.push(checkbox.value); }
139
+ return values;
140
+ }).join(this.options.valueSeparator);
141
+ },
142
+ addExtraOption: function(){
143
+ this.removeExtraOption();
144
+ this.hasExtraOption = true;
145
+ this.select.options[this.select.options.length] = new Option(this.getLabelForExtraOption(),this.getValueForExtraOption());
146
+ this.select.options.selectedIndex = this.select.options.length - 1;
147
+ },
148
+ removeExtraOption: function(){
149
+ if(this.hasExtraOption){
150
+ this.select.remove(this.select.options.length - 1);
151
+ this.hasExtraOption = false;
152
+ }
153
+ }
154
+ });
155
+ Object.Event.extend(Control.SelectMultiple);
js/realex/livepipe/tabs.js ADDED
@@ -0,0 +1,233 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/tabs
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global window, document, Prototype, $, $A, $H, $break, Class, Element, Event, Control */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.Tabs requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.Tabs requires Object.Event to be loaded."; }
16
+
17
+ Control.Tabs = Class.create({
18
+ initialize: function(tab_list_container,options){
19
+ if(!$(tab_list_container)) {
20
+ throw "Control.Tabs could not find the element: " + tab_list_container; }
21
+ this.activeContainer = false;
22
+ this.activeLink = false;
23
+ this.containers = $H({});
24
+ this.links = [];
25
+ this.options = {
26
+ beforeChange: Prototype.emptyFunction,
27
+ afterChange: Prototype.emptyFunction,
28
+ hover: false,
29
+ tracked: true,
30
+ linkSelector: 'li a',
31
+ linkAttribute: 'href',
32
+ setClassOnContainer: false,
33
+ activeClassName: 'active',
34
+ disabledClassName: 'disabled',
35
+ defaultTab: 'first',
36
+ autoLinkExternal: true,
37
+ targetRegExp: /#(.+)$/,
38
+ showFunction: Element.show,
39
+ hideFunction: Element.hide
40
+ };
41
+ Object.extend(this.options,options || {});
42
+ if (this.options.tracked) {
43
+ Control.Tabs.instances.push(this);
44
+ }
45
+ var filterLinks;
46
+ switch (this.options.linkAttribute) {
47
+ case 'href':
48
+ case 'src':
49
+ filterLinks = function(link){
50
+ return (/^#/).test(link.getAttribute(this.options.linkAttribute).replace(
51
+ window.location.href.split('#')[0],''));
52
+ };
53
+ break;
54
+
55
+ default:
56
+ if (typeof(this.options.linkAttribute) == 'function') {
57
+ filterLinks = this.options.linkAttribute;
58
+ }
59
+ else {
60
+ filterLinks = function(link) {
61
+ return link.hasAttribute(this.options.linkAttribute);
62
+ };
63
+ }
64
+ }
65
+
66
+ (typeof(this.options.linkSelector) == 'string' ?
67
+ $(tab_list_container).select(this.options.linkSelector) :
68
+ this.options.linkSelector($(tab_list_container))
69
+ ).findAll(filterLinks.bind(this)).each(function(link){
70
+ this.addTab(link);
71
+ }.bind(this));
72
+ this.containers.values().each(Element.hide);
73
+ if(this.options.defaultTab == 'first') {
74
+ this.setActiveTab(this.links.first());
75
+ } else if(this.options.defaultTab == 'last') {
76
+ this.setActiveTab(this.links.last());
77
+ } else {
78
+ this.setActiveTab(this.options.defaultTab); }
79
+ var targets = this.options.targetRegExp.exec(window.location);
80
+ if(targets && targets[1]){
81
+ targets[1].split(',').each(function(target){
82
+ this.setActiveTab(this.links.find(function(link){
83
+ return link.key == target;
84
+ }));
85
+ }.bind(this));
86
+ }
87
+ if(this.options.autoLinkExternal){
88
+ $A(document.getElementsByTagName('a')).each(function(a){
89
+ if(!this.links.include(a)){
90
+ var clean_href = a.href.replace(window.location.href.split('#')[0],'');
91
+ if(clean_href.substring(0,1) == '#'){
92
+ if(this.containers.keys().include(clean_href.substring(1))){
93
+ $(a).observe('click',function(event,clean_href){
94
+ this.setActiveTab(clean_href.substring(1));
95
+ }.bindAsEventListener(this,clean_href));
96
+ }
97
+ }
98
+ }
99
+ }.bind(this));
100
+ }
101
+ },
102
+ addTab: function(link){
103
+ this.links.push(link);
104
+
105
+ switch (this.options.linkAttribute) {
106
+ case 'href':
107
+ case 'src':
108
+ link.key = link.getAttribute(this.options.linkAttribute).replace(
109
+ window.location.href.split('#')[0],'').split('#').last().replace(/#/,'');
110
+ break;
111
+
112
+ default:
113
+ if (typeof(this.options.linkAttribute) == 'function') {
114
+ link.key = this.options.linkAttribute(link);
115
+ }
116
+ else {
117
+ link.key = link.getAttribute(this.options.linkAttribute);
118
+ }
119
+ }
120
+ var container = this.options.tabs_container ? this.options.tabs_container.down('#'+link.key) : $(link.key);
121
+ if(!container) {
122
+ throw "Control.Tabs: #" + link.key + " was not found on the page."; }
123
+ this.containers.set(link.key,container);
124
+ link[this.options.hover ? 'onmouseover' : 'onclick'] = function(link){
125
+ if(window.event) {
126
+ Event.stop(window.event); }
127
+ this.setActiveTab(link);
128
+ return false;
129
+ }.bind(this,link);
130
+ },
131
+ getTab: function (link) {
132
+ if(!link && typeof(link) == 'undefined') {
133
+ return null; }
134
+ if(typeof(link) == 'string'){
135
+ return this.getTab(this.links.find(function(_link){
136
+ return _link.key == link;
137
+ }));
138
+ }else if(typeof(link) == 'number'){
139
+ return this.getTab(this.links[link]);
140
+ }else {
141
+ return this.containers.get(link.key);
142
+ }
143
+ },
144
+ setActiveTab: function(link){
145
+ if(!link && typeof(link) == 'undefined') {
146
+ return; }
147
+ if(typeof(link) == 'string'){
148
+ this.setActiveTab(this.links.find(function(_link){
149
+ return _link.key == link;
150
+ }));
151
+ }else if(typeof(link) == 'number'){
152
+ this.setActiveTab(this.links[link]);
153
+ }else if(!(this.options.setClassOnContainer ? $(link.parentNode) : link).hasClassName(this.options.disabledClassName)){
154
+ if(link == this.activeLink) {
155
+ return; }
156
+ if(this.notify('beforeChange',this.activeContainer,this.containers.get(link.key)) === false) {
157
+ return; }
158
+ if(this.activeContainer) {
159
+ this.options.hideFunction(this.activeContainer); }
160
+ this.links.each(function(item){
161
+ (this.options.setClassOnContainer ? $(item.parentNode) : item).removeClassName(this.options.activeClassName);
162
+ }.bind(this));
163
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.activeClassName);
164
+ this.activeContainer = this.containers.get(link.key);
165
+ this.activeLink = link;
166
+ this.options.showFunction(this.containers.get(link.key));
167
+ this.notify('afterChange',this.containers.get(link.key));
168
+ }
169
+ },
170
+ disableTab: function (link) {
171
+ if(!link && typeof(link) == 'undefined') {
172
+ return; }
173
+ if(typeof(link) == 'string'){
174
+ this.disableTab(this.links.find(function(_link){
175
+ return _link.key == link;
176
+ }));
177
+ }else if(typeof(link) == 'number'){
178
+ this.disableTab(this.links[link]);
179
+ }else{
180
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
181
+ link.disabled = true; }
182
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).addClassName(this.options.disabledClassName);
183
+ }
184
+ },
185
+ enableTab: function (link) {
186
+ if(!link && typeof(link) == 'undefined') {
187
+ return; }
188
+ if(typeof(link) == 'string'){
189
+ this.enableTab(this.links.find(function(_link){
190
+ return _link.key == link;
191
+ }));
192
+ }else if(typeof(link) == 'number'){
193
+ this.enableTab(this.links[link]);
194
+ }else{
195
+ if ({'INPUT':true,'BUTTON':true,'SELECT':true,'TEXTAREA':true}[link.nodeName]) {
196
+ link.disabled = false; }
197
+ (this.options.setClassOnContainer ? $(link.parentNode) : link).removeClassName(this.options.disabledClassName);
198
+ }
199
+ },
200
+ next: function(){
201
+ this.links.each(function(link,i){
202
+ if(this.activeLink == link && this.links[i + 1]){
203
+ this.setActiveTab(this.links[i + 1]);
204
+ throw $break;
205
+ }
206
+ }.bind(this));
207
+ },
208
+ previous: function(){
209
+ this.links.each(function(link,i){
210
+ if(this.activeLink == link && this.links[i - 1]){
211
+ this.setActiveTab(this.links[i - 1]);
212
+ throw $break;
213
+ }
214
+ }.bind(this));
215
+ },
216
+ first: function(){
217
+ this.setActiveTab(this.links.first());
218
+ },
219
+ last: function(){
220
+ this.setActiveTab(this.links.last());
221
+ }
222
+ });
223
+ Object.extend(Control.Tabs,{
224
+ instances: [],
225
+ findByTabId: function(id){
226
+ return Control.Tabs.instances.find(function(tab){
227
+ return tab.links.find(function(link){
228
+ return link.key == id;
229
+ });
230
+ });
231
+ }
232
+ });
233
+ Object.Event.extend(Control.Tabs);
js/realex/livepipe/textarea.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/textarea
7
+ * @require prototype.js, livepipe.js
8
+ */
9
+
10
+ /*global window, document, Prototype, Class, $, $A, Control */
11
+
12
+ if(typeof(Prototype) == "undefined") {
13
+ throw "Control.TextArea requires Prototype to be loaded."; }
14
+ if(typeof(Object.Event) == "undefined") {
15
+ throw "Control.TextArea requires Object.Event to be loaded."; }
16
+
17
+ Control.TextArea = Class.create({
18
+ initialize: function(textarea){
19
+ this.onChangeTimeout = false;
20
+ this.element = $(textarea);
21
+ $(this.element).observe('keyup',this.doOnChange.bindAsEventListener(this));
22
+ $(this.element).observe('paste',this.doOnChange.bindAsEventListener(this));
23
+ $(this.element).observe('input',this.doOnChange.bindAsEventListener(this));
24
+ if(!!document.selection){
25
+ $(this.element).observe('mouseup',this.saveRange.bindAsEventListener(this));
26
+ $(this.element).observe('keyup',this.saveRange.bindAsEventListener(this));
27
+ }
28
+ },
29
+ doOnChange: function(event){
30
+ if(this.onChangeTimeout) {
31
+ window.clearTimeout(this.onChangeTimeout); }
32
+ this.onChangeTimeout = window.setTimeout(function(){
33
+ this.notify('change',this.getValue());
34
+ }.bind(this),Control.TextArea.onChangeTimeoutLength);
35
+ },
36
+ saveRange: function(){
37
+ this.range = document.selection.createRange();
38
+ },
39
+ getValue: function(){
40
+ return this.element.value;
41
+ },
42
+ getSelection: function(){
43
+ if(!!document.selection) {
44
+ return document.selection.createRange().text; }
45
+ else if(!!this.element.setSelectionRange) {
46
+ return this.element.value.substring(this.element.selectionStart,this.element.selectionEnd); }
47
+ else {
48
+ return false; }
49
+ },
50
+ replaceSelection: function(text){
51
+ var scroll_top = this.element.scrollTop;
52
+ if(!!document.selection){
53
+ this.element.focus();
54
+ var range = (this.range) ? this.range : document.selection.createRange();
55
+ range.text = text;
56
+ range.select();
57
+ }else if(!!this.element.setSelectionRange){
58
+ var selection_start = this.element.selectionStart;
59
+ this.element.value = this.element.value.substring(0,selection_start) + text + this.element.value.substring(this.element.selectionEnd);
60
+ this.element.setSelectionRange(selection_start + text.length,selection_start + text.length);
61
+ }
62
+ this.doOnChange();
63
+ this.element.focus();
64
+ this.element.scrollTop = scroll_top;
65
+ },
66
+ wrapSelection: function(before,after){
67
+ var sel = this.getSelection();
68
+ // Remove the wrapping if the selection has the same before/after
69
+ if (sel.indexOf(before) === 0 &&
70
+ sel.lastIndexOf(after) === (sel.length - after.length)) {
71
+ this.replaceSelection(sel.substring(before.length,
72
+ sel.length - after.length));
73
+ } else { this.replaceSelection(before + sel + after); }
74
+ },
75
+ insertBeforeSelection: function(text){
76
+ this.replaceSelection(text + this.getSelection());
77
+ },
78
+ insertAfterSelection: function(text){
79
+ this.replaceSelection(this.getSelection() + text);
80
+ },
81
+ collectFromEachSelectedLine: function(callback,before,after){
82
+ this.replaceSelection((before || '') + $A(this.getSelection().split("\n")).collect(callback).join("\n") + (after || ''));
83
+ },
84
+ insertBeforeEachSelectedLine: function(text,before,after){
85
+ this.collectFromEachSelectedLine(function(line){
86
+ },before,after);
87
+ }
88
+ });
89
+ Object.extend(Control.TextArea,{
90
+ onChangeTimeoutLength: 500
91
+ });
92
+ Object.Event.extend(Control.TextArea);
93
+
94
+ Control.TextArea.ToolBar = Class.create( {
95
+ initialize: function(textarea,toolbar){
96
+ this.textarea = textarea;
97
+ if(toolbar) {
98
+ this.container = $(toolbar); }
99
+ else{
100
+ this.container = $(document.createElement('ul'));
101
+ this.textarea.element.parentNode.insertBefore(this.container,this.textarea.element);
102
+ }
103
+ },
104
+ attachButton: function(node,callback){
105
+ node.onclick = function(){return false;};
106
+ $(node).observe('click',callback.bindAsEventListener(this.textarea));
107
+ },
108
+ addButton: function(link_text,callback,attrs){
109
+ var li = document.createElement('li');
110
+ var a = document.createElement('a');
111
+ a.href = '#';
112
+ this.attachButton(a,callback);
113
+ li.appendChild(a);
114
+ Object.extend(a,attrs || {});
115
+ if(link_text){
116
+ var span = document.createElement('span');
117
+ span.innerHTML = link_text;
118
+ a.appendChild(span);
119
+ }
120
+ this.container.appendChild(li);
121
+ }
122
+ });
js/realex/livepipe/window.js ADDED
@@ -0,0 +1,947 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Ryan Johnson <http://syntacticx.com/>
3
+ * @copyright 2008 PersonalGrid Corporation <http://personalgrid.com/>
4
+ * @package LivePipe UI
5
+ * @license MIT
6
+ * @url http://livepipe.net/control/window
7
+ * @require prototype.js, effects.js, draggable.js, resizable.js, livepipe.js
8
+ */
9
+
10
+ //adds onDraw and constrainToViewport option to draggable
11
+ if(typeof(Draggable) != 'undefined'){
12
+ //allows the point to be modified with an onDraw callback
13
+ Draggable.prototype.draw = function(point) {
14
+ var pos = Position.cumulativeOffset(this.element);
15
+ if(this.options.ghosting) {
16
+ var r = Position.realOffset(this.element);
17
+ pos[0] += r[0] - Position.deltaX; pos[1] += r[1] - Position.deltaY;
18
+ }
19
+
20
+ var d = this.currentDelta();
21
+ pos[0] -= d[0]; pos[1] -= d[1];
22
+
23
+ if(this.options.scroll && (this.options.scroll != window && this._isScrollChild)) {
24
+ pos[0] -= this.options.scroll.scrollLeft-this.originalScrollLeft;
25
+ pos[1] -= this.options.scroll.scrollTop-this.originalScrollTop;
26
+ }
27
+
28
+ var p = [0,1].map(function(i){
29
+ return (point[i]-pos[i]-this.offset[i])
30
+ }.bind(this));
31
+
32
+ if(this.options.snap) {
33
+ if(typeof this.options.snap == 'function') {
34
+ p = this.options.snap(p[0],p[1],this);
35
+ } else {
36
+ if(this.options.snap instanceof Array) {
37
+ p = p.map( function(v, i) {return Math.round(v/this.options.snap[i])*this.options.snap[i] }.bind(this))
38
+ } else {
39
+ p = p.map( function(v) {return Math.round(v/this.options.snap)*this.options.snap }.bind(this))
40
+ }
41
+ }
42
+ }
43
+
44
+ if(this.options.onDraw)
45
+ this.options.onDraw.bind(this)(p);
46
+ else{
47
+ var style = this.element.style;
48
+ if(this.options.constrainToViewport){
49
+ var viewport_dimensions = document.viewport.getDimensions();
50
+ var container_dimensions = this.element.getDimensions();
51
+ var margin_top = parseInt(this.element.getStyle('margin-top'));
52
+ var margin_left = parseInt(this.element.getStyle('margin-left'));
53
+ var boundary = [[
54
+ 0 - margin_left,
55
+ 0 - margin_top
56
+ ],[
57
+ (viewport_dimensions.width - container_dimensions.width) - margin_left,
58
+ (viewport_dimensions.height - container_dimensions.height) - margin_top
59
+ ]];
60
+ if((!this.options.constraint) || (this.options.constraint=='horizontal')){
61
+ if((p[0] >= boundary[0][0]) && (p[0] <= boundary[1][0]))
62
+ this.element.style.left = p[0] + "px";
63
+ else
64
+ this.element.style.left = ((p[0] < boundary[0][0]) ? boundary[0][0] : boundary[1][0]) + "px";
65
+ }
66
+ if((!this.options.constraint) || (this.options.constraint=='vertical')){
67
+ if((p[1] >= boundary[0][1] ) && (p[1] <= boundary[1][1]))
68
+ this.element.style.top = p[1] + "px";
69
+ else
70
+ this.element.style.top = ((p[1] <= boundary[0][1]) ? boundary[0][1] : boundary[1][1]) + "px";
71
+ }
72
+ }else{
73
+ if((!this.options.constraint) || (this.options.constraint=='horizontal'))
74
+ style.left = p[0] + "px";
75
+ if((!this.options.constraint) || (this.options.constraint=='vertical'))
76
+ style.top = p[1] + "px";
77
+ }
78
+ if(style.visibility=="hidden")
79
+ style.visibility = ""; // fix gecko rendering
80
+ }
81
+ };
82
+ }
83
+
84
+ if(typeof(Prototype) == "undefined")
85
+ throw "Control.Window requires Prototype to be loaded.";
86
+ if(typeof(IframeShim) == "undefined")
87
+ throw "Control.Window requires IframeShim to be loaded.";
88
+ if(typeof(Object.Event) == "undefined")
89
+ throw "Control.Window requires Object.Event to be loaded.";
90
+ /*
91
+ known issues:
92
+ - when iframe is clicked is does not gain focus
93
+ - safari can't open multiple iframes properly
94
+ - constrainToViewport: body must have no margin or padding for this to work properly
95
+ - iframe will be mis positioned during fade in
96
+ - document.viewport does not account for scrollbars (this will eventually be fixed in the prototype core)
97
+ notes
98
+ - setting constrainToViewport only works when the page is not scrollable
99
+ - setting draggable: true will negate the effects of position: center
100
+ */
101
+ Control.Window = Class.create({
102
+ initialize: function(container,options){
103
+ Control.Window.windows.push(this);
104
+
105
+ //attribute initialization
106
+ this.container = false;
107
+ this.isOpen = false;
108
+ this.href = false;
109
+ this.sourceContainer = false; //this is optionally the container that will open the window
110
+ this.ajaxRequest = false;
111
+ this.remoteContentLoaded = false; //this is set when the code to load the remote content is run, onRemoteContentLoaded is fired when the connection is closed
112
+ this.numberInSequence = Control.Window.windows.length + 1; //only useful for the effect scoping
113
+ this.indicator = false;
114
+ this.effects = {
115
+ fade: false,
116
+ appear: false
117
+ };
118
+ this.indicatorEffects = {
119
+ fade: false,
120
+ appear: false
121
+ };
122
+
123
+ //options
124
+ this.options = Object.extend({
125
+ //lifecycle
126
+ beforeOpen: Prototype.emptyFunction,
127
+ afterOpen: Prototype.emptyFunction,
128
+ beforeClose: Prototype.emptyFunction,
129
+ afterClose: Prototype.emptyFunction,
130
+ //dimensions and modes
131
+ height: null,
132
+ width: null,
133
+ className: false,
134
+ position: 'center', //'center', 'center_once', 'relative', [x,y], [function(){return x;},function(){return y;}]
135
+ offsetLeft: 0, //available only for anchors opening the window, or windows set to position: hover
136
+ offsetTop: 0, //""
137
+ iframe: false, //if the window has an href, this will display the href as an iframe instead of requesting the url as an an Ajax.Request
138
+ hover: false, //element object to hover over, or if "true" only available for windows with sourceContainer (an anchor or any element already on the page with an href attribute)
139
+ indicator: false, //element to show or hide when ajax requests, images and iframes are loading
140
+ closeOnClick: false, //does not work with hover,can be: true (click anywhere), 'container' (will refer to this.container), or element (a specific element)
141
+ iframeshim: true, //whether or not to position an iFrameShim underneath the window
142
+ //effects
143
+ fade: false,
144
+ fadeDuration: 0.75,
145
+ //draggable
146
+ draggable: false,
147
+ onDrag: Prototype.emptyFunction,
148
+ //resizable
149
+ resizable: false,
150
+ minHeight: false,
151
+ minWidth: false,
152
+ maxHeight: false,
153
+ maxWidth: false,
154
+ onResize: Prototype.emptyFunction,
155
+ //draggable and resizable
156
+ constrainToViewport: false,
157
+ //ajax
158
+ method: 'post',
159
+ parameters: {},
160
+ onComplete: Prototype.emptyFunction,
161
+ onSuccess: Prototype.emptyFunction,
162
+ onFailure: Prototype.emptyFunction,
163
+ onException: Prototype.emptyFunction,
164
+ //any element with an href (image,iframe,ajax) will call this after it is done loading
165
+ onRemoteContentLoaded: Prototype.emptyFunction,
166
+ insertRemoteContentAt: false //false will set this to this.container, can be string selector (first returned will be selected), or an Element that must be a child of this.container
167
+ },options || {});
168
+
169
+ //container setup
170
+ this.indicator = this.options.indicator ? $(this.options.indicator) : false;
171
+ if(container){
172
+ if(typeof(container) == "string" && container.match(Control.Window.uriRegex))
173
+ this.href = container;
174
+ else{
175
+ this.container = $(container);
176
+ //need to create the container now for tooltips (or hover: element with no container already on the page)
177
+ //second call made below will not create the container since the check is done inside createDefaultContainer()
178
+ this.createDefaultContainer(container);
179
+ //if an element with an href was passed in we use it to activate the window
180
+ if(this.container && ((this.container.readAttribute('href') && this.container.readAttribute('href') != '') || (this.options.hover && this.options.hover !== true))){
181
+ if(this.options.hover && this.options.hover !== true)
182
+ this.sourceContainer = $(this.options.hover);
183
+ else{
184
+ this.sourceContainer = this.container;
185
+ this.href = this.container.readAttribute('href');
186
+ var rel = this.href.match(/^#(.+)$/);
187
+ if(rel && rel[1]){
188
+ this.container = $(rel[1]);
189
+ this.href = false;
190
+ }else
191
+ this.container = false;
192
+ }
193
+ //hover or click handling
194
+ this.sourceContainerOpenHandler = function(event){
195
+ this.open(event);
196
+ event.stop();
197
+ return false;
198
+ }.bindAsEventListener(this);
199
+ this.sourceContainerCloseHandler = function(event){
200
+ this.close(event);
201
+ }.bindAsEventListener(this);
202
+ this.sourceContainerMouseMoveHandler = function(event){
203
+ this.position(event);
204
+ }.bindAsEventListener(this);
205
+ if(this.options.hover){
206
+ this.sourceContainer.observe('mouseenter',this.sourceContainerOpenHandler);
207
+ this.sourceContainer.observe('mouseleave',this.sourceContainerCloseHandler);
208
+ if(this.options.position == 'mouse')
209
+ this.sourceContainer.observe('mousemove',this.sourceContainerMouseMoveHandler);
210
+ }else
211
+ this.sourceContainer.observe('click',this.sourceContainerOpenHandler);
212
+ }
213
+ }
214
+ }
215
+ this.createDefaultContainer(container);
216
+ if(this.options.insertRemoteContentAt === false)
217
+ this.options.insertRemoteContentAt = this.container;
218
+ var styles = {
219
+ margin: 0,
220
+ position: 'absolute',
221
+ zIndex: Control.Window.initialZIndexForWindow()
222
+ };
223
+ if(this.options.width)
224
+ styles.width = $value(this.options.width) + 'px';
225
+ if(this.options.height)
226
+ styles.height = $value(this.options.height) + 'px';
227
+ this.container.setStyle(styles);
228
+ if(this.options.className)
229
+ this.container.addClassName(this.options.className);
230
+ this.positionHandler = this.position.bindAsEventListener(this);
231
+ this.outOfBoundsPositionHandler = this.ensureInBounds.bindAsEventListener(this);
232
+ this.bringToFrontHandler = this.bringToFront.bindAsEventListener(this);
233
+ this.container.observe('mousedown',this.bringToFrontHandler);
234
+ this.container.hide();
235
+ this.closeHandler = this.close.bindAsEventListener(this);
236
+ //iframeshim setup
237
+ if(this.options.iframeshim){
238
+ this.iFrameShim = new IframeShim();
239
+ this.iFrameShim.hide();
240
+ }
241
+ //resizable support
242
+ this.applyResizable();
243
+ //draggable support
244
+ this.applyDraggable();
245
+
246
+ //makes sure the window can't go out of bounds
247
+ Event.observe(window,'resize',this.outOfBoundsPositionHandler);
248
+
249
+ this.notify('afterInitialize');
250
+ },
251
+ open: function(event){
252
+ if(this.isOpen){
253
+ this.bringToFront();
254
+ return false;
255
+ }
256
+ if(this.notify('beforeOpen') === false)
257
+ return false;
258
+ //closeOnClick
259
+ if(this.options.closeOnClick){
260
+ if(this.options.closeOnClick === true)
261
+ this.closeOnClickContainer = $(document.body);
262
+ else if(this.options.closeOnClick == 'container')
263
+ this.closeOnClickContainer = this.container;
264
+ else if (this.options.closeOnClick == 'overlay'){
265
+ Control.Overlay.load();
266
+ this.closeOnClickContainer = Control.Overlay.container;
267
+ }else
268
+ this.closeOnClickContainer = $(this.options.closeOnClick);
269
+ this.closeOnClickContainer.observe('click',this.closeHandler);
270
+ }
271
+ if(this.href && !this.options.iframe && !this.remoteContentLoaded){
272
+ //link to image
273
+ this.remoteContentLoaded = true;
274
+ if(this.href.match(/\.(jpe?g|gif|png|tiff?)$/i)){
275
+ var img = new Element('img');
276
+ img.observe('load',function(img){
277
+ this.getRemoteContentInsertionTarget().insert(img);
278
+ this.position();
279
+ if(this.notify('onRemoteContentLoaded') !== false){
280
+ if(this.options.indicator)
281
+ this.hideIndicator();
282
+ this.finishOpen();
283
+ }
284
+ }.bind(this,img));
285
+ img.writeAttribute('src',this.href);
286
+ }else{
287
+ //if this is an ajax window it will only open if the request is successful
288
+ if(!this.ajaxRequest){
289
+ if(this.options.indicator)
290
+ this.showIndicator();
291
+ this.ajaxRequest = new Ajax.Request(this.href,{
292
+ method: this.options.method,
293
+ parameters: this.options.parameters,
294
+ onComplete: function(request){
295
+ this.notify('onComplete',request);
296
+ this.ajaxRequest = false;
297
+ }.bind(this),
298
+ onSuccess: function(request){
299
+ this.getRemoteContentInsertionTarget().insert(request.responseText);
300
+ this.notify('onSuccess',request);
301
+ if(this.notify('onRemoteContentLoaded') !== false){
302
+ if(this.options.indicator)
303
+ this.hideIndicator();
304
+ this.finishOpen();
305
+ }
306
+ }.bind(this),
307
+ onFailure: function(request){
308
+ this.notify('onFailure',request);
309
+ if(this.options.indicator)
310
+ this.hideIndicator();
311
+ }.bind(this),
312
+ onException: function(request,e){
313
+ this.notify('onException',request,e);
314
+ if(this.options.indicator)
315
+ this.hideIndicator();
316
+ }.bind(this)
317
+ });
318
+ }
319
+ }
320
+ return true;
321
+ }else if(this.options.iframe && !this.remoteContentLoaded){
322
+ //iframe
323
+ this.remoteContentLoaded = true;
324
+ if(this.options.indicator)
325
+ this.showIndicator();
326
+ this.getRemoteContentInsertionTarget().insert(Control.Window.iframeTemplate.evaluate({
327
+ href: this.href
328
+ }));
329
+ var iframe = this.container.down('iframe');
330
+ iframe.onload = function(){
331
+ this.notify('onRemoteContentLoaded');
332
+ if(this.options.indicator)
333
+ this.hideIndicator();
334
+ iframe.onload = null;
335
+ }.bind(this);
336
+ }
337
+ this.finishOpen(event);
338
+ return true
339
+ },
340
+ close: function(event){ //event may or may not be present
341
+ if(!this.isOpen || this.notify('beforeClose',event) === false)
342
+ return false;
343
+ if(this.options.closeOnClick)
344
+ this.closeOnClickContainer.stopObserving('click',this.closeHandler);
345
+ if(this.options.fade){
346
+ this.effects.fade = new Effect.Fade(this.container,{
347
+ queue: {
348
+ position: 'front',
349
+ scope: 'Control.Window' + this.numberInSequence
350
+ },
351
+ from: 1,
352
+ to: 0,
353
+ duration: this.options.fadeDuration / 2,
354
+ afterFinish: function(){
355
+ if(this.iFrameShim)
356
+ this.iFrameShim.hide();
357
+ this.isOpen = false;
358
+ this.notify('afterClose');
359
+ }.bind(this)
360
+ });
361
+ }else{
362
+ this.container.hide();
363
+ if(this.iFrameShim)
364
+ this.iFrameShim.hide();
365
+ }
366
+ if(this.ajaxRequest)
367
+ this.ajaxRequest.transport.abort();
368
+ if(!(this.options.draggable || this.options.resizable) && this.options.position == 'center')
369
+ Event.stopObserving(window,'resize',this.positionHandler);
370
+ if(!this.options.draggable && this.options.position == 'center')
371
+ Event.stopObserving(window,'scroll',this.positionHandler);
372
+ if(this.options.indicator)
373
+ this.hideIndicator();
374
+ if(!this.options.fade){
375
+ this.isOpen = false;
376
+ this.notify('afterClose');
377
+ }
378
+ return true;
379
+ },
380
+ position: function(event){
381
+ //this is up top for performance reasons
382
+ if(this.options.position == 'mouse'){
383
+ var xy = [Event.pointerX(event),Event.pointerY(event)];
384
+ this.container.setStyle({
385
+ top: xy[1] + $value(this.options.offsetTop) + 'px',
386
+ left: xy[0] + $value(this.options.offsetLeft) + 'px'
387
+ });
388
+ return;
389
+ }
390
+ var container_dimensions = this.container.getDimensions();
391
+ var viewport_dimensions = document.viewport.getDimensions();
392
+ Position.prepare();
393
+ var offset_left = (Position.deltaX + Math.floor((viewport_dimensions.width - container_dimensions.width) / 2));
394
+ var offset_top = (Position.deltaY + ((viewport_dimensions.height > container_dimensions.height) ? Math.floor((viewport_dimensions.height - container_dimensions.height) / 2) : 0));
395
+ if(this.options.position == 'center' || this.options.position == 'center_once'){
396
+ this.container.setStyle({
397
+ top: (container_dimensions.height <= viewport_dimensions.height) ? ((offset_top != null && offset_top > 0) ? offset_top : 0) + 'px' : 0,
398
+ left: (container_dimensions.width <= viewport_dimensions.width) ? ((offset_left != null && offset_left > 0) ? offset_left : 0) + 'px' : 0
399
+ });
400
+ }else if(this.options.position == 'relative'){
401
+ var xy = this.sourceContainer.cumulativeOffset();
402
+ var top = xy[1] + $value(this.options.offsetTop);
403
+ var left = xy[0] + $value(this.options.offsetLeft);
404
+ this.container.setStyle({
405
+ top: (container_dimensions.height <= viewport_dimensions.height) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.height - (container_dimensions.height),top)) : top) + 'px' : 0,
406
+ left: (container_dimensions.width <= viewport_dimensions.width) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.width - (container_dimensions.width),left)) : left) + 'px' : 0
407
+ });
408
+ }else if(this.options.position.length){
409
+ var top = $value(this.options.position[1]) + $value(this.options.offsetTop);
410
+ var left = $value(this.options.position[0]) + $value(this.options.offsetLeft);
411
+ this.container.setStyle({
412
+ top: (container_dimensions.height <= viewport_dimensions.height) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.height - (container_dimensions.height),top)) : top) + 'px' : 0,
413
+ left: (container_dimensions.width <= viewport_dimensions.width) ? (this.options.constrainToViewport ? Math.max(0,Math.min(viewport_dimensions.width - (container_dimensions.width),left)) : left) + 'px' : 0
414
+ });
415
+ }
416
+ if(this.iFrameShim)
417
+ this.updateIFrameShimZIndex();
418
+ },
419
+ ensureInBounds: function(){
420
+ if(!this.isOpen)
421
+ return;
422
+ var viewport_dimensions = document.viewport.getDimensions();
423
+ var container_offset = this.container.cumulativeOffset();
424
+ var container_dimensions = this.container.getDimensions();
425
+ if(container_offset.left + container_dimensions.width > viewport_dimensions.width){
426
+ this.container.setStyle({
427
+ left: (Math.max(0,viewport_dimensions.width - container_dimensions.width)) + 'px'
428
+ });
429
+ }
430
+ if(container_offset.top + container_dimensions.height > viewport_dimensions.height){
431
+ this.container.setStyle({
432
+ top: (Math.max(0,viewport_dimensions.height - container_dimensions.height)) + 'px'
433
+ });
434
+ }
435
+ },
436
+ bringToFront: function(){
437
+ Control.Window.bringToFront(this);
438
+ this.notify('bringToFront');
439
+ },
440
+ destroy: function(){
441
+ this.container.stopObserving('mousedown',this.bringToFrontHandler);
442
+ if(this.draggable){
443
+ Draggables.removeObserver(this.container);
444
+ this.draggable.handle.stopObserving('mousedown',this.bringToFrontHandler);
445
+ this.draggable.destroy();
446
+ }
447
+ if(this.resizable){
448
+ Resizables.removeObserver(this.container);
449
+ this.resizable.handle.stopObserving('mousedown',this.bringToFrontHandler);
450
+ this.resizable.destroy();
451
+ }
452
+ if(this.container && !this.sourceContainer)
453
+ this.container.remove();
454
+ if(this.sourceContainer){
455
+ if(this.options.hover){
456
+ this.sourceContainer.stopObserving('mouseenter',this.sourceContainerOpenHandler);
457
+ this.sourceContainer.stopObserving('mouseleave',this.sourceContainerCloseHandler);
458
+ if(this.options.position == 'mouse')
459
+ this.sourceContainer.stopObserving('mousemove',this.sourceContainerMouseMoveHandler);
460
+ }else
461
+ this.sourceContainer.stopObserving('click',this.sourceContainerOpenHandler);
462
+ }
463
+ if(this.iFrameShim)
464
+ this.iFrameShim.destroy();
465
+ Event.stopObserving(window,'resize',this.outOfBoundsPositionHandler);
466
+ Control.Window.windows = Control.Window.windows.without(this);
467
+ this.notify('afterDestroy');
468
+ },
469
+ //private
470
+ applyResizable: function(){
471
+ if(this.options.resizable){
472
+ if(typeof(Resizable) == "undefined")
473
+ throw "Control.Window requires resizable.js to be loaded.";
474
+ var resizable_handle = null;
475
+ if(this.options.resizable === true){
476
+ resizable_handle = new Element('div',{
477
+ className: 'resizable_handle'
478
+ });
479
+ this.container.insert(resizable_handle);
480
+ }else
481
+ resizable_handle = $(this.options.resziable);
482
+ this.resizable = new Resizable(this.container,{
483
+ handle: resizable_handle,
484
+ minHeight: this.options.minHeight,
485
+ minWidth: this.options.minWidth,
486
+ maxHeight: this.options.constrainToViewport ? function(element){
487
+ //viewport height - top - total border height
488
+ return (document.viewport.getDimensions().height - parseInt(element.style.top || 0)) - (element.getHeight() - parseInt(element.style.height || 0));
489
+ } : this.options.maxHeight,
490
+ maxWidth: this.options.constrainToViewport ? function(element){
491
+ //viewport width - left - total border width
492
+ return (document.viewport.getDimensions().width - parseInt(element.style.left || 0)) - (element.getWidth() - parseInt(element.style.width || 0));
493
+ } : this.options.maxWidth
494
+ });
495
+ this.resizable.handle.observe('mousedown',this.bringToFrontHandler);
496
+ Resizables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){
497
+ if(this.iFrameShim)
498
+ this.updateIFrameShimZIndex();
499
+ this.notify('onResize');
500
+ }.bind(this)));
501
+ }
502
+ },
503
+ applyDraggable: function(){
504
+ if(this.options.draggable){
505
+ if(typeof(Draggables) == "undefined")
506
+ throw "Control.Window requires dragdrop.js to be loaded.";
507
+ var draggable_handle = null;
508
+ if(this.options.draggable === true){
509
+ draggable_handle = new Element('div',{
510
+ className: 'draggable_handle'
511
+ });
512
+ this.container.insert(draggable_handle);
513
+ }else
514
+ draggable_handle = $(this.options.draggable);
515
+ this.draggable = new Draggable(this.container,{
516
+ handle: draggable_handle,
517
+ constrainToViewport: this.options.constrainToViewport,
518
+ zindex: this.container.getStyle('z-index'),
519
+ starteffect: function(){
520
+ if(Prototype.Browser.IE){
521
+ this.old_onselectstart = document.onselectstart;
522
+ document.onselectstart = function(){
523
+ return false;
524
+ };
525
+ }
526
+ }.bind(this),
527
+ endeffect: function(){
528
+ document.onselectstart = this.old_onselectstart;
529
+ }.bind(this)
530
+ });
531
+ this.draggable.handle.observe('mousedown',this.bringToFrontHandler);
532
+ Draggables.addObserver(new Control.Window.LayoutUpdateObserver(this,function(){
533
+ if(this.iFrameShim)
534
+ this.updateIFrameShimZIndex();
535
+ this.notify('onDrag');
536
+ }.bind(this)));
537
+ }
538
+ },
539
+ createDefaultContainer: function(container){
540
+ if(!this.container){
541
+ //no container passed or found, create it
542
+ this.container = new Element('div',{
543
+ id: 'control_window_' + this.numberInSequence
544
+ });
545
+ $(document.body).insert(this.container);
546
+ if(typeof(container) == "string" && $(container) == null && !container.match(/^#(.+)$/) && !container.match(Control.Window.uriRegex))
547
+ this.container.update(container);
548
+ }
549
+ },
550
+ finishOpen: function(event){
551
+ this.bringToFront();
552
+ if(this.options.fade){
553
+ if(typeof(Effect) == "undefined")
554
+ throw "Control.Window requires effects.js to be loaded."
555
+ if(this.effects.fade)
556
+ this.effects.fade.cancel();
557
+ this.effects.appear = new Effect.Appear(this.container,{
558
+ queue: {
559
+ position: 'end',
560
+ scope: 'Control.Window.' + this.numberInSequence
561
+ },
562
+ from: 0,
563
+ to: 1,
564
+ duration: this.options.fadeDuration / 2,
565
+ afterFinish: function(){
566
+ if(this.iFrameShim)
567
+ this.updateIFrameShimZIndex();
568
+ this.isOpen = true;
569
+ this.notify('afterOpen');
570
+ }.bind(this)
571
+ });
572
+ }else
573
+ this.container.show();
574
+ this.position(event);
575
+ if(!(this.options.draggable || this.options.resizable) && this.options.position == 'center')
576
+ Event.observe(window,'resize',this.positionHandler,false);
577
+ if(!this.options.draggable && this.options.position == 'center')
578
+ Event.observe(window,'scroll',this.positionHandler,false);
579
+ if(!this.options.fade){
580
+ this.isOpen = true;
581
+ this.notify('afterOpen');
582
+ }
583
+ return true;
584
+ },
585
+ showIndicator: function(){
586
+ this.showIndicatorTimeout = window.setTimeout(function(){
587
+ if(this.options.fade){
588
+ this.indicatorEffects.appear = new Effect.Appear(this.indicator,{
589
+ queue: {
590
+ position: 'front',
591
+ scope: 'Control.Window.indicator.' + this.numberInSequence
592
+ },
593
+ from: 0,
594
+ to: 1,
595
+ duration: this.options.fadeDuration / 2
596
+ });
597
+ }else
598
+ this.indicator.show();
599
+ }.bind(this),Control.Window.indicatorTimeout);
600
+ },
601
+ hideIndicator: function(){
602
+ if(this.showIndicatorTimeout)
603
+ window.clearTimeout(this.showIndicatorTimeout);
604
+ this.indicator.hide();
605
+ },
606
+ getRemoteContentInsertionTarget: function(){
607
+ return typeof(this.options.insertRemoteContentAt) == "string" ? this.container.down(this.options.insertRemoteContentAt) : $(this.options.insertRemoteContentAt);
608
+ },
609
+ updateIFrameShimZIndex: function(){
610
+ if(this.iFrameShim)
611
+ this.iFrameShim.positionUnder(this.container);
612
+ }
613
+ });
614
+ //class methods
615
+ Object.extend(Control.Window,{
616
+ windows: [],
617
+ baseZIndex: 9999,
618
+ indicatorTimeout: 250,
619
+ iframeTemplate: new Template('<iframe src="#{href}" width="100%" height="100%" frameborder="0"></iframe>'),
620
+ uriRegex: /^(\/|\#|https?\:\/\/|[\w]+\/)/,
621
+ bringToFront: function(w){
622
+ Control.Window.windows = Control.Window.windows.without(w);
623
+ Control.Window.windows.push(w);
624
+ Control.Window.windows.each(function(w,i){
625
+ var z_index = Control.Window.baseZIndex + i;
626
+ w.container.setStyle({
627
+ zIndex: z_index
628
+ });
629
+ if(w.isOpen){
630
+ if(w.iFrameShim)
631
+ w.updateIFrameShimZIndex();
632
+ }
633
+ if(w.options.draggable)
634
+ w.draggable.options.zindex = z_index;
635
+ });
636
+ },
637
+ open: function(container,options){
638
+ var w = new Control.Window(container,options);
639
+ w.open();
640
+ return w;
641
+ },
642
+ //protected
643
+ initialZIndexForWindow: function(w){
644
+ return Control.Window.baseZIndex + (Control.Window.windows.length - 1);
645
+ }
646
+ });
647
+ Object.Event.extend(Control.Window);
648
+
649
+ //this is the observer for both Resizables and Draggables
650
+ Control.Window.LayoutUpdateObserver = Class.create({
651
+ initialize: function(w,observer){
652
+ this.w = w;
653
+ this.element = $(w.container);
654
+ this.observer = observer;
655
+ },
656
+ onStart: Prototype.emptyFunction,
657
+ onEnd: function(event_name,instance){
658
+ if(instance.element == this.element && this.iFrameShim)
659
+ this.w.updateIFrameShimZIndex();
660
+ },
661
+ onResize: function(event_name,instance){
662
+ if(instance.element == this.element)
663
+ this.observer(this.element);
664
+ },
665
+ onDrag: function(event_name,instance){
666
+ if(instance.element == this.element)
667
+ this.observer(this.element);
668
+ }
669
+ });
670
+
671
+ //overlay for Control.Modal
672
+ Control.Overlay = {
673
+ id: 'control_overlay',
674
+ loaded: false,
675
+ container: false,
676
+ lastOpacity: 0,
677
+ getStyles: function() {
678
+ return {
679
+ position: 'fixed',
680
+ top: 0,
681
+ left: 0,
682
+ width: '100%',
683
+ height: '100%',
684
+ zIndex: Control.Window.baseZIndex - 1
685
+ };
686
+ },
687
+ getIeStyles: function() {
688
+ return {
689
+ position: 'absolute',
690
+ top: 0,
691
+ left: 0,
692
+ zIndex: Control.Window.baseZIndex - 1
693
+ };
694
+ },
695
+ effects: {
696
+ fade: false,
697
+ appear: false
698
+ },
699
+ load: function(){
700
+ if(Control.Overlay.loaded)
701
+ return false;
702
+ Control.Overlay.loaded = true;
703
+ Control.Overlay.container = new Element('div',{
704
+ id: Control.Overlay.id
705
+ });
706
+ $(document.body).insert(Control.Overlay.container);
707
+ if(Prototype.Browser.IE){
708
+ Control.Overlay.container.setStyle(Control.Overlay.getIeStyles());
709
+ Event.observe(window,'scroll',Control.Overlay.positionOverlay);
710
+ Event.observe(window,'resize',Control.Overlay.positionOverlay);
711
+ Control.Overlay.observe('beforeShow',Control.Overlay.positionOverlay);
712
+ }else
713
+ Control.Overlay.container.setStyle(Control.Overlay.getStyles());
714
+ Control.Overlay.iFrameShim = new IframeShim();
715
+ Control.Overlay.iFrameShim.hide();
716
+ Event.observe(window,'resize',Control.Overlay.positionIFrameShim);
717
+ Control.Overlay.container.hide();
718
+ return true;
719
+ },
720
+ unload: function(){
721
+ if(!Control.Overlay.loaded)
722
+ return false;
723
+ Event.stopObserving(window,'resize',Control.Overlay.positionOverlay);
724
+ Control.Overlay.stopObserving('beforeShow',Control.Overlay.positionOverlay);
725
+ Event.stopObserving(window,'resize',Control.Overlay.positionIFrameShim);
726
+ Control.Overlay.iFrameShim.destroy();
727
+ Control.Overlay.container.remove();
728
+ Control.Overlay.loaded = false;
729
+ return true;
730
+ },
731
+ show: function(opacity,fade){
732
+ if(Control.Overlay.notify('beforeShow') === false)
733
+ return false;
734
+ Control.Overlay.lastOpacity = opacity;
735
+ Control.Overlay.positionIFrameShim();
736
+ Control.Overlay.iFrameShim.show();
737
+ if(fade){
738
+ if(typeof(Effect) == "undefined")
739
+ throw "Control.Window requires effects.js to be loaded."
740
+ if(Control.Overlay.effects.fade)
741
+ Control.Overlay.effects.fade.cancel();
742
+ Control.Overlay.effects.appear = new Effect.Appear(Control.Overlay.container,{
743
+ queue: {
744
+ position: 'end',
745
+ scope: 'Control.Overlay'
746
+ },
747
+ afterFinish: function(){
748
+ Control.Overlay.notify('afterShow');
749
+ },
750
+ from: 0,
751
+ to: Control.Overlay.lastOpacity,
752
+ duration: (fade === true ? 0.75 : fade) / 2
753
+ });
754
+ }else{
755
+ Control.Overlay.container.setStyle({
756
+ opacity: opacity || 1
757
+ });
758
+ Control.Overlay.container.show();
759
+ Control.Overlay.notify('afterShow');
760
+ }
761
+ return true;
762
+ },
763
+ hide: function(fade){
764
+ if(Control.Overlay.notify('beforeHide') === false)
765
+ return false;
766
+ if(Control.Overlay.effects.appear)
767
+ Control.Overlay.effects.appear.cancel();
768
+ Control.Overlay.iFrameShim.hide();
769
+ if(fade){
770
+ Control.Overlay.effects.fade = new Effect.Fade(Control.Overlay.container,{
771
+ queue: {
772
+ position: 'front',
773
+ scope: 'Control.Overlay'
774
+ },
775
+ afterFinish: function(){
776
+ Control.Overlay.notify('afterHide');
777
+ },
778
+ from: Control.Overlay.lastOpacity,
779
+ to: 0,
780
+ duration: (fade === true ? 0.75 : fade) / 2
781
+ });
782
+ }else{
783
+ Control.Overlay.container.hide();
784
+ Control.Overlay.notify('afterHide');
785
+ }
786
+ return true;
787
+ },
788
+ positionIFrameShim: function(){
789
+ if(Control.Overlay.container.visible())
790
+ Control.Overlay.iFrameShim.positionUnder(Control.Overlay.container);
791
+ },
792
+ //IE only
793
+ positionOverlay: function(){
794
+ Control.Overlay.container.setStyle({
795
+ width: document.body.clientWidth + 'px',
796
+ height: document.body.clientHeight + 'px'
797
+ });
798
+ }
799
+ };
800
+ Object.Event.extend(Control.Overlay);
801
+
802
+ Control.ToolTip = Class.create(Control.Window,{
803
+ initialize: function($super,container,tooltip,options){
804
+ $super(tooltip,Object.extend(Object.extend(Object.clone(Control.ToolTip.defaultOptions),options || {}),{
805
+ position: 'mouse',
806
+ hover: container
807
+ }));
808
+ }
809
+ });
810
+ Object.extend(Control.ToolTip,{
811
+ defaultOptions: {
812
+ offsetLeft: 10
813
+ }
814
+ });
815
+
816
+ Control.Modal = Class.create(Control.Window,{
817
+ initialize: function($super,container,options){
818
+ Control.Modal.InstanceMethods.beforeInitialize.bind(this)();
819
+ $super(container,Object.extend(Object.clone(Control.Modal.defaultOptions),options || {}));
820
+ },
821
+ closeWithoutOverlay: function(){
822
+ this.keepOverlay = true;
823
+ this.close();
824
+ }
825
+ });
826
+ Object.extend(Control.Modal,{
827
+ defaultOptions: {
828
+ overlayOpacity: 0.5,
829
+ closeOnClick: 'overlay'
830
+ },
831
+ current: false,
832
+ open: function(container,options){
833
+ var modal = new Control.Modal(container,options);
834
+ modal.open();
835
+ return modal;
836
+ },
837
+ close: function(){
838
+ if(Control.Modal.current)
839
+ Control.Modal.current.close();
840
+ },
841
+ InstanceMethods: {
842
+ beforeInitialize: function(){
843
+ Control.Overlay.load();
844
+ this.observe('beforeOpen',Control.Modal.Observers.beforeOpen.bind(this));
845
+ this.observe('afterOpen',Control.Modal.Observers.afterOpen.bind(this));
846
+ this.observe('afterClose',Control.Modal.Observers.afterClose.bind(this));
847
+ }
848
+ },
849
+ Observers: {
850
+ beforeOpen: function(){
851
+ Control.Window.windows.without(this).each(function(w){
852
+ if(w.closeWithoutOverlay && w.isOpen){
853
+ w.closeWithoutOverlay();
854
+ }else{
855
+ w.close();
856
+ }
857
+ });
858
+ if(!Control.Overlay.overlayFinishedOpening){
859
+ Control.Overlay.observeOnce('afterShow',function(){
860
+ Control.Overlay.overlayFinishedOpening = true;
861
+ this.open();
862
+ }.bind(this));
863
+ Control.Overlay.show(this.options.overlayOpacity,this.options.fade ? this.options.fadeDuration : false);
864
+ throw $break;
865
+ }
866
+ },
867
+ afterOpen: function(){
868
+ Control.Overlay.show(this.options.overlayOpacity);
869
+ Control.Overlay.overlayFinishedOpening = true;
870
+ Control.Modal.current = this;
871
+ },
872
+ afterClose: function(){
873
+ if(!this.keepOverlay){
874
+ Control.Overlay.hide(this.options.fade ? this.options.fadeDuration : false);
875
+ Control.Overlay.overlayFinishedOpening = false;
876
+ }
877
+ this.keepOverlay = false;
878
+ Control.Modal.current = false;
879
+ }
880
+ }
881
+ });
882
+
883
+ Control.LightBox = Class.create(Control.Window,{
884
+ initialize: function($super,container,options){
885
+ this.allImagesLoaded = false;
886
+ if(options.modal){
887
+ var options = Object.extend(Object.clone(Control.LightBox.defaultOptions),options || {});
888
+ options = Object.extend(Object.clone(Control.Modal.defaultOptions),options);
889
+ options = Control.Modal.InstanceMethods.beforeInitialize.bind(this)(options);
890
+ $super(container,options);
891
+ }else
892
+ $super(container,Object.extend(Object.clone(Control.LightBox.defaultOptions),options || {}));
893
+ this.hasRemoteContent = this.href && !this.options.iframe;
894
+ if(this.hasRemoteContent)
895
+ this.observe('onRemoteContentLoaded',Control.LightBox.Observers.onRemoteContentLoaded.bind(this));
896
+ else
897
+ this.applyImageObservers();
898
+ this.observe('beforeOpen',Control.LightBox.Observers.beforeOpen.bind(this));
899
+ },
900
+ applyImageObservers:function(){
901
+ var images = this.getImages();
902
+ this.numberImagesToLoad = images.length;
903
+ this.numberofImagesLoaded = 0;
904
+ images.each(function(image){
905
+ image.observe('load',function(image){
906
+ ++this.numberofImagesLoaded;
907
+ if(this.numberImagesToLoad == this.numberofImagesLoaded){
908
+ this.allImagesLoaded = true;
909
+ this.onAllImagesLoaded();
910
+ }
911
+ }.bind(this,image));
912
+ image.hide();
913
+ }.bind(this));
914
+ },
915
+ onAllImagesLoaded: function(){
916
+ this.getImages().each(function(image){
917
+ this.showImage(image);
918
+ }.bind(this));
919
+ if(this.hasRemoteContent){
920
+ if(this.options.indicator)
921
+ this.hideIndicator();
922
+ this.finishOpen();
923
+ }else
924
+ this.open();
925
+ },
926
+ getImages: function(){
927
+ return this.container.select(Control.LightBox.imageSelector);
928
+ },
929
+ showImage: function(image){
930
+ image.show();
931
+ }
932
+ });
933
+ Object.extend(Control.LightBox,{
934
+ imageSelector: 'img',
935
+ defaultOptions: {},
936
+ Observers: {
937
+ beforeOpen: function(){
938
+ if(!this.hasRemoteContent && !this.allImagesLoaded)
939
+ throw $break;
940
+ },
941
+ onRemoteContentLoaded: function(){
942
+ this.applyImageObservers();
943
+ if(!this.allImagesLoaded)
944
+ throw $break;
945
+ }
946
+ }
947
+ });
js/realex/validation.js ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ Validation.creditCartTypes.set('YOMA_DINERS_CLUB', [false, new RegExp('^([0-9]{3}|[0-9]{4})?$'), true]);
20
+ Validation.creditCartTypes.set('YOMA_MAESTRO', [false, new RegExp('^[0-9]{3}$'), true]);
lib/Realex/Log.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class Realex_Log
3
+ {
4
+
5
+ public static function log($message, $level = null, $file = '')
6
+ {
7
+ Yoma_Realex_Model_Log::write($message, $level, $file);
8
+ }
9
+
10
+ public static function logException(Exception $e)
11
+ {
12
+ Yoma_Realex_Model_Log::writeException($e);
13
+ }
14
+
15
+ }
lib/Realex/check.xsl ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform" xmlns:xs="http://www.w3.org/2001/XMLSchema" exclude-result-prefixes="xs" version="1.0">
2
+
3
+ <xsl:template match="//tss/check">
4
+ <xsl:variable name="a" select="concat(name(),'_',@id)"/>
5
+ <xsl:element name="{$a}">
6
+ <xsl:apply-templates/>
7
+ </xsl:element>
8
+ </xsl:template>
9
+
10
+ <xsl:template match="@*|node()">
11
+ <xsl:copy>
12
+ <xsl:apply-templates select="@*|node()"/>
13
+ </xsl:copy>
14
+ </xsl:template>
15
+
16
+ </xsl:stylesheet>
package.xml ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>Yoma_Realex</name>
4
+ <version>1.1.0</version>
5
+ <stability>stable</stability>
6
+ <license uri="http://opensource.org/licenses/osl-3.0.php">Open Software License (OSL)</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Realex Payments</summary>
10
+ <description>Payment Gateway module for Realex Payments</description>
11
+ <notes>Stable Version</notes>
12
+ <authors><author><name>Steve Cantlay</name><user>Stephen_cantlay</user><email>steve.cantlay@gmail.com</email></author></authors>
13
+ <date>2015-04-04</date>
14
+ <time>06:43:17</time>
15
+ <contents><target name="magelocal"><dir name="Yoma"><dir name="RealexRewrite"><dir name="Helper"><file name="Data.php" hash="28c2e1f6c2a9b4e226794060734439f1"/></dir><dir name="Model"><dir name="Sales"><dir name="Order"><file name="Creditmemo.php" hash="51589ff94f6cd6d7231a3e992a483fc0"/><dir name="Payment"><file name="Transaction.php" hash="0c2b6a6062ac259382efd2850acb9e90"/></dir><file name="Payment.php" hash="6f1be7e664baa256e61fdff9f6fdb275"/></dir></dir></dir><dir name="etc"><file name="config.xml" hash="672573791e1436209da6ceac4dab8f43"/></dir></dir></dir></target><target name="magecommunity"><dir name="Yoma"><dir name="Realex"><dir name="Block"><dir name="Adminhtml"><dir name="Customer"><file name="Tab.php" hash="88af064291904d8728228dafff1af00f"/></dir><dir name="Form"><dir name="Edit"><dir name="Renderer"><file name="Expiry.php" hash="66e5dea59fb5696385f20b027ecf3eda"/></dir></dir></dir><file name="Notifications.php" hash="ca75f2734d9894d50c0648921525e171"/><dir name="Sales"><dir name="Order"><dir name="Creditmemo"><file name="Rebate.php" hash="7569e8da8237e8ad697353ae0a5b8d8c"/></dir><dir name="Invoice"><file name="Settle.php" hash="38d353f0f325c08d86e2d89c2b88f15f"/></dir></dir><dir name="Realex"><file name="Logs.php" hash="af9192e668be587a3ffb80b2e5fed484"/></dir></dir><dir name="System"><dir name="Config"><dir name="Renderer"><dir name="SubAccount"><file name="Abstract.php" hash="d541a5b8cb60e0183efc976cf268adcd"/><file name="Direct.php" hash="702c74ee1433ad7e81dc1386c89ae563"/></dir></dir></dir></dir><dir name="Tokencard"><dir name="Edit"><file name="Form.php" hash="7576f6f9ca901e81a3bf38da521d8580"/><dir name="Tab"><file name="Form.php" hash="fdc77a5a05cf2708369ba440357b7e05"/></dir><file name="Tabs.php" hash="049364c9808703a0bcf07ed8bb08501c"/></dir><file name="Edit.php" hash="a91abd2c1c5fc9fc613cc44f2a51884b"/><file name="Grid.php" hash="dd21530f88846eb33b485acfb9093ba9"/></dir><file name="Tokencard.php" hash="c1f8f89b301eeb6486c1ba20ff07624c"/><dir name="Transaction"><dir name="Detail"><file name="Grid.php" hash="20b12221beb7c235cc79ca4e584a1ad8"/></dir><file name="Detail.php" hash="49cec63bb523a7b3198b1acd8e110d8e"/><file name="Grid.php" hash="6bdd47bf8672251d1506a0b451cce2a5"/></dir><file name="Transaction.php" hash="079fe4240344c8be0e24b5bc63f8c720"/></dir><file name="Config.php" hash="088a211133577ec9e0c6eff8fa8f3148"/><dir name="Customer"><dir name="Account"><dir name="Cards"><file name="Edit.php" hash="f11d28810e4296168c98ee933d5e8118"/></dir><file name="Cards.php" hash="0b87ba4e8ff242013f1154d8aed74d5d"/></dir></dir><dir name="Direct"><file name="Form.php" hash="971b520c425ab6ea3d193b28dee73b6b"/><file name="Frame.php" hash="102a9ceb1228419d18d6dd19e1bbb5af"/></dir><dir name="Form"><file name="Direct.php" hash="1192a8c184f552efe758414697894cbd"/><file name="Redirect.php" hash="512deab01f11194e86793ccb1e1e8fbf"/><file name="Token.php" hash="8a1bc4539f12543b7e6ce15ca46ecd1a"/></dir><dir name="Info"><file name="Direct.php" hash="a62feb0c57b5682e9efc070701994eb0"/><file name="Redirect.php" hash="ddf1e3fdb2b8ed8dcda42c769bb65728"/><file name="Token.php" hash="25e036b3dcbfa8751bf4c31ffa0b6377"/></dir><dir name="Onepage"><file name="Success.php" hash="2203ffc49a084ff1a783ec4f8a95478a"/></dir><dir name="Redirect"><file name="Form.php" hash="f23a29402b0689538ef6514c6a3d89bc"/><file name="Frame.php" hash="adf2d848e9a29a7e6e2e28573f80cbb1"/><file name="Result.php" hash="64fb03ab7eba009cf49e8126bc678d34"/></dir><file name=".DS_Store" hash="dc8b08fa4e82ccac73039c34a860d679"/></dir><dir name="Helper"><file name="Data.php" hash="a0076a0b26e5dffeefdb0e966f5c6041"/><file name="Direct.php" hash="bbfab90b84392e317c8ca278366305ed"/><file name="Redirect.php" hash="3b188f5126936fcefc4f4c018ed136f1"/></dir><dir name="Model"><dir name="Api"><file name="Payment.php" hash="45f1650df7babc3c5a9acb8c4f022e05"/></dir><file name="Direct.php" hash="05284d98171225c63ca40525d6330886"/><dir name="Exception"><file name="DenyPayment.php" hash="61a7aeb350ab75732b7fb599e9a3b673"/><file name="NoLiabilityShift.php" hash="3c9825ec6e6ebde1e282d743c2c2f321"/><file name="NoneParticipatingCard.php" hash="21623004c0d2a6690e09631412035149"/><file name="NotAuthenticated.php" hash="49499b5e35e154507c51f322f24981f6"/><file name="NotEnrolled.php" hash="956c67f31936782b5ef4d0c492d093d3"/><file name="NotVerified.php" hash="95151a08a00f295cc5a97f94841f20c2"/><file name="PayerNew.php" hash="373c2fd49bcddc2ee1d86c838972e423"/><file name="Payment.php" hash="7bc733b1d8adfe751e9acdf44e5512b8"/><file name="ThreedSecure.php" hash="deeb736dcea686334470b73270443f45"/></dir><file name="Log.php" hash="a81a87dc1afaff9ad1cf4d879ae7b824"/><dir name="Message"><file name="Abstract.php" hash="d3fbb9a7432a3c762cf81aa333623ef3"/><dir name="Direct"><file name="Authorize.php" hash="ec3c71b034e67d9be62f99d71e1a42cc"/><file name="Capture.php" hash="4c2f27096aaf1bd9321d92fe0392ad91"/><file name="Partial.php" hash="45983bc89ce6ab21ce8a2ca9f37e51d8"/><file name="Refund.php" hash="0ff7e4051877225ae52e8de9ed8a25d6"/><file name="ThreedSecure.php" hash="3543bba52685242d90d194a24812abc3"/><file name="ThreedSecureVerify.php" hash="11870881ef6a06118c38e0b4c7a5e125"/><file name="Void.php" hash="80e39904a6f9706650934577ec8fb5f8"/></dir><dir name="Redirect"><file name="Authorize.php" hash="5748d12e383404ca4f19031a4eed287c"/><file name="Capture.php" hash="40c6128c5e5373287b47f5791f270174"/><file name="EditPayer.php" hash="cae844b8ab3f4489b21cf30e242c83d0"/><file name="Partial.php" hash="381cd1fa35c2c2f1fde3a63e6a97ebe5"/><file name="Refund.php" hash="32f84d27bf7e35c853ed0def14a0df5f"/><file name="Void.php" hash="8ccb62339addd5dd7a60c85981f5d0b7"/></dir><dir name="Token"><file name="Authorize.php" hash="0b27432200d0d0b0cdf61608ab625a57"/><file name="Capture.php" hash="ab246c82ff1c66248b1eab67488141fc"/><file name="Delete.php" hash="3506eb1ab7050ec1bf19c478d7d3cde8"/><file name="EditPayer.php" hash="261cb44febd7d68f79d542bb8119ac96"/><file name="EditToken.php" hash="a59f302ffe6656b3dd40fc9a7c9c799d"/><file name="Partial.php" hash="4f78d1ec9de8748b997bb9897728fb4a"/><file name="PayerNew.php" hash="0f3c3c38f6cb3baa0b54e8307a5729cf"/><file name="Refund.php" hash="c1fc7d020001336df90ff5ecd0b28257"/><file name="RegisterToken.php" hash="95fa638a54121c80121e7613337b42ce"/><file name="ThreedSecure.php" hash="880e32cc1bb7b1aac4cf1832946108e5"/><file name="ThreedSecureVerify.php" hash="f9b170367eb79391a49fd5a7295c4aff"/><file name="Void.php" hash="1db8c2ae9fa82e662021d2d35d63ed63"/></dir></dir><dir name="Observer"><file name="Cron.php" hash="2145f69265a0357883dba4b69544d230"/><file name="Tokencard.php" hash="008d8fdcb48daf84d799ae5b9f4c2af3"/></dir><file name="Observer.php" hash="53139bbcc94149e51ce621ea0e62b344"/><dir name="Order"><dir name="Creditmemo"><dir name="Total"><file name="Rebate.php" hash="dfad1cd7ae603f02af63dbc95c23df84"/></dir></dir><dir name="Invoice"><dir name="Total"><file name="SettleAmount.php" hash="9df9d123509cdad53b790e6ba0b48ef2"/></dir></dir></dir><dir name="Payment"><file name="Abstract.php" hash="4a6a020af7ccd2fc8df0cea5571b4228"/><dir name="Direct"><file name="Authorize.php" hash="981f0a0f73bf04c2f22ef79aa6217ddd"/><file name="Capture.php" hash="2771c3821feda293817060844ebd3ad4"/><file name="Partial.php" hash="9773173ffd06f079e6e7afae107071c9"/><file name="Refund.php" hash="56f6af38616f75ba8d6d50675c1672f6"/><file name="RegisterToken.php" hash="3049776eec00a48421da3716bf65da26"/><file name="Void.php" hash="1fc7a686c7671a1685dc2be91a480fee"/></dir><file name="Direct.php" hash="66db9b81f26b6073eb054fdebdff00ae"/><dir name="Redirect"><file name="Authorize.php" hash="71b83e47493dacdf3f75e82a093c4613"/><file name="Capture.php" hash="390c5adf954be19dd823d54b55ff30d2"/><file name="EditPayer.php" hash="182483b9ddd32175ca98dcb40784390b"/><file name="Partial.php" hash="f4a1933e06f662f2d0b98448f41b0d06"/><file name="Refund.php" hash="2d9a5bf75948ad65af72740e8b70c77c"/><file name="Void.php" hash="9994d805622eb3a77ebfe921f36b6b08"/></dir><file name="Redirect.php" hash="d3eea3813a14e98a6840ced818531763"/><dir name="Token"><file name="Authorize.php" hash="ed1427538a44caee84212a291ec130b6"/><file name="Capture.php" hash="054e3352ea32de039620f7d43f63c07e"/><file name="Delete.php" hash="bb03069fcf9b38e6008045a52898c1cf"/><file name="EditPayer.php" hash="fa09ad2c0e1ba34a9e771771c53dd57a"/><file name="EditToken.php" hash="32bcef3fba81db00a3a7a21d15af34ba"/><file name="Partial.php" hash="8cb1ed5e59fc75892641288f3f4f6692"/><file name="Refund.php" hash="e29a35150030f1e24ddbf099e03bb00c"/><file name="Void.php" hash="5c23a6f44b81deec3e9bd34794950bf7"/></dir><file name="Token.php" hash="b560272dab8e9c9952d8fb2da3381724"/></dir><file name="PaymentInfo.php" hash="d00bf6fe810f5be08baa917eec67c79b"/><dir name="Realex"><dir name="Source"><file name="Cards.php" hash="d380e49a84ff914a8fc0689f457b50e4"/><file name="IframeSize.php" hash="7d39b0f398ff6e358df1e96a6fa58e8a"/><file name="PaymentAction.php" hash="68ba587941349097cb31673b99127fe6"/><file name="PaymentMode.php" hash="92f64c660625a098f772ed286150589d"/><file name="Status.php" hash="c1de9dffcb1c8d5caf9f4b151495d5f3"/></dir></dir><file name="Redirect.php" hash="32b392de0f0e597068e618ef3858e96f"/><file name="Redirect.php.orig" hash="874a1e50e222332898b0dd337da0aef6"/><dir name="Resource"><dir name="PaymentInfo"><file name="Collection.php" hash="d6dc7d3bc950233376c697d164781c18"/></dir><file name="PaymentInfo.php" hash="f174c7ff27dddea4d7b1c75c9c390508"/><dir name="Tokencard"><file name="Collection.php" hash="645fa7623e5c3639afc00888a289d23c"/></dir><file name="Tokencard.php" hash="cf75a9a1b0c33a7f03749461204617fc"/><dir name="Transaction"><file name="Collection.php" hash="4c56cd385bdbec6947b2c729a3bc6875"/></dir><file name="Transaction.php" hash="7f1ed0d3115ddbd90a9a6ec9e18d822c"/></dir><dir name="Response"><file name="Abstract.php" hash="f531aaf6b334f4456d05b87f44f9972f"/><dir name="Direct"><file name="Authorize.php" hash="5f1d3e1862b11b243283904729e99bdb"/><file name="Capture.php" hash="f03bcc291f5703bd7987decdbe3a0bd1"/><file name="Partial.php" hash="bea0f00d2c8c434f40ee3ba565af299f"/><file name="Refund.php" hash="d3d1ee6c083cd148ae9df82f413942a5"/><file name="ThreedSecure.php" hash="1de608bee4ef3adf2c4160b1b65379e6"/><file name="ThreedSecureVerify.php" hash="d5f5c7b5c2140a4d6fd36cb0489d35a9"/><file name="Void.php" hash="972a132ecd6b28b3fa70b49bf273bc8b"/></dir><file name="Direct.php" hash="066c4fecb0e478cd62440040e6f2859e"/><dir name="Redirect"><file name="Abstract.php" hash="9fa3bf68ba617d11575a08a589eaff81"/><file name="Authorize.php" hash="4ba9349ea0f4dce27cfe160116a04895"/><file name="Capture.php" hash="c4c88b5a66f42edfb552e1eaeab1cb90"/><file name="EditPayer.php" hash="477e3e0ec4fab643dd1a41cfc111e465"/><file name="Partial.php" hash="da99f0d8d8bf365c048293d9c2e00f25"/><file name="Refund.php" hash="5d7b9a1c246aa0da7f121fdb6b69005c"/><file name="Void.php" hash="068c8853082cdaa6e228aa581a75b05a"/></dir><file name="Redirect.php" hash="bb3b0ed5e955dcbf5120856955defd96"/><dir name="Token"><file name="Authorize.php" hash="319b247e542c631aa14c24e4f1eccbbd"/><file name="Capture.php" hash="2fb9806f5c9c11e9a43a567ac5d446f3"/><file name="Delete.php" hash="b6a6fdac91f417eec73827f8ed666045"/><file name="EditPayer.php" hash="a47f0e8fb616ec3821cf1f156b650fae"/><file name="EditToken.php" hash="bca1f2b7aa0ed22a99b06615fa6f768c"/><file name="Partial.php" hash="a4e281708b63f760900c6afb0565db29"/><file name="PayerNew.php" hash="faabc09e2143a64aebac0ff1fda4607b"/><file name="Refund.php" hash="9b5e823592ff6531cb1f5775d3f728b7"/><file name="RegisterToken.php" hash="02e6a073ff7168c4e199305136f8e649"/><file name="ThreedSecure.php" hash="65221b87367dc8222b3b9c7fab8ef5d5"/><file name="ThreedSecureVerify.php" hash="9cc80a9847e7e67efc9d472dd3b06076"/><file name="Void.php" hash="1287e311cbbfdf2a4052bcd1bdd79e39"/></dir><file name="Token.php" hash="1b37d6db39b9c8e4610675ea2123a070"/></dir><dir name="Service"><file name="Abstract.php" hash="0050860b72b7b8458e554d11bcdb4f84"/><file name="Direct.php" hash="f73484a43e80c188780bf6f64686aa58"/><file name="Redirect.php" hash="731250ad3beb85f083c86f2425d7a695"/><file name="Token.php" hash="b93d7ec1f91717c9c16d991d9834cd08"/></dir><file name="Session.php" hash="c0270d8c2bd41865706cc12c76cab291"/><file name="SubAccountProcessor.php" hash="df46e92caccc85c1d4e8185aa643e8f7"/><dir name="System"><dir name="Config"><dir name="Source"><file name="Storecard.php" hash="d4196ef6c9a1c6315046c108f0069fb6"/></dir></dir></dir><file name="Token.php" hash="acdd686d4cc620e23117ded452be486e"/><file name="Tokencard.php" hash="da85df44874dd2461c7550fa4b6a5d1b"/><dir name="Total"><dir name="Creditmemo"><file name="Rebate.php" hash="015b50ebf47083c823aa9f558ef43953"/></dir><dir name="Invoice"><file name="Settle.php" hash="18b66fff64a09d61097058d1031b6639"/></dir></dir><file name="Transaction.php" hash="52a0770b2d37bb5e4f1d00bacf1c8b9f"/><file name=".DS_Store" hash="f0d35caa53ddb4f705e943d424860d53"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="LogController.php" hash="7ed9dbc2470f072278b7a34137620ea3"/><file name="TokencardController.php" hash="23e114f38de7ce43e4a1ab8b54838c2c"/><file name="TransactionController.php" hash="589d718f043322bb909f612efafe9833"/></dir><file name="CardsController.php" hash="87c1bd30a28556d4f5b02551d62306a3"/><dir name="Checkout"><file name="OnepageController.php" hash="09e394843a36a719ee838d91ce8b275d"/></dir><file name="DirectController.php" hash="0262214d83b359e7073a6aa5d1b7190d"/><file name="PaymentController.php" hash="d1b407cb3e15cf09ba94fad873593e63"/><file name="RedirectController.php" hash="2254fa266ff92159b6228d624a38e69f"/><file name="TokenController.php" hash="1a405c13a5926403df204a60778b7f35"/><file name=".DS_Store" hash="16bd3b3979e9c90e5a1d4f6b2eb62188"/></dir><dir name="etc"><file name="adminhtml.xml" hash="4391e44dfa31bc3259abf67e1366e6cc"/><file name="config.xml" hash="2cf66edd6c13fe2c38622312f02c3fda"/><file name="system.xml" hash="e2cc75e7241c6426eedbc9fa55eac239"/></dir><dir name="sql"><dir name="realex_setup"><file name="mysql4-install-0.0.1.php" hash="caeb790dbd9847c7aa02cacf11371e2f"/></dir><file name=".DS_Store" hash="f1354cbdd15bcc5bfbb22490d377f5e6"/></dir><file name=".DS_Store" hash="20cf9788acf4f3e01cd0cecf893980c3"/></dir><file name=".DS_Store" hash="a51f79fcb7e96cac5b14f0a1768247da"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><dir name="realex"><file name="realex.xml" hash="b7a94e323ce08b966e401dae90a69bc4"/></dir></dir><dir name="template"><dir name="realex"><dir name="customer"><file name="tab.phtml" hash="6217ec5a038da5eed7c7cec5b7ceff9d"/></dir><file name="notifications.phtml" hash="164e5f9e7dcfc5c2d2451f0e77776d77"/><dir name="payment"><dir name="info"><file name="payment-info.phtml" hash="0126a562de45d5d219882d8f41fed191"/></dir></dir><dir name="sales"><dir name="order"><dir name="creditmemo"><dir name="totals"><file name="rebate.phtml" hash="7d86e1ee141e18dd247fdd215b378e48"/></dir></dir><dir name="invoice"><dir name="totals"><file name="settle.phtml" hash="0364b91c6919052bb798e8cdbe4e6c9e"/><file name="settled.phtml" hash="c012cb874839cd19078b7f96db274a99"/></dir></dir></dir><dir name="realex"><file name="logs.phtml" hash="84c812d33ed7c6356f4222e2d76b863c"/></dir><dir name="transaction"><file name="detail.phtml" hash="7da6a47008b11a0537e372c50cb01bff"/></dir></dir></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="layout"><dir name="realex"><file name="realex.xml" hash="cd1bce43f10fc80afa9a57974cb911bb"/></dir></dir><dir name="template"><dir name="realex"><dir name="customer"><dir name="cards"><file name="edit.phtml" hash="8f24cc1a0b327dba629ace8e77a0c0f5"/></dir><file name="cards.phtml" hash="a3b7d60bde339ddc8c43c3c24be5effe"/></dir><dir name="onepage"><file name="success.phtml" hash="608c3b4df497ee5e02db5c743e6bdf46"/></dir><dir name="payment"><file name="config.phtml" hash="9f4ee8993d4a627b129c3cac98bd09fa"/><dir name="direct"><file name="form.phtml" hash="7ff0cdc804051f1c3027a72f02b96fd3"/><file name="frame.phtml" hash="89a2b49bc798bb3cb21581a12348add8"/></dir><dir name="form"><file name="direct.phtml" hash="30e3fcc13494ece2c89365b340683b9e"/><file name="redirect.phtml" hash="1d20b1c12fbb621e6a4a1e48f25699fb"/><file name="token.phtml" hash="8202e5581a1ccca0ebd92f2d94cf9e2b"/></dir><dir name="info"><file name="redirect.phtml" hash="d41d8cd98f00b204e9800998ecf8427e"/></dir><dir name="redirect"><file name="form.phtml" hash="6f280da99c9a757a6b778a591d0366b3"/><file name="frame.phtml" hash="ac4d62178ddf6df3829f8dc7bd15bfbb"/><file name="result.phtml" hash="69faf9730e290adc690a22e3f28eb058"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Yoma_Realex.xml" hash="f5bb4e0ff3197f946706a006e39fb386"/><file name="Yoma_RealexRewrite.xml" hash="05b334d56a45b1a5a4e738ae2479bbae"/></dir></target><target name="magelib"><dir name="Realex"><file name="Log.php" hash="c9993e5ec00d349a9a19fc9cffdbb0fd"/><file name="check.xsl" hash="72ffe45a249c321b7387f93e8c7bb8d6"/></dir></target><target name="magelocale"><dir name="en_GB"><dir name="realex"><file name="Yoma_Realex.csv" hash="aa223b498ff83c2cf50c767d39e3a3a0"/><file name="Yoma_Realex_Adminhtml.csv" hash="5daff7ad687e5d20bf4f8b9e47f4b33d"/></dir></dir></target><target name="mageskin"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="realex"><dir name="css"><file name="realex.css" hash="94e88b504ca2339edd9a8bec5a73ac60"/></dir><dir name="js"><file name="realex.js" hash="9a533e456f790936854f796da7fde0f0"/></dir></dir></dir></dir></dir><dir name="frontend"><dir name="base"><dir name="default"><dir name="realex"><dir name="css"><file name="realex.css" hash="f056bbc57afb1d50a9e586108dd40c3c"/></dir><dir name="images"><file name="icons.png" hash="e2a800f8348d10536e71fab17d911c6b"/></dir><dir name="js"><file name="checkout.js" hash="d62a6fd0ed935130d0c98f56d1877d1c"/><file name="customer.js" hash="676c6eb635d5f44156b6751498be47a4"/><file name="iframe.js" hash="0cb15cf1d6617069e7ce13082721d294"/><file name="iframe.js.orig" hash="cae511921fcb3426e0848352718280ea"/><file name="realex.js" hash="2c82912f3054b8cbf9b783ba735579b6"/><file name="realexosc.js" hash="0e810e281ac504ecd2753712c566b19c"/></dir></dir></dir></dir></dir></target><target name="mageweb"><dir name="js"><dir name="realex"><file name="invoice.js" hash="038b39c2e06782efb9b64e0458f0cfff"/><dir name="livepipe"><file name="contextmenu.js" hash="a5dbab9663d94d9d848e84b524c1f925"/><file name="cookie.js" hash="eab2042ac637aec7777c7c64e3e2bb1a"/><file name="event_behavior.js" hash="a59a00ad652efb1596b5bd2e6f5cfe48"/><file name="hotkey.js" hash="c6193fc03e4cd4c94ee4fb37e3d5ed6b"/><file name="livepipe.js" hash="417ba064736fed2772778641f66555c0"/><file name="progressbar.js" hash="69719eccbecbc0378d9919c53a3ef7dd"/><file name="rating.js" hash="adb5ce773c37b40fb590a877d949be7a"/><file name="resizable.js" hash="38fd18daa37e5612495cc7b42fd32b3d"/><file name="scrollbar.js" hash="7a2603c2107944b8a70e41e7a84133ba"/><file name="selection.js" hash="3f48981cccffdb5fcc5f5ff27d0b0b68"/><file name="selectmultiple.js" hash="d8f044eb344061bdcce405f671b15654"/><file name="tabs.js" hash="22abb9a3ec3933d54ff9ede0338ca7f3"/><file name="textarea.js" hash="9825782bf78d38efa53200a206d8cd77"/><file name="window.js" hash="f6eba488d6a80e05f59d97a0cef59730"/></dir><file name="validation.js" hash="9c031e26aa1dc4baa2f674744a577d96"/></dir></dir></target></contents>
16
+ <compatible/>
17
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
18
+ </package>
skin/adminhtml/default/default/realex/css/realex.css ADDED
@@ -0,0 +1,2 @@
 
 
1
+ div#realex-log-view-cont label {display:block;}
2
+ iframe#realex-log-view { background: #BFBFBF; width: 100%; height:800px; border:1px solid #CCC; margin-top:10px; }
skin/adminhtml/default/default/realex/js/realex.js ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ logSelectObserve = function () {
2
+ var rl = $('rl-log-switcher');
3
+ if (rl) {
4
+ rl.observe('change', function (ev) {
5
+ $('realex-log-view').src = rl.getValue();
6
+ });
7
+ }
8
+ }
9
+
10
+ loadActions = function () {
11
+ logSelectObserve();
12
+ }
13
+
14
+ Event.observe(window, 'load', loadActions);
skin/frontend/base/default/realex/css/realex.css ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #control_overlay {
2
+ background-color: #000;
3
+ }
4
+
5
+ .modal {
6
+ padding: 10px;
7
+ background-color: #fff !important;
8
+ border: 1px solid #333 !important;
9
+ }
10
+
11
+ .window .window_close {
12
+ position: absolute;
13
+ top: 4px;
14
+ left: 5px;
15
+ display: block;
16
+ width: 13px;
17
+ height: 13px;
18
+ background-image: url("/stylesheets/window_close.gif");
19
+ cursor: pointer;
20
+ cursor: hand;
21
+ }
22
+
23
+ .tokencvv {
24
+ clear: both;
25
+ display: inline;
26
+ width: 43px;
27
+ padding-top: 10px;
28
+ }
29
+
30
+ .tokencvv label {
31
+ float: none;
32
+ margin-right: 8px;
33
+ }
34
+
35
+ .tokencvv input.cvv {
36
+ float: none;
37
+ width: 3em !important;
38
+ vertical-align: middle;
39
+ margin-right: 5px;
40
+ }
41
+
42
+ #payment_form_realexdirect label.token,
43
+ #payment_form_realexredirect label.token {
44
+ float: none;
45
+ margin-left: 7px;
46
+ }
47
+
48
+ .token-icon {
49
+ position: relative;
50
+ top: -1px;
51
+ display: inline-block;
52
+ *display: inline;
53
+ *zoom: 1;
54
+ width: 41px;
55
+ height: 25px;
56
+ overflow: hidden;
57
+ vertical-align: middle;
58
+ margin-left: 10px;
59
+ text-indent: -99em;
60
+ background: transparent url('../images/icons.png') no-repeat;
61
+ }
62
+ .token-icon-vi { background-position: 0 0; }
63
+ .token-icon-ae { background-position: -41px 0; }
64
+ .token-icon-mc { background-position: -82px 0; }
65
+ .token-icon-yoma_diners_club { background-position: -123px 0; }
66
+ .token-icon-yoma_maestro { background-position: -164px 0; }
67
+
68
+ iframe#iframeId{
69
+ width: 100%;
70
+ background: none;
71
+ border: 0;
72
+ }
73
+
74
+ @media screen and (min-device-width : 320px) and (max-device-width : 480px) {
75
+
76
+ .modal{
77
+ width: 90% !important;
78
+ position: fixed !important;
79
+ height: 100% !important;
80
+ top: 0 !important;
81
+ }
82
+
83
+ }
84
+
85
+ @media screen and (device-width: 375px) and (device-height: 667px) and (-webkit-device-pixel-ratio: 2){
86
+
87
+ .modal{
88
+ height: auto !important;
89
+ }
90
+
91
+ .modal select:focus,
92
+ .modal textarea:focus,
93
+ .modal input:focus {
94
+ font-size: 16px;
95
+ background: #eee;
96
+ }
97
+
98
+ }
skin/frontend/base/default/realex/images/icons.png ADDED
Binary file
skin/frontend/base/default/realex/js/checkout.js ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+
20
+ cardOpt = function(radioelement) {
21
+ var option = radioelement.value;
22
+ $('realexdirect_card_type').value = option;
23
+ if(option == 1){
24
+ $('realexdirect_card_stored').show();
25
+ $('realexdirect_card_form').hide();
26
+ } else if (option == 0) {
27
+ $('realexdirect_card_stored').hide();
28
+ $('realexdirect_card_form').show();
29
+ }
30
+ }
31
+
32
+ storeCard = function(checkboxelement) {
33
+ var value = checkboxelement.checked ? 1 : 0;
34
+ $('CARD_STORAGE_ENABLE').value = value;
35
+ }
36
+
37
+ storeCardDirect = function(radioelement) {
38
+ $('realexdirect_CARD_STORAGE_ENABLE').value = radioelement.value;
39
+ }
40
+
41
+ switchToken = function(radio){
42
+
43
+ $$('div.tokencvv').invoke('hide');
44
+ $$('input.tokencvv').each(function(inp){
45
+ inp.disabled = 'disabled';
46
+ inp.setValue('');
47
+ })
48
+
49
+ $$('input.tokencctype').each(function(inp){
50
+ inp.disabled = 'disabled';
51
+ })
52
+ var divcont = radio.next('div');
53
+
54
+ if((typeof divcont) != 'undefined'){
55
+ divcont.down().next('input').removeAttribute('disabled');
56
+ divcont.down('input.tokencctype').removeAttribute('disabled');
57
+ divcont.show();
58
+ }
59
+
60
+ }
61
+
62
+ tokenRadioCheck = function(radioID, cvv){
63
+
64
+ try{
65
+ $(radioID).checked = true;
66
+ }catch(noex){}
67
+
68
+ $$('input.tokencvv').each(function(sl){
69
+ if(sl.id != cvv.id){
70
+ sl.disabled = true;
71
+ sl.setValue('');
72
+ }
73
+ });
74
+
75
+ $$('input.tokencctype').each(function(sl){
76
+ if(sl.id != cvv.id){
77
+ sl.disabled = true;
78
+ sl.setValue('');
79
+ }
80
+ });
81
+ }
82
+
83
+ Validation.addAllThese([
84
+
85
+ ['validate-realex-cvn', 'Please enter a valid credit card verification number.', function(v, elm) {
86
+ try{
87
+
88
+ var ccTypeContainer = $(elm.id.replace('token_cvv','cc_type'));
89
+
90
+ if(ccTypeContainer === undefined)
91
+ {
92
+ return true;
93
+ }
94
+ var ccType = ccTypeContainer.value;
95
+
96
+ switch (ccType) {
97
+ case 'VISA' :
98
+ case 'MC' :
99
+ re = new RegExp('^[0-9]{3}$');
100
+ break;
101
+ case 'AMEX' :
102
+ re = new RegExp('^[0-9]{4}$');
103
+ break;
104
+ case 'YOMA_MAESTRO':
105
+ case 'SOLO':
106
+ case 'SWITCH':
107
+ re = new RegExp('^([0-9]{1}|^[0-9]{2}|^[0-9]{3})?$');
108
+ break;
109
+ default:
110
+ re = new RegExp('^([0-9]{3}|[0-9]{4})?$');
111
+ break;
112
+ }
113
+
114
+ if (v.match(re)) {
115
+ return true;
116
+ }
117
+ return false;
118
+ }catch(_error){return true;}
119
+ }]
120
+ ]);
121
+
122
+
skin/frontend/base/default/realex/js/customer.js ADDED
@@ -0,0 +1,109 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ setDefault = function (radioelement){
20
+ new Ajax.Request(('default'), {
21
+ method: 'get',
22
+ parameters: {
23
+ card:radioelement.value
24
+ },
25
+ onSuccess: function(transport) {
26
+ var rsp = transport.responseText.evalJSON();
27
+ if(rsp.st != 'ok'){
28
+ alert(rsp.text);
29
+ }
30
+ },
31
+ onLoading: function(){
32
+ }
33
+ })
34
+ }
35
+
36
+ // remove credit card
37
+ removeCard = function(elem) {
38
+ var oncheckout = elem.hasClassName('oncheckout');
39
+ new Ajax.Request(elem.href, {
40
+ method: 'get',
41
+ onSuccess: function(transport) {
42
+ try {
43
+ var rsp = transport.responseText.evalJSON();
44
+
45
+ if(rsp.st != 'ok') {
46
+ new Effect.Opacity(elem.up(), { from: 0.3, to: 1.0, duration: 0.5 });
47
+ alert(rsp.text);
48
+ }
49
+ else {
50
+ if(false === oncheckout) {
51
+ elem.up().up().fade({
52
+ afterFinish:function(){
53
+ elem.up().up().remove();
54
+ updateEvenOdd();
55
+ }
56
+ });
57
+ }
58
+ else {
59
+ elem.up().fade({
60
+ afterFinish:function() {
61
+ var daiv = elem.up('div');
62
+ elem.up().remove();
63
+ //If no tokens, open new token dialog
64
+ var tokens = daiv.select("li.tokencard-radio input").length;
65
+ if(parseInt(tokens) === 0) {
66
+ toggleNewCard(2);
67
+ $$("a.usexist").first().up().remove();
68
+ }
69
+
70
+ }
71
+ });
72
+ }
73
+ }
74
+ }catch(er){
75
+ alert(er);
76
+ }
77
+ },
78
+ onLoading: function() {
79
+ if(!oncheckout) {
80
+ if($('iframeRegCard')) {
81
+ $('iframeRegCard').remove();
82
+ }
83
+ else if($('frmRegCard')) {
84
+ $('frmRegCard').remove();
85
+ }
86
+ $('sageTokenCardLoading').show();
87
+ }
88
+ else {
89
+ new Effect.Opacity(elem.up(), { from: 1.0, to: 0.3, duration: 0.5 });
90
+ }
91
+
92
+ }
93
+ })
94
+
95
+ }
96
+
97
+ evenOdd = function(row, index){
98
+ var _class = ((index+1)%2 == 0 ? 'even' : 'odd');
99
+ row.addClassName(_class);
100
+ }
101
+
102
+ updateEvenOdd = function(){
103
+ var rows = $$('table#realex-card-tabl tbody tr');
104
+ rows.invoke('removeClassName', 'odd').invoke('removeClassName', 'even');
105
+ rows.each(
106
+ function(row, index){
107
+ evenOdd(row, index);
108
+ });
109
+ }
skin/frontend/base/default/realex/js/iframe.js ADDED
@@ -0,0 +1,114 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ var Iframe = Class.create();
20
+ Iframe.prototype = {
21
+ initialize: function(closeUrl, contentUrl, srcUrl, width, height){
22
+ this.closeUrl = closeUrl;
23
+ this.contentUrl = contentUrl;
24
+ this.srcUrl = srcUrl;
25
+ this.onShow = this.showForm.bindAsEventListener(this);
26
+ this.onClose = this.closeForm.bindAsEventListener(this);
27
+ this.width = typeof width !== 'undefined' ? width : 460;
28
+ this.height = typeof height !== 'undefined' ? height: 600;
29
+ this.message = false;
30
+ },
31
+ show: function(){
32
+ //Event.observe(window, 'beforeunload', this.register.bind(this));
33
+ Event.observe(window, 'message', this.callBack.bind(this));
34
+
35
+ var request = new Ajax.Request(
36
+ this.contentUrl,
37
+ {
38
+ method:'post',
39
+ onSuccess: this.onShow,
40
+ onFailure: this.onClose
41
+ }
42
+ );
43
+ },
44
+ showForm: function(transport){
45
+ if (transport && transport.responseText) {
46
+ result = transport.responseText.trim();
47
+ if(result !== ''){
48
+ try{
49
+ var iframe = document.createElement('iframe');
50
+
51
+ iframe.src = this.srcUrl
52
+ iframe.id = 'iframeId';
53
+ document.body.appendChild(iframe);
54
+
55
+ if (iframe.contentWindow){
56
+ iframe = iframe.contentWindow;
57
+ }else{
58
+ if (iframe.contentDocument && iframe.contentDocument.document){
59
+ iframe = iframe.contentDocument.document;
60
+ }else{
61
+ iframe = iframe.contentDocument;
62
+ }
63
+ }
64
+
65
+ iframe.document.open();
66
+ iframe.document.write(result);
67
+ iframe.document.close();
68
+
69
+ var wm = new Control.Modal('iframeId',{
70
+ className: 'modal',
71
+ closeOnClick: true,
72
+ width: this.width ,
73
+ height: this.height,
74
+ fade: true,
75
+ afterClose: this.onClose
76
+ });
77
+ wm.open();
78
+ }catch (_error){
79
+ this.onClose;
80
+ }
81
+ }else{
82
+ this.onClose;
83
+ }
84
+ }
85
+ },
86
+ closeForm: function(){
87
+ window.location=this.closeUrl;
88
+ },
89
+ callBack: function(evt){
90
+ if ( evt.origin === this.srcUrl ){
91
+ this.message = true;
92
+ }
93
+ }
94
+ /*,
95
+ register: function (evt) {
96
+ if(this.message === true){
97
+ return;
98
+ }
99
+ location.replace(this.closeUrl);
100
+ return '';
101
+ //alert('h');
102
+ //window.location=this.closeUrl;
103
+ //this.theTimer.delay(5);
104
+ //this.timeout = window.setTimeout(this.clearit, 500000);
105
+ },
106
+ cleanup: function(evt){
107
+ clearTimeout(this.timeout);
108
+ },
109
+ theTimer: function(url){
110
+ history.replaceState({}, '', url);
111
+ return false;
112
+ }
113
+ */
114
+ }
skin/frontend/base/default/realex/js/iframe.js.orig ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ var Iframe = Class.create();
2
+ Iframe.prototype = {
3
+ initialize: function(closeUrl, contentUrl, srcUrl, width, height){
4
+ this.closeUrl = closeUrl;
5
+ this.contentUrl = contentUrl;
6
+ this.srcUrl = srcUrl;
7
+ this.onShow = this.showForm.bindAsEventListener(this);
8
+ this.onClose = this.closeForm.bindAsEventListener(this);
9
+ this.width = typeof width !== 'undefined' ? width : 460;
10
+ this.height = typeof height !== 'undefined' ? height: 600;
11
+ },
12
+ show: function(){
13
+ Event.observe(window, 'beforeunload', this.register.bind(this));
14
+ var request = new Ajax.Request(
15
+ this.contentUrl,
16
+ {
17
+ method:'post',
18
+ onSuccess: this.onShow,
19
+ onFailure: this.onClose
20
+ }
21
+ );
22
+ },
23
+ showForm: function(transport){
24
+ if (transport && transport.responseText) {
25
+ result = transport.responseText;
26
+ if(result !== ''){
27
+ try{
28
+ var iframe = document.createElement('iframe');
29
+
30
+ iframe.src = this.srcUrl;
31
+ iframe.id = 'iframeId';
32
+ document.body.appendChild(iframe);
33
+ iframe.contentWindow.document.open('text/htmlreplace');
34
+ iframe.contentWindow.document.write(result.str.trim());
35
+ iframe.contentWindow.document.close();
36
+
37
+ var iHeight = iframe.contentWindow.document.body.scrollHeight;
38
+
39
+ var wm = new Control.Modal('iframeId',{
40
+ className: 'modal',
41
+ closeOnClick: true,
42
+ width: this.width ,
43
+ height: this.height,
44
+ fade: true,
45
+ afterClose: this.onClose
46
+ });
47
+ wm.open();
48
+ }catch (_error){
49
+ this.onClose;
50
+ }
51
+ }else{
52
+ this.onClose;
53
+ }
54
+ }
55
+ },
56
+ closeForm: function(){
57
+ window.location=this.closeUrl;
58
+ },
59
+ register: function (evt) {
60
+ console.log(evt);
61
+ }
62
+ }
skin/frontend/base/default/realex/js/realex.js ADDED
@@ -0,0 +1,157 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Open Software License (OSL 3.0)
7
+ * that is bundled with this package in the file LICENSE.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/osl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * @category Yoma
15
+ * @package Yoma_Realex
16
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
17
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
18
+ */
19
+ var Realex = Class.create({
20
+ initialize: function () {
21
+ // This variable is used for storing fields values on change into JS object
22
+ this.storedFields = $H({});
23
+ // Binded element change observer method
24
+ },
25
+ // Creates form and appending it body element
26
+ createForm: function () {
27
+ $(document.body).insert('div');
28
+ },
29
+ showModel: function(redirect,failUrl,iframeSize,deny){
30
+
31
+ this.closeUrl = failUrl;
32
+ var close = this.onClose.bind(this);
33
+ if((failUrl == redirect) || (deny == redirect)){
34
+ close;
35
+ }
36
+ var iframe = document.createElement('iframe');
37
+ iframe.src = redirect;
38
+ iframe.id = 'iframeId';
39
+ document.body.appendChild(iframe);
40
+
41
+ var wm = new Control.Modal('iframeId',{
42
+ className: 'modal',
43
+ closeOnClick: true,
44
+ width: iframeSize[0],
45
+ height: iframeSize[1],
46
+ fade: true,
47
+ afterClose: close,
48
+ position: 'center_once'
49
+ });
50
+ wm.open();
51
+ },
52
+ showInline: function(redirect,failUrl,iframeSize,deny){
53
+
54
+ this.closeUrl = failUrl;
55
+ if((failUrl == redirect) || (deny == redirect)){
56
+ close;
57
+ }
58
+ var iframe = document.createElement('iframe');
59
+ iframe.src = redirect;
60
+ iframe.id = 'iframeId';
61
+ iframe.width = iframeSize[0];
62
+ iframe.height = iframeSize[1];
63
+ $('checkoutSteps').appendChild(iframe);
64
+ },
65
+ onClose: function(){
66
+ window.location=this.closeUrl;
67
+ }
68
+
69
+
70
+ });
71
+ // Our class singleton
72
+ Realex.getInstance = function () {
73
+ if (!this.instance) {
74
+ this.instance = new this();
75
+ }
76
+ return this.instance;
77
+ };
78
+
79
+ var ReviewRegister = Class.create(Realex,{
80
+ initialize: function () {
81
+ // Registers wrapper on DOM tree load event.
82
+ document.observe('dom:loaded', this.register.bind(this));
83
+ // Registers wrapper on AJAX calls, since review object can be overridden in it
84
+ Ajax.Responders.register(this);
85
+ },
86
+ register: function () {
87
+ if (!window.review || review.overriddenOnSave) {
88
+ // In case if review object is not yet available
89
+ // or wrapper was already applied
90
+ return this;
91
+ }
92
+
93
+ var method = window.payment.currentMethod;
94
+
95
+ if(['realexredirect','realexdirect','realvault'].indexOf(method) < 0){
96
+ return;
97
+ }
98
+ if(!realexConfig){
99
+ return;
100
+ }
101
+ var config = realexConfig[window.payment.currentMethod];
102
+
103
+ if(config == undefined){
104
+ return
105
+ }
106
+ if(config.iframe !== '1' || config.display !== '1' || config.secure !== '1'){
107
+ return;
108
+ }
109
+
110
+ review.overriddenOnSave = function (transport) {
111
+ try{
112
+ if (transport && transport.responseText) {
113
+ try {
114
+ response = eval('(' + transport.responseText + ')');
115
+ }
116
+ catch (e) {
117
+ response = {};
118
+ }
119
+ if (response.redirect) {
120
+ review.isSuccess = true;
121
+
122
+ //Change to inline if using Safari on iOS
123
+ if (/Constructor/.test(window.HTMLElement) && /iP(ad|hone|od)/i.test(navigator.userAgent)){
124
+ config.inline = 1;
125
+ }
126
+
127
+ if(config.inline == 1){
128
+ Realex.getInstance().showInline(response.redirect, realexConfig.failUrl, realexConfig.iframeSize, config.deny);
129
+ }else {
130
+ Realex.getInstance().showModel(response.redirect, realexConfig.failUrl, realexConfig.iframeSize, config.deny);
131
+ }
132
+ return;
133
+ }
134
+ if (response.goto_section) {
135
+ if(response.goto_section == 'payment') {
136
+ $$('input.tokencvv').each(function (sl) {
137
+ sl.setValue('');
138
+ });
139
+ }
140
+ }
141
+ }
142
+
143
+ }
144
+ catch (e) { /* some error processing logic */ }
145
+ // Invokation original order save method
146
+ this.nextStep(transport);
147
+ }
148
+ // Replace original onSave with overridden one
149
+ review.onSave = review.overriddenOnSave.bind(review);
150
+ },
151
+ // This one is invoked when AJAX request gets completed
152
+ onComplete: function () {
153
+ this.register.defer();
154
+ }
155
+ });
156
+ // Invoke ReviewRegister class routines
157
+ var realex = new ReviewRegister();
skin/frontend/base/default/realex/js/realexosc.js ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /**
3
+ * Magento
4
+ *
5
+ * NOTICE OF LICENSE
6
+ *
7
+ * This source file is subject to the Open Software License (OSL 3.0)
8
+ * that is bundled with this package in the file LICENSE.txt.
9
+ * It is also available through the world-wide-web at this URL:
10
+ * http://opensource.org/licenses/osl-3.0.php
11
+ * If you did not receive a copy of the license and are unable to
12
+ * obtain it through the world-wide-web, please send an email
13
+ * to license@magentocommerce.com so we can send you a copy immediately.
14
+ *
15
+ * @category Yoma
16
+ * @package Yoma_Realex
17
+ * @copyright Copyright (c) 2014 YOMA LIMITED (http://www.yoma.co.uk)
18
+ * @license http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
19
+ */
20
+ var Realex = Class.create({
21
+ initialize: function () {
22
+ // This variable is used for storing fields values on change into JS object
23
+ this.storedFields = $H({});
24
+ // Binded element change observer method
25
+ },
26
+ // Creates form and appending it body element
27
+ createForm: function () {
28
+ $(document.body).insert('div');
29
+ },
30
+ showModel: function(redirect,failUrl,iframeSize,deny){
31
+
32
+ this.closeUrl = failUrl;
33
+ var close = this.onClose.bind(this);
34
+ if((failUrl == redirect) || (deny == redirect)){
35
+ close;
36
+ }
37
+ var iframe = document.createElement('iframe');
38
+ iframe.src = redirect;
39
+ iframe.id = 'iframeId';
40
+ document.body.appendChild(iframe);
41
+
42
+ var wm = new Control.Modal('iframeId',{
43
+ className: 'modal',
44
+ closeOnClick: true,
45
+ width: iframeSize[0],
46
+ height: iframeSize[1],
47
+ fade: true,
48
+ afterClose: close
49
+ });
50
+ wm.open();
51
+ },
52
+ onClose: function(){
53
+ window.location=this.closeUrl;
54
+ }
55
+
56
+
57
+ });
58
+ // Our class singleton
59
+ Realex.getInstance = function () {
60
+ if (!this.instance) {
61
+ this.instance = new this();
62
+ }
63
+ return this.instance;
64
+ };
65
+
66
+ var ReviewRegister = Class.create(Realex,{
67
+ initialize: function () {
68
+ // Registers wrapper on DOM tree load event.
69
+ document.observe('dom:loaded', this.register.bind(this));
70
+ // Registers wrapper on AJAX calls, since review object can be overridden in it
71
+ Ajax.Responders.register(this);
72
+
73
+ },
74
+ osc: function () {
75
+ var t = 1;
76
+ },
77
+ register: function () {
78
+
79
+ if (!window.review || review.overriddenOnSave) {
80
+ // In case if review object is not yet available
81
+ // or wrapper was already applied
82
+ return this;
83
+ }
84
+
85
+ var method = window.payment.currentMethod;
86
+
87
+ if(['realexredirect','realexdirect','realvault'].indexOf(method) < 0){
88
+ return;
89
+ }
90
+ if(!realexConfig){
91
+ return;
92
+ }
93
+ var config = realexConfig[window.payment.currentMethod];
94
+
95
+ if(config == undefined){
96
+ return
97
+ }
98
+ if(config.iframe !== '1' || config.display !== '1' || config.secure !== '1'){
99
+ return;
100
+ }
101
+
102
+ review.overriddenOnSave = function (transport) {
103
+ try{
104
+ if (transport && transport.responseText) {
105
+ try {
106
+ response = eval('(' + transport.responseText + ')');
107
+ }
108
+ catch (e) {
109
+ response = {};
110
+ }
111
+ if (response.redirect) {
112
+ review.isSuccess = true;
113
+ Realex.getInstance().showModel(response.redirect,realexConfig.failUrl,realexConfig.iframeSize,config.deny);
114
+ return;
115
+ }
116
+ }
117
+
118
+ }
119
+ catch (e) { /* some error processing logic */ }
120
+ // Invokation original order save method
121
+ this.nextStep(transport);
122
+ }
123
+ // Replace original onSave with overridden one
124
+ review.onSave = review.overriddenOnSave.bind(review);
125
+ },
126
+ // This one is invoked when AJAX request gets completed
127
+ onComplete: function () {
128
+ this.register.defer();
129
+ }
130
+ });
131
+ // Invoke ReviewRegister class routines
132
+ var realex = new ReviewRegister();