activemerchant 1.79.2 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +1391 -0
  3. data/README.md +29 -14
  4. data/lib/active_merchant/billing/avs_result.rb +25 -28
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +55 -22
  7. data/lib/active_merchant/billing/compatibility.rb +10 -12
  8. data/lib/active_merchant/billing/credit_card.rb +82 -62
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  10. data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +61 -56
  13. data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +35 -36
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
  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 +12 -12
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
  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 +115 -115
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
  33. data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
  34. data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +561 -259
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
  42. data/lib/active_merchant/billing/gateways/cams.rb +31 -31
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
  52. data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
  56. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  57. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  58. data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
  59. data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
  60. data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
  61. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  62. data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
  63. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  64. data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
  65. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
  68. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  69. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  70. data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
  71. data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
  72. data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
  73. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  74. data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
  75. data/lib/active_merchant/billing/gateways/element.rb +106 -56
  76. data/lib/active_merchant/billing/gateways/epay.rb +74 -64
  77. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  78. data/lib/active_merchant/billing/gateways/eway.rb +74 -73
  79. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  80. data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
  81. data/lib/active_merchant/billing/gateways/exact.rb +29 -37
  82. data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
  83. data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
  84. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  85. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
  86. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  87. data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
  88. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
  89. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/forte.rb +70 -40
  93. data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
  94. data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
  95. data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
  96. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  97. data/lib/active_merchant/billing/gateways/hps.rb +236 -69
  98. data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
  99. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  100. data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
  101. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  102. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  103. data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
  104. data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
  105. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  106. data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
  107. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  108. data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
  109. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
  110. data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
  111. data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
  112. data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
  113. data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
  114. data/lib/active_merchant/billing/gateways/litle.rb +247 -53
  115. data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
  116. data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
  118. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
  119. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  120. data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
  121. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  122. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
  123. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
  124. data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
  125. data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
  126. data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
  127. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  128. data/lib/active_merchant/billing/gateways/migs.rb +45 -40
  129. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  130. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
  132. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  133. data/lib/active_merchant/billing/gateways/monei.rb +255 -138
  134. data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
  135. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  136. data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
  137. data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
  138. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
  139. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  140. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  141. data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
  142. data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
  143. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  144. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  145. data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
  146. data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
  147. data/lib/active_merchant/billing/gateways/omise.rb +30 -31
  148. data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
  149. data/lib/active_merchant/billing/gateways/opp.rb +166 -144
  150. data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
  151. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  152. data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
  153. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
  154. data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
  155. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  156. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  157. data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
  158. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
  159. data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
  160. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  161. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
  162. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  163. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  164. data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
  165. data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
  166. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  167. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
  168. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  169. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  170. data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
  171. data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
  172. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
  173. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
  174. data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
  175. data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
  176. data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
  177. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  178. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  179. data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
  180. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
  183. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  185. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  186. data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
  187. data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
  188. data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
  189. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  190. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  191. data/lib/active_merchant/billing/gateways/pin.rb +87 -34
  192. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  193. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  194. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  195. data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
  196. data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
  197. data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
  198. data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
  199. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  200. data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
  201. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
  202. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
  203. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
  204. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
  205. data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
  206. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  207. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  208. data/lib/active_merchant/billing/gateways/realex.rb +132 -50
  209. data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
  210. data/lib/active_merchant/billing/gateways/s5.rb +16 -16
  211. data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
  212. data/lib/active_merchant/billing/gateways/sage.rb +49 -48
  213. data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
  214. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  215. data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
  216. data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
  217. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
  218. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  219. data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
  220. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  221. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  222. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
  223. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  224. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  225. data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
  226. data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
  227. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
  228. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
  229. data/lib/active_merchant/billing/gateways/telr.rb +46 -48
  230. data/lib/active_merchant/billing/gateways/tns.rb +8 -7
  231. data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
  232. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
  233. data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
  234. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  235. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  236. data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
  237. data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
  238. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  239. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
  240. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
  241. data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
  242. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  243. data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
  244. data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
  245. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  246. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  247. data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
  248. data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
  249. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  250. data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
  251. data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
  252. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
  253. data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
  254. data/lib/active_merchant/billing/model.rb +2 -2
  255. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
  256. data/lib/active_merchant/billing/rails.rb +1 -1
  257. data/lib/active_merchant/billing/response.rb +32 -13
  258. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  259. data/lib/active_merchant/billing.rb +1 -0
  260. data/lib/active_merchant/connection.rb +24 -38
  261. data/lib/active_merchant/country.rb +9 -5
  262. data/lib/active_merchant/errors.rb +4 -1
  263. data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
  264. data/lib/active_merchant/network_connection_retries.rb +28 -31
  265. data/lib/active_merchant/post_data.rb +5 -3
  266. data/lib/active_merchant/posts_data.rb +5 -7
  267. data/lib/active_merchant/version.rb +1 -1
  268. data/lib/active_merchant.rb +3 -3
  269. data/lib/activemerchant.rb +1 -1
  270. data/lib/certs/cacert.pem +1592 -2329
  271. data/lib/support/gateway_support.rb +8 -10
  272. data/lib/support/ssl_verify.rb +9 -14
  273. data/lib/support/ssl_version.rb +9 -10
  274. metadata +98 -37
  275. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  278. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  279. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -24,11 +24,11 @@ module ActiveMerchant
24
24
  r.process {
25
25
  post = authorization_params(money, credit_card_or_reference, options)
26
26
  add_autocapture(post, false)
27
- commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post)
27
+ commit(synchronized_path("/payments/#{r.responses.last.params['id']}/authorize"), post)
28
28
  }
29
29
  r.process {
30
30
  post = capture_params(money, credit_card_or_reference, options)
31
- commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/capture"), post)
31
+ commit(synchronized_path("/payments/#{r.responses.last.params['id']}/capture"), post)
32
32
  }
33
33
  end
34
34
  end
@@ -42,7 +42,7 @@ module ActiveMerchant
42
42
  r.process { create_payment(money, options) }
43
43
  r.process {
44
44
  post = authorization_params(money, credit_card_or_reference, options)
45
- commit(synchronized_path("/payments/#{r.responses.last.params["id"]}/authorize"), post)
45
+ commit(synchronized_path("/payments/#{r.responses.last.params['id']}/authorize"), post)
46
46
  }
47
47
  end
48
48
  end
@@ -68,7 +68,7 @@ module ActiveMerchant
68
68
  commit(synchronized_path("/payments/#{identification}/refund"), post)
69
69
  end
70
70
 
71
- def verify(credit_card, options={})
71
+ def verify(credit_card, options = {})
72
72
  MultiResponse.run(:use_first_response) do |r|
73
73
  r.process { authorize(100, credit_card, options) }
74
74
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -78,7 +78,7 @@ module ActiveMerchant
78
78
  def store(credit_card, options = {})
79
79
  MultiResponse.run do |r|
80
80
  r.process { create_store(options) }
81
- r.process { authorize_store(r.authorization, credit_card, options)}
81
+ r.process { authorize_store(r.authorization, credit_card, options) }
82
82
  end
83
83
  end
84
84
 
@@ -99,201 +99,199 @@ module ActiveMerchant
99
99
 
100
100
  private
101
101
 
102
- def authorization_params(money, credit_card_or_reference, options = {})
103
- post = {}
104
-
105
- add_amount(post, money, options)
106
- add_credit_card_or_reference(post, credit_card_or_reference)
107
- add_additional_params(:authorize, post, options)
102
+ def authorization_params(money, credit_card_or_reference, options = {})
103
+ post = {}
108
104
 
109
- post
110
- end
105
+ add_amount(post, money, options)
106
+ add_credit_card_or_reference(post, credit_card_or_reference, options)
107
+ add_additional_params(:authorize, post, options)
111
108
 
112
- def capture_params(money, credit_card, options = {})
113
- post = {}
109
+ post
110
+ end
114
111
 
115
- add_amount(post, money, options)
116
- add_additional_params(:capture, post, options)
112
+ def capture_params(money, credit_card, options = {})
113
+ post = {}
117
114
 
118
- post
119
- end
115
+ add_amount(post, money, options)
116
+ add_additional_params(:capture, post, options)
120
117
 
121
- def create_store(options = {})
122
- post = {}
123
- commit('/cards', post)
124
- end
118
+ post
119
+ end
125
120
 
126
- def authorize_store(identification, credit_card, options = {})
127
- post = {}
121
+ def create_store(options = {})
122
+ post = {}
123
+ commit('/cards', post)
124
+ end
128
125
 
129
- add_credit_card_or_reference(post, credit_card, options)
130
- commit(synchronized_path("/cards/#{identification}/authorize"), post)
131
- end
126
+ def authorize_store(identification, credit_card, options = {})
127
+ post = {}
132
128
 
133
- def create_token(identification, options)
134
- post = {}
135
- commit(synchronized_path("/cards/#{identification}/tokens"), post)
136
- end
129
+ add_credit_card_or_reference(post, credit_card, options)
130
+ commit(synchronized_path("/cards/#{identification}/authorize"), post)
131
+ end
137
132
 
138
- def create_payment(money, options = {})
139
- post = {}
140
- add_currency(post, money, options)
141
- add_invoice(post, options)
142
- commit('/payments', post)
143
- end
133
+ def create_token(identification, options)
134
+ post = {}
135
+ commit(synchronized_path("/cards/#{identification}/tokens"), post)
136
+ end
144
137
 
145
- def commit(action, params = {})
146
- success = false
147
- begin
148
- response = parse(ssl_post(self.live_url + action, params.to_json, headers))
149
- success = successful?(response)
150
- rescue ResponseError => e
151
- response = response_error(e.response.body)
152
- rescue JSON::ParserError
153
- response = json_error(response)
154
- end
138
+ def create_payment(money, options = {})
139
+ post = {}
140
+ add_currency(post, money, options)
141
+ add_invoice(post, options)
142
+ commit('/payments', post)
143
+ end
155
144
 
156
- Response.new(success, message_from(success, response), response,
157
- :test => test?,
158
- :authorization => authorization_from(response)
159
- )
145
+ def commit(action, params = {})
146
+ success = false
147
+ begin
148
+ response = parse(ssl_post(self.live_url + action, params.to_json, headers))
149
+ success = successful?(response)
150
+ rescue ResponseError => e
151
+ response = response_error(e.response.body)
152
+ rescue JSON::ParserError
153
+ response = json_error(response)
160
154
  end
161
155
 
162
- def authorization_from(response)
163
- if response["token"]
164
- response["token"].to_s
165
- else
166
- response["id"].to_s
167
- end
168
- end
156
+ Response.new(success, message_from(success, response), response,
157
+ test: test?,
158
+ authorization: authorization_from(response))
159
+ end
169
160
 
170
- def add_currency(post, money, options)
171
- post[:currency] = options[:currency] || currency(money)
161
+ def authorization_from(response)
162
+ if response['token']
163
+ response['token'].to_s
164
+ else
165
+ response['id'].to_s
172
166
  end
167
+ end
173
168
 
174
- def add_amount(post, money, options)
175
- post[:amount] = options[:amount] || amount(money)
176
- end
169
+ def add_currency(post, money, options)
170
+ post[:currency] = options[:currency] || currency(money)
171
+ end
177
172
 
178
- def add_autocapture(post, value)
179
- post[:auto_capture] = value
180
- end
173
+ def add_amount(post, money, options)
174
+ post[:amount] = options[:amount] || amount(money)
175
+ end
181
176
 
182
- def add_order_id(post, options)
183
- requires!(options, :order_id)
184
- post[:order_id] = format_order_id(options[:order_id])
185
- end
177
+ def add_autocapture(post, value)
178
+ post[:auto_capture] = value
179
+ end
186
180
 
187
- def add_invoice(post, options)
188
- add_order_id(post, options)
181
+ def add_order_id(post, options)
182
+ requires!(options, :order_id)
183
+ post[:order_id] = format_order_id(options[:order_id])
184
+ end
189
185
 
190
- if options[:billing_address]
191
- post[:invoice_address] = map_address(options[:billing_address])
192
- end
186
+ def add_invoice(post, options)
187
+ add_order_id(post, options)
193
188
 
194
- if options[:shipping_address]
195
- post[:shipping_address] = map_address(options[:shipping_address])
196
- end
189
+ post[:invoice_address] = map_address(options[:billing_address]) if options[:billing_address]
197
190
 
198
- [:metadata, :branding_id, :variables].each do |field|
199
- post[field] = options[field] if options[field]
200
- end
191
+ post[:shipping_address] = map_address(options[:shipping_address]) if options[:shipping_address]
192
+
193
+ %i[metadata branding_id variables].each do |field|
194
+ post[field] = options[field] if options[field]
201
195
  end
196
+ end
202
197
 
203
- def add_additional_params(action, post, options = {})
204
- MD5_CHECK_FIELDS[API_VERSION][action].each do |key|
205
- key = key.to_sym
206
- post[key] = options[key] if options[key]
207
- end
198
+ def add_additional_params(action, post, options = {})
199
+ MD5_CHECK_FIELDS[API_VERSION][action].each do |key|
200
+ key = key.to_sym
201
+ post[key] = options[key] if options[key]
208
202
  end
203
+ end
209
204
 
210
- def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
211
- post[:card] ||= {}
212
- if credit_card_or_reference.is_a?(String)
213
- post[:card][:token] = credit_card_or_reference
214
- else
215
- post[:card][:number] = credit_card_or_reference.number
216
- post[:card][:cvd] = credit_card_or_reference.verification_value
217
- post[:card][:expiration] = expdate(credit_card_or_reference)
218
- post[:card][:issued_to] = credit_card_or_reference.name
219
- end
205
+ def add_credit_card_or_reference(post, credit_card_or_reference, options = {})
206
+ post[:card] ||= {}
207
+ if credit_card_or_reference.is_a?(String)
208
+ post[:card][:token] = credit_card_or_reference
209
+ else
210
+ post[:card][:number] = credit_card_or_reference.number
211
+ post[:card][:cvd] = credit_card_or_reference.verification_value
212
+ post[:card][:expiration] = expdate(credit_card_or_reference)
213
+ post[:card][:issued_to] = credit_card_or_reference.name
220
214
  end
221
215
 
222
- def parse(body)
223
- JSON.parse(body)
216
+ if options[:three_d_secure]
217
+ post[:card][:cavv] = options.dig(:three_d_secure, :cavv)
218
+ post[:card][:eci] = options.dig(:three_d_secure, :eci)
219
+ post[:card][:xav] = options.dig(:three_d_secure, :xid)
224
220
  end
221
+ end
225
222
 
226
- def successful?(response)
227
- has_error = response['errors']
228
- invalid_code = invalid_operation_code?(response)
223
+ def parse(body)
224
+ JSON.parse(body)
225
+ end
229
226
 
230
- !(has_error || invalid_code)
231
- end
227
+ def successful?(response)
228
+ has_error = response['errors']
229
+ invalid_code = invalid_operation_code?(response)
232
230
 
233
- def message_from(success, response)
234
- success ? 'OK' : (response['message'] || invalid_operation_message(response) || "Unknown error - please contact QuickPay")
235
- end
231
+ !(has_error || invalid_code)
232
+ end
236
233
 
237
- def invalid_operation_code?(response)
238
- if response['operations']
239
- operation = response['operations'].last
240
- operation && operation['qp_status_code'] != "20000"
241
- end
242
- end
234
+ def message_from(success, response)
235
+ success ? 'OK' : (response['message'] || invalid_operation_message(response) || 'Unknown error - please contact QuickPay')
236
+ end
243
237
 
244
- def invalid_operation_message(response)
245
- response['operations'] && response['operations'].last['qp_status_msg']
238
+ def invalid_operation_code?(response)
239
+ if response['operations']
240
+ operation = response['operations'].last
241
+ operation && operation['qp_status_code'] != '20000'
246
242
  end
243
+ end
247
244
 
248
- def map_address(address)
249
- return {} if address.nil?
250
- requires!(address, :name, :address1, :city, :zip, :country)
251
- country = Country.find(address[:country])
252
- mapped = {
253
- :name => address[:name],
254
- :street => address[:address1],
255
- :city => address[:city],
256
- :region => address[:address2],
257
- :zip_code => address[:zip],
258
- :country_code => country.code(:alpha3).value
259
- }
260
- mapped
261
- end
245
+ def invalid_operation_message(response)
246
+ response['operations'] && response['operations'].last['qp_status_msg']
247
+ end
262
248
 
263
- def format_order_id(order_id)
264
- truncate(order_id.to_s.gsub(/#/, ''), 20)
265
- end
249
+ def map_address(address)
250
+ return {} if address.nil?
251
+
252
+ requires!(address, :name, :address1, :city, :zip, :country)
253
+ country = Country.find(address[:country])
254
+ mapped = {
255
+ name: address[:name],
256
+ street: address[:address1],
257
+ city: address[:city],
258
+ region: address[:address2],
259
+ zip_code: address[:zip],
260
+ country_code: country.code(:alpha3).value
261
+ }
262
+ mapped
263
+ end
266
264
 
267
- def headers
268
- auth = Base64.strict_encode64(":#{@options[:api_key]}")
269
- {
270
- "Authorization" => "Basic " + auth,
271
- "User-Agent" => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
272
- "Accept" => "application/json",
273
- "Accept-Version" => "v#{API_VERSION}",
274
- "Content-Type" => "application/json"
275
- }
276
- end
265
+ def format_order_id(order_id)
266
+ truncate(order_id.to_s.delete('#'), 20)
267
+ end
277
268
 
278
- def response_error(raw_response)
279
- begin
280
- parse(raw_response)
281
- rescue JSON::ParserError
282
- json_error(raw_response)
283
- end
284
- end
269
+ def headers
270
+ auth = Base64.strict_encode64(":#{@options[:api_key]}")
271
+ {
272
+ 'Authorization' => 'Basic ' + auth,
273
+ 'User-Agent' => "Quickpay-v#{API_VERSION} ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
274
+ 'Accept' => 'application/json',
275
+ 'Accept-Version' => "v#{API_VERSION}",
276
+ 'Content-Type' => 'application/json'
277
+ }
278
+ end
285
279
 
286
- def json_error(raw_response)
287
- msg = 'Invalid response received from the Quickpay API.'
288
- msg += " (The raw response returned by the API was #{raw_response.inspect})"
289
- { "message" => msg }
290
- end
280
+ def response_error(raw_response)
281
+ parse(raw_response)
282
+ rescue JSON::ParserError
283
+ json_error(raw_response)
284
+ end
291
285
 
292
- def synchronized_path(path)
293
- "#{path}?synchronized"
294
- end
286
+ def json_error(raw_response)
287
+ msg = 'Invalid response received from the Quickpay API.'
288
+ msg += " (The raw response returned by the API was #{raw_response.inspect})"
289
+ { 'message' => msg }
290
+ end
295
291
 
292
+ def synchronized_path(path)
293
+ "#{path}?synchronized"
294
+ end
296
295
  end
297
-
298
296
  end
299
297
  end
@@ -6,7 +6,7 @@ module ActiveMerchant #:nodoc:
6
6
  module Billing #:nodoc:
7
7
  class QuickpayV4to7Gateway < Gateway
8
8
  include QuickpayCommon
9
- self.live_url = self.test_url = 'https://secure.quickpay.dk/api'
9
+ self.live_url = self.test_url = 'https://secure.quickpay.dk/api'
10
10
  APPROVED = '000'
11
11
 
12
12
  # The login is the QuickpayId
@@ -136,11 +136,12 @@ module ActiveMerchant #:nodoc:
136
136
  end
137
137
 
138
138
  def add_description(post, options)
139
- post[:description] = options[:description] || "Description"
139
+ post[:description] = options[:description] || 'Description'
140
140
  end
141
141
 
142
142
  def add_testmode(post)
143
143
  return if post[:transaction].present?
144
+
144
145
  post[:testmode] = test? ? '1' : '0'
145
146
  end
146
147
 
@@ -164,9 +165,8 @@ module ActiveMerchant #:nodoc:
164
165
  response = parse(ssl_post(self.live_url, post_data(action, params)))
165
166
 
166
167
  Response.new(successful?(response), message_from(response), response,
167
- :test => test?,
168
- :authorization => response[:transaction]
169
- )
168
+ test: test?,
169
+ authorization: response[:transaction])
170
170
  end
171
171
 
172
172
  def successful?(response)
@@ -196,7 +196,7 @@ module ActiveMerchant #:nodoc:
196
196
  params[:apikey] = @options[:apikey] if @options[:apikey]
197
197
  params[:md5check] = generate_check_hash(action, params)
198
198
 
199
- params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
199
+ params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
200
200
  end
201
201
 
202
202
  def generate_check_hash(action, params)
@@ -219,9 +219,8 @@ module ActiveMerchant #:nodoc:
219
219
 
220
220
  # Limited to 20 digits max
221
221
  def format_order_number(number)
222
- number.to_s.gsub(/[^\w]/, '').rjust(4, "0")[0...20]
222
+ number.to_s.gsub(/[^\w]/, '').rjust(4, '0')[0...20]
223
223
  end
224
224
  end
225
225
  end
226
226
  end
227
-
@@ -10,7 +10,7 @@ module ActiveMerchant #:nodoc:
10
10
  self.abstract_class = true
11
11
 
12
12
  def self.new(options = {})
13
- options.fetch(:login) { raise ArgumentError.new("Missing required parameter: login") }
13
+ options.fetch(:login) { raise ArgumentError.new('Missing required parameter: login') }
14
14
 
15
15
  version = options[:login].to_i < 10000000 ? 10 : 7
16
16
  if version <= 7
@@ -19,8 +19,6 @@ module ActiveMerchant #:nodoc:
19
19
  QuickpayV10Gateway.new(options)
20
20
  end
21
21
  end
22
-
23
22
  end
24
23
  end
25
24
  end
26
-