activemerchant 1.43.3 → 1.44.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (326) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data.tar.gz.sig +0 -0
  4. data/CHANGELOG +133 -3
  5. data/CONTRIBUTORS +25 -0
  6. data/README.md +14 -39
  7. data/lib/active_merchant.rb +43 -2
  8. data/lib/active_merchant/billing.rb +3 -1
  9. data/lib/active_merchant/billing/base.rb +10 -2
  10. data/lib/active_merchant/billing/check.rb +29 -22
  11. data/lib/active_merchant/billing/compatibility.rb +120 -0
  12. data/lib/active_merchant/billing/credit_card.rb +129 -60
  13. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  14. data/lib/active_merchant/billing/credit_card_methods.rb +60 -43
  15. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  16. data/lib/active_merchant/billing/gateway.rb +46 -11
  17. data/lib/active_merchant/billing/gateways/adyen.rb +205 -0
  18. data/lib/active_merchant/billing/gateways/app55.rb +1 -9
  19. data/lib/active_merchant/billing/gateways/authorize_net.rb +7 -391
  20. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  21. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +20 -4
  22. data/lib/active_merchant/billing/gateways/balanced.rb +127 -367
  23. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/beanstream.rb +25 -6
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +3 -3
  26. data/lib/active_merchant/billing/gateways/blue_pay.rb +11 -3
  27. data/lib/active_merchant/billing/gateways/bogus.rb +1 -13
  28. data/lib/active_merchant/billing/gateways/borgun.rb +211 -0
  29. data/lib/active_merchant/billing/gateways/braintree_blue.rb +31 -13
  30. data/lib/active_merchant/billing/gateways/bridge_pay.rb +7 -0
  31. data/lib/active_merchant/billing/gateways/cashnet.rb +184 -0
  32. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  33. data/lib/active_merchant/billing/gateways/certo_direct.rb +3 -2
  34. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  35. data/lib/active_merchant/billing/gateways/conekta.rb +56 -81
  36. data/lib/active_merchant/billing/gateways/cyber_source.rb +1 -0
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +3 -1
  38. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  39. data/lib/active_merchant/billing/gateways/elavon.rb +45 -9
  40. data/lib/active_merchant/billing/gateways/epay.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/eway.rb +1 -12
  42. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  43. data/lib/active_merchant/billing/gateways/eway_rapid.rb +233 -202
  44. data/lib/active_merchant/billing/gateways/exact.rb +1 -1
  45. data/lib/active_merchant/billing/gateways/fat_zebra.rb +1 -1
  46. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  47. data/lib/active_merchant/billing/gateways/finansbank.rb +2 -1
  48. data/lib/active_merchant/billing/gateways/first_pay.rb +108 -124
  49. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +43 -13
  50. data/lib/active_merchant/billing/gateways/garanti.rb +2 -2
  51. data/lib/active_merchant/billing/gateways/hps.rb +281 -0
  52. data/lib/active_merchant/billing/gateways/iats_payments.rb +2 -2
  53. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +1 -4
  54. data/lib/active_merchant/billing/gateways/inspire.rb +0 -8
  55. data/lib/active_merchant/billing/gateways/iridium.rb +25 -3
  56. data/lib/active_merchant/billing/gateways/jetpay.rb +1 -1
  57. data/lib/active_merchant/billing/gateways/linkpoint.rb +4 -13
  58. data/lib/active_merchant/billing/gateways/litle.rb +10 -4
  59. data/lib/active_merchant/billing/gateways/maxipago.rb +7 -0
  60. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -6
  61. data/lib/active_merchant/billing/gateways/merchant_ware.rb +4 -11
  62. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +3 -10
  63. data/lib/active_merchant/billing/gateways/mercury.rb +0 -7
  64. data/lib/active_merchant/billing/gateways/metrics_global.rb +1 -20
  65. data/lib/active_merchant/billing/gateways/migs.rb +1 -1
  66. data/lib/active_merchant/billing/gateways/moneris.rb +29 -21
  67. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -11
  68. data/lib/active_merchant/billing/gateways/money_movers.rb +1 -8
  69. data/lib/active_merchant/billing/gateways/nab_transact.rb +16 -15
  70. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/netbilling.rb +0 -7
  72. data/lib/active_merchant/billing/gateways/network_merchants.rb +21 -18
  73. data/lib/active_merchant/billing/gateways/ogone.rb +3 -3
  74. data/lib/active_merchant/billing/gateways/openpay.rb +1 -8
  75. data/lib/active_merchant/billing/gateways/optimal_payment.rb +34 -23
  76. data/lib/active_merchant/billing/gateways/orbital.rb +121 -4
  77. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  78. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +2 -9
  79. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  80. data/lib/active_merchant/billing/gateways/pay_junction.rb +3 -13
  81. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  82. data/lib/active_merchant/billing/gateways/paybox_direct.rb +1 -9
  83. data/lib/active_merchant/billing/gateways/payex.rb +1 -1
  84. data/lib/active_merchant/billing/gateways/payflow.rb +7 -1
  85. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +15 -15
  86. data/lib/active_merchant/billing/gateways/payflow_express.rb +19 -19
  87. data/lib/active_merchant/billing/gateways/payment_express.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/paymill.rb +7 -2
  89. data/lib/active_merchant/billing/gateways/paypal.rb +25 -14
  90. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +16 -2
  92. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +3 -2
  93. data/lib/active_merchant/billing/gateways/paypal_express.rb +25 -0
  94. data/lib/active_merchant/billing/gateways/payscout.rb +1 -8
  95. data/lib/active_merchant/billing/gateways/pin.rb +39 -7
  96. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  97. data/lib/active_merchant/billing/gateways/psigate.rb +1 -12
  98. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  100. data/lib/active_merchant/billing/gateways/quickpay.rb +17 -15
  101. data/lib/active_merchant/billing/gateways/realex.rb +3 -12
  102. data/lib/active_merchant/billing/gateways/sage.rb +1 -1
  103. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +2 -8
  104. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +1 -1
  105. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +1 -1
  106. data/lib/active_merchant/billing/gateways/sage_pay.rb +93 -28
  107. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -8
  108. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +3 -3
  109. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  110. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -2
  111. data/lib/active_merchant/billing/gateways/smart_ps.rb +8 -2
  112. data/lib/active_merchant/billing/gateways/spreedly_core.rb +2 -1
  113. data/lib/active_merchant/billing/gateways/stripe.rb +14 -15
  114. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +0 -1
  115. data/lib/active_merchant/billing/gateways/trust_commerce.rb +4 -9
  116. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +46 -43
  117. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +7 -0
  118. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  119. data/lib/active_merchant/billing/gateways/viaklix.rb +0 -6
  120. data/lib/active_merchant/billing/gateways/vindicia.rb +68 -44
  121. data/lib/active_merchant/billing/gateways/webpay.rb +1 -9
  122. data/lib/active_merchant/billing/gateways/wirecard.rb +117 -11
  123. data/lib/active_merchant/billing/gateways/worldpay.rb +50 -22
  124. data/lib/active_merchant/billing/gateways/worldpay_us.rb +181 -0
  125. data/lib/active_merchant/billing/model.rb +30 -0
  126. data/lib/active_merchant/billing/rails.rb +3 -0
  127. data/lib/active_merchant/billing/response.rb +20 -15
  128. data/lib/active_merchant/country.rb +327 -0
  129. data/lib/active_merchant/empty.rb +20 -0
  130. data/lib/active_merchant/errors.rb +29 -0
  131. data/lib/active_merchant/offsite_payments_shim.rb +19 -0
  132. data/lib/active_merchant/version.rb +1 -1
  133. metadata +60 -243
  134. metadata.gz.sig +0 -0
  135. data/gem-public_cert.pem +0 -21
  136. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  137. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  138. data/lib/active_merchant/billing/gateways/orbital/cvv_result.rb +0 -34
  139. data/lib/active_merchant/billing/integrations.rb +0 -17
  140. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  141. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  142. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  143. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  144. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -78
  145. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  146. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  147. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  148. data/lib/active_merchant/billing/integrations/bit_pay.rb +0 -30
  149. data/lib/active_merchant/billing/integrations/bit_pay/helper.rb +0 -66
  150. data/lib/active_merchant/billing/integrations/bit_pay/notification.rb +0 -74
  151. data/lib/active_merchant/billing/integrations/bit_pay/return.rb +0 -10
  152. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  153. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  154. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  155. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  156. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  157. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  158. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  159. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  160. data/lib/active_merchant/billing/integrations/citrus.rb +0 -28
  161. data/lib/active_merchant/billing/integrations/citrus/helper.rb +0 -57
  162. data/lib/active_merchant/billing/integrations/citrus/notification.rb +0 -133
  163. data/lib/active_merchant/billing/integrations/citrus/return.rb +0 -40
  164. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  165. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  166. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  167. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  168. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  169. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  170. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  171. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  172. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  173. data/lib/active_merchant/billing/integrations/doku.rb +0 -24
  174. data/lib/active_merchant/billing/integrations/doku/helper.rb +0 -102
  175. data/lib/active_merchant/billing/integrations/doku/notification.rb +0 -69
  176. data/lib/active_merchant/billing/integrations/doku/return.rb +0 -10
  177. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  178. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  179. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  180. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  181. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  182. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  183. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  184. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  185. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  186. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  187. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  188. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  189. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  190. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  191. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  192. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  193. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  194. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  195. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  196. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  197. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  198. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  199. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  200. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  201. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  202. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  203. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  204. data/lib/active_merchant/billing/integrations/helper.rb +0 -123
  205. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  206. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  207. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  208. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  209. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -23
  210. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -118
  211. data/lib/active_merchant/billing/integrations/ipay88/notification.rb +0 -103
  212. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -29
  213. data/lib/active_merchant/billing/integrations/klarna.rb +0 -71
  214. data/lib/active_merchant/billing/integrations/klarna/helper.rb +0 -123
  215. data/lib/active_merchant/billing/integrations/klarna/notification.rb +0 -103
  216. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  217. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  218. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  219. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  220. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  221. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  222. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  223. data/lib/active_merchant/billing/integrations/mollie_ideal.rb +0 -98
  224. data/lib/active_merchant/billing/integrations/mollie_ideal/helper.rb +0 -67
  225. data/lib/active_merchant/billing/integrations/mollie_ideal/notification.rb +0 -69
  226. data/lib/active_merchant/billing/integrations/mollie_ideal/return.rb +0 -10
  227. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  228. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  229. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -123
  230. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  231. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  232. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  233. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  234. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  235. data/lib/active_merchant/billing/integrations/pag_seguro.rb +0 -53
  236. data/lib/active_merchant/billing/integrations/pag_seguro/helper.rb +0 -121
  237. data/lib/active_merchant/billing/integrations/pag_seguro/notification.rb +0 -104
  238. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  239. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  240. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  241. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  242. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  243. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  244. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  245. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  246. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  247. data/lib/active_merchant/billing/integrations/paydollar.rb +0 -59
  248. data/lib/active_merchant/billing/integrations/paydollar/helper.rb +0 -41
  249. data/lib/active_merchant/billing/integrations/paydollar/notification.rb +0 -64
  250. data/lib/active_merchant/billing/integrations/paydollar/return.rb +0 -15
  251. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  252. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  253. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  254. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  255. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  256. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  257. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  258. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  259. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  260. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  261. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  262. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -39
  263. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -36
  264. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -76
  265. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -154
  266. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  267. data/lib/active_merchant/billing/integrations/payu_in_paisa.rb +0 -30
  268. data/lib/active_merchant/billing/integrations/payu_in_paisa/helper.rb +0 -19
  269. data/lib/active_merchant/billing/integrations/payu_in_paisa/notification.rb +0 -13
  270. data/lib/active_merchant/billing/integrations/payu_in_paisa/return.rb +0 -16
  271. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  272. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  273. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  274. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  275. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -113
  276. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  277. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  278. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  279. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -96
  280. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  281. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  282. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  283. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  284. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  285. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  286. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  287. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  288. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  289. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  290. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  291. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  292. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  293. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  294. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  295. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  296. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -107
  297. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -171
  298. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -58
  299. data/lib/active_merchant/billing/integrations/universal.rb +0 -23
  300. data/lib/active_merchant/billing/integrations/universal/helper.rb +0 -76
  301. data/lib/active_merchant/billing/integrations/universal/notification.rb +0 -52
  302. data/lib/active_merchant/billing/integrations/universal/return.rb +0 -18
  303. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  304. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  305. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  306. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  307. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  308. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  309. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  310. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  311. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  312. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  313. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  314. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  315. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  316. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  317. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  318. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  319. data/lib/active_merchant/billing/integrations/wirecard_checkout_page.rb +0 -39
  320. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/common.rb +0 -104
  321. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/helper.rb +0 -145
  322. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/notification.rb +0 -101
  323. data/lib/active_merchant/billing/integrations/wirecard_checkout_page/return.rb +0 -35
  324. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  325. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  326. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
@@ -557,6 +557,7 @@ module ActiveMerchant #:nodoc:
557
557
  add_check(xml, payment_method_or_reference)
558
558
  else
559
559
  add_address(xml, payment_method_or_reference, options[:billing_address], options)
560
+ add_address(xml, payment_method_or_reference, options[:shipping_address], options, true)
560
561
  add_purchase_data(xml, money, true, options)
561
562
  add_creditcard(xml, payment_method_or_reference)
562
563
  end
@@ -1,3 +1,5 @@
1
+ require "active_support/core_ext/string/access"
2
+
1
3
  module ActiveMerchant
2
4
  module Billing
3
5
  class DataCashGateway < Gateway
@@ -138,7 +140,7 @@ module ActiveMerchant
138
140
  # * <tt>:address</tt>:: billing address for card
139
141
  def credit(money, reference_or_credit_card, options = {})
140
142
  if reference_or_credit_card.is_a?(String)
141
- deprecated CREDIT_DEPRECATION_MESSAGE
143
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
142
144
  refund(money, reference_or_credit_card)
143
145
  else
144
146
  request = build_refund_request(money, reference_or_credit_card, options)
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
36
36
 
37
37
  def credit(money, identification_or_credit_card, options = {})
38
38
  if identification_or_credit_card.is_a?(String)
39
- deprecated CREDIT_DEPRECATION_MESSAGE
39
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
40
40
  # Perform authorization reversal
41
41
  refund(money, identification_or_credit_card, options)
42
42
  else
@@ -54,7 +54,7 @@ module ActiveMerchant #:nodoc:
54
54
 
55
55
  def void(identification, options = {})
56
56
  requires!(options, :order_id)
57
- original_transaction_id, original_transaction_amount = identification.split(";")
57
+ original_transaction_id, _ = identification.split(";")
58
58
  commit(:void_transaction, {:reference_number => format_reference_number(options[:order_id]), :transaction_id => original_transaction_id})
59
59
  end
60
60
 
@@ -81,7 +81,7 @@ module ActiveMerchant #:nodoc:
81
81
 
82
82
  requires!(options, :order_id)
83
83
 
84
- post = {
84
+ {
85
85
  :reference_number => format_reference_number(options[:order_id]),
86
86
  :transaction_amount => amount(money),
87
87
  :original_transaction_amount => original_transaction_amount,
@@ -197,17 +197,6 @@ module ActiveMerchant #:nodoc:
197
197
  message.gsub(/[^\w]/, ' ').split.join(" ").capitalize
198
198
  end
199
199
 
200
- # Make a ruby type out of the response string
201
- def normalize(field)
202
- case field
203
- when "true" then true
204
- when "false" then false
205
- when "" then nil
206
- when "null" then nil
207
- else field
208
- end
209
- end
210
-
211
200
  def actions
212
201
  ACTIONS
213
202
  end
@@ -47,7 +47,9 @@ module ActiveMerchant #:nodoc:
47
47
  :refund => 'CCRETURN',
48
48
  :authorize => 'CCAUTHONLY',
49
49
  :capture => 'CCFORCE',
50
- :void => 'CCVOID'
50
+ :void => 'CCDELETE',
51
+ :store => 'CCGETTOKEN',
52
+ :update => 'CCUPDATETOKEN',
51
53
  }
52
54
 
53
55
  # Initialize the Gateway
@@ -67,11 +69,15 @@ module ActiveMerchant #:nodoc:
67
69
  end
68
70
 
69
71
  # Make a purchase
70
- def purchase(money, creditcard, options = {})
72
+ def purchase(money, payment_method, options = {})
71
73
  form = {}
72
74
  add_salestax(form, options)
73
75
  add_invoice(form, options)
74
- add_creditcard(form, creditcard)
76
+ if payment_method.is_a?(String)
77
+ add_token(form, payment_method)
78
+ else
79
+ add_creditcard(form, payment_method)
80
+ end
75
81
  add_address(form, options)
76
82
  add_customer_data(form, options)
77
83
  add_test_mode(form, options)
@@ -166,8 +172,36 @@ module ActiveMerchant #:nodoc:
166
172
  commit(:credit, money, form)
167
173
  end
168
174
 
175
+ def verify(credit_card, options = {})
176
+ MultiResponse.run(:use_first_response) do |r|
177
+ r.process { authorize(100, credit_card, options) }
178
+ r.process(:ignore_result) { void(r.authorization, options) }
179
+ end
180
+ end
181
+
182
+ def store(creditcard, options = {})
183
+ form = {}
184
+ add_creditcard(form, creditcard)
185
+ add_address(form, options)
186
+ add_customer_data(form, options)
187
+ add_test_mode(form, options)
188
+ add_verification(form, options)
189
+ form[:add_token] = 'Y'
190
+ commit(:store, nil, form)
191
+ end
192
+
193
+ def update(token, creditcard, options = {})
194
+ form = {}
195
+ add_token(form, token)
196
+ add_creditcard(form, creditcard)
197
+ add_address(form, options)
198
+ add_customer_data(form, options)
199
+ add_test_mode(form, options)
200
+ commit(:update, nil, form)
201
+ end
169
202
 
170
203
  private
204
+
171
205
  def add_invoice(form,options)
172
206
  form[:invoice_number] = (options[:order_id] || options[:invoice]).to_s.slice(0, 10)
173
207
  form[:description] = options[:description].to_s.slice(0, 255)
@@ -197,6 +231,10 @@ module ActiveMerchant #:nodoc:
197
231
  form[:last_name] = creditcard.last_name.to_s.slice(0, 30)
198
232
  end
199
233
 
234
+ def add_token(form, token)
235
+ form[:token] = token
236
+ end
237
+
200
238
  def add_verification_value(form, creditcard)
201
239
  form[:cvv2cvc2] = creditcard.verification_value
202
240
  form[:cvv2cvc2_indicator] = '1'
@@ -211,12 +249,6 @@ module ActiveMerchant #:nodoc:
211
249
  form[:salestax] = options[:tax] if options[:tax].present?
212
250
  end
213
251
 
214
- def expdate(creditcard)
215
- year = sprintf("%.4i", creditcard.year)
216
- month = sprintf("%.2i", creditcard.month)
217
- "#{month}#{year[2..3]}"
218
- end
219
-
220
252
  def add_address(form,options)
221
253
  billing_address = options[:billing_address] || options[:address]
222
254
 
@@ -245,6 +277,10 @@ module ActiveMerchant #:nodoc:
245
277
  end
246
278
  end
247
279
 
280
+ def add_verification(form, options)
281
+ form[:verify] = 'Y' if options[:verify]
282
+ end
283
+
248
284
  def parse_first_and_last_name(value)
249
285
  name = value.to_s.split(' ')
250
286
 
@@ -106,7 +106,7 @@ module ActiveMerchant #:nodoc:
106
106
  end
107
107
 
108
108
  def credit(money, identification, options = {})
109
- deprecated CREDIT_DEPRECATION_MESSAGE
109
+ ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
110
110
  refund(money, identification, options)
111
111
  end
112
112
 
@@ -268,7 +268,7 @@ module ActiveMerchant #:nodoc:
268
268
 
269
269
  # Limited to 20 digits max
270
270
  def format_order_number(number)
271
- number.to_s.gsub(/[^\w_]/, '').rjust(4, "0")[0...20]
271
+ number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20]
272
272
  end
273
273
  end
274
274
  end
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  self.live_url = 'https://www.eway.com.au'
9
9
 
10
10
  self.money_format = :cents
11
- self.supported_countries = ['AU', 'NZ', 'GB']
11
+ self.supported_countries = ['AU']
12
12
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
13
13
  self.homepage_url = 'http://www.eway.com.au/'
14
14
  self.display_name = 'eWAY'
@@ -136,17 +136,6 @@ module ActiveMerchant #:nodoc:
136
136
  MESSAGES[message[0,2]] || message
137
137
  end
138
138
 
139
- # Make a ruby type out of the response string
140
- def normalize(field)
141
- case field
142
- when "true" then true
143
- when "false" then false
144
- when "" then nil
145
- when "null" then nil
146
- else field
147
- end
148
- end
149
-
150
139
  def purchase_url(cvn)
151
140
  suffix = test? ? 'xmltest/testpage.asp' : 'xmlpayment.asp'
152
141
  gateway_part = cvn ? 'gateway_cvn' : 'gateway'
@@ -150,7 +150,7 @@ module ActiveMerchant #:nodoc:
150
150
  def parse(body)
151
151
  reply = {}
152
152
  xml = REXML::Document.new(body)
153
- if root = REXML::XPath.first(xml, "//soap:Fault") then
153
+ if root = REXML::XPath.first(xml, "//soap:Fault") then
154
154
  reply=parse_fault(root)
155
155
  else
156
156
  if root = REXML::XPath.first(xml, '//ProcessPaymentResponse/ewayResponse') then
@@ -1,5 +1,4 @@
1
- require "nokogiri"
2
- require "cgi"
1
+ require 'json'
3
2
 
4
3
  module ActiveMerchant #:nodoc:
5
4
  module Billing #:nodoc:
@@ -8,10 +7,10 @@ module ActiveMerchant #:nodoc:
8
7
  self.live_url = "https://api.ewaypayments.com/"
9
8
 
10
9
  self.money_format = :cents
11
- self.supported_countries = ["AU"]
10
+ self.supported_countries = ['AU', 'NZ', 'GB']
12
11
  self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
13
12
  self.homepage_url = "http://www.eway.com.au/"
14
- self.display_name = "eWAY Rapid 3.0"
13
+ self.display_name = "eWAY Rapid 3.1"
15
14
  self.default_currency = "AUD"
16
15
 
17
16
  def initialize(options = {})
@@ -19,203 +18,240 @@ module ActiveMerchant #:nodoc:
19
18
  super
20
19
  end
21
20
 
22
- # Public: Run a purchase transaction. Treats the Rapid 3.0 transparent
23
- # redirect as an API endpoint in order to conform to the standard
24
- # ActiveMerchant #purchase API.
21
+ # Public: Run a purchase transaction.
25
22
  #
26
- # amount - The monetary amount of the transaction in cents.
27
- # options - A standard ActiveMerchant options hash:
28
- # :order_id - A merchant-supplied identifier for the
29
- # transaction (optional).
30
- # :description - A merchant-supplied description of the
31
- # transaction (optional).
32
- # :currency - Three letter currency code for the
33
- # transaction (default: "AUD")
34
- # :billing_address - Standard ActiveMerchant address hash
35
- # (optional).
36
- # :shipping_address - Standard ActiveMerchant address hash
37
- # (optional).
38
- # :ip - The ip of the consumer initiating the
39
- # transaction (optional).
40
- # :application_id - A string identifying the application
41
- # submitting the transaction
42
- # (default: "https://github.com/Shopify/active_merchant")
23
+ # amount - The monetary amount of the transaction in cents.
24
+ # payment_method - The payment method or authorization token returned from store.
25
+ # options - A standard ActiveMerchant options hash:
26
+ # :transaction_type - One of: Purchase (default), MOTO
27
+ # or Recurring. For stored card payments (aka - TokenPayments),
28
+ # this must be either MOTO or Recurring.
29
+ # :order_id - A merchant-supplied identifier for the
30
+ # transaction (optional).
31
+ # :description - A merchant-supplied description of the
32
+ # transaction (optional).
33
+ # :currency - Three letter currency code for the
34
+ # transaction (default: "AUD")
35
+ # :billing_address - Standard ActiveMerchant address hash
36
+ # (optional).
37
+ # :shipping_address - Standard ActiveMerchant address hash
38
+ # (optional).
39
+ # :ip - The ip of the consumer initiating the
40
+ # transaction (optional).
41
+ # :application_id - A string identifying the application
42
+ # submitting the transaction
43
+ # (default: "https://github.com/Shopify/active_merchant")
43
44
  #
44
- # Returns an ActiveMerchant::Billing::Response object
45
+ # Returns an ActiveMerchant::Billing::Response object where authorization is the Transaction ID on success
45
46
  def purchase(amount, payment_method, options={})
46
- MultiResponse.new.tap do |r|
47
- # Rather than follow the redirect, we detect the 302 and capture the
48
- # token out of the Location header in the run_purchase step. But we
49
- # still need a placeholder url to pass to eWay, and that is what
50
- # example.com is used for here.
51
- r.process{setup_purchase(amount, options.merge(:redirect_url => "http://example.com/"))}
52
- r.process{run_purchase(r.authorization, payment_method, r.params["formactionurl"])}
53
- r.process{status(r.authorization)}
54
- end
47
+ params = {}
48
+ add_metadata(params, options)
49
+ add_invoice(params, amount, options)
50
+ add_customer_data(params, options)
51
+ add_credit_card(params, payment_method, options)
52
+ commit(url_for('Transaction'), params)
55
53
  end
56
54
 
57
- # Public: Acquire the token necessary to run a transparent redirect.
58
- #
59
- # amount - The monetary amount of the transaction in cents.
60
- # options - A supplemented ActiveMerchant options hash:
61
- # :redirect_url - The url to return the customer to after
62
- # the transparent redirect is completed
63
- # (required).
64
- # :order_id - A merchant-supplied identifier for the
65
- # transaction (optional).
66
- # :description - A merchant-supplied description of the
67
- # transaction (optional).
68
- # :currency - Three letter currency code for the
69
- # transaction (default: "AUD")
70
- # :billing_address - Standard ActiveMerchant address hash
71
- # (optional).
72
- # :shipping_address - Standard ActiveMerchant address hash
73
- # (optional).
74
- # :ip - The ip of the consumer initiating the
75
- # transaction (optional).
76
- # :application_id - A string identifying the application
77
- # submitting the transaction
78
- # (default: "https://github.com/Shopify/active_merchant")
79
- #
80
- # Returns an EwayRapidResponse object, which conforms to the
81
- # ActiveMerchant::Billing::Response API, but also exposes #form_url.
82
- def setup_purchase(amount, options={})
83
- requires!(options, :redirect_url)
84
- request = build_xml_request("CreateAccessCodeRequest") do |doc|
85
- add_metadata(doc, options)
86
- add_invoice(doc, amount, options)
87
- add_customer_data(doc, options)
88
- end
55
+ def authorize(amount, payment_method, options={})
56
+ params = {}
57
+ add_metadata(params, options)
58
+ add_invoice(params, amount, options)
59
+ add_customer_data(params, options)
60
+ add_credit_card(params, payment_method, options)
61
+ commit(url_for('Authorisation'), params)
62
+ end
63
+
64
+ def capture(amount, identification, options = {})
65
+ params = {}
66
+ add_metadata(params, options)
67
+ add_invoice(params, amount, options)
68
+ add_reference(params, identification)
69
+ commit(url_for("CapturePayment"), params)
70
+ end
89
71
 
90
- commit(url_for("CreateAccessCode"), request)
72
+ def void(identification, options = {})
73
+ params = {}
74
+ add_reference(params, identification)
75
+ commit(url_for("CancelAuthorisation"), params)
91
76
  end
92
77
 
93
- # Public: Retrieve the status of a transaction.
78
+ # Public: Refund a transaction.
94
79
  #
95
- # identification - The Eway Rapid 3.0 access code for the transaction
96
- # (returned as the response.authorization by
97
- # #setup_purchase).
80
+ # amount - The monetary amount of the transaction in cents
81
+ # identification - The transaction id which is returned in the
82
+ # authorization of the successful purchase transaction
83
+ # options - A standard ActiveMerchant options hash:
84
+ # :order_id - A merchant-supplied identifier for the
85
+ # transaction (optional).
86
+ # :description - A merchant-supplied description of the
87
+ # transaction (optional).
88
+ # :currency - Three letter currency code for the
89
+ # transaction (default: "AUD")
90
+ # :billing_address - Standard ActiveMerchant address hash
91
+ # (optional).
92
+ # :shipping_address - Standard ActiveMerchant address hash
93
+ # (optional).
94
+ # :ip - The ip of the consumer initiating the
95
+ # transaction (optional).
96
+ # :application_id - A string identifying the application
97
+ # submitting the transaction
98
+ # (default: "https://github.com/Shopify/active_merchant")
98
99
  #
99
- # Returns an EwayRapidResponse object.
100
- def status(identification)
101
- request = build_xml_request("GetAccessCodeResultRequest") do |doc|
102
- doc.AccessCode identification
103
- end
104
- commit(url_for("GetAccessCodeResult"), request)
100
+ # Returns an ActiveMerchant::Billing::Response object
101
+ def refund(amount, identification, options = {})
102
+ params = {}
103
+ add_metadata(params, options)
104
+ add_invoice(params, amount, options, "Refund")
105
+ add_reference(params["Refund"], identification)
106
+ add_customer_data(params, options)
107
+ commit(url_for("Transaction/#{identification}/Refund"), params)
105
108
  end
106
109
 
107
110
  # Public: Store card details and return a valid token
108
111
  #
109
- # options - A supplemented ActiveMerchant options hash:
110
- # :order_id - A merchant-supplied identifier for the
111
- # transaction (optional).
112
- # :billing_address - Standard ActiveMerchant address hash
113
- # (required).
114
- # :ip - The ip of the consumer initiating the
115
- # transaction (optional).
116
- # :application_id - A string identifying the application
117
- # submitting the transaction
118
- # (default: "https://github.com/Shopify/active_merchant")
112
+ # payment_method - The payment method or nil if :customer_token is provided
113
+ # options - A supplemented ActiveMerchant options hash:
114
+ # :order_id - A merchant-supplied identifier for the
115
+ # transaction (optional).
116
+ # :description - A merchant-supplied description of the
117
+ # transaction (optional).
118
+ # :billing_address - Standard ActiveMerchant address hash
119
+ # (required).
120
+ # :ip - The ip of the consumer initiating the
121
+ # transaction (optional).
122
+ # :application_id - A string identifying the application
123
+ # submitting the transaction
124
+ # (default: "https://github.com/Shopify/active_merchant")
125
+ #
126
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
119
127
  def store(payment_method, options = {})
120
128
  requires!(options, :billing_address)
121
- purchase(0, payment_method, options.merge(:request_method => "CreateTokenCustomer"))
129
+ params = {}
130
+ add_metadata(params, options)
131
+ add_invoice(params, 0, options)
132
+ add_customer_data(params, options)
133
+ add_credit_card(params, payment_method, options)
134
+ params['Method'] = 'CreateTokenCustomer'
135
+ commit(url_for("Transaction"), params)
122
136
  end
123
137
 
124
- private
138
+ # Public: Update a customer's data
139
+ #
140
+ # customer_token - The customer token returned in the authorization of
141
+ # a successful store transaction.
142
+ # payment_method - The payment method or nil if :customer_token is provided
143
+ # options - A supplemented ActiveMerchant options hash:
144
+ # :order_id - A merchant-supplied identifier for the
145
+ # transaction (optional).
146
+ # :description - A merchant-supplied description of the
147
+ # transaction (optional).
148
+ # :billing_address - Standard ActiveMerchant address hash
149
+ # (optional).
150
+ # :ip - The ip of the consumer initiating the
151
+ # transaction (optional).
152
+ # :application_id - A string identifying the application
153
+ # submitting the transaction
154
+ # (default: "https://github.com/Shopify/active_merchant")
155
+ #
156
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
157
+ def update(customer_token, payment_method, options = {})
158
+ params = {}
159
+ add_metadata(params, options)
160
+ add_invoice(params, 0, options)
161
+ add_customer_data(params, options)
162
+ add_credit_card(params, payment_method, options)
163
+ add_customer_token(params, customer_token)
164
+ params['Method'] = 'UpdateTokenCustomer'
165
+ commit(url_for("Transaction"), params)
166
+ end
125
167
 
126
- def run_purchase(identification, payment_method, endpoint)
127
- post = {
128
- "accesscode" => identification
129
- }
130
- add_credit_card(post, payment_method)
168
+ private
131
169
 
132
- commit_form(endpoint, build_form_request(post), :identification => identification)
170
+ def add_metadata(params, options)
171
+ params['RedirectUrl'] = options[:redirect_url] || 'http://example.com'
172
+ params['CustomerIP'] = options[:ip] if options[:ip]
173
+ params['TransactionType'] = options[:transaction_type] || 'Purchase'
174
+ params['DeviceID'] = options[:application_id] || application_id
133
175
  end
134
176
 
135
- def add_metadata(doc, options)
136
- doc.RedirectUrl(options[:redirect_url])
137
- doc.CustomerIP options[:ip] if options[:ip]
138
- doc.Method options[:request_method] || "ProcessPayment"
139
- doc.DeviceID(options[:application_id] || application_id)
177
+ def add_invoice(params, money, options, key = "Payment")
178
+ currency_code = options[:currency] || currency(money)
179
+ params[key] = {
180
+ 'TotalAmount' => localized_amount(money, currency_code),
181
+ 'InvoiceReference' => truncate(options[:order_id]),
182
+ 'InvoiceDescription' => truncate(options[:description], 64),
183
+ 'CurrencyCode' => currency_code,
184
+ }
140
185
  end
141
186
 
142
- def add_invoice(doc, money, options)
143
- doc.Payment do
144
- currency_code = options[:currency] || currency(money)
145
- doc.TotalAmount localized_amount(money, currency_code)
146
- doc.InvoiceReference options[:order_id]
147
- doc.InvoiceDescription options[:description]
148
- doc.CurrencyCode currency_code
149
- end
187
+ def add_reference(params, reference)
188
+ params['TransactionID'] = reference
150
189
  end
151
190
 
152
- def add_customer_data(doc, options)
153
- doc.Customer do
154
- add_address(doc, (options[:billing_address] || options[:address]), {:email => options[:email]})
155
- end
156
- doc.ShippingAddress do
157
- add_address(doc, options[:shipping_address], {:skip_company => true})
158
- end
191
+ def add_customer_data(params, options)
192
+ params['Customer'] ||= {}
193
+ add_address(params['Customer'], (options[:billing_address] || options[:address]), {:email => options[:email]})
194
+ params['ShippingAddress'] = {}
195
+ add_address(params['ShippingAddress'], options[:shipping_address], {:skip_company => true})
159
196
  end
160
197
 
161
- def add_address(doc, address, options={})
198
+ def add_address(params, address, options={})
162
199
  return unless address
163
- if name = address[:name]
164
- parts = name.split(/\s+/)
165
- doc.FirstName parts.shift if parts.size > 1
166
- doc.LastName parts.join(" ")
167
- end
168
- doc.Title address[:title]
169
- doc.CompanyName address[:company] unless options[:skip_company]
170
- doc.Street1 address[:address1]
171
- doc.Street2 address[:address2]
172
- doc.City address[:city]
173
- doc.State address[:state]
174
- doc.PostalCode address[:zip]
175
- doc.Country address[:country].to_s.downcase
176
- doc.Phone address[:phone]
177
- doc.Fax address[:fax]
178
- doc.Email options[:email]
179
- end
180
200
 
181
- def add_credit_card(post, credit_card)
182
- post["cardname"] = credit_card.name
183
- post["cardnumber"] = credit_card.number
184
- post["cardexpirymonth"] = credit_card.month
185
- post["cardexpiryyear"] = credit_card.year
186
- post["cardcvn"] = credit_card.verification_value
201
+ if address[:name]
202
+ parts = address[:name].split(/\s+/)
203
+ params['FirstName'] = parts.shift if parts.size > 1
204
+ params['LastName'] = parts.join(" ")
205
+ end
206
+ params['Title'] = address[:title]
207
+ params['CompanyName'] = address[:company] unless options[:skip_company]
208
+ params['Street1'] = truncate(address[:address1])
209
+ params['Street2'] = truncate(address[:address2])
210
+ params['City'] = truncate(address[:city])
211
+ params['State'] = address[:state]
212
+ params['PostalCode'] = address[:zip]
213
+ params['Country'] = address[:country].to_s.downcase
214
+ params['Phone'] = address[:phone]
215
+ params['Fax'] = address[:fax]
216
+ params['Email'] = options[:email]
187
217
  end
188
218
 
189
- def build_xml_request(root)
190
- builder = Nokogiri::XML::Builder.new
191
- builder.__send__(root) do |doc|
192
- yield(doc)
219
+ def add_credit_card(params, credit_card, options)
220
+ return unless credit_card
221
+ params['Customer'] ||= {}
222
+ if credit_card.respond_to? :number
223
+ params['Method'] = 'ProcessPayment'
224
+ card_details = params['Customer']['CardDetails'] = {}
225
+ card_details['Name'] = truncate(credit_card.name)
226
+ card_details['Number'] = credit_card.number
227
+ card_details['ExpiryMonth'] = "%02d" % (credit_card.month || 0)
228
+ card_details['ExpiryYear'] = "%02d" % (credit_card.year || 0)
229
+ card_details['CVN'] = credit_card.verification_value
230
+ else
231
+ params['Method'] = 'TokenPayment'
232
+ add_customer_token(params, credit_card)
193
233
  end
194
- builder.to_xml
195
234
  end
196
235
 
197
- def build_form_request(post)
198
- request = []
199
- post.each do |key, value|
200
- request << "EWAY_#{key.upcase}=#{CGI.escape(value.to_s)}"
201
- end
202
- request.join("&")
236
+ def add_customer_token(params, token)
237
+ params['Customer'] ||= {}
238
+ params['Customer']['TokenCustomerID'] = token
203
239
  end
204
240
 
205
241
  def url_for(action)
206
- (test? ? test_url : live_url) + action + ".xml"
242
+ (test? ? test_url : live_url) + action
207
243
  end
208
244
 
209
- def commit(url, request, form_post=false)
245
+ def commit(url, params)
210
246
  headers = {
211
247
  "Authorization" => ("Basic " + Base64.strict_encode64(@options[:login].to_s + ":" + @options[:password].to_s).chomp),
212
- "Content-Type" => "text/xml"
248
+ "Content-Type" => "application/json"
213
249
  }
214
-
250
+ request = params.to_json
215
251
  raw = parse(ssl_post(url, request, headers))
216
252
 
217
253
  succeeded = success?(raw)
218
- EwayRapidResponse.new(
254
+ ActiveMerchant::Billing::Response.new(
219
255
  succeeded,
220
256
  message_from(succeeded, raw),
221
257
  raw,
@@ -225,56 +261,32 @@ module ActiveMerchant #:nodoc:
225
261
  :cvv_result => cvv_result_from(raw)
226
262
  )
227
263
  rescue ActiveMerchant::ResponseError => e
228
- return EwayRapidResponse.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
229
- end
230
-
231
- def commit_form(url, request, parameters)
232
- http_response = raw_ssl_request(:post, url, request)
233
-
234
- success = (http_response.code.to_s == "302")
235
- message = (success ? "Succeeded" : http_response.body)
236
- authorization = parameters[:identification] if success
237
-
238
- Response.new(success, message, {:location => http_response["Location"]}, :authorization => authorization, :test => test?)
264
+ return ActiveMerchant::Billing::Response.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
239
265
  end
240
266
 
241
- def parse(xml)
242
- response = {}
243
-
244
- doc = Nokogiri::XML(xml)
245
- doc.root.xpath("*").each do |node|
246
- if (node.elements.size == 0)
247
- response[node.name.downcase.to_sym] = node.text
248
- else
249
- node.elements.each do |childnode|
250
- name = "#{node.name.downcase}_#{childnode.name.downcase}"
251
- response[name.to_sym] = childnode.text
252
- end
253
- end
254
- end unless doc.root.nil?
255
-
256
- response
267
+ def parse(data)
268
+ JSON.parse(data)
257
269
  end
258
270
 
259
271
  def success?(response)
260
- if response[:errors]
261
- false
262
- elsif response[:responsecode] == "00"
272
+ if response['ResponseCode'] == "00"
263
273
  true
264
- elsif response[:transactionstatus]
265
- (response[:transactionstatus] == "true")
274
+ elsif response['TransactionStatus']
275
+ (response['TransactionStatus'] == true)
276
+ elsif response["Succeeded"]
277
+ (response["Succeeded"] == true)
266
278
  else
267
- true
279
+ false
268
280
  end
269
281
  end
270
282
 
271
283
  def message_from(succeeded, response)
272
- if response[:errors]
273
- (MESSAGES[response[:errors]] || response[:errors])
274
- elsif response[:responsecode]
275
- ActiveMerchant::Billing::EwayGateway::MESSAGES[response[:responsecode]]
276
- elsif response[:responsemessage]
277
- (MESSAGES[response[:responsemessage]] || response[:responsemessage])
284
+ if response['Errors']
285
+ (MESSAGES[response['Errors']] || response['Errors'])
286
+ elsif response['Responsecode']
287
+ ActiveMerchant::Billing::EwayGateway::MESSAGES[response['ResponseCode']]
288
+ elsif response['ResponseMessage']
289
+ (MESSAGES[response['ResponseMessage']] || response['ResponseMessage'])
278
290
  elsif succeeded
279
291
  "Succeeded"
280
292
  else
@@ -283,11 +295,14 @@ module ActiveMerchant #:nodoc:
283
295
  end
284
296
 
285
297
  def authorization_from(response)
286
- response[:accesscode]
298
+ # Note: TransactionID is always null for store requests, but TokenCustomerID is also sent back for purchase from
299
+ # stored card transactions so we give precendence to TransactionID
300
+ response['TransactionID'] || response['Customer']['TokenCustomerID']
287
301
  end
288
302
 
289
303
  def avs_result_from(response)
290
- code = case response[:verification_address]
304
+ verification = response['Verification'] || {}
305
+ code = case verification['Address']
291
306
  when "Valid"
292
307
  "M"
293
308
  when "Invalid"
@@ -299,7 +314,8 @@ module ActiveMerchant #:nodoc:
299
314
  end
300
315
 
301
316
  def cvv_result_from(response)
302
- case response[:verification_cvn]
317
+ verification = response['Verification'] || {}
318
+ case verification['CVN']
303
319
  when "Valid"
304
320
  "M"
305
321
  when "Invalid"
@@ -309,16 +325,30 @@ module ActiveMerchant #:nodoc:
309
325
  end
310
326
  end
311
327
 
312
- class EwayRapidResponse < ActiveMerchant::Billing::Response
313
- def form_url
314
- params["formactionurl"]
315
- end
328
+ def truncate(value, max_size = 50)
329
+ return nil unless value
330
+ value.to_s[0, max_size]
316
331
  end
317
332
 
318
333
  MESSAGES = {
334
+ 'A2000' => 'Transaction Approved Successful',
335
+ 'A2008' => 'Honour With Identification Successful',
336
+ 'A2010' => 'Approved For Partial Amount Successful',
337
+ 'A2011' => 'Approved, VIP Successful',
338
+ 'A2016' => 'Approved, Update Track 3 Successful',
339
+ 'S5000' => 'System Error',
340
+ 'S5085' => 'Started 3dSecure',
341
+ 'S5086' => 'Routed 3dSecure',
342
+ 'S5087' => 'Completed 3dSecure',
343
+ 'S5088' => 'PayPal Transaction Created',
344
+ 'S5099' => 'Incomplete (Access Code in progress/incomplete)',
345
+ 'S5010' => 'Unknown error returned by gateway',
319
346
  'V6000' => 'Validation error',
320
347
  'V6001' => 'Invalid CustomerIP',
321
348
  'V6002' => 'Invalid DeviceID',
349
+ 'V6003' => 'Invalid Request PartnerID',
350
+ 'V6004' => 'Invalid Request Method',
351
+ 'V6010' => 'Invalid TransactionType, account not certified for eCome only MOTO or Recurring available',
322
352
  'V6011' => 'Invalid Payment TotalAmount',
323
353
  'V6012' => 'Invalid Payment InvoiceDescription',
324
354
  'V6013' => 'Invalid Payment InvoiceNumber',
@@ -385,7 +415,8 @@ module ActiveMerchant #:nodoc:
385
415
  'V6107' => 'Invalid EWAY_ACCESSCODE',
386
416
  'V6108' => 'Invalid CustomerHostAddress',
387
417
  'V6109' => 'Invalid UserAgent',
388
- 'V6110' => 'Invalid EWAY_CARDNUMBER'
418
+ 'V6110' => 'Invalid EWAY_CARDNUMBER',
419
+ 'V6111' => 'Unauthorised API Access, Account Not PCI Certified'
389
420
  }
390
421
  end
391
422
  end