activemerchant 1.45.0 → 1.126.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +2167 -2
  3. data/CONTRIBUTORS +57 -0
  4. data/README.md +62 -41
  5. data/lib/active_merchant/billing/avs_result.rb +25 -28
  6. data/lib/active_merchant/billing/base.rb +11 -35
  7. data/lib/active_merchant/billing/check.rb +28 -24
  8. data/lib/active_merchant/billing/compatibility.rb +10 -12
  9. data/lib/active_merchant/billing/credit_card.rb +141 -69
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  11. data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
  12. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  13. data/lib/active_merchant/billing/gateway.rb +125 -61
  14. data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
  15. data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  21. data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
  24. data/lib/active_merchant/billing/gateways/banwire.rb +24 -13
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +143 -62
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
  33. data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
  34. data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  57. data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
  63. data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
  65. data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
  66. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  67. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  68. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  69. data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
  70. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  71. data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
  72. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  73. data/lib/active_merchant/billing/gateways/epay.rb +92 -71
  74. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  75. data/lib/active_merchant/billing/gateways/eway.rb +85 -73
  76. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  77. data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
  78. data/lib/active_merchant/billing/gateways/exact.rb +37 -36
  79. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  80. data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
  81. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  82. data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
  83. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  84. data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
  85. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
  86. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  88. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  89. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  90. data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
  91. data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
  92. data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
  93. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  94. data/lib/active_merchant/billing/gateways/hps.rb +252 -68
  95. data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
  96. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  97. data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
  98. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  99. data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
  100. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  101. data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
  102. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  103. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  104. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
  111. data/lib/active_merchant/billing/gateways/litle.rb +371 -94
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
  121. data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  124. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  125. data/lib/active_merchant/billing/gateways/migs.rb +101 -37
  126. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  128. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
  129. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  130. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  131. data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
  132. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  133. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  134. data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
  135. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  136. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  137. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  138. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  139. data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
  140. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  141. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  142. data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
  143. data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
  144. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  145. data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
  146. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  147. data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  149. data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
  150. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
  151. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  152. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  153. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  154. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  155. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
  156. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  158. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  160. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  161. data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
  162. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  163. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  167. data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
  169. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  170. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
  172. data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
  173. data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
  176. data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  183. data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
  186. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  187. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  188. data/lib/active_merchant/billing/gateways/pin.rb +113 -37
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  190. data/lib/active_merchant/billing/gateways/priority.rb +369 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  192. data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
  194. data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
  195. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +154 -52
  204. data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +404 -133
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
  216. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
  217. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  218. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  219. data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
  220. data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
  221. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
  222. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
  223. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  224. data/lib/active_merchant/billing/gateways/tns.rb +16 -217
  225. data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
  226. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  227. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  228. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  229. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  230. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  231. data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
  232. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  233. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
  234. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
  235. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  236. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  237. data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
  238. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  239. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  240. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  241. data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
  242. data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
  243. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  244. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  245. data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
  246. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  247. data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
  248. data/lib/active_merchant/billing/gateways.rb +8 -11
  249. data/lib/active_merchant/billing/model.rb +2 -2
  250. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  251. data/lib/active_merchant/billing/payment_token.rb +1 -1
  252. data/lib/active_merchant/billing/rails.rb +1 -1
  253. data/lib/active_merchant/billing/response.rb +19 -13
  254. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  255. data/lib/active_merchant/billing.rb +3 -0
  256. data/lib/active_merchant/connection.rb +196 -0
  257. data/lib/active_merchant/country.rb +13 -8
  258. data/lib/active_merchant/errors.rb +6 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +1 -1
  264. data/lib/active_merchant.rb +14 -59
  265. data/lib/activemerchant.rb +1 -1
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +8 -10
  268. data/lib/support/outbound_hosts.rb +13 -10
  269. data/lib/support/ssl_verify.rb +9 -14
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +136 -94
  272. checksums.yaml.gz.sig +0 -1
  273. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  274. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  275. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  278. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  279. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  280. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
  281. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
  282. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  283. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  284. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  285. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
  286. data/lib/active_merchant/offsite_payments_shim.rb +0 -19
  287. data.tar.gz.sig +0 -0
  288. metadata.gz.sig +0 -0
@@ -12,33 +12,34 @@ module ActiveMerchant #:nodoc:
12
12
 
13
13
  # Transactions hash
14
14
  TRANSACTIONS = {
15
- :authorization => '00001',
16
- :capture => '00002',
17
- :purchase => '00003',
18
- :unreferenced_credit => '00004',
19
- :void => '00005',
20
- :refund => '00014'
15
+ authorization: '00001',
16
+ capture: '00002',
17
+ purchase: '00003',
18
+ unreferenced_credit: '00004',
19
+ void: '00005',
20
+ refund: '00014'
21
21
  }
22
22
 
23
23
  CURRENCY_CODES = {
24
- "AUD"=> '036',
25
- "CAD"=> '124',
26
- "CZK"=> '203',
27
- "DKK"=> '208',
28
- "HKD"=> '344',
29
- "ICK"=> '352',
30
- "JPY"=> '392',
31
- "NOK"=> '578',
32
- "SGD"=> '702',
33
- "SEK"=> '752',
34
- "CHF"=> '756',
35
- "GBP"=> '826',
36
- "USD"=> '840',
37
- "EUR"=> '978'
24
+ 'AUD' => '036',
25
+ 'CAD' => '124',
26
+ 'CZK' => '203',
27
+ 'DKK' => '208',
28
+ 'HKD' => '344',
29
+ 'ICK' => '352',
30
+ 'JPY' => '392',
31
+ 'NOK' => '578',
32
+ 'SGD' => '702',
33
+ 'SEK' => '752',
34
+ 'CHF' => '756',
35
+ 'GBP' => '826',
36
+ 'USD' => '840',
37
+ 'EUR' => '978',
38
+ 'XPF' => '953'
38
39
  }
39
40
 
40
41
  SUCCESS_CODES = ['00000']
41
- UNAVAILABILITY_CODES = ['00001', '00097', '00098']
42
+ UNAVAILABILITY_CODES = %w[00001 00097 00098]
42
43
  SUCCESS_MESSAGE = 'The transaction was approved'
43
44
  FAILURE_MESSAGE = 'The transaction failed'
44
45
 
@@ -50,7 +51,7 @@ module ActiveMerchant #:nodoc:
50
51
  self.supported_countries = ['FR']
51
52
 
52
53
  # The card types supported by the payment gateway
53
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
54
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
54
55
 
55
56
  # The homepage URL of the gateway
56
57
  self.homepage_url = 'http://www.paybox.com/'
@@ -63,10 +64,33 @@ module ActiveMerchant #:nodoc:
63
64
  super
64
65
  end
65
66
 
67
+ def add_3dsecure(post, options)
68
+ # ECI=02 => MasterCard success
69
+ # ECI=05 => Visa, Amex or JCB success
70
+ if options[:eci] == '02' || options[:eci] == '05'
71
+ post[:"3DSTATUS"] = 'Y'
72
+ post[:"3DENROLLED"] = 'Y'
73
+ post[:"3DSIGNVAL"] = 'Y'
74
+ post[:"3DERROR"] = '0'
75
+ else
76
+ post[:"3DSTATUS"] = 'N'
77
+ post[:"3DENROLLED"] = 'N'
78
+ post[:"3DSIGNVAL"] = 'N'
79
+ post[:"3DERROR"] = '10000'
80
+ end
81
+ post[:"3DECI"] = options[:eci]
82
+ post[:"3DXID"] = options[:xid]
83
+ post[:"3DCAVV"] = options[:cavv]
84
+ post[:"3DCAVVALGO"] = options[:cavv_algorithm]
85
+ end
86
+
66
87
  def authorize(money, creditcard, options = {})
67
88
  post = {}
68
89
  add_invoice(post, options)
69
90
  add_creditcard(post, creditcard)
91
+ add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
92
+ add_amount(post, money, options)
93
+
70
94
  commit('authorization', money, post)
71
95
  end
72
96
 
@@ -74,6 +98,9 @@ module ActiveMerchant #:nodoc:
74
98
  post = {}
75
99
  add_invoice(post, options)
76
100
  add_creditcard(post, creditcard)
101
+ add_3dsecure(post, options[:three_d_secure]) if options[:three_d_secure]
102
+ add_amount(post, money, options)
103
+
77
104
  commit('purchase', money, post)
78
105
  end
79
106
 
@@ -81,18 +108,22 @@ module ActiveMerchant #:nodoc:
81
108
  requires!(options, :order_id)
82
109
  post = {}
83
110
  add_invoice(post, options)
84
- post[:numappel] = authorization[0,10]
85
- post[:numtrans] = authorization[10,10]
111
+ add_amount(post, money, options)
112
+ post[:numappel] = authorization[0, 10]
113
+ post[:numtrans] = authorization[10, 10]
114
+
86
115
  commit('capture', money, post)
87
116
  end
88
117
 
89
118
  def void(identification, options = {})
90
119
  requires!(options, :order_id, :amount)
91
- post ={}
120
+ post = {}
92
121
  add_invoice(post, options)
93
122
  add_reference(post, identification)
123
+ add_amount(post, options[:amount], options)
94
124
  post[:porteur] = '000000000000000'
95
125
  post[:dateval] = '0000'
126
+
96
127
  commit('void', options[:amount], post)
97
128
  end
98
129
 
@@ -105,6 +136,7 @@ module ActiveMerchant #:nodoc:
105
136
  post = {}
106
137
  add_invoice(post, options)
107
138
  add_reference(post, identification)
139
+ add_amount(post, money, options)
108
140
  commit('refund', money, post)
109
141
  end
110
142
 
@@ -121,31 +153,36 @@ module ActiveMerchant #:nodoc:
121
153
  end
122
154
 
123
155
  def add_reference(post, identification)
124
- post[:numappel] = identification[0,10]
125
- post[:numtrans] = identification[10,10]
156
+ post[:numappel] = identification[0, 10]
157
+ post[:numtrans] = identification[10, 10]
158
+ end
159
+
160
+ def add_amount(post, money, options)
161
+ post[:montant] = ('0000000000' + (money ? amount(money) : ''))[-10..-1]
162
+ post[:devise] = CURRENCY_CODES[options[:currency] || currency(money)]
126
163
  end
127
164
 
128
165
  def parse(body)
129
166
  results = {}
130
167
  body.split(/&/).each do |pair|
131
- key,val = pair.split(/\=/)
168
+ key, val = pair.split(/\=/)
132
169
  results[key.downcase.to_sym] = CGI.unescape(val) if val
133
170
  end
134
171
  results
135
172
  end
136
173
 
137
174
  def commit(action, money = nil, parameters = nil)
138
- parameters[:montant] = ('0000000000' + (money ? amount(money) : ''))[-10..-1]
139
- parameters[:devise] = CURRENCY_CODES[options[:currency] || currency(money)]
140
- request_data = post_data(action,parameters)
175
+ request_data = post_data(action, parameters)
141
176
  response = parse(ssl_post(test? ? self.test_url : self.live_url, request_data))
142
177
  response = parse(ssl_post(self.live_url_backup, request_data)) if service_unavailable?(response) && !test?
143
- Response.new(success?(response), message_from(response), response.merge(
144
- :timestamp => parameters[:dateq]),
145
- :test => test?,
146
- :authorization => response[:numappel].to_s + response[:numtrans].to_s,
147
- :fraud_review => false,
148
- :sent_params => parameters.delete_if{|key,value| ['porteur','dateval','cvv'].include?(key.to_s)}
178
+ Response.new(
179
+ success?(response),
180
+ message_from(response),
181
+ response.merge(timestamp: parameters[:dateq]),
182
+ test: test?,
183
+ authorization: response[:numappel].to_s + response[:numtrans].to_s,
184
+ fraud_review: false,
185
+ sent_params: parameters.delete_if { |key, _value| %w[porteur dateval cvv].include?(key.to_s) }
149
186
  )
150
187
  end
151
188
 
@@ -158,24 +195,23 @@ module ActiveMerchant #:nodoc:
158
195
  end
159
196
 
160
197
  def message_from(response)
161
- success?(response) ? SUCCESS_MESSAGE : (response[:commentaire] || FAILURE_MESSAGE)
198
+ success?(response) ? SUCCESS_MESSAGE : (response[:commentaire] || FAILURE_MESSAGE)
162
199
  end
163
200
 
164
201
  def post_data(action, parameters = {})
165
-
166
202
  parameters.update(
167
- :version => API_VERSION,
168
- :type => TRANSACTIONS[action.to_sym],
169
- :dateq => Time.now.strftime('%d%m%Y%H%M%S'),
170
- :numquestion => unique_id(parameters[:order_id]),
171
- :site => @options[:login].to_s[0,7],
172
- :rang => @options[:login].to_s[7..-1],
173
- :cle => @options[:password],
174
- :pays => '',
175
- :archivage => parameters[:order_id]
203
+ version: API_VERSION,
204
+ type: TRANSACTIONS[action.to_sym],
205
+ dateq: Time.now.strftime('%d%m%Y%H%M%S'),
206
+ numquestion: unique_id(parameters[:order_id]),
207
+ site: @options[:login].to_s[0, 7],
208
+ rang: @options[:rang] || @options[:login].to_s[7..-1],
209
+ cle: @options[:password],
210
+ pays: '',
211
+ archivage: parameters[:order_id]
176
212
  )
177
213
 
178
- parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join("&")
214
+ parameters.collect { |key, value| "#{key.to_s.upcase}=#{CGI.escape(value.to_s)}" }.join('&')
179
215
  end
180
216
 
181
217
  def unique_id(seed = 0)
@@ -0,0 +1,458 @@
1
+ module ActiveMerchant
2
+ module Billing
3
+ class PayeezyGateway < Gateway
4
+ class_attribute :integration_url
5
+
6
+ self.test_url = 'https://api-cert.payeezy.com/v1'
7
+ self.integration_url = 'https://api-cat.payeezy.com/v1'
8
+ self.live_url = 'https://api.payeezy.com/v1'
9
+
10
+ self.default_currency = 'USD'
11
+ self.money_format = :cents
12
+ self.supported_countries = %w(US CA)
13
+
14
+ self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
15
+
16
+ self.homepage_url = 'https://developer.payeezy.com/'
17
+ self.display_name = 'Payeezy'
18
+
19
+ CREDIT_CARD_BRAND = {
20
+ 'visa' => 'Visa',
21
+ 'master' => 'Mastercard',
22
+ 'american_express' => 'American Express',
23
+ 'discover' => 'Discover',
24
+ 'jcb' => 'JCB',
25
+ 'diners_club' => 'Diners Club'
26
+ }
27
+
28
+ def initialize(options = {})
29
+ requires!(options, :apikey, :apisecret, :token)
30
+ super
31
+ end
32
+
33
+ def purchase(amount, payment_method, options = {})
34
+ params = payment_method.is_a?(String) ? { transaction_type: 'recurring' } : { transaction_type: 'purchase' }
35
+
36
+ add_invoice(params, options)
37
+ add_reversal_id(params, options)
38
+ add_payment_method(params, payment_method, options)
39
+ add_address(params, options)
40
+ add_amount(params, amount, options)
41
+ add_soft_descriptors(params, options)
42
+ add_level2_data(params, options)
43
+ add_stored_credentials(params, options)
44
+
45
+ commit(params, options)
46
+ end
47
+
48
+ def authorize(amount, payment_method, options = {})
49
+ params = { transaction_type: 'authorize' }
50
+
51
+ add_invoice(params, options)
52
+ add_reversal_id(params, options)
53
+ add_payment_method(params, payment_method, options)
54
+ add_address(params, options)
55
+ add_amount(params, amount, options)
56
+ add_soft_descriptors(params, options)
57
+ add_level2_data(params, options)
58
+ add_stored_credentials(params, options)
59
+
60
+ commit(params, options)
61
+ end
62
+
63
+ def capture(amount, authorization, options = {})
64
+ params = { transaction_type: 'capture' }
65
+
66
+ add_authorization_info(params, authorization)
67
+ add_amount(params, amount, options)
68
+ add_soft_descriptors(params, options)
69
+
70
+ commit(params, options)
71
+ end
72
+
73
+ def refund(amount, authorization, options = {})
74
+ params = { transaction_type: 'refund' }
75
+
76
+ add_authorization_info(params, authorization)
77
+ add_amount(params, (amount || amount_from_authorization(authorization)), options)
78
+ add_soft_descriptors(params, options)
79
+ add_invoice(params, options)
80
+
81
+ commit(params, options)
82
+ end
83
+
84
+ def credit(amount, payment_method, options = {})
85
+ params = { transaction_type: 'refund' }
86
+
87
+ add_amount(params, amount, options)
88
+ add_payment_method(params, payment_method, options)
89
+ add_soft_descriptors(params, options)
90
+ add_invoice(params, options)
91
+ commit(params, options)
92
+ end
93
+
94
+ def store(payment_method, options = {})
95
+ params = { transaction_type: 'store' }
96
+
97
+ add_creditcard_for_tokenization(params, payment_method, options)
98
+
99
+ commit(params, options)
100
+ end
101
+
102
+ def void(authorization, options = {})
103
+ params = { transaction_type: 'void' }
104
+
105
+ add_authorization_info(params, authorization, options)
106
+ add_amount(params, amount_from_authorization(authorization), options)
107
+
108
+ commit(params, options)
109
+ end
110
+
111
+ def verify(credit_card, options = {})
112
+ MultiResponse.run(:use_first_response) do |r|
113
+ r.process { authorize(0, credit_card, options) }
114
+ r.process(:ignore_result) { void(r.authorization, options) }
115
+ end
116
+ end
117
+
118
+ def supports_scrubbing?
119
+ true
120
+ end
121
+
122
+ def scrub(transcript)
123
+ transcript.
124
+ gsub(%r((Token: )(\w|-)+), '\1[FILTERED]').
125
+ gsub(%r((Apikey: )(\w|-)+), '\1[FILTERED]').
126
+ gsub(%r((\\?"card_number\\?":\\?")\d+), '\1[FILTERED]').
127
+ gsub(%r((\\?"cvv\\?":\\?")\d+), '\1[FILTERED]').
128
+ gsub(%r((\\?"account_number\\?":\\?")\d+), '\1[FILTERED]').
129
+ gsub(%r((\\?"routing_number\\?":\\?")\d+), '\1[FILTERED]').
130
+ gsub(%r((\\?card_number=)\d+(&?)), '\1[FILTERED]').
131
+ gsub(%r((\\?cvv=)\d+(&?)), '\1[FILTERED]').
132
+ gsub(%r((\\?apikey=)\w+(&?)), '\1[FILTERED]').
133
+ gsub(%r{(\\?"credit_card\.card_number\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
134
+ gsub(%r{(\\?"credit_card\.cvv\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]').
135
+ gsub(%r{(\\?"apikey\\?":)(\\?"[^"]+\\?")}, '\1[FILTERED]')
136
+ end
137
+
138
+ private
139
+
140
+ def add_invoice(params, options)
141
+ params[:merchant_ref] = options[:order_id]
142
+ end
143
+
144
+ def add_reversal_id(params, options)
145
+ params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
146
+ end
147
+
148
+ def amount_from_authorization(authorization)
149
+ authorization.split('|').last.to_i
150
+ end
151
+
152
+ def add_authorization_info(params, authorization, options = {})
153
+ transaction_id, transaction_tag, method, = authorization.split('|')
154
+ params[:method] = method == 'token' ? 'credit_card' : method
155
+
156
+ if options[:reversal_id]
157
+ params[:reversal_id] = options[:reversal_id]
158
+ else
159
+ params[:transaction_id] = transaction_id
160
+ params[:transaction_tag] = transaction_tag
161
+ end
162
+ end
163
+
164
+ def add_creditcard_for_tokenization(params, payment_method, options)
165
+ params[:apikey] = @options[:apikey]
166
+ params[:ta_token] = options[:ta_token]
167
+ params[:type] = 'FDToken'
168
+ params[:credit_card] = add_card_data(payment_method)
169
+ params[:auth] = 'false'
170
+ end
171
+
172
+ def store_action?(params)
173
+ params[:transaction_type] == 'store'
174
+ end
175
+
176
+ def add_payment_method(params, payment_method, options)
177
+ if payment_method.is_a? Check
178
+ add_echeck(params, payment_method, options)
179
+ elsif payment_method.is_a? String
180
+ add_token(params, payment_method, options)
181
+ else
182
+ add_creditcard(params, payment_method)
183
+ end
184
+ end
185
+
186
+ def add_echeck(params, echeck, options)
187
+ tele_check = {}
188
+
189
+ tele_check[:check_number] = echeck.number || '001'
190
+ tele_check[:check_type] = 'P'
191
+ tele_check[:routing_number] = echeck.routing_number
192
+ tele_check[:account_number] = echeck.account_number
193
+ tele_check[:accountholder_name] = "#{echeck.first_name} #{echeck.last_name}"
194
+ tele_check[:customer_id_type] = options[:customer_id_type] if options[:customer_id_type]
195
+ tele_check[:customer_id_number] = options[:customer_id_number] if options[:customer_id_number]
196
+ tele_check[:client_email] = options[:client_email] if options[:client_email]
197
+
198
+ params[:method] = 'tele_check'
199
+ params[:tele_check] = tele_check
200
+ end
201
+
202
+ def add_token(params, payment_method, options)
203
+ token = {}
204
+ token[:token_type] = 'FDToken'
205
+
206
+ type, cardholder_name, exp_date, card_number = payment_method.split('|')
207
+
208
+ token[:token_data] = {}
209
+ token[:token_data][:type] = type
210
+ token[:token_data][:cardholder_name] = cardholder_name
211
+ token[:token_data][:value] = card_number
212
+ token[:token_data][:exp_date] = exp_date
213
+ token[:token_data][:cvv] = options[:cvv] if options[:cvv]
214
+
215
+ params[:method] = 'token'
216
+ params[:token] = token
217
+ end
218
+
219
+ def add_creditcard(params, creditcard)
220
+ credit_card = add_card_data(creditcard)
221
+
222
+ params[:method] = 'credit_card'
223
+ params[:credit_card] = credit_card
224
+ end
225
+
226
+ def add_card_data(payment_method)
227
+ card = {}
228
+ card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
229
+ card[:cardholder_name] = payment_method.name
230
+ card[:card_number] = payment_method.number
231
+ card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
232
+ card[:cvv] = payment_method.verification_value if payment_method.verification_value?
233
+ card
234
+ end
235
+
236
+ def format_exp_date(month, year)
237
+ "#{format(month, :two_digits)}#{format(year, :two_digits)}"
238
+ end
239
+
240
+ def add_address(params, options)
241
+ address = options[:billing_address]
242
+ return unless address
243
+
244
+ billing_address = {}
245
+ billing_address[:street] = address[:address1] if address[:address1]
246
+ billing_address[:city] = address[:city] if address[:city]
247
+ billing_address[:state_province] = address[:state] if address[:state]
248
+ billing_address[:zip_postal_code] = address[:zip] if address[:zip]
249
+ billing_address[:country] = address[:country] if address[:country]
250
+
251
+ params[:billing_address] = billing_address
252
+ end
253
+
254
+ def add_amount(params, money, options)
255
+ params[:currency_code] = (options[:currency] || default_currency).upcase
256
+ params[:amount] = amount(money)
257
+ end
258
+
259
+ def add_soft_descriptors(params, options)
260
+ params[:soft_descriptors] = options[:soft_descriptors] if options[:soft_descriptors]
261
+ end
262
+
263
+ def add_level2_data(params, options)
264
+ return unless level2_data = options[:level2]
265
+
266
+ params[:level2] = {}
267
+ params[:level2][:customer_ref] = level2_data[:customer_ref]
268
+ end
269
+
270
+ def add_stored_credentials(params, options)
271
+ if options[:sequence] || options[:stored_credential]
272
+ params[:stored_credentials] = {}
273
+ params[:stored_credentials][:cardbrand_original_transaction_id] = original_transaction_id(options) if original_transaction_id(options)
274
+ params[:stored_credentials][:initiator] = initiator(options) if initiator(options)
275
+ params[:stored_credentials][:sequence] = options[:sequence] || sequence(options[:stored_credential][:initial_transaction])
276
+ params[:stored_credentials][:is_scheduled] = options[:is_scheduled] || is_scheduled(options[:stored_credential][:reason_type])
277
+ params[:stored_credentials][:auth_type_override] = options[:auth_type_override] if options[:auth_type_override]
278
+ end
279
+ end
280
+
281
+ def original_transaction_id(options)
282
+ return options[:cardbrand_original_transaction_id] if options[:cardbrand_original_transaction_id]
283
+ return options[:stored_credential][:network_transaction_id] if options.dig(:stored_credential, :network_transaction_id)
284
+ end
285
+
286
+ def initiator(options)
287
+ return options[:initiator] if options[:initiator]
288
+ return options[:stored_credential][:initiator].upcase if options.dig(:stored_credential, :initiator)
289
+ end
290
+
291
+ def sequence(initial_transaction)
292
+ initial_transaction ? 'FIRST' : 'SUBSEQUENT'
293
+ end
294
+
295
+ def is_scheduled(reason_type)
296
+ reason_type == 'recurring' ? 'true' : 'false'
297
+ end
298
+
299
+ def commit(params, options)
300
+ url = base_url(options) + endpoint(params)
301
+
302
+ if transaction_id = params.delete(:transaction_id)
303
+ url = "#{url}/#{transaction_id}"
304
+ end
305
+
306
+ begin
307
+ response = api_request(url, params)
308
+ rescue ResponseError => e
309
+ response = response_error(e.response.body)
310
+ rescue JSON::ParserError
311
+ response = json_error(e.response.body)
312
+ end
313
+
314
+ success = success_from(response)
315
+ Response.new(
316
+ success,
317
+ handle_message(response, success),
318
+ response,
319
+ test: test?,
320
+ authorization: authorization_from(params, response),
321
+ avs_result: { code: response['avs'] },
322
+ cvv_result: response['cvv2'],
323
+ error_code: success ? nil : error_code_from(response)
324
+ )
325
+ end
326
+
327
+ def base_url(options)
328
+ if options[:integration]
329
+ integration_url
330
+ elsif test?
331
+ test_url
332
+ else
333
+ live_url
334
+ end
335
+ end
336
+
337
+ def endpoint(params)
338
+ store_action?(params) ? '/transactions/tokens' : '/transactions'
339
+ end
340
+
341
+ def api_request(url, params)
342
+ body = params.to_json
343
+ parse(ssl_post(url, body, headers(body)))
344
+ end
345
+
346
+ def post_data(params)
347
+ return nil unless params
348
+
349
+ params.reject { |_k, v| v.blank? }.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
350
+ end
351
+
352
+ def generate_hmac(nonce, current_timestamp, payload)
353
+ message = [
354
+ @options[:apikey],
355
+ nonce.to_s,
356
+ current_timestamp.to_s,
357
+ @options[:token],
358
+ payload
359
+ ].join('')
360
+ hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
361
+ hash
362
+ end
363
+
364
+ def headers(payload)
365
+ nonce = (SecureRandom.random_number * 10_000_000_000)
366
+ current_timestamp = (Time.now.to_f * 1000).to_i
367
+ {
368
+ 'Content-Type' => 'application/json',
369
+ 'apikey' => options[:apikey],
370
+ 'token' => options[:token],
371
+ 'nonce' => nonce.to_s,
372
+ 'timestamp' => current_timestamp.to_s,
373
+ 'Authorization' => generate_hmac(nonce, current_timestamp, payload)
374
+ }
375
+ end
376
+
377
+ def error_code_from(response)
378
+ error_code = nil
379
+ if response['bank_resp_code'] == '100'
380
+ return
381
+ elsif response['bank_resp_code']
382
+ error_code = response['bank_resp_code']
383
+ elsif error_code = response['Error'].to_h['messages'].to_a.map { |e| e['code'] }.join(', ')
384
+ end
385
+
386
+ error_code
387
+ end
388
+
389
+ def success_from(response)
390
+ if response['transaction_status']
391
+ response['transaction_status'] == 'approved'
392
+ elsif response['results']
393
+ response['results']['status'] == 'success'
394
+ elsif response['status']
395
+ response['status'] == 'success'
396
+ else
397
+ false
398
+ end
399
+ end
400
+
401
+ def handle_message(response, success)
402
+ if success && response['status'].present?
403
+ 'Token successfully created.'
404
+ elsif success
405
+ "#{response['gateway_message']} - #{response['bank_message']}"
406
+ elsif %w(401 403).include?(response['code'])
407
+ response['message']
408
+ elsif response.key?('Error')
409
+ response['Error']['messages'].first['description']
410
+ elsif response.key?('results')
411
+ response['results']['Error']['messages'].first['description']
412
+ elsif response.key?('error')
413
+ response['error']
414
+ elsif response.key?('fault')
415
+ response['fault'].to_h['faultstring']
416
+ else
417
+ response['bank_message'] || response['gateway_message'] || 'Failure to successfully create token.'
418
+ end
419
+ end
420
+
421
+ def authorization_from(params, response)
422
+ if store_action?(params)
423
+ if success_from(response)
424
+ [
425
+ response['token']['type'],
426
+ response['token']['cardholder_name'],
427
+ response['token']['exp_date'],
428
+ response['token']['value']
429
+ ].join('|')
430
+ else
431
+ nil
432
+ end
433
+ else
434
+ [
435
+ response['transaction_id'],
436
+ response['transaction_tag'],
437
+ params[:method],
438
+ response['amount']&.to_i
439
+ ].join('|')
440
+ end
441
+ end
442
+
443
+ def parse(body)
444
+ JSON.parse(body)
445
+ end
446
+
447
+ def response_error(raw_response)
448
+ parse(raw_response)
449
+ rescue JSON::ParserError
450
+ json_error(raw_response)
451
+ end
452
+
453
+ def json_error(raw_response)
454
+ { 'error' => "Unable to parse response: #{raw_response.inspect}" }
455
+ end
456
+ end
457
+ end
458
+ end