activemerchant 1.133.0 → 1.138.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (285) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +450 -0
  3. data/CONTRIBUTORS +1 -0
  4. data/lib/active_merchant/billing/apple_pay_payment_token.rb +2 -2
  5. data/lib/active_merchant/billing/base.rb +2 -2
  6. data/lib/active_merchant/billing/check.rb +16 -4
  7. data/lib/active_merchant/billing/compatibility.rb +4 -4
  8. data/lib/active_merchant/billing/credit_card.rb +35 -16
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +13 -2
  10. data/lib/active_merchant/billing/credit_card_methods.rb +74 -19
  11. data/lib/active_merchant/billing/gateway.rb +22 -2
  12. data/lib/active_merchant/billing/gateways/adyen.rb +282 -87
  13. data/lib/active_merchant/billing/gateways/airwallex.rb +46 -25
  14. data/lib/active_merchant/billing/gateways/alelo.rb +29 -11
  15. data/lib/active_merchant/billing/gateways/allied_wallet.rb +2 -2
  16. data/lib/active_merchant/billing/gateways/authorize_net.rb +49 -41
  17. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +14 -10
  18. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +3 -5
  19. data/lib/active_merchant/billing/gateways/axcessms.rb +9 -5
  20. data/lib/active_merchant/billing/gateways/balanced.rb +2 -2
  21. data/lib/active_merchant/billing/gateways/bambora_apac.rb +2 -2
  22. data/lib/active_merchant/billing/gateways/bank_frick.rb +2 -2
  23. data/lib/active_merchant/billing/gateways/banwire.rb +6 -4
  24. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +8 -8
  25. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +2 -2
  26. data/lib/active_merchant/billing/gateways/be2bill.rb +2 -2
  27. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +12 -8
  28. data/lib/active_merchant/billing/gateways/beanstream.rb +2 -2
  29. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +2 -2
  30. data/lib/active_merchant/billing/gateways/blue_pay.rb +15 -7
  31. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  32. data/lib/active_merchant/billing/gateways/bogus.rb +2 -2
  33. data/lib/active_merchant/billing/gateways/borgun.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/bpoint.rb +2 -2
  35. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +3 -1
  36. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +68 -23
  37. data/lib/active_merchant/billing/gateways/braintree.rb +2 -2
  38. data/lib/active_merchant/billing/gateways/braintree_blue.rb +266 -89
  39. data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -3
  40. data/lib/active_merchant/billing/gateways/bridge_pay.rb +2 -2
  41. data/lib/active_merchant/billing/gateways/cams.rb +2 -2
  42. data/lib/active_merchant/billing/gateways/card_connect.rb +7 -4
  43. data/lib/active_merchant/billing/gateways/card_save.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +12 -13
  45. data/lib/active_merchant/billing/gateways/cardknox.rb +2 -2
  46. data/lib/active_merchant/billing/gateways/cardprocess.rb +2 -2
  47. data/lib/active_merchant/billing/gateways/cashnet.rb +4 -4
  48. data/lib/active_merchant/billing/gateways/cc5.rb +2 -2
  49. data/lib/active_merchant/billing/gateways/cecabank/cecabank_common.rb +36 -0
  50. data/lib/active_merchant/billing/gateways/cecabank/cecabank_json.rb +331 -0
  51. data/lib/active_merchant/billing/gateways/cecabank/cecabank_xml.rb +220 -0
  52. data/lib/active_merchant/billing/gateways/cecabank.rb +9 -242
  53. data/lib/active_merchant/billing/gateways/cenpos.rb +9 -3
  54. data/lib/active_merchant/billing/gateways/checkout.rb +5 -5
  55. data/lib/active_merchant/billing/gateways/checkout_v2.rb +362 -50
  56. data/lib/active_merchant/billing/gateways/clearhaus.rb +2 -2
  57. data/lib/active_merchant/billing/gateways/commerce_hub.rb +117 -35
  58. data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
  59. data/lib/active_merchant/billing/gateways/conekta.rb +2 -2
  60. data/lib/active_merchant/billing/gateways/creditcall.rb +2 -2
  61. data/lib/active_merchant/billing/gateways/credorax.rb +109 -20
  62. data/lib/active_merchant/billing/gateways/ct_payment.rb +6 -6
  63. data/lib/active_merchant/billing/gateways/culqi.rb +2 -2
  64. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +2 -2
  65. data/lib/active_merchant/billing/gateways/cyber_source.rb +379 -100
  66. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +147 -76
  67. data/lib/active_merchant/billing/gateways/d_local.rb +45 -22
  68. data/lib/active_merchant/billing/gateways/data_cash.rb +22 -18
  69. data/lib/active_merchant/billing/gateways/datatrans.rb +284 -0
  70. data/lib/active_merchant/billing/gateways/decidir.rb +82 -46
  71. data/lib/active_merchant/billing/gateways/decidir_plus.rb +31 -35
  72. data/lib/active_merchant/billing/gateways/deepstack.rb +382 -0
  73. data/lib/active_merchant/billing/gateways/dibs.rb +3 -3
  74. data/lib/active_merchant/billing/gateways/digitzs.rb +2 -2
  75. data/lib/active_merchant/billing/gateways/ebanx.rb +116 -68
  76. data/lib/active_merchant/billing/gateways/efsnet.rb +13 -8
  77. data/lib/active_merchant/billing/gateways/elavon.rb +80 -47
  78. data/lib/active_merchant/billing/gateways/element.rb +39 -10
  79. data/lib/active_merchant/billing/gateways/epay.rb +8 -4
  80. data/lib/active_merchant/billing/gateways/evo_ca.rb +8 -4
  81. data/lib/active_merchant/billing/gateways/eway.rb +6 -4
  82. data/lib/active_merchant/billing/gateways/eway_managed.rb +8 -4
  83. data/lib/active_merchant/billing/gateways/eway_rapid.rb +3 -3
  84. data/lib/active_merchant/billing/gateways/exact.rb +8 -4
  85. data/lib/active_merchant/billing/gateways/fat_zebra.rb +37 -7
  86. data/lib/active_merchant/billing/gateways/federated_canada.rb +8 -4
  87. data/lib/active_merchant/billing/gateways/finansbank.rb +2 -2
  88. data/lib/active_merchant/billing/gateways/first_giving.rb +2 -2
  89. data/lib/active_merchant/billing/gateways/first_pay/first_pay_common.rb +15 -0
  90. data/lib/active_merchant/billing/gateways/first_pay/first_pay_json.rb +190 -0
  91. data/lib/active_merchant/billing/gateways/first_pay/first_pay_xml.rb +183 -0
  92. data/lib/active_merchant/billing/gateways/first_pay.rb +8 -174
  93. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +8 -4
  94. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +9 -5
  95. data/lib/active_merchant/billing/gateways/flex_charge.rb +359 -0
  96. data/lib/active_merchant/billing/gateways/flo2cash.rb +4 -2
  97. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  98. data/lib/active_merchant/billing/gateways/forte.rb +6 -4
  99. data/lib/active_merchant/billing/gateways/fortis.rb +347 -0
  100. data/lib/active_merchant/billing/gateways/garanti.rb +6 -4
  101. data/lib/active_merchant/billing/gateways/global_collect.rb +69 -50
  102. data/lib/active_merchant/billing/gateways/global_transport.rb +2 -2
  103. data/lib/active_merchant/billing/gateways/hdfc.rb +2 -2
  104. data/lib/active_merchant/billing/gateways/hi_pay.rb +287 -0
  105. data/lib/active_merchant/billing/gateways/hps.rb +40 -47
  106. data/lib/active_merchant/billing/gateways/iats_payments.rb +9 -4
  107. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +2 -2
  108. data/lib/active_merchant/billing/gateways/inspire.rb +8 -6
  109. data/lib/active_merchant/billing/gateways/instapay.rb +9 -6
  110. data/lib/active_merchant/billing/gateways/ipg.rb +14 -10
  111. data/lib/active_merchant/billing/gateways/ipp.rb +2 -2
  112. data/lib/active_merchant/billing/gateways/iridium.rb +18 -8
  113. data/lib/active_merchant/billing/gateways/itransact.rb +8 -4
  114. data/lib/active_merchant/billing/gateways/iveri.rb +12 -9
  115. data/lib/active_merchant/billing/gateways/ixopay.rb +4 -4
  116. data/lib/active_merchant/billing/gateways/jetpay.rb +6 -4
  117. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +9 -6
  118. data/lib/active_merchant/billing/gateways/komoju.rb +2 -2
  119. data/lib/active_merchant/billing/gateways/kushki.rb +79 -16
  120. data/lib/active_merchant/billing/gateways/latitude19.rb +2 -2
  121. data/lib/active_merchant/billing/gateways/linkpoint.rb +8 -4
  122. data/lib/active_merchant/billing/gateways/litle.rb +37 -54
  123. data/lib/active_merchant/billing/gateways/loan_payment_pro.rb +267 -0
  124. data/lib/active_merchant/billing/gateways/loan_payment_pro_ach.rb +93 -0
  125. data/lib/active_merchant/billing/gateways/mastercard.rb +4 -4
  126. data/lib/active_merchant/billing/gateways/maxipago.rb +4 -4
  127. data/lib/active_merchant/billing/gateways/mercado_pago.rb +32 -11
  128. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +10 -7
  129. data/lib/active_merchant/billing/gateways/merchant_one.rb +2 -2
  130. data/lib/active_merchant/billing/gateways/merchant_partners.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/merchant_ware.rb +13 -6
  132. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +13 -6
  133. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +21 -5
  134. data/lib/active_merchant/billing/gateways/mercury.rb +11 -5
  135. data/lib/active_merchant/billing/gateways/metrics_global.rb +10 -8
  136. data/lib/active_merchant/billing/gateways/micropayment.rb +2 -2
  137. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -6
  138. data/lib/active_merchant/billing/gateways/migs.rb +8 -4
  139. data/lib/active_merchant/billing/gateways/mit.rb +10 -5
  140. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  141. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +21 -13
  142. data/lib/active_merchant/billing/gateways/moka.rb +2 -2
  143. data/lib/active_merchant/billing/gateways/monei.rb +3 -3
  144. data/lib/active_merchant/billing/gateways/moneris.rb +11 -5
  145. data/lib/active_merchant/billing/gateways/money_movers.rb +8 -4
  146. data/lib/active_merchant/billing/gateways/multi_pay.rb +267 -0
  147. data/lib/active_merchant/billing/gateways/mundipagg.rb +5 -3
  148. data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -10
  149. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +2 -2
  150. data/lib/active_merchant/billing/gateways/net_registry.rb +6 -2
  151. data/lib/active_merchant/billing/gateways/netaxept.rb +4 -4
  152. data/lib/active_merchant/billing/gateways/netbanx.rb +4 -6
  153. data/lib/active_merchant/billing/gateways/netbilling.rb +8 -4
  154. data/lib/active_merchant/billing/gateways/netpay.rb +2 -2
  155. data/lib/active_merchant/billing/gateways/network_merchants.rb +9 -5
  156. data/lib/active_merchant/billing/gateways/nmi.rb +29 -8
  157. data/lib/active_merchant/billing/gateways/nuvei.rb +573 -0
  158. data/lib/active_merchant/billing/gateways/ogone.rb +8 -4
  159. data/lib/active_merchant/billing/gateways/omise.rb +2 -2
  160. data/lib/active_merchant/billing/gateways/openpay.rb +6 -4
  161. data/lib/active_merchant/billing/gateways/opp.rb +3 -4
  162. data/lib/active_merchant/billing/gateways/optimal_payment.rb +12 -6
  163. data/lib/active_merchant/billing/gateways/orbital/orbital_codes.rb +273 -0
  164. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
  165. data/lib/active_merchant/billing/gateways/orbital.rb +114 -94
  166. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +9 -6
  167. data/lib/active_merchant/billing/gateways/pagarme.rb +2 -2
  168. data/lib/active_merchant/billing/gateways/pago_facil.rb +2 -2
  169. data/lib/active_merchant/billing/gateways/pay_arc.rb +9 -7
  170. data/lib/active_merchant/billing/gateways/pay_conex.rb +6 -4
  171. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +8 -4
  172. data/lib/active_merchant/billing/gateways/pay_hub.rb +7 -5
  173. data/lib/active_merchant/billing/gateways/pay_junction.rb +8 -4
  174. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +2 -2
  175. data/lib/active_merchant/billing/gateways/pay_secure.rb +8 -4
  176. data/lib/active_merchant/billing/gateways/pay_trace.rb +36 -22
  177. data/lib/active_merchant/billing/gateways/paybox_direct.rb +14 -14
  178. data/lib/active_merchant/billing/gateways/payeezy.rb +26 -13
  179. data/lib/active_merchant/billing/gateways/payex.rb +8 -6
  180. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +3 -3
  181. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +2 -2
  183. data/lib/active_merchant/billing/gateways/payflow.rb +12 -11
  184. data/lib/active_merchant/billing/gateways/payflow_express.rb +2 -2
  185. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -2
  186. data/lib/active_merchant/billing/gateways/payflow_uk.rb +2 -2
  187. data/lib/active_merchant/billing/gateways/payment_express.rb +10 -6
  188. data/lib/active_merchant/billing/gateways/paymentez.rb +30 -16
  189. data/lib/active_merchant/billing/gateways/paymill.rb +6 -4
  190. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +17 -12
  191. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +2 -2
  192. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +2 -2
  193. data/lib/active_merchant/billing/gateways/paypal.rb +4 -2
  194. data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
  195. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  196. data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -2
  197. data/lib/active_merchant/billing/gateways/paysafe.rb +48 -24
  198. data/lib/active_merchant/billing/gateways/payscout.rb +9 -6
  199. data/lib/active_merchant/billing/gateways/paystation.rb +9 -5
  200. data/lib/active_merchant/billing/gateways/payu_in.rb +2 -2
  201. data/lib/active_merchant/billing/gateways/payu_latam.rb +7 -5
  202. data/lib/active_merchant/billing/gateways/payway.rb +6 -2
  203. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +6 -6
  204. data/lib/active_merchant/billing/gateways/pin.rb +126 -41
  205. data/lib/active_merchant/billing/gateways/plexo.rb +71 -20
  206. data/lib/active_merchant/billing/gateways/plugnpay.rb +6 -2
  207. data/lib/active_merchant/billing/gateways/priority.rb +29 -24
  208. data/lib/active_merchant/billing/gateways/pro_pay.rb +2 -2
  209. data/lib/active_merchant/billing/gateways/psigate.rb +8 -4
  210. data/lib/active_merchant/billing/gateways/psl_card.rb +6 -2
  211. data/lib/active_merchant/billing/gateways/qbms.rb +9 -5
  212. data/lib/active_merchant/billing/gateways/quantum.rb +9 -5
  213. data/lib/active_merchant/billing/gateways/quickbooks.rb +27 -17
  214. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +7 -4
  215. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +8 -4
  216. data/lib/active_merchant/billing/gateways/quickpay.rb +2 -2
  217. data/lib/active_merchant/billing/gateways/qvalent.rb +2 -2
  218. data/lib/active_merchant/billing/gateways/rapyd.rb +172 -53
  219. data/lib/active_merchant/billing/gateways/reach.rb +16 -9
  220. data/lib/active_merchant/billing/gateways/redsys.rb +7 -15
  221. data/lib/active_merchant/billing/gateways/redsys_rest.rb +545 -0
  222. data/lib/active_merchant/billing/gateways/s5.rb +5 -5
  223. data/lib/active_merchant/billing/gateways/safe_charge.rb +47 -24
  224. data/lib/active_merchant/billing/gateways/sage.rb +14 -6
  225. data/lib/active_merchant/billing/gateways/sage_pay.rb +81 -7
  226. data/lib/active_merchant/billing/gateways/sallie_mae.rb +8 -4
  227. data/lib/active_merchant/billing/gateways/secure_net.rb +9 -5
  228. data/lib/active_merchant/billing/gateways/secure_pay.rb +10 -8
  229. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +25 -15
  230. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +8 -4
  231. data/lib/active_merchant/billing/gateways/securion_pay.rb +26 -12
  232. data/lib/active_merchant/billing/gateways/shift4.rb +34 -26
  233. data/lib/active_merchant/billing/gateways/shift4_v2.rb +117 -0
  234. data/lib/active_merchant/billing/gateways/simetrik.rb +26 -17
  235. data/lib/active_merchant/billing/gateways/skip_jack.rb +8 -4
  236. data/lib/active_merchant/billing/gateways/smart_ps.rb +10 -7
  237. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +6 -4
  238. data/lib/active_merchant/billing/gateways/spreedly_core.rb +4 -6
  239. data/lib/active_merchant/billing/gateways/stripe.rb +88 -84
  240. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +388 -77
  241. data/lib/active_merchant/billing/gateways/sum_up.rb +224 -0
  242. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +6 -4
  243. data/lib/active_merchant/billing/gateways/telr.rb +6 -7
  244. data/lib/active_merchant/billing/gateways/trans_first.rb +6 -4
  245. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +10 -18
  246. data/lib/active_merchant/billing/gateways/transact_pro.rb +3 -3
  247. data/lib/active_merchant/billing/gateways/transax.rb +2 -2
  248. data/lib/active_merchant/billing/gateways/transnational.rb +2 -2
  249. data/lib/active_merchant/billing/gateways/trexle.rb +2 -2
  250. data/lib/active_merchant/billing/gateways/trust_commerce.rb +9 -5
  251. data/lib/active_merchant/billing/gateways/usa_epay.rb +2 -2
  252. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +32 -31
  253. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +8 -4
  254. data/lib/active_merchant/billing/gateways/vanco.rb +2 -4
  255. data/lib/active_merchant/billing/gateways/vantiv_express.rb +668 -0
  256. data/lib/active_merchant/billing/gateways/verifi.rb +12 -8
  257. data/lib/active_merchant/billing/gateways/versa_pay.rb +307 -0
  258. data/lib/active_merchant/billing/gateways/viaklix.rb +8 -4
  259. data/lib/active_merchant/billing/gateways/visanet_peru.rb +5 -5
  260. data/lib/active_merchant/billing/gateways/vpos.rb +25 -13
  261. data/lib/active_merchant/billing/gateways/webpay.rb +3 -3
  262. data/lib/active_merchant/billing/gateways/wepay.rb +6 -4
  263. data/lib/active_merchant/billing/gateways/wirecard.rb +10 -6
  264. data/lib/active_merchant/billing/gateways/wompi.rb +14 -7
  265. data/lib/active_merchant/billing/gateways/world_net.rb +2 -2
  266. data/lib/active_merchant/billing/gateways/worldpay.rb +297 -113
  267. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +16 -13
  268. data/lib/active_merchant/billing/gateways/worldpay_us.rb +2 -2
  269. data/lib/active_merchant/billing/gateways/xpay.rb +244 -0
  270. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +15 -3
  271. data/lib/active_merchant/billing/payment_token.rb +2 -2
  272. data/lib/active_merchant/billing/response.rb +7 -6
  273. data/lib/active_merchant/billing.rb +1 -0
  274. data/lib/active_merchant/connection.rb +8 -20
  275. data/lib/active_merchant/country.rb +3 -1
  276. data/lib/active_merchant/errors.rb +12 -2
  277. data/lib/active_merchant/net_http_ssl_connection.rb +35 -0
  278. data/lib/active_merchant/posts_data.rb +19 -4
  279. data/lib/active_merchant/version.rb +1 -1
  280. data/lib/active_merchant/versionable.rb +29 -0
  281. data/lib/certs/cacert.pem +1326 -1491
  282. data/lib/support/gateway_support.rb +3 -3
  283. data/lib/support/ssl_verify.rb +6 -6
  284. data/lib/support/ssl_version.rb +8 -8
  285. metadata +35 -9
@@ -1,7 +1,7 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class PayTraceGateway < Gateway
4
- self.test_url = 'https://api.paytrace.com'
4
+ self.test_url = 'https://api.sandbox.paytrace.com'
5
5
  self.live_url = 'https://api.paytrace.com'
6
6
 
7
7
  self.supported_countries = ['US']
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  def initialize(options = {})
47
47
  requires!(options, :username, :password, :integrator_id)
48
48
  super
49
- acquire_access_token
49
+ acquire_access_token unless options[:access_token]
50
50
  end
51
51
 
52
52
  def purchase(money, payment_or_customer_id, options = {})
@@ -95,7 +95,7 @@ module ActiveMerchant #:nodoc:
95
95
 
96
96
  def capture(money, authorization, options = {})
97
97
  if visa_or_mastercard?(options)
98
- MultiResponse.run do |r|
98
+ MultiResponse.run(:use_first_response) do |r|
99
99
  r.process { commit(ENDPOINTS[:capture], build_capture_request(money, authorization, options)) }
100
100
  r.process { commit(ENDPOINTS[:"level_3_#{options[:visa_or_mastercard]}"], send_level_3_data(r, options)) }
101
101
  end
@@ -169,28 +169,35 @@ module ActiveMerchant #:nodoc:
169
169
  transcript.
170
170
  gsub(%r((Authorization: Bearer )[a-zA-Z0-9:_]+), '\1[FILTERED]').
171
171
  gsub(%r(("credit_card\\?":{\\?"number\\?":\\?")\d+), '\1[FILTERED]').
172
- gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]').
172
+ gsub(%r(("csc\\?":\\?")\d+), '\1[FILTERED]').
173
173
  gsub(%r(("username\\?":\\?")\w+@+\w+.+\w+), '\1[FILTERED]').
174
+ gsub(%r(("username\\?":\\?")\w+), '\1[FILTERED]').
174
175
  gsub(%r(("password\\?":\\?")\w+), '\1[FILTERED]').
175
176
  gsub(%r(("integrator_id\\?":\\?")\w+), '\1[FILTERED]')
176
177
  end
177
178
 
178
179
  def acquire_access_token
179
180
  post = {}
181
+ base_url = (test? ? test_url : live_url)
180
182
  post[:grant_type] = 'password'
181
183
  post[:username] = @options[:username]
182
184
  post[:password] = @options[:password]
183
185
  data = post.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
184
- url = live_url + '/oauth/token'
186
+ url = base_url + '/oauth/token'
185
187
  oauth_headers = {
186
188
  'Accept' => '*/*',
187
189
  'Content-Type' => 'application/x-www-form-urlencoded'
188
190
  }
189
191
  response = ssl_post(url, data, oauth_headers)
190
- json_response = JSON.parse(response)
192
+ json_response = parse(response)
191
193
 
192
- @options[:access_token] = json_response['access_token'] if json_response['access_token']
193
- response
194
+ if json_response.include?('error')
195
+ oauth_response = Response.new(false, json_response['error_description'])
196
+ raise OAuthResponseError.new(oauth_response)
197
+ else
198
+ @options[:access_token] = json_response['access_token'] if json_response['access_token']
199
+ response
200
+ end
194
201
  end
195
202
 
196
203
  private
@@ -237,17 +244,18 @@ module ActiveMerchant #:nodoc:
237
244
  end
238
245
 
239
246
  def customer_id?(payment_or_customer_id)
240
- payment_or_customer_id.class == String
247
+ payment_or_customer_id.instance_of?(String)
241
248
  end
242
249
 
243
250
  def string_literal_to_boolean(value)
244
- return value unless value.class == String
251
+ return value unless value.instance_of?(String)
245
252
 
246
253
  if value.casecmp('true').zero?
247
254
  true
248
255
  elsif value.casecmp('false').zero?
249
256
  false
250
- else return nil
257
+ else
258
+ return nil
251
259
  end
252
260
  end
253
261
 
@@ -258,15 +266,16 @@ module ActiveMerchant #:nodoc:
258
266
  end
259
267
 
260
268
  def add_address(post, creditcard, options)
261
- return unless options[:billing_address] || options[:address]
262
-
263
- address = options[:billing_address] || options[:address]
264
269
  post[:billing_address] = {}
270
+
271
+ if (address = options[:billing_address] || options[:address])
272
+ post[:billing_address][:street_address] = address[:address1]
273
+ post[:billing_address][:city] = address[:city]
274
+ post[:billing_address][:state] = address[:state]
275
+ post[:billing_address][:zip] = address[:zip]
276
+ end
277
+
265
278
  post[:billing_address][:name] = creditcard.name
266
- post[:billing_address][:street_address] = address[:address1]
267
- post[:billing_address][:city] = address[:city]
268
- post[:billing_address][:state] = address[:state]
269
- post[:billing_address][:zip] = address[:zip]
270
279
  end
271
280
 
272
281
  def add_amount(post, money, options)
@@ -283,6 +292,7 @@ module ActiveMerchant #:nodoc:
283
292
  post[:credit_card][:number] = payment.number
284
293
  post[:credit_card][:expiration_month] = payment.month
285
294
  post[:credit_card][:expiration_year] = payment.year
295
+ post[:csc] = payment.verification_value
286
296
  end
287
297
  end
288
298
 
@@ -373,6 +383,12 @@ module ActiveMerchant #:nodoc:
373
383
  url = base_url + '/v1/' + action
374
384
  raw_response = ssl_post(url, post_data(parameters), headers)
375
385
  response = parse(raw_response)
386
+ handle_final_response(action, response)
387
+ rescue JSON::ParserError
388
+ unparsable_response(raw_response)
389
+ end
390
+
391
+ def handle_final_response(action, response)
376
392
  success = success_from(response)
377
393
 
378
394
  Response.new(
@@ -385,8 +401,6 @@ module ActiveMerchant #:nodoc:
385
401
  test: test?,
386
402
  error_code: success ? nil : error_code_from(response)
387
403
  )
388
- rescue JSON::ParserError
389
- unparsable_response(raw_response)
390
404
  end
391
405
 
392
406
  def unparsable_response(raw_response)
@@ -1,5 +1,5 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class PayboxDirectGateway < Gateway
4
4
  class_attribute :live_url_backup
5
5
 
@@ -68,20 +68,20 @@ module ActiveMerchant #:nodoc:
68
68
  # ECI=02 => MasterCard success
69
69
  # ECI=05 => Visa, Amex or JCB success
70
70
  if options[:eci] == '02' || options[:eci] == '05'
71
- post[:"3DSTATUS"] = 'Y'
72
- post[:"3DENROLLED"] = 'Y'
73
- post[:"3DSIGNVAL"] = 'Y'
74
- post[:"3DERROR"] = '0'
71
+ post[:'3DSTATUS'] = 'Y'
72
+ post[:'3DENROLLED'] = 'Y'
73
+ post[:'3DSIGNVAL'] = 'Y'
74
+ post[:'3DERROR'] = '0'
75
75
  else
76
- post[:"3DSTATUS"] = 'N'
77
- post[:"3DENROLLED"] = 'N'
78
- post[:"3DSIGNVAL"] = 'N'
79
- post[:"3DERROR"] = '10000'
76
+ post[:'3DSTATUS'] = 'N'
77
+ post[:'3DENROLLED'] = 'N'
78
+ post[:'3DSIGNVAL'] = 'N'
79
+ post[:'3DERROR'] = '10000'
80
80
  end
81
- post[:"3DECI"] = options[:eci]
82
- post[:"3DXID"] = options[:xid]
83
- post[:"3DCAVV"] = options[:cavv]
84
- post[:"3DCAVVALGO"] = options[:cavv_algorithm]
81
+ post[:'3DECI'] = options[:eci]
82
+ post[:'3DXID'] = options[:xid]
83
+ post[:'3DCAVV'] = options[:cavv]
84
+ post[:'3DCAVVALGO'] = options[:cavv_algorithm]
85
85
  end
86
86
 
87
87
  def authorize(money, creditcard, options = {})
@@ -3,9 +3,11 @@ module ActiveMerchant
3
3
  class PayeezyGateway < Gateway
4
4
  class_attribute :integration_url
5
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'
6
+ version 'v1'
7
+
8
+ self.test_url = "https://api-cert.payeezy.com/#{fetch_version}"
9
+ self.integration_url = "https://api-cat.payeezy.com/#{fetch_version}"
10
+ self.live_url = "https://api.payeezy.com/#{fetch_version}"
9
11
 
10
12
  self.default_currency = 'USD'
11
13
  self.money_format = :cents
@@ -35,6 +37,8 @@ module ActiveMerchant
35
37
 
36
38
  add_invoice(params, options)
37
39
  add_reversal_id(params, options)
40
+ add_customer_ref(params, options)
41
+ add_reference_3(params, options)
38
42
  add_payment_method(params, payment_method, options)
39
43
  add_address(params, options)
40
44
  add_amount(params, amount, options)
@@ -51,6 +55,8 @@ module ActiveMerchant
51
55
 
52
56
  add_invoice(params, options)
53
57
  add_reversal_id(params, options)
58
+ add_customer_ref(params, options)
59
+ add_reference_3(params, options)
54
60
  add_payment_method(params, payment_method, options)
55
61
  add_address(params, options)
56
62
  add_amount(params, amount, options)
@@ -170,6 +176,14 @@ module ActiveMerchant
170
176
  params[:reversal_id] = options[:reversal_id] if options[:reversal_id]
171
177
  end
172
178
 
179
+ def add_customer_ref(params, options)
180
+ params[:customer_ref] = options[:customer_ref] if options[:customer_ref]
181
+ end
182
+
183
+ def add_reference_3(params, options)
184
+ params[:reference_3] = options[:reference_3] if options[:reference_3]
185
+ end
186
+
173
187
  def amount_from_authorization(authorization)
174
188
  authorization.split('|').last.to_i
175
189
  end
@@ -192,7 +206,7 @@ module ActiveMerchant
192
206
  params[:apikey] = @options[:apikey]
193
207
  params[:ta_token] = options[:ta_token]
194
208
  params[:type] = 'FDToken'
195
- params[:credit_card] = add_card_data(payment_method)
209
+ params[:credit_card] = add_card_data(payment_method, options)
196
210
  params[:auth] = 'false'
197
211
  end
198
212
 
@@ -208,7 +222,7 @@ module ActiveMerchant
208
222
  elsif payment_method.is_a? NetworkTokenizationCreditCard
209
223
  add_network_tokenization(params, payment_method, options)
210
224
  else
211
- add_creditcard(params, payment_method)
225
+ add_creditcard(params, payment_method, options)
212
226
  end
213
227
  end
214
228
 
@@ -245,17 +259,17 @@ module ActiveMerchant
245
259
  params[:token] = token
246
260
  end
247
261
 
248
- def add_creditcard(params, creditcard)
249
- credit_card = add_card_data(creditcard)
262
+ def add_creditcard(params, creditcard, options)
263
+ credit_card = add_card_data(creditcard, options)
250
264
 
251
265
  params[:method] = 'credit_card'
252
266
  params[:credit_card] = credit_card
253
267
  end
254
268
 
255
- def add_card_data(payment_method)
269
+ def add_card_data(payment_method, options = {})
256
270
  card = {}
257
271
  card[:type] = CREDIT_CARD_BRAND[payment_method.brand]
258
- card[:cardholder_name] = payment_method.name
272
+ card[:cardholder_name] = name_from_payment_method(payment_method) || name_from_address(options)
259
273
  card[:card_number] = payment_method.number
260
274
  card[:exp_date] = format_exp_date(payment_method.month, payment_method.year)
261
275
  card[:cvv] = payment_method.verification_value if payment_method.verification_value?
@@ -354,7 +368,7 @@ module ActiveMerchant
354
368
  def commit(params, options)
355
369
  url = base_url(options) + endpoint(params)
356
370
 
357
- if transaction_id = params.delete(:transaction_id)
371
+ if transaction_id = params.delete(:transaction_id)&.delete(' ')
358
372
  url = "#{url}/#{transaction_id}"
359
373
  end
360
374
 
@@ -412,8 +426,7 @@ module ActiveMerchant
412
426
  @options[:token],
413
427
  payload
414
428
  ].join('')
415
- hash = Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
416
- hash
429
+ Base64.strict_encode64(OpenSSL::HMAC.hexdigest('sha256', @options[:apisecret], message))
417
430
  end
418
431
 
419
432
  def headers(payload)
@@ -487,7 +500,7 @@ module ActiveMerchant
487
500
  end
488
501
  else
489
502
  [
490
- response['transaction_id'],
503
+ response['transaction_id']&.delete(' '),
491
504
  response['transaction_tag'],
492
505
  params[:method],
493
506
  response['amount']&.to_i
@@ -1,7 +1,7 @@
1
1
  require 'nokogiri'
2
2
 
3
- module ActiveMerchant #:nodoc:
4
- module Billing #:nodoc:
3
+ module ActiveMerchant # :nodoc:
4
+ module Billing # :nodoc:
5
5
  class PayexGateway < Gateway
6
6
  class_attribute :live_external_url, :test_external_url, :live_confined_url, :test_confined_url
7
7
 
@@ -245,7 +245,7 @@ module ActiveMerchant #:nodoc:
245
245
  properties = {
246
246
  accountNumber: @options[:account],
247
247
  transactionNumber: transaction_number,
248
- amount: amount,
248
+ amount:,
249
249
  orderId: options[:order_id] || '',
250
250
  vatAmount: options[:vat_amount] || 0,
251
251
  additionalValues: ''
@@ -262,7 +262,7 @@ module ActiveMerchant #:nodoc:
262
262
  properties = {
263
263
  accountNumber: @options[:account],
264
264
  transactionNumber: transaction_number,
265
- amount: amount,
265
+ amount:,
266
266
  orderId: options[:order_id],
267
267
  vatAmount: options[:vat_amount] || 0,
268
268
  additionalValues: ''
@@ -385,11 +385,13 @@ module ActiveMerchant #:nodoc:
385
385
  'Content-Length' => request.size.to_s
386
386
  }
387
387
  response = parse(ssl_post(url, request, headers))
388
- Response.new(success?(response),
388
+ Response.new(
389
+ success?(response),
389
390
  message_from(response),
390
391
  response,
391
392
  test: test?,
392
- authorization: build_authorization(response))
393
+ authorization: build_authorization(response)
394
+ )
393
395
  end
394
396
 
395
397
  def build_authorization(response)
@@ -1,6 +1,6 @@
1
1
  require 'nokogiri'
2
- module ActiveMerchant #:nodoc:
3
- module Billing #:nodoc:
2
+ module ActiveMerchant # :nodoc:
3
+ module Billing # :nodoc:
4
4
  module PayflowCommonAPI
5
5
  def self.included(base)
6
6
  base.default_currency = 'USD'
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  end
100
100
  xml.tag! 'RequestAuth' do
101
101
  xml.tag! 'UserPass' do
102
- xml.tag! 'User', !@options[:user].blank? ? @options[:user] : @options[:login]
102
+ xml.tag! 'User', @options[:user].blank? ? @options[:login] : @options[:user]
103
103
  xml.tag! 'Password', @options[:password]
104
104
  end
105
105
  end
@@ -1,5 +1,5 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class PayflowExpressResponse < Response
4
4
  def email
5
5
  @params['e_mail']
@@ -1,5 +1,5 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class PayflowResponse < Response
4
4
  def profile_id
5
5
  @params['profile_id']
@@ -3,8 +3,8 @@ require 'active_merchant/billing/gateways/payflow/payflow_common_api'
3
3
  require 'active_merchant/billing/gateways/payflow/payflow_response'
4
4
  require 'active_merchant/billing/gateways/payflow_express'
5
5
 
6
- module ActiveMerchant #:nodoc:
7
- module Billing #:nodoc:
6
+ module ActiveMerchant # :nodoc:
7
+ module Billing # :nodoc:
8
8
  class PayflowGateway < Gateway
9
9
  include PayflowCommonAPI
10
10
 
@@ -91,14 +91,14 @@ module ActiveMerchant #:nodoc:
91
91
  def cancel_recurring(profile_id)
92
92
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
93
93
 
94
- request = build_recurring_request(:cancel, 0, profile_id: profile_id)
94
+ request = build_recurring_request(:cancel, 0, profile_id:)
95
95
  commit(request, options.merge(request_type: :recurring))
96
96
  end
97
97
 
98
98
  def recurring_inquiry(profile_id, options = {})
99
99
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
100
100
 
101
- request = build_recurring_request(:inquiry, nil, options.update(profile_id: profile_id))
101
+ request = build_recurring_request(:inquiry, nil, options.update(profile_id:))
102
102
  commit(request, options.merge(request_type: :recurring))
103
103
  end
104
104
 
@@ -192,9 +192,7 @@ module ActiveMerchant #:nodoc:
192
192
  xml.tag! 'TotalAmt', amount(money), 'Currency' => options[:currency] || currency(money)
193
193
  end
194
194
 
195
- if %i(authorization purchase).include? action
196
- add_mpi_3ds(xml, options[:three_d_secure]) if options[:three_d_secure]
197
- end
195
+ add_mpi_3ds(xml, options[:three_d_secure]) if %i(authorization purchase).include?(action) && (options[:three_d_secure])
198
196
 
199
197
  xml.tag! 'Tender' do
200
198
  add_credit_card(xml, credit_card, options)
@@ -213,11 +211,11 @@ module ActiveMerchant #:nodoc:
213
211
 
214
212
  eci = three_d_secure_options[:eci]
215
213
  cavv = three_d_secure_options[:cavv]
216
- xid = three_d_secure_options[:xid]
217
214
  version = three_d_secure_options[:version]
218
215
 
219
216
  # 3DS2 only
220
217
  ds_transaction_id = three_d_secure_options[:ds_transaction_id] if version_2_or_newer?(three_d_secure_options)
218
+ xid = three_d_secure_options[:xid].presence || cavv
221
219
 
222
220
  xml.tag!('ExtData', 'Name' => 'AUTHENTICATION_ID', 'Value' => authentication_id) unless authentication_id.blank?
223
221
  xml.tag!('ExtData', 'Name' => 'AUTHENTICATION_STATUS', 'Value' => authentication_status) unless authentication_status.blank?
@@ -343,6 +341,9 @@ module ActiveMerchant #:nodoc:
343
341
  def add_three_d_secure(options, xml)
344
342
  if options[:three_d_secure]
345
343
  three_d_secure = options[:three_d_secure]
344
+ ds_transaction_id = three_d_secure[:ds_transaction_id]
345
+ xid = three_d_secure[:xid].presence || three_d_secure[:cavv]
346
+
346
347
  xml.tag! 'BuyerAuthResult' do
347
348
  authentication_status(three_d_secure, xml)
348
349
  xml.tag! 'AuthenticationId', three_d_secure[:authentication_id] unless three_d_secure[:authentication_id].blank?
@@ -350,9 +351,9 @@ module ActiveMerchant #:nodoc:
350
351
  xml.tag! 'ACSUrl', three_d_secure[:acs_url] unless three_d_secure[:acs_url].blank?
351
352
  xml.tag! 'ECI', three_d_secure[:eci] unless three_d_secure[:eci].blank?
352
353
  xml.tag! 'CAVV', three_d_secure[:cavv] unless three_d_secure[:cavv].blank?
353
- xml.tag! 'XID', three_d_secure[:xid] unless three_d_secure[:xid].blank?
354
+ xml.tag! 'XID', xid unless xid.blank?
354
355
  xml.tag! 'ThreeDSVersion', three_d_secure[:version] unless three_d_secure[:version].blank?
355
- xml.tag! 'DSTransactionID', three_d_secure[:ds_transaction_id] unless three_d_secure[:ds_transaction_id].blank?
356
+ xml.tag! 'DSTransactionID', ds_transaction_id unless ds_transaction_id.blank?
356
357
  end
357
358
  end
358
359
  end
@@ -419,7 +420,7 @@ module ActiveMerchant #:nodoc:
419
420
  end
420
421
 
421
422
  if action == :add
422
- xml.tag! 'Start', format_rp_date(options[:starting_at] || Date.today + 1)
423
+ xml.tag! 'Start', format_rp_date(options[:starting_at] || (Date.today + 1))
423
424
  else
424
425
  xml.tag! 'Start', format_rp_date(options[:starting_at]) unless options[:starting_at].nil?
425
426
  end
@@ -2,8 +2,8 @@ require 'active_merchant/billing/gateways/payflow/payflow_common_api'
2
2
  require 'active_merchant/billing/gateways/payflow/payflow_express_response'
3
3
  require 'active_merchant/billing/gateways/paypal_express_common'
4
4
 
5
- module ActiveMerchant #:nodoc:
6
- module Billing #:nodoc:
5
+ module ActiveMerchant # :nodoc:
6
+ module Billing # :nodoc:
7
7
  # ==General Parameters
8
8
  # The following parameters are supported for #setup_authorization, #setup_purchase, #authorize and #purchase transactions. I've read
9
9
  # in the docs that they recommend you pass the exact same parameters to both setup and authorize/purchase.
@@ -1,7 +1,7 @@
1
1
  require 'active_merchant/billing/gateways/payflow_express'
2
2
 
3
- module ActiveMerchant #:nodoc:
4
- module Billing #:nodoc:
3
+ module ActiveMerchant # :nodoc:
4
+ module Billing # :nodoc:
5
5
  class PayflowExpressUkGateway < PayflowExpressGateway
6
6
  self.default_currency = 'GBP'
7
7
  self.partner = 'PayPalUk'
@@ -1,8 +1,8 @@
1
1
  require 'active_merchant/billing/gateways/payflow'
2
2
  require 'active_merchant/billing/gateways/payflow_express_uk'
3
3
 
4
- module ActiveMerchant #:nodoc:
5
- module Billing #:nodoc:
4
+ module ActiveMerchant # :nodoc:
5
+ module Billing # :nodoc:
6
6
  class PayflowUkGateway < PayflowGateway
7
7
  self.default_currency = 'GBP'
8
8
  self.partner = 'PayPalUk'
@@ -1,7 +1,7 @@
1
1
  require 'rexml/document'
2
2
 
3
- module ActiveMerchant #:nodoc:
4
- module Billing #:nodoc:
3
+ module ActiveMerchant # :nodoc:
4
+ module Billing # :nodoc:
5
5
  # In NZ DPS supports ANZ, Westpac, National Bank, ASB and BNZ.
6
6
  # In Australia DPS supports ANZ, NAB, Westpac, CBA, St George and Bank of South Australia.
7
7
  # The Maybank in Malaysia is supported and the Citibank for Singapore.
@@ -20,8 +20,8 @@ module ActiveMerchant #:nodoc:
20
20
  self.homepage_url = 'https://www.windcave.com/'
21
21
  self.display_name = 'Windcave (formerly PaymentExpress)'
22
22
 
23
- self.live_url = 'https://sec.paymentexpress.com/pxpost.aspx'
24
- self.test_url = 'https://uat.paymentexpress.com/pxpost.aspx'
23
+ self.live_url = 'https://sec.windcave.com/pxpost.aspx'
24
+ self.test_url = 'https://uat.windcave.com/pxpost.aspx'
25
25
 
26
26
  APPROVED = '1'
27
27
 
@@ -306,9 +306,13 @@ module ActiveMerchant #:nodoc:
306
306
  response = parse(ssl_post(url, request.to_s))
307
307
 
308
308
  # Return a response
309
- PaymentExpressResponse.new(response[:success] == APPROVED, message_from(response), response,
309
+ PaymentExpressResponse.new(
310
+ response[:success] == APPROVED,
311
+ message_from(response),
312
+ response,
310
313
  test: response[:test_mode] == '1',
311
- authorization: authorization_from(action, response))
314
+ authorization: authorization_from(action, response)
315
+ )
312
316
  end
313
317
 
314
318
  # Response XML documentation: http://www.paymentexpress.com/technical_resources/ecommerce_nonhosted/pxpost.html#XMLTxnOutput
@@ -1,11 +1,13 @@
1
1
  require 'base64'
2
2
  require 'digest'
3
3
 
4
- module ActiveMerchant #:nodoc:
5
- module Billing #:nodoc:
6
- class PaymentezGateway < Gateway #:nodoc:
7
- self.test_url = 'https://ccapi-stg.paymentez.com/v2/'
8
- self.live_url = 'https://ccapi.paymentez.com/v2/'
4
+ module ActiveMerchant # :nodoc:
5
+ module Billing # :nodoc:
6
+ class PaymentezGateway < Gateway # :nodoc:
7
+ version 'v2'
8
+
9
+ self.test_url = "https://ccapi-stg.paymentez.com/#{fetch_version}/"
10
+ self.live_url = "https://ccapi.paymentez.com/#{fetch_version}/"
9
11
 
10
12
  self.supported_countries = %w[MX EC CO BR CL PE]
11
13
  self.default_currency = 'USD'
@@ -34,7 +36,7 @@ module ActiveMerchant #:nodoc:
34
36
  28 => :card_declined
35
37
  }.freeze
36
38
 
37
- SUCCESS_STATUS = ['success', 'pending', 1, 0]
39
+ SUCCESS_STATUS = ['APPROVED', 'PENDING', 'pending', 'success', 1, 0]
38
40
 
39
41
  CARD_MAPPING = {
40
42
  'visa' => 'vi',
@@ -218,7 +220,7 @@ module ActiveMerchant #:nodoc:
218
220
  xid: three_d_secure_options[:xid],
219
221
  eci: three_d_secure_options[:eci],
220
222
  version: three_d_secure_options[:version],
221
- reference_id: three_d_secure_options[:three_ds_server_trans_id],
223
+ reference_id: three_d_secure_options[:ds_transaction_id],
222
224
  status: three_d_secure_options[:authentication_response_status] || three_d_secure_options[:directory_response_status]
223
225
  }.compact
224
226
 
@@ -237,14 +239,14 @@ module ActiveMerchant #:nodoc:
237
239
 
238
240
  def commit_raw(object, action, parameters)
239
241
  if action == 'inquire'
240
- url = "#{(test? ? test_url : live_url)}#{object}/#{parameters}"
242
+ url = "#{test? ? test_url : live_url}#{object}/#{parameters}"
241
243
  begin
242
244
  raw_response = ssl_get(url, headers)
243
245
  rescue ResponseError => e
244
246
  raw_response = e.response.body
245
247
  end
246
248
  else
247
- url = "#{(test? ? test_url : live_url)}#{object}/#{action}"
249
+ url = "#{test? ? test_url : live_url}#{object}/#{action}"
248
250
  begin
249
251
  raw_response = ssl_post(url, post_data(parameters), headers)
250
252
  rescue ResponseError => e
@@ -262,7 +264,7 @@ module ActiveMerchant #:nodoc:
262
264
  def commit_transaction(action, parameters)
263
265
  response = commit_raw('transaction', action, parameters)
264
266
  Response.new(
265
- success_from(response),
267
+ success_from(response, action),
266
268
  message_from(response),
267
269
  response,
268
270
  authorization: authorization_from(response),
@@ -290,10 +292,22 @@ module ActiveMerchant #:nodoc:
290
292
  }
291
293
  end
292
294
 
293
- def success_from(response)
294
- return false if response.include?('error')
295
+ def success_from(response, action = nil)
296
+ transaction_current_status = response.dig('transaction', 'current_status')
297
+ request_status = response['status']
298
+ transaction_status = response.dig('transaction', 'status')
299
+ default_response = SUCCESS_STATUS.include?(transaction_current_status || request_status || transaction_status)
295
300
 
296
- SUCCESS_STATUS.include?(response['status'] || response['transaction']['status'])
301
+ case action
302
+ when 'refund'
303
+ if transaction_current_status && request_status
304
+ transaction_current_status&.upcase == 'CANCELLED' && request_status&.downcase == 'success'
305
+ else
306
+ default_response
307
+ end
308
+ else
309
+ default_response
310
+ end
297
311
  end
298
312
 
299
313
  def card_success_from(response)
@@ -314,10 +328,10 @@ module ActiveMerchant #:nodoc:
314
328
  end
315
329
 
316
330
  def card_message_from(response)
317
- if !response.include?('error')
318
- response['message'] || response['card']['message']
319
- else
331
+ if response.include?('error')
320
332
  response['error']['type']
333
+ else
334
+ response['message'] || response['card']['message']
321
335
  end
322
336
  end
323
337
 
@@ -1,6 +1,8 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class PaymillGateway < Gateway
4
+ version 'v2'
5
+
4
6
  self.supported_countries = %w(AD AT BE BG CH CY CZ DE DK EE ES FI FO FR GB
5
7
  GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT
6
8
  NL NO PL PT RO SE SI SK TR VA)
@@ -10,7 +12,7 @@ module ActiveMerchant #:nodoc:
10
12
  self.display_name = 'PAYMILL'
11
13
  self.money_format = :cents
12
14
  self.default_currency = 'EUR'
13
- self.live_url = 'https://api.paymill.com/v2/'
15
+ self.live_url = "https://api.paymill.com/#{fetch_version}/"
14
16
 
15
17
  def initialize(options = {})
16
18
  requires!(options, :public_key, :private_key)
@@ -192,7 +194,7 @@ module ActiveMerchant #:nodoc:
192
194
  end
193
195
 
194
196
  def save_card_url
195
- (test? ? 'https://test-token.paymill.com' : 'https://token-v2.paymill.de')
197
+ (test? ? 'https://test-token.paymill.com' : "https://token-#{fetch_version}.paymill.de")
196
198
  end
197
199
 
198
200
  def post_data(params)