activemerchant 1.38.0 → 1.79.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (400) hide show
  1. checksums.yaml +7 -0
  2. data/CHANGELOG +1402 -3
  3. data/CONTRIBUTORS +154 -0
  4. data/README.md +157 -144
  5. data/lib/active_merchant/billing/apple_pay_payment_token.rb +22 -0
  6. data/lib/active_merchant/billing/base.rb +21 -17
  7. data/lib/active_merchant/billing/check.rb +32 -22
  8. data/lib/active_merchant/billing/compatibility.rb +120 -0
  9. data/lib/active_merchant/billing/credit_card.rb +215 -67
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -1
  11. data/lib/active_merchant/billing/credit_card_methods.rb +152 -53
  12. data/lib/active_merchant/billing/cvv_result.rb +15 -15
  13. data/lib/active_merchant/billing/gateway.rb +170 -24
  14. data/lib/active_merchant/billing/gateways/adyen.rb +299 -0
  15. data/lib/active_merchant/billing/gateways/allied_wallet.rb +206 -0
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +904 -606
  17. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +417 -0
  18. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +43 -18
  19. data/lib/active_merchant/billing/gateways/axcessms.rb +181 -0
  20. data/lib/active_merchant/billing/gateways/balanced.rb +134 -346
  21. data/lib/active_merchant/billing/gateways/bank_frick.rb +225 -0
  22. data/lib/active_merchant/billing/gateways/banwire.rb +13 -2
  23. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +326 -0
  24. data/lib/active_merchant/billing/gateways/be2bill.rb +131 -0
  25. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +96 -15
  26. data/lib/active_merchant/billing/gateways/beanstream.rb +52 -9
  27. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +12 -8
  28. data/lib/active_merchant/billing/gateways/blue_pay.rb +520 -501
  29. data/lib/active_merchant/billing/gateways/blue_snap.rb +343 -0
  30. data/lib/active_merchant/billing/gateways/bogus.rb +94 -50
  31. data/lib/active_merchant/billing/gateways/borgun.rb +221 -0
  32. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  33. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +15 -2
  34. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -139
  36. data/lib/active_merchant/billing/gateways/braintree_orange.rb +4 -4
  37. data/lib/active_merchant/billing/gateways/bridge_pay.rb +245 -0
  38. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  39. data/lib/active_merchant/billing/gateways/card_connect.rb +286 -0
  40. data/lib/active_merchant/billing/gateways/card_stream.rb +269 -118
  41. data/lib/active_merchant/billing/gateways/cardknox.rb +328 -0
  42. data/lib/active_merchant/billing/gateways/cardprocess.rb +254 -0
  43. data/lib/active_merchant/billing/gateways/cashnet.rb +219 -0
  44. data/lib/active_merchant/billing/gateways/cc5.rb +45 -0
  45. data/lib/active_merchant/billing/gateways/cecabank.rb +239 -0
  46. data/lib/active_merchant/billing/gateways/cenpos.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/checkout.rb +214 -0
  48. data/lib/active_merchant/billing/gateways/checkout_v2.rb +233 -0
  49. data/lib/active_merchant/billing/gateways/citrus_pay.rb +23 -0
  50. data/lib/active_merchant/billing/gateways/clearhaus.rb +220 -0
  51. data/lib/active_merchant/billing/gateways/commercegate.rb +143 -0
  52. data/lib/active_merchant/billing/gateways/conekta.rb +225 -0
  53. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  54. data/lib/active_merchant/billing/gateways/credorax.rb +345 -0
  55. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  56. data/lib/active_merchant/billing/gateways/cyber_source.rb +237 -98
  57. data/lib/active_merchant/billing/gateways/data_cash.rb +41 -314
  58. data/lib/active_merchant/billing/gateways/dibs.rb +205 -0
  59. data/lib/active_merchant/billing/gateways/digitzs.rb +292 -0
  60. data/lib/active_merchant/billing/gateways/ebanx.rb +296 -0
  61. data/lib/active_merchant/billing/gateways/efsnet.rb +3 -14
  62. data/lib/active_merchant/billing/gateways/elavon.rb +143 -142
  63. data/lib/active_merchant/billing/gateways/element.rb +356 -0
  64. data/lib/active_merchant/billing/gateways/epay.rb +23 -12
  65. data/lib/active_merchant/billing/gateways/eway.rb +12 -12
  66. data/lib/active_merchant/billing/gateways/eway_managed.rb +1 -1
  67. data/lib/active_merchant/billing/gateways/eway_rapid.rb +417 -204
  68. data/lib/active_merchant/billing/gateways/exact.rb +10 -1
  69. data/lib/active_merchant/billing/gateways/ezic.rb +196 -0
  70. data/lib/active_merchant/billing/gateways/fat_zebra.rb +65 -37
  71. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -8
  72. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -2
  73. data/lib/active_merchant/billing/gateways/first_giving.rb +143 -0
  74. data/lib/active_merchant/billing/gateways/first_pay.rb +110 -124
  75. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +155 -29
  76. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  77. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  78. data/lib/active_merchant/billing/gateways/forte.rb +256 -0
  79. data/lib/active_merchant/billing/gateways/garanti.rb +11 -5
  80. data/lib/active_merchant/billing/gateways/global_collect.rb +334 -0
  81. data/lib/active_merchant/billing/gateways/global_transport.rb +194 -0
  82. data/lib/active_merchant/billing/gateways/hps.rb +305 -0
  83. data/lib/active_merchant/billing/gateways/iats_payments.rb +271 -16
  84. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +2 -5
  85. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -0
  86. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  88. data/lib/active_merchant/billing/gateways/inspire.rb +8 -10
  89. data/lib/active_merchant/billing/gateways/instapay.rb +0 -0
  90. data/lib/active_merchant/billing/gateways/ipp.rb +175 -0
  91. data/lib/active_merchant/billing/gateways/iridium.rb +210 -4
  92. data/lib/active_merchant/billing/gateways/iveri.rb +251 -0
  93. data/lib/active_merchant/billing/gateways/jetpay.rb +176 -49
  94. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +437 -0
  95. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  96. data/lib/active_merchant/billing/gateways/kushki.rb +227 -0
  97. data/lib/active_merchant/billing/gateways/latitude19.rb +416 -0
  98. data/lib/active_merchant/billing/gateways/linkpoint.rb +17 -13
  99. data/lib/active_merchant/billing/gateways/litle.rb +329 -439
  100. data/lib/active_merchant/billing/gateways/mastercard.rb +268 -0
  101. data/lib/active_merchant/billing/gateways/maxipago.rb +220 -0
  102. data/lib/active_merchant/billing/gateways/mercado_pago.rb +262 -0
  103. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +26 -7
  104. data/lib/active_merchant/billing/gateways/merchant_one.rb +0 -1
  105. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  106. data/lib/active_merchant/billing/gateways/merchant_ware.rb +12 -15
  107. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +24 -13
  108. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +33 -14
  109. data/lib/active_merchant/billing/gateways/mercury.rb +74 -29
  110. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -21
  111. data/lib/active_merchant/billing/gateways/micropayment.rb +185 -0
  112. data/lib/active_merchant/billing/gateways/migs.rb +73 -14
  113. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -1
  114. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +1 -3
  115. data/lib/active_merchant/billing/gateways/monei.rb +307 -0
  116. data/lib/active_merchant/billing/gateways/moneris.rb +119 -36
  117. data/lib/active_merchant/billing/gateways/moneris_us.rb +146 -45
  118. data/lib/active_merchant/billing/gateways/money_movers.rb +152 -0
  119. data/lib/active_merchant/billing/gateways/mundipagg.rb +292 -0
  120. data/lib/active_merchant/billing/gateways/nab_transact.rb +81 -56
  121. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +165 -0
  122. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -3
  123. data/lib/active_merchant/billing/gateways/netbanx.rb +289 -0
  124. data/lib/active_merchant/billing/gateways/netbilling.rb +61 -26
  125. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  126. data/lib/active_merchant/billing/gateways/network_merchants.rb +242 -0
  127. data/lib/active_merchant/billing/gateways/nmi.rb +265 -10
  128. data/lib/active_merchant/billing/gateways/ogone.rb +85 -27
  129. data/lib/active_merchant/billing/gateways/omise.rb +324 -0
  130. data/lib/active_merchant/billing/gateways/openpay.rb +227 -0
  131. data/lib/active_merchant/billing/gateways/opp.rb +372 -0
  132. data/lib/active_merchant/billing/gateways/optimal_payment.rb +59 -28
  133. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +22 -21
  134. data/lib/active_merchant/billing/gateways/orbital.rb +346 -56
  135. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +207 -0
  136. data/lib/active_merchant/billing/gateways/pagarme.rb +248 -0
  137. data/lib/active_merchant/billing/gateways/pago_facil.rb +122 -0
  138. data/lib/active_merchant/billing/gateways/pay_conex.rb +246 -0
  139. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -14
  140. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  141. data/lib/active_merchant/billing/gateways/pay_junction.rb +19 -25
  142. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +190 -0
  143. data/lib/active_merchant/billing/gateways/pay_secure.rb +0 -7
  144. data/lib/active_merchant/billing/gateways/paybox_direct.rb +16 -12
  145. data/lib/active_merchant/billing/gateways/payeezy.rb +386 -0
  146. data/lib/active_merchant/billing/gateways/payex.rb +412 -0
  147. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +38 -17
  148. data/lib/active_merchant/billing/gateways/payflow.rb +100 -19
  149. data/lib/active_merchant/billing/gateways/payflow_express.rb +22 -22
  150. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
  151. data/lib/active_merchant/billing/gateways/payflow_uk.rb +6 -6
  152. data/lib/active_merchant/billing/gateways/payment_express.rb +15 -3
  153. data/lib/active_merchant/billing/gateways/paymentez.rb +276 -0
  154. data/lib/active_merchant/billing/gateways/paymill.rb +237 -48
  155. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -8
  156. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  157. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +18 -4
  158. data/lib/active_merchant/billing/gateways/paypal.rb +37 -20
  159. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  160. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +6 -5
  161. data/lib/active_merchant/billing/gateways/paypal_express.rb +32 -4
  162. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  163. data/lib/active_merchant/billing/gateways/payscout.rb +162 -0
  164. data/lib/active_merchant/billing/gateways/paystation.rb +32 -24
  165. data/lib/active_merchant/billing/gateways/payu_in.rb +248 -0
  166. data/lib/active_merchant/billing/gateways/payu_latam.rb +440 -0
  167. data/lib/active_merchant/billing/gateways/pin.rb +68 -13
  168. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -12
  169. data/lib/active_merchant/billing/gateways/pro_pay.rb +326 -0
  170. data/lib/active_merchant/billing/gateways/psigate.rb +14 -14
  171. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  172. data/lib/active_merchant/billing/gateways/qbms.rb +12 -1
  173. data/lib/active_merchant/billing/gateways/quantum.rb +2 -2
  174. data/lib/active_merchant/billing/gateways/quickbooks.rb +290 -0
  175. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +188 -0
  176. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +299 -0
  177. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +227 -0
  178. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -319
  179. data/lib/active_merchant/billing/gateways/qvalent.rb +236 -0
  180. data/lib/active_merchant/billing/gateways/realex.rb +40 -25
  181. data/lib/active_merchant/billing/gateways/redsys.rb +212 -80
  182. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  183. data/lib/active_merchant/billing/gateways/safe_charge.rb +262 -0
  184. data/lib/active_merchant/billing/gateways/sage.rb +412 -119
  185. data/lib/active_merchant/billing/gateways/sage_pay.rb +176 -59
  186. data/lib/active_merchant/billing/gateways/secure_net.rb +35 -29
  187. data/lib/active_merchant/billing/gateways/secure_pay.rb +182 -9
  188. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +21 -7
  189. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +0 -7
  190. data/lib/active_merchant/billing/gateways/securion_pay.rb +267 -0
  191. data/lib/active_merchant/billing/gateways/skip_jack.rb +1 -3
  192. data/lib/active_merchant/billing/gateways/smart_ps.rb +14 -3
  193. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +194 -0
  194. data/lib/active_merchant/billing/gateways/spreedly_core.rb +74 -14
  195. data/lib/active_merchant/billing/gateways/stripe.rb +472 -83
  196. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +156 -0
  197. data/lib/active_merchant/billing/gateways/telr.rb +275 -0
  198. data/lib/active_merchant/billing/gateways/tns.rb +22 -0
  199. data/lib/active_merchant/billing/gateways/trans_first.rb +142 -28
  200. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +608 -0
  201. data/lib/active_merchant/billing/gateways/transact_pro.rb +224 -0
  202. data/lib/active_merchant/billing/gateways/transnational.rb +2 -231
  203. data/lib/active_merchant/billing/gateways/trexle.rb +217 -0
  204. data/lib/active_merchant/billing/gateways/trust_commerce.rb +17 -11
  205. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +193 -75
  206. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +156 -64
  207. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  208. data/lib/active_merchant/billing/gateways/verifi.rb +1 -8
  209. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -15
  210. data/lib/active_merchant/billing/gateways/visanet_peru.rb +209 -0
  211. data/lib/active_merchant/billing/gateways/webpay.rb +45 -28
  212. data/lib/active_merchant/billing/gateways/wepay.rb +238 -0
  213. data/lib/active_merchant/billing/gateways/wirecard.rb +167 -49
  214. data/lib/active_merchant/billing/gateways/world_net.rb +344 -0
  215. data/lib/active_merchant/billing/gateways/worldpay.rb +171 -45
  216. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +218 -0
  217. data/lib/active_merchant/billing/gateways/worldpay_us.rb +221 -0
  218. data/lib/active_merchant/billing/gateways.rb +8 -11
  219. data/lib/active_merchant/billing/model.rb +30 -0
  220. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  221. data/lib/active_merchant/billing/payment_token.rb +21 -0
  222. data/lib/active_merchant/billing/rails.rb +3 -0
  223. data/lib/active_merchant/billing/response.rb +24 -17
  224. data/lib/active_merchant/billing.rb +7 -1
  225. data/lib/active_merchant/connection.rb +208 -0
  226. data/lib/active_merchant/country.rb +334 -0
  227. data/lib/active_merchant/empty.rb +20 -0
  228. data/lib/active_merchant/errors.rb +35 -0
  229. data/lib/active_merchant/net_http_ssl_connection.rb +9 -0
  230. data/lib/active_merchant/network_connection_retries.rb +81 -0
  231. data/lib/active_merchant/post_data.rb +24 -0
  232. data/lib/active_merchant/posts_data.rb +94 -0
  233. data/lib/active_merchant/version.rb +1 -1
  234. data/lib/active_merchant.rb +22 -22
  235. data/lib/certs/cacert.pem +3951 -0
  236. data/lib/support/gateway_support.rb +16 -10
  237. data/lib/support/outbound_hosts.rb +13 -10
  238. data/lib/support/ssl_version.rb +87 -0
  239. metadata +164 -306
  240. data/gem-public_cert.pem +0 -20
  241. data/lib/active_merchant/billing/expiry_date.rb +0 -34
  242. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  243. data/lib/active_merchant/billing/gateways/card_stream_modern.rb +0 -155
  244. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -277
  245. data/lib/active_merchant/billing/gateways/orbital/avs_result.rb +0 -93
  246. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -93
  247. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  248. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  249. data/lib/active_merchant/billing/gateways/samurai.rb +0 -118
  250. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -361
  251. data/lib/active_merchant/billing/integrations/a1agregator/helper.rb +0 -31
  252. data/lib/active_merchant/billing/integrations/a1agregator/notification.rb +0 -186
  253. data/lib/active_merchant/billing/integrations/a1agregator/status.rb +0 -38
  254. data/lib/active_merchant/billing/integrations/a1agregator.rb +0 -26
  255. data/lib/active_merchant/billing/integrations/action_view_helper.rb +0 -73
  256. data/lib/active_merchant/billing/integrations/authorize_net_sim/helper.rb +0 -229
  257. data/lib/active_merchant/billing/integrations/authorize_net_sim/notification.rb +0 -340
  258. data/lib/active_merchant/billing/integrations/authorize_net_sim.rb +0 -38
  259. data/lib/active_merchant/billing/integrations/bogus/helper.rb +0 -17
  260. data/lib/active_merchant/billing/integrations/bogus/notification.rb +0 -11
  261. data/lib/active_merchant/billing/integrations/bogus/return.rb +0 -10
  262. data/lib/active_merchant/billing/integrations/bogus.rb +0 -23
  263. data/lib/active_merchant/billing/integrations/chronopay/helper.rb +0 -120
  264. data/lib/active_merchant/billing/integrations/chronopay/notification.rb +0 -158
  265. data/lib/active_merchant/billing/integrations/chronopay/return.rb +0 -10
  266. data/lib/active_merchant/billing/integrations/chronopay.rb +0 -23
  267. data/lib/active_merchant/billing/integrations/direc_pay/helper.rb +0 -200
  268. data/lib/active_merchant/billing/integrations/direc_pay/notification.rb +0 -76
  269. data/lib/active_merchant/billing/integrations/direc_pay/return.rb +0 -32
  270. data/lib/active_merchant/billing/integrations/direc_pay/status.rb +0 -37
  271. data/lib/active_merchant/billing/integrations/direc_pay.rb +0 -41
  272. data/lib/active_merchant/billing/integrations/directebanking/helper.rb +0 -90
  273. data/lib/active_merchant/billing/integrations/directebanking/notification.rb +0 -120
  274. data/lib/active_merchant/billing/integrations/directebanking/return.rb +0 -11
  275. data/lib/active_merchant/billing/integrations/directebanking.rb +0 -47
  276. data/lib/active_merchant/billing/integrations/dotpay/helper.rb +0 -77
  277. data/lib/active_merchant/billing/integrations/dotpay/notification.rb +0 -86
  278. data/lib/active_merchant/billing/integrations/dotpay/return.rb +0 -11
  279. data/lib/active_merchant/billing/integrations/dotpay.rb +0 -22
  280. data/lib/active_merchant/billing/integrations/dwolla/common.rb +0 -23
  281. data/lib/active_merchant/billing/integrations/dwolla/helper.rb +0 -43
  282. data/lib/active_merchant/billing/integrations/dwolla/notification.rb +0 -64
  283. data/lib/active_merchant/billing/integrations/dwolla/return.rb +0 -49
  284. data/lib/active_merchant/billing/integrations/dwolla.rb +0 -23
  285. data/lib/active_merchant/billing/integrations/e_payment_plans/helper.rb +0 -34
  286. data/lib/active_merchant/billing/integrations/e_payment_plans/notification.rb +0 -84
  287. data/lib/active_merchant/billing/integrations/e_payment_plans.rb +0 -48
  288. data/lib/active_merchant/billing/integrations/easy_pay/common.rb +0 -40
  289. data/lib/active_merchant/billing/integrations/easy_pay/helper.rb +0 -36
  290. data/lib/active_merchant/billing/integrations/easy_pay/notification.rb +0 -59
  291. data/lib/active_merchant/billing/integrations/easy_pay.rb +0 -30
  292. data/lib/active_merchant/billing/integrations/epay/helper.rb +0 -55
  293. data/lib/active_merchant/billing/integrations/epay/notification.rb +0 -110
  294. data/lib/active_merchant/billing/integrations/epay.rb +0 -21
  295. data/lib/active_merchant/billing/integrations/first_data/helper.rb +0 -61
  296. data/lib/active_merchant/billing/integrations/first_data/notification.rb +0 -56
  297. data/lib/active_merchant/billing/integrations/first_data.rb +0 -38
  298. data/lib/active_merchant/billing/integrations/gestpay/common.rb +0 -42
  299. data/lib/active_merchant/billing/integrations/gestpay/helper.rb +0 -70
  300. data/lib/active_merchant/billing/integrations/gestpay/notification.rb +0 -85
  301. data/lib/active_merchant/billing/integrations/gestpay/return.rb +0 -10
  302. data/lib/active_merchant/billing/integrations/gestpay.rb +0 -25
  303. data/lib/active_merchant/billing/integrations/helper.rb +0 -117
  304. data/lib/active_merchant/billing/integrations/hi_trust/helper.rb +0 -58
  305. data/lib/active_merchant/billing/integrations/hi_trust/notification.rb +0 -59
  306. data/lib/active_merchant/billing/integrations/hi_trust/return.rb +0 -68
  307. data/lib/active_merchant/billing/integrations/hi_trust.rb +0 -27
  308. data/lib/active_merchant/billing/integrations/ipay88/helper.rb +0 -114
  309. data/lib/active_merchant/billing/integrations/ipay88/return.rb +0 -95
  310. data/lib/active_merchant/billing/integrations/ipay88.rb +0 -19
  311. data/lib/active_merchant/billing/integrations/liqpay/helper.rb +0 -43
  312. data/lib/active_merchant/billing/integrations/liqpay/notification.rb +0 -89
  313. data/lib/active_merchant/billing/integrations/liqpay/return.rb +0 -83
  314. data/lib/active_merchant/billing/integrations/liqpay.rb +0 -30
  315. data/lib/active_merchant/billing/integrations/maksuturva/helper.rb +0 -119
  316. data/lib/active_merchant/billing/integrations/maksuturva/notification.rb +0 -48
  317. data/lib/active_merchant/billing/integrations/maksuturva.rb +0 -86
  318. data/lib/active_merchant/billing/integrations/moneybookers/helper.rb +0 -75
  319. data/lib/active_merchant/billing/integrations/moneybookers/notification.rb +0 -129
  320. data/lib/active_merchant/billing/integrations/moneybookers.rb +0 -26
  321. data/lib/active_merchant/billing/integrations/nochex/helper.rb +0 -68
  322. data/lib/active_merchant/billing/integrations/nochex/notification.rb +0 -94
  323. data/lib/active_merchant/billing/integrations/nochex/return.rb +0 -10
  324. data/lib/active_merchant/billing/integrations/nochex.rb +0 -88
  325. data/lib/active_merchant/billing/integrations/notification.rb +0 -71
  326. data/lib/active_merchant/billing/integrations/paxum/common.rb +0 -24
  327. data/lib/active_merchant/billing/integrations/paxum/helper.rb +0 -42
  328. data/lib/active_merchant/billing/integrations/paxum/notification.rb +0 -33
  329. data/lib/active_merchant/billing/integrations/paxum.rb +0 -44
  330. data/lib/active_merchant/billing/integrations/pay_fast/common.rb +0 -42
  331. data/lib/active_merchant/billing/integrations/pay_fast/helper.rb +0 -50
  332. data/lib/active_merchant/billing/integrations/pay_fast/notification.rb +0 -134
  333. data/lib/active_merchant/billing/integrations/pay_fast/return.rb +0 -10
  334. data/lib/active_merchant/billing/integrations/pay_fast.rb +0 -70
  335. data/lib/active_merchant/billing/integrations/payflow_link/helper.rb +0 -116
  336. data/lib/active_merchant/billing/integrations/payflow_link/notification.rb +0 -78
  337. data/lib/active_merchant/billing/integrations/payflow_link.rb +0 -21
  338. data/lib/active_merchant/billing/integrations/paypal/helper.rb +0 -119
  339. data/lib/active_merchant/billing/integrations/paypal/notification.rb +0 -227
  340. data/lib/active_merchant/billing/integrations/paypal/return.rb +0 -10
  341. data/lib/active_merchant/billing/integrations/paypal.rb +0 -39
  342. data/lib/active_merchant/billing/integrations/paypal_payments_advanced/helper.rb +0 -15
  343. data/lib/active_merchant/billing/integrations/paypal_payments_advanced.rb +0 -20
  344. data/lib/active_merchant/billing/integrations/paysbuy/helper.rb +0 -15
  345. data/lib/active_merchant/billing/integrations/paysbuy/notification.rb +0 -28
  346. data/lib/active_merchant/billing/integrations/paysbuy.rb +0 -36
  347. data/lib/active_merchant/billing/integrations/payu_in/helper.rb +0 -74
  348. data/lib/active_merchant/billing/integrations/payu_in/notification.rb +0 -165
  349. data/lib/active_merchant/billing/integrations/payu_in/return.rb +0 -36
  350. data/lib/active_merchant/billing/integrations/payu_in.rb +0 -43
  351. data/lib/active_merchant/billing/integrations/platron/helper.rb +0 -32
  352. data/lib/active_merchant/billing/integrations/platron/notification.rb +0 -113
  353. data/lib/active_merchant/billing/integrations/platron.rb +0 -28
  354. data/lib/active_merchant/billing/integrations/pxpay/helper.rb +0 -112
  355. data/lib/active_merchant/billing/integrations/pxpay/notification.rb +0 -157
  356. data/lib/active_merchant/billing/integrations/pxpay/return.rb +0 -25
  357. data/lib/active_merchant/billing/integrations/pxpay.rb +0 -31
  358. data/lib/active_merchant/billing/integrations/quickpay/helper.rb +0 -74
  359. data/lib/active_merchant/billing/integrations/quickpay/notification.rb +0 -137
  360. data/lib/active_merchant/billing/integrations/quickpay.rb +0 -21
  361. data/lib/active_merchant/billing/integrations/rbkmoney/helper.rb +0 -23
  362. data/lib/active_merchant/billing/integrations/rbkmoney/notification.rb +0 -91
  363. data/lib/active_merchant/billing/integrations/rbkmoney.rb +0 -17
  364. data/lib/active_merchant/billing/integrations/return.rb +0 -42
  365. data/lib/active_merchant/billing/integrations/robokassa/common.rb +0 -19
  366. data/lib/active_merchant/billing/integrations/robokassa/helper.rb +0 -50
  367. data/lib/active_merchant/billing/integrations/robokassa/notification.rb +0 -55
  368. data/lib/active_merchant/billing/integrations/robokassa/return.rb +0 -17
  369. data/lib/active_merchant/billing/integrations/robokassa.rb +0 -49
  370. data/lib/active_merchant/billing/integrations/sage_pay_form/encryption.rb +0 -33
  371. data/lib/active_merchant/billing/integrations/sage_pay_form/helper.rb +0 -136
  372. data/lib/active_merchant/billing/integrations/sage_pay_form/notification.rb +0 -210
  373. data/lib/active_merchant/billing/integrations/sage_pay_form/return.rb +0 -31
  374. data/lib/active_merchant/billing/integrations/sage_pay_form.rb +0 -37
  375. data/lib/active_merchant/billing/integrations/two_checkout/helper.rb +0 -91
  376. data/lib/active_merchant/billing/integrations/two_checkout/notification.rb +0 -139
  377. data/lib/active_merchant/billing/integrations/two_checkout/return.rb +0 -17
  378. data/lib/active_merchant/billing/integrations/two_checkout.rb +0 -44
  379. data/lib/active_merchant/billing/integrations/valitor/helper.rb +0 -86
  380. data/lib/active_merchant/billing/integrations/valitor/notification.rb +0 -13
  381. data/lib/active_merchant/billing/integrations/valitor/response_fields.rb +0 -97
  382. data/lib/active_merchant/billing/integrations/valitor/return.rb +0 -13
  383. data/lib/active_merchant/billing/integrations/valitor.rb +0 -33
  384. data/lib/active_merchant/billing/integrations/verkkomaksut/helper.rb +0 -88
  385. data/lib/active_merchant/billing/integrations/verkkomaksut/notification.rb +0 -59
  386. data/lib/active_merchant/billing/integrations/verkkomaksut.rb +0 -20
  387. data/lib/active_merchant/billing/integrations/web_pay/common.rb +0 -50
  388. data/lib/active_merchant/billing/integrations/web_pay/helper.rb +0 -68
  389. data/lib/active_merchant/billing/integrations/web_pay/notification.rb +0 -51
  390. data/lib/active_merchant/billing/integrations/web_pay.rb +0 -45
  391. data/lib/active_merchant/billing/integrations/webmoney/common.rb +0 -17
  392. data/lib/active_merchant/billing/integrations/webmoney/helper.rb +0 -40
  393. data/lib/active_merchant/billing/integrations/webmoney/notification.rb +0 -47
  394. data/lib/active_merchant/billing/integrations/webmoney.rb +0 -43
  395. data/lib/active_merchant/billing/integrations/world_pay/helper.rb +0 -101
  396. data/lib/active_merchant/billing/integrations/world_pay/notification.rb +0 -160
  397. data/lib/active_merchant/billing/integrations/world_pay.rb +0 -34
  398. data/lib/active_merchant/billing/integrations.rb +0 -17
  399. data.tar.gz.sig +0 -0
  400. metadata.gz.sig +0 -0
@@ -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,214 +7,269 @@ 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"]
12
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
10
+ self.supported_countries = ['AU', 'NZ', 'GB', 'SG', 'MY', 'HK']
11
+ self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
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
 
16
+ class_attribute :partner_id
17
+
17
18
  def initialize(options = {})
18
19
  requires!(options, :login, :password)
19
20
  super
20
21
  end
21
22
 
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.
23
+ # Public: Run a purchase transaction.
25
24
  #
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")
25
+ # amount - The monetary amount of the transaction in cents.
26
+ # payment_method - The payment method or authorization token returned from store.
27
+ # options - A standard ActiveMerchant options hash:
28
+ # :transaction_type - One of: Purchase (default), MOTO
29
+ # or Recurring. For stored card payments (aka - TokenPayments),
30
+ # this must be either MOTO or Recurring.
31
+ # :invoice - The merchant’s invoice number for this
32
+ # transaction (optional).
33
+ # :order_id - A merchant-supplied identifier for the
34
+ # transaction (optional).
35
+ # :description - A merchant-supplied description of the
36
+ # transaction (optional).
37
+ # :currency - Three letter currency code for the
38
+ # transaction (default: "AUD")
39
+ # :billing_address - Standard ActiveMerchant address hash
40
+ # (optional).
41
+ # :shipping_address - Standard ActiveMerchant address hash
42
+ # (optional).
43
+ # :ip - The ip of the consumer initiating the
44
+ # transaction (optional).
45
+ # :application_id - A string identifying the application
46
+ # submitting the transaction
47
+ # (default: "https://github.com/activemerchant/active_merchant")
43
48
  #
44
- # Returns an ActiveMerchant::Billing::Response object
49
+ # Returns an ActiveMerchant::Billing::Response object where authorization is the Transaction ID on success
45
50
  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
51
+ params = {}
52
+ add_metadata(params, options)
53
+ add_invoice(params, amount, options)
54
+ add_customer_data(params, options)
55
+ add_credit_card(params, payment_method, options)
56
+ params['Method'] = payment_method.respond_to?(:number) ? 'ProcessPayment' : 'TokenPayment'
57
+ commit(url_for('Transaction'), params)
55
58
  end
56
59
 
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
60
+ def authorize(amount, payment_method, options={})
61
+ params = {}
62
+ add_metadata(params, options)
63
+ add_invoice(params, amount, options)
64
+ add_customer_data(params, options)
65
+ add_credit_card(params, payment_method, options)
66
+ params['Method'] = 'Authorise'
67
+ commit(url_for('Authorisation'), params)
68
+ end
69
+
70
+ def capture(amount, identification, options = {})
71
+ params = {}
72
+ add_metadata(params, options)
73
+ add_invoice(params, amount, options)
74
+ add_reference(params, identification)
75
+ commit(url_for("CapturePayment"), params)
76
+ end
89
77
 
90
- commit(url_for("CreateAccessCode"), request)
78
+ def void(identification, options = {})
79
+ params = {}
80
+ add_reference(params, identification)
81
+ commit(url_for("CancelAuthorisation"), params)
91
82
  end
92
83
 
93
- # Public: Retrieve the status of a transaction.
84
+ # Public: Refund a transaction.
94
85
  #
95
- # identification - The Eway Rapid 3.0 access code for the transaction
96
- # (returned as the response.authorization by
97
- # #setup_purchase).
86
+ # amount - The monetary amount of the transaction in cents
87
+ # identification - The transaction id which is returned in the
88
+ # authorization of the successful purchase transaction
89
+ # options - A standard ActiveMerchant options hash:
90
+ # :invoice - The merchant’s invoice number for this
91
+ # transaction (optional).
92
+ # :order_id - A merchant-supplied identifier for the
93
+ # transaction (optional).
94
+ # :description - A merchant-supplied description of the
95
+ # transaction (optional).
96
+ # :currency - Three letter currency code for the
97
+ # transaction (default: "AUD")
98
+ # :billing_address - Standard ActiveMerchant address hash
99
+ # (optional).
100
+ # :shipping_address - Standard ActiveMerchant address hash
101
+ # (optional).
102
+ # :ip - The ip of the consumer initiating the
103
+ # transaction (optional).
104
+ # :application_id - A string identifying the application
105
+ # submitting the transaction
106
+ # (default: "https://github.com/activemerchant/active_merchant")
98
107
  #
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)
108
+ # Returns an ActiveMerchant::Billing::Response object
109
+ def refund(amount, identification, options = {})
110
+ params = {}
111
+ add_metadata(params, options)
112
+ add_invoice(params, amount, options, "Refund")
113
+ add_reference(params["Refund"], identification)
114
+ add_customer_data(params, options)
115
+ commit(url_for("Transaction/#{identification}/Refund"), params)
105
116
  end
106
117
 
107
118
  # Public: Store card details and return a valid token
108
119
  #
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")
120
+ # payment_method - The payment method or nil if :customer_token is provided
121
+ # options - A supplemented ActiveMerchant options hash:
122
+ # :order_id - A merchant-supplied identifier for the
123
+ # transaction (optional).
124
+ # :description - A merchant-supplied description of the
125
+ # transaction (optional).
126
+ # :billing_address - Standard ActiveMerchant address hash
127
+ # (required).
128
+ # :ip - The ip of the consumer initiating the
129
+ # transaction (optional).
130
+ # :application_id - A string identifying the application
131
+ # submitting the transaction
132
+ # (default: "https://github.com/activemerchant/active_merchant")
133
+ #
134
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
119
135
  def store(payment_method, options = {})
120
136
  requires!(options, :billing_address)
121
- purchase(0, payment_method, options.merge(:request_method => "CreateTokenCustomer"))
137
+ params = {}
138
+ add_metadata(params, options)
139
+ add_invoice(params, 0, options)
140
+ add_customer_data(params, options)
141
+ add_credit_card(params, payment_method, options)
142
+ params['Method'] = 'CreateTokenCustomer'
143
+ commit(url_for("Transaction"), params)
122
144
  end
123
145
 
124
- private
125
-
126
- def run_purchase(identification, payment_method, endpoint)
127
- post = {
128
- "accesscode" => identification
129
- }
130
- add_credit_card(post, payment_method)
146
+ # Public: Update a customer's data
147
+ #
148
+ # customer_token - The customer token returned in the authorization of
149
+ # a successful store transaction.
150
+ # payment_method - The payment method or nil if :customer_token is provided
151
+ # options - A supplemented ActiveMerchant options hash:
152
+ # :order_id - A merchant-supplied identifier for the
153
+ # transaction (optional).
154
+ # :description - A merchant-supplied description of the
155
+ # transaction (optional).
156
+ # :billing_address - Standard ActiveMerchant address hash
157
+ # (optional).
158
+ # :ip - The ip of the consumer initiating the
159
+ # transaction (optional).
160
+ # :application_id - A string identifying the application
161
+ # submitting the transaction
162
+ # (default: "https://github.com/activemerchant/active_merchant")
163
+ #
164
+ # Returns an ActiveMerchant::Billing::Response object where the authorization is the customer_token on success
165
+ def update(customer_token, payment_method, options = {})
166
+ params = {}
167
+ add_metadata(params, options)
168
+ add_invoice(params, 0, options)
169
+ add_customer_data(params, options)
170
+ add_credit_card(params, payment_method, options)
171
+ add_customer_token(params, customer_token)
172
+ params['Method'] = 'UpdateTokenCustomer'
173
+ commit(url_for("Transaction"), params)
174
+ end
131
175
 
132
- commit_form(endpoint, build_form_request(post))
176
+ def supports_scrubbing
177
+ true
133
178
  end
134
179
 
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)
180
+ def scrub(transcript)
181
+ transcript.
182
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
183
+ gsub(%r(("Number\\?":\\?")[^"]*)i, '\1[FILTERED]').
184
+ gsub(%r(("CVN\\?":\\?"?)[^",]*)i, '\1[FILTERED]')
140
185
  end
141
186
 
142
- def add_invoice(doc, money, options)
143
- doc.Payment do
144
- doc.TotalAmount amount(money)
145
- doc.InvoiceReference options[:order_id]
146
- doc.InvoiceDescription options[:description]
147
- currency_code = (options[:currency] || currency(money) || default_currency)
148
- doc.CurrencyCode currency_code
187
+ private
188
+
189
+ def add_metadata(params, options)
190
+ params['RedirectUrl'] = options[:redirect_url] || 'http://example.com'
191
+ params['CustomerIP'] = options[:ip] if options[:ip]
192
+ params['TransactionType'] = options[:transaction_type] || 'Purchase'
193
+ params['DeviceID'] = options[:application_id] || application_id
194
+ if partner = options[:partner_id] || partner_id
195
+ params['PartnerID'] = truncate(partner, 50)
149
196
  end
197
+ params
150
198
  end
151
199
 
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
200
+ def add_invoice(params, money, options, key = "Payment")
201
+ currency_code = options[:currency] || currency(money)
202
+ params[key] = {
203
+ 'TotalAmount' => localized_amount(money, currency_code),
204
+ 'InvoiceReference' => truncate(options[:order_id], 50),
205
+ 'InvoiceNumber' => truncate(options[:invoice] || options[:order_id], 12),
206
+ 'InvoiceDescription' => truncate(options[:description], 64),
207
+ 'CurrencyCode' => currency_code,
208
+ }
159
209
  end
160
210
 
161
- def add_address(doc, address, options={})
162
- 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]
211
+ def add_reference(params, reference)
212
+ params['TransactionID'] = reference
179
213
  end
180
214
 
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
215
+ def add_customer_data(params, options)
216
+ params['Customer'] ||= {}
217
+ add_address(params['Customer'], (options[:billing_address] || options[:address]), {:email => options[:email]})
218
+ params['ShippingAddress'] = {}
219
+ add_address(params['ShippingAddress'], options[:shipping_address], {:skip_company => true})
187
220
  end
188
221
 
189
- def build_xml_request(root)
190
- builder = Nokogiri::XML::Builder.new
191
- builder.__send__(root) do |doc|
192
- yield(doc)
193
- end
194
- builder.to_xml
222
+ def add_address(params, address, options={})
223
+ return unless address
224
+
225
+ params['FirstName'], params['LastName'] = split_names(address[:name])
226
+ params['Title'] = address[:title]
227
+ params['CompanyName'] = address[:company] unless options[:skip_company]
228
+ params['Street1'] = truncate(address[:address1], 50)
229
+ params['Street2'] = truncate(address[:address2], 50)
230
+ params['City'] = truncate(address[:city], 50)
231
+ params['State'] = address[:state]
232
+ params['PostalCode'] = address[:zip]
233
+ params['Country'] = address[:country].to_s.downcase
234
+ params['Phone'] = address[:phone]
235
+ params['Fax'] = address[:fax]
236
+ params['Email'] = options[:email]
195
237
  end
196
238
 
197
- def build_form_request(post)
198
- request = []
199
- post.each do |key, value|
200
- request << "EWAY_#{key.upcase}=#{CGI.escape(value.to_s)}"
239
+ def add_credit_card(params, credit_card, options)
240
+ return unless credit_card
241
+ params['Customer'] ||= {}
242
+ if credit_card.respond_to? :number
243
+ card_details = params['Customer']['CardDetails'] = {}
244
+ card_details['Name'] = truncate(credit_card.name, 50)
245
+ card_details['Number'] = credit_card.number
246
+ card_details['ExpiryMonth'] = "%02d" % (credit_card.month || 0)
247
+ card_details['ExpiryYear'] = "%02d" % (credit_card.year || 0)
248
+ card_details['CVN'] = credit_card.verification_value
249
+ else
250
+ add_customer_token(params, credit_card)
201
251
  end
202
- request.join("&")
252
+ end
253
+
254
+ def add_customer_token(params, token)
255
+ params['Customer'] ||= {}
256
+ params['Customer']['TokenCustomerID'] = token
203
257
  end
204
258
 
205
259
  def url_for(action)
206
- (test? ? test_url : live_url) + action + ".xml"
260
+ (test? ? test_url : live_url) + action
207
261
  end
208
262
 
209
- def commit(url, request, form_post=false)
263
+ def commit(url, params)
210
264
  headers = {
211
265
  "Authorization" => ("Basic " + Base64.strict_encode64(@options[:login].to_s + ":" + @options[:password].to_s).chomp),
212
- "Content-Type" => "text/xml"
266
+ "Content-Type" => "application/json"
213
267
  }
214
-
268
+ request = params.to_json
215
269
  raw = parse(ssl_post(url, request, headers))
216
270
 
217
271
  succeeded = success?(raw)
218
- EwayRapidResponse.new(
272
+ ActiveMerchant::Billing::Response.new(
219
273
  succeeded,
220
274
  message_from(succeeded, raw),
221
275
  raw,
@@ -225,57 +279,37 @@ module ActiveMerchant #:nodoc:
225
279
  :cvv_result => cvv_result_from(raw)
226
280
  )
227
281
  rescue ActiveMerchant::ResponseError => e
228
- return EwayRapidResponse.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
282
+ return ActiveMerchant::Billing::Response.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
229
283
  end
230
284
 
231
- def commit_form(url, request)
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
- if success
237
- authorization = CGI.unescape(http_response["Location"].split("=").last)
238
- end
239
- Response.new(success, message, {:location => http_response["Location"]}, :authorization => authorization, :test => test?)
240
- end
241
-
242
- def parse(xml)
243
- response = {}
244
-
245
- doc = Nokogiri::XML(xml)
246
- doc.root.xpath("*").each do |node|
247
- if (node.elements.size == 0)
248
- response[node.name.downcase.to_sym] = node.text
249
- else
250
- node.elements.each do |childnode|
251
- name = "#{node.name.downcase}_#{childnode.name.downcase}"
252
- response[name.to_sym] = childnode.text
253
- end
254
- end
255
- end unless doc.root.nil?
256
-
257
- response
285
+ def parse(data)
286
+ JSON.parse(data)
258
287
  end
259
288
 
260
289
  def success?(response)
261
- if response[:errors]
262
- false
263
- elsif response[:responsecode] == "00"
290
+ if response['ResponseCode'] == "00"
264
291
  true
265
- elsif response[:transactionstatus]
266
- (response[:transactionstatus] == "true")
292
+ elsif response['TransactionStatus']
293
+ (response['TransactionStatus'] == true)
294
+ elsif response["Succeeded"]
295
+ (response["Succeeded"] == true)
267
296
  else
268
- true
297
+ false
269
298
  end
270
299
  end
271
300
 
301
+ def parse_errors(message)
302
+ errors = message.split(',').collect{|code| MESSAGES[code.strip]}.flatten.join(',')
303
+ errors.presence || message
304
+ end
305
+
272
306
  def message_from(succeeded, response)
273
- if response[:errors]
274
- response[:errors]
275
- elsif response[:responsecode]
276
- ActiveMerchant::Billing::EwayGateway::MESSAGES[response[:responsecode]]
277
- elsif response[:responsemessage]
278
- response[:responsemessage]
307
+ if response['Errors']
308
+ parse_errors(response['Errors'])
309
+ elsif response['ResponseMessage']
310
+ parse_errors(response['ResponseMessage'])
311
+ elsif response['ResponseCode']
312
+ ActiveMerchant::Billing::EwayGateway::MESSAGES[response['ResponseCode']]
279
313
  elsif succeeded
280
314
  "Succeeded"
281
315
  else
@@ -284,11 +318,14 @@ module ActiveMerchant #:nodoc:
284
318
  end
285
319
 
286
320
  def authorization_from(response)
287
- response[:accesscode]
321
+ # Note: TransactionID is always null for store requests, but TokenCustomerID is also sent back for purchase from
322
+ # stored card transactions so we give precedence to TransactionID
323
+ response['TransactionID'] || response['Customer']['TokenCustomerID']
288
324
  end
289
325
 
290
326
  def avs_result_from(response)
291
- code = case response[:verification_address]
327
+ verification = response['Verification'] || {}
328
+ code = case verification['Address']
292
329
  when "Valid"
293
330
  "M"
294
331
  when "Invalid"
@@ -300,7 +337,8 @@ module ActiveMerchant #:nodoc:
300
337
  end
301
338
 
302
339
  def cvv_result_from(response)
303
- case response[:verification_cvn]
340
+ verification = response['Verification'] || {}
341
+ case verification['CVN']
304
342
  when "Valid"
305
343
  "M"
306
344
  when "Invalid"
@@ -310,11 +348,186 @@ module ActiveMerchant #:nodoc:
310
348
  end
311
349
  end
312
350
 
313
- class EwayRapidResponse < ActiveMerchant::Billing::Response
314
- def form_url
315
- params["formactionurl"]
316
- end
317
- end
351
+ MESSAGES = {
352
+ 'A2000' => 'Transaction Approved Successful',
353
+ 'A2008' => 'Honour With Identification Successful',
354
+ 'A2010' => 'Approved For Partial Amount Successful',
355
+ 'A2011' => 'Approved, VIP Successful',
356
+ 'A2016' => 'Approved, Update Track 3 Successful',
357
+ 'D4401' => 'Refer to Issuer Failed',
358
+ 'D4402' => 'Refer to Issuer, special Failed',
359
+ 'D4403' => 'No Merchant Failed',
360
+ 'D4404' => 'Pick Up Card Failed',
361
+ 'D4405' => 'Do Not Honour Failed',
362
+ 'D4406' => 'Error Failed',
363
+ 'D4407' => 'Pick Up Card, Special Failed',
364
+ 'D4409' => 'Request In Progress Failed',
365
+ 'D4412' => 'Invalid Transaction Failed',
366
+ 'D4413' => 'Invalid Amount Failed',
367
+ 'D4414' => 'Invalid Card Number Failed',
368
+ 'D4415' => 'No Issuer Failed',
369
+ 'D4419' => 'Re-enter Last Transaction Failed',
370
+ 'D4421' => 'No Action Taken Failed',
371
+ 'D4422' => 'Suspected Malfunction Failed',
372
+ 'D4423' => 'Unacceptable Transaction Fee Failed',
373
+ 'D4425' => 'Unable to Locate Record On File Failed',
374
+ 'D4430' => 'Format Error Failed ',
375
+ 'D4431' => 'Bank Not Supported By Switch Failed',
376
+ 'D4433' => 'Expired Card, Capture Failed ',
377
+ 'D4434' => 'Suspected Fraud, Retain Card Failed',
378
+ 'D4435' => 'Card Acceptor, Contact Acquirer, Retain Card Failed',
379
+ 'D4436' => 'Restricted Card, Retain Card Failed',
380
+ 'D4437' => 'Contact Acquirer Security Department, Retain Card Failed',
381
+ 'D4438' => 'PIN Tries Exceeded, Capture Failed',
382
+ 'D4439' => 'No Credit Account Failed',
383
+ 'D4440' => 'Function Not Supported Failed',
384
+ 'D4441' => 'Lost Card Failed',
385
+ 'D4442' => 'No Universal Account Failed',
386
+ 'D4443' => 'Stolen Card Failed',
387
+ 'D4444' => 'No Investment Account Failed',
388
+ 'D4451' => 'Insufficient Funds Failed',
389
+ 'D4452' => 'No Cheque Account Failed',
390
+ 'D4453' => 'No Savings Account Failed',
391
+ 'D4454' => 'Expired Card Failed',
392
+ 'D4455' => 'Incorrect PIN Failed',
393
+ 'D4456' => 'No Card Record Failed',
394
+ 'D4457' => 'Function Not Permitted to Cardholder Failed',
395
+ 'D4458' => 'Function Not Permitted to Terminal Failed',
396
+ 'D4459' => 'Suspected Fraud Failed',
397
+ 'D4460' => 'Acceptor Contact Acquirer Failed',
398
+ 'D4461' => 'Exceeds Withdrawal Limit Failed',
399
+ 'D4462' => 'Restricted Card Failed',
400
+ 'D4463' => 'Security Violation Failed',
401
+ 'D4464' => 'Original Amount Incorrect Failed',
402
+ 'D4466' => 'Acceptor Contact Acquirer, Security Failed',
403
+ 'D4467' => 'Capture Card Failed',
404
+ 'D4475' => 'PIN Tries Exceeded Failed',
405
+ 'D4482' => 'CVV Validation Error Failed',
406
+ 'D4490' => 'Cut off In Progress Failed',
407
+ 'D4491' => 'Card Issuer Unavailable Failed',
408
+ 'D4492' => 'Unable To Route Transaction Failed',
409
+ 'D4493' => 'Cannot Complete, Violation Of The Law Failed',
410
+ 'D4494' => 'Duplicate Transaction Failed',
411
+ 'D4496' => 'System Error Failed',
412
+ 'D4497' => 'MasterPass Error Failed',
413
+ 'D4498' => 'PayPal Create Transaction Error Failed',
414
+ 'D4499' => 'Invalid Transaction for Auth/Void Failed',
415
+ 'S5000' => 'System Error',
416
+ 'S5011' => 'PayPal Connection Error',
417
+ 'S5012' => 'PayPal Settings Error',
418
+ 'S5085' => 'Started 3dSecure',
419
+ 'S5086' => 'Routed 3dSecure',
420
+ 'S5087' => 'Completed 3dSecure',
421
+ 'S5088' => 'PayPal Transaction Created',
422
+ 'S5099' => 'Incomplete (Access Code in progress/incomplete)',
423
+ 'S5010' => 'Unknown error returned by gateway',
424
+ 'V6000' => 'Validation error',
425
+ 'V6001' => 'Invalid CustomerIP',
426
+ 'V6002' => 'Invalid DeviceID',
427
+ 'V6003' => 'Invalid Request PartnerID',
428
+ 'V6004' => 'Invalid Request Method',
429
+ 'V6010' => 'Invalid TransactionType, account not certified for eCome only MOTO or Recurring available',
430
+ 'V6011' => 'Invalid Payment TotalAmount',
431
+ 'V6012' => 'Invalid Payment InvoiceDescription',
432
+ 'V6013' => 'Invalid Payment InvoiceNumber',
433
+ 'V6014' => 'Invalid Payment InvoiceReference',
434
+ 'V6015' => 'Invalid Payment CurrencyCode',
435
+ 'V6016' => 'Payment Required',
436
+ 'V6017' => 'Payment CurrencyCode Required',
437
+ 'V6018' => 'Unknown Payment CurrencyCode',
438
+ 'V6021' => 'EWAY_CARDHOLDERNAME Required',
439
+ 'V6022' => 'EWAY_CARDNUMBER Required',
440
+ 'V6023' => 'EWAY_CARDCVN Required',
441
+ 'V6033' => 'Invalid Expiry Date',
442
+ 'V6034' => 'Invalid Issue Number',
443
+ 'V6035' => 'Invalid Valid From Date',
444
+ 'V6040' => 'Invalid TokenCustomerID',
445
+ 'V6041' => 'Customer Required',
446
+ 'V6042' => 'Customer FirstName Required',
447
+ 'V6043' => 'Customer LastName Required',
448
+ 'V6044' => 'Customer CountryCode Required',
449
+ 'V6045' => 'Customer Title Required ',
450
+ 'V6046' => 'TokenCustomerID Required',
451
+ 'V6047' => 'RedirectURL Required',
452
+ 'V6048' => 'Invalid Checkout URL',
453
+ 'V6051' => 'Invalid Customer FirstName',
454
+ 'V6052' => 'Invalid Customer LastName',
455
+ 'V6053' => 'Invalid Customer CountryCode',
456
+ 'V6058' => 'Invalid Customer Title ',
457
+ 'V6059' => 'Invalid RedirectURL',
458
+ 'V6060' => 'Invalid TokenCustomerID',
459
+ 'V6061' => 'Invalid Customer Reference',
460
+ 'V6062' => 'Invalid Customer CompanyName',
461
+ 'V6063' => 'Invalid Customer JobDescription',
462
+ 'V6064' => 'Invalid Customer Street1',
463
+ 'V6065' => 'Invalid Customer Street2',
464
+ 'V6066' => 'Invalid Customer City',
465
+ 'V6067' => 'Invalid Customer State',
466
+ 'V6068' => 'Invalid Customer PostalCode',
467
+ 'V6069' => 'Invalid Customer Email ',
468
+ 'V6070' => 'Invalid Customer Phone',
469
+ 'V6071' => 'Invalid Customer Mobile',
470
+ 'V6072' => 'Invalid Customer Comments',
471
+ 'V6073' => 'Invalid Customer Fax',
472
+ 'V6074' => 'Invalid Customer URL',
473
+ 'V6075' => 'Invalid ShippingAddress FirstName',
474
+ 'V6076' => 'Invalid ShippingAddress LastName',
475
+ 'V6077' => 'Invalid ShippingAddress Street1',
476
+ 'V6078' => 'Invalid ShippingAddress Street2',
477
+ 'V6079' => 'Invalid ShippingAddress City',
478
+ 'V6080' => 'Invalid ShippingAddress State',
479
+ 'V6081' => 'Invalid ShippingAddress PostalCode',
480
+ 'V6082' => 'Invalid ShippingAddress Email',
481
+ 'V6083' => 'Invalid ShippingAddress Phone',
482
+ 'V6084' => 'Invalid ShippingAddress Country',
483
+ 'V6085' => 'Invalid ShippingAddress ShippingMethod',
484
+ 'V6086' => 'Invalid ShippingAddress Fax',
485
+ 'V6091' => 'Unknown Customer CountryCode',
486
+ 'V6092' => 'Unknown ShippingAddress CountryCode',
487
+ 'V6100' => 'Invalid EWAY_CARDNAME',
488
+ 'V6101' => 'Invalid EWAY_CARDEXPIRYMONTH',
489
+ 'V6102' => 'Invalid EWAY_CARDEXPIRYYEAR ',
490
+ 'V6103' => 'Invalid EWAY_CARDSTARTMONTH',
491
+ 'V6104' => 'Invalid EWAY_CARDSTARTYEAR',
492
+ 'V6105' => 'Invalid EWAY_CARDISSUENUMBER ',
493
+ 'V6106' => 'Invalid EWAY_CARDCVN',
494
+ 'V6107' => 'Invalid EWAY_ACCESSCODE',
495
+ 'V6108' => 'Invalid CustomerHostAddress',
496
+ 'V6109' => 'Invalid UserAgent',
497
+ 'V6110' => 'Invalid EWAY_CARDNUMBER',
498
+ 'V6111' => 'Unauthorised API Access, Account Not PCI Certified',
499
+ 'V6112' => 'Redundant card details other than expiry year and month',
500
+ 'V6113' => 'Invalid transaction for refund',
501
+ 'V6114' => 'Gateway validation error',
502
+ 'V6115' => 'Invalid DirectRefundRequest, Transaction ID',
503
+ 'V6116' => 'Invalid card data on original TransactionID',
504
+ 'V6117' => 'Invalid CreateAccessCodeSharedRequest, FooterText',
505
+ 'V6118' => 'Invalid CreateAccessCodeSharedRequest, HeaderText',
506
+ 'V6119' => 'Invalid CreateAccessCodeSharedRequest, Language',
507
+ 'V6120' => 'Invalid CreateAccessCodeSharedRequest, LogoUrl ',
508
+ 'V6121' => 'Invalid TransactionSearch, Filter Match Type',
509
+ 'V6122' => 'Invalid TransactionSearch, Non numeric Transaction ID',
510
+ 'V6123' => 'Invalid TransactionSearch,no TransactionID or AccessCode specified',
511
+ 'V6124' => 'Invalid Line Items. The line items have been provided however the totals do not match the TotalAmount field',
512
+ 'V6125' => 'Selected Payment Type not enabled',
513
+ 'V6126' => 'Invalid encrypted card number, decryption failed',
514
+ 'V6127' => 'Invalid encrypted cvn, decryption failed',
515
+ 'V6128' => 'Invalid Method for Payment Type',
516
+ 'V6129' => 'Transaction has not been authorised for Capture/Cancellation',
517
+ 'V6130' => 'Generic customer information error ',
518
+ 'V6131' => 'Generic shipping information error',
519
+ 'V6132' => 'Transaction has already been completed or voided, operation not permitted',
520
+ 'V6133' => 'Checkout not available for Payment Type',
521
+ 'V6134' => 'Invalid Auth Transaction ID for Capture/Void',
522
+ 'V6135' => 'PayPal Error Processing Refund',
523
+ 'V6140' => 'Merchant account is suspended',
524
+ 'V6141' => 'Invalid PayPal account details or API signature',
525
+ 'V6142' => 'Authorise not available for Bank/Branch',
526
+ 'V6150' => 'Invalid Refund Amount',
527
+ 'V6151' => 'Refund amount greater than original transaction',
528
+ 'V6152' => 'Original transaction already refunded for total amount',
529
+ 'V6153' => 'Card type not support by merchant',
530
+ }
318
531
  end
319
532
  end
320
533
  end