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
@@ -0,0 +1,359 @@
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
+ class FlexChargeGateway < Gateway
4
+ version 'v1'
5
+
6
+ self.test_url = "https://api-sandbox.flex-charge.com/#{fetch_version}/"
7
+ self.live_url = "https://api.flex-charge.com/#{fetch_version}/"
8
+
9
+ self.supported_countries = ['US']
10
+ self.default_currency = 'USD'
11
+ self.supported_cardtypes = %i[visa master american_express discover]
12
+ self.money_format = :cents
13
+ self.homepage_url = 'https://www.flexfactor.io/'
14
+ self.display_name = 'FlexCharge'
15
+
16
+ ENDPOINTS_MAPPING = {
17
+ authenticate: 'oauth2/token',
18
+ purchase: 'evaluate',
19
+ sync: 'outcome',
20
+ refund: 'orders/%s/refund',
21
+ store: 'tokenize',
22
+ inquire: 'orders/%s',
23
+ capture: 'capture',
24
+ void: 'orders/%s/cancel'
25
+ }
26
+
27
+ SUCCESS_MESSAGES = %w(APPROVED CHALLENGE SUBMITTED SUCCESS PROCESSING CAPTUREREQUIRED).freeze
28
+
29
+ NO_ERROR_KEYS = %w(TraceId access_token token_expires).freeze
30
+
31
+ def initialize(options = {})
32
+ requires!(options, :app_key, :app_secret, :site_id, :mid)
33
+ super
34
+ end
35
+
36
+ def purchase(money, credit_card, options = {})
37
+ post = { transactionType: options.fetch(:transactionType, 'Purchase') }
38
+
39
+ add_merchant_data(post, options)
40
+ add_base_data(post, options)
41
+ add_invoice(post, money, credit_card, options)
42
+ add_mit_data(post, options)
43
+ add_payment_method(post, credit_card, address(options), options)
44
+ add_address(post, credit_card, address(options), :billingInformation)
45
+ add_address(post, credit_card, options[:shipping_address], :shippingInformation)
46
+ add_customer_data(post, options)
47
+ add_three_ds(post, options)
48
+ add_metadata(post, options)
49
+
50
+ commit(:purchase, post, nil, :post, options)
51
+ end
52
+
53
+ def authorize(money, credit_card, options = {})
54
+ options[:transactionType] = 'Authorization'
55
+ purchase(money, credit_card, options)
56
+ end
57
+
58
+ def capture(money, authorization, options = {})
59
+ order_id, currency = authorization.split('#')
60
+ post = {
61
+ idempotencyKey: options[:idempotency_key] || SecureRandom.uuid,
62
+ orderId: order_id,
63
+ amount: money,
64
+ currency:
65
+ }
66
+
67
+ commit(:capture, post, authorization)
68
+ end
69
+
70
+ def refund(money, authorization, options = {})
71
+ order_id, _currency = authorization.split('#')
72
+ self.money_format = :dollars
73
+ commit(:refund, { amountToRefund: localized_amount(money, 2).to_f }, order_id)
74
+ end
75
+
76
+ def void(authorization, options = {})
77
+ order_id, _currency = authorization.split('#')
78
+ commit(:void, {}, order_id)
79
+ end
80
+
81
+ def store(credit_card, options = {})
82
+ first_name, last_name = names_from_address(address(options), credit_card)
83
+
84
+ post = {
85
+ payment_method: {
86
+ credit_card: {
87
+ first_name:,
88
+ last_name:,
89
+ month: credit_card.month,
90
+ year: credit_card.year,
91
+ number: credit_card.number,
92
+ verification_value: credit_card.verification_value
93
+ }.compact
94
+ }
95
+ }
96
+ commit(:store, post)
97
+ end
98
+
99
+ def supports_scrubbing?
100
+ true
101
+ end
102
+
103
+ def scrub(transcript)
104
+ transcript.
105
+ gsub(%r((Authorization: Bearer )[a-zA-Z0-9._-]+)i, '\1[FILTERED]').
106
+ gsub(%r(("AppKey\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
107
+ gsub(%r(("AppSecret\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
108
+ gsub(%r(("accessToken\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
109
+ gsub(%r(("mid\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
110
+ gsub(%r(("siteId\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
111
+ gsub(%r(("environment\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
112
+ gsub(%r(("number\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
113
+ gsub(%r(("cardNumber\\?"\s*:\s*\\?")[^"]*)i, '\1[FILTERED]').
114
+ gsub(%r(("verification_value\\?":\\?")\d+), '\1[FILTERED]').
115
+ gsub(%r(("verificationValue\\?":\\?")\d+), '\1[FILTERED]')
116
+ end
117
+
118
+ def inquire(authorization, options = {})
119
+ order_id, _currency = authorization.split('#')
120
+ commit(:inquire, {}, order_id, :get)
121
+ end
122
+
123
+ def add_metadata(post, options)
124
+ post[:Source] = 'Spreedly'
125
+ post[:ExtraData] = options[:extra_data] if options[:extra_data].present?
126
+ end
127
+
128
+ private
129
+
130
+ def address(options)
131
+ options[:billing_address] || options[:address] || {}
132
+ end
133
+
134
+ def add_three_ds(post, options)
135
+ return unless three_d_secure = options[:three_d_secure]
136
+
137
+ post[:threeDSecure] = {
138
+ threeDsVersion: three_d_secure[:version],
139
+ EcommerceIndicator: three_d_secure[:eci],
140
+ authenticationValue: three_d_secure[:cavv],
141
+ directoryServerTransactionId: three_d_secure[:ds_transaction_id],
142
+ xid: three_d_secure[:xid],
143
+ authenticationValueAlgorithm: three_d_secure[:cavv_algorithm],
144
+ directoryResponseStatus: three_d_secure[:directory_response_status],
145
+ authenticationResponseStatus: three_d_secure[:authentication_response_status],
146
+ enrolled: three_d_secure[:enrolled]
147
+ }
148
+ end
149
+
150
+ def add_merchant_data(post, options)
151
+ post[:siteId] = @options[:site_id]
152
+ post[:mid] = @options[:mid]
153
+ end
154
+
155
+ def add_base_data(post, options)
156
+ post[:isDeclined] = cast_bool(options[:is_declined])
157
+ post[:orderId] = options[:order_id]
158
+ post[:idempotencyKey] = options[:idempotency_key] || SecureRandom.uuid
159
+ post[:senseKey] = options[:sense_key]
160
+ end
161
+
162
+ def add_mit_data(post, options)
163
+ return if options[:is_mit].nil?
164
+
165
+ post[:isMIT] = cast_bool(options[:is_mit])
166
+ post[:isRecurring] = cast_bool(options[:is_recurring])
167
+ post[:expiryDateUtc] = options[:mit_expiry_date_utc]
168
+ end
169
+
170
+ def add_customer_data(post, options)
171
+ post[:payer] = { email: options[:email] || 'NA', phone: phone_from(options) }.compact
172
+ end
173
+
174
+ def add_address(post, payment, address, address_type)
175
+ return unless address.present?
176
+
177
+ first_name, last_name = names_from_address(address, payment)
178
+
179
+ post[address_type] = {
180
+ firstName: first_name,
181
+ lastName: last_name,
182
+ country: address[:country],
183
+ phone: address[:phone],
184
+ countryCode: address[:country],
185
+ addressLine1: address[:address1],
186
+ state: address[:state],
187
+ city: address[:city],
188
+ zipCode: address[:zip]
189
+ }.compact
190
+ end
191
+
192
+ def add_invoice(post, money, credit_card, options)
193
+ post[:transaction] = {
194
+ id: options[:order_id],
195
+ dynamicDescriptor: options[:description],
196
+ timestamp: Time.now.utc.iso8601,
197
+ timezoneUtcOffset: options[:timezone_utc_offset],
198
+ amount: money,
199
+ currency: (options[:currency] || currency(money)),
200
+ responseCode: options[:response_code],
201
+ responseCodeSource: options[:response_code_source] || '',
202
+ avsResultCode: options[:avs_result_code],
203
+ cvvResultCode: options[:cvv_result_code],
204
+ cavvResultCode: options[:cavv_result_code],
205
+ cardNotPresent: credit_card.is_a?(String) ? false : credit_card.verification_value.blank?
206
+ }.compact
207
+ end
208
+
209
+ def add_payment_method(post, credit_card, address, options)
210
+ payment_method = case credit_card
211
+ when String
212
+ { Token: true, cardNumber: credit_card }
213
+ when CreditCard
214
+ if credit_card.number
215
+ {
216
+ holderName: credit_card.name,
217
+ cardType: 'CREDIT',
218
+ cardBrand: credit_card.brand&.upcase,
219
+ cardCountry: address[:country],
220
+ expirationMonth: credit_card.month,
221
+ expirationYear: credit_card.year,
222
+ cardBinNumber: credit_card.number[0..5],
223
+ cardLast4Digits: credit_card.number[-4..-1],
224
+ cardNumber: credit_card.number,
225
+ verificationValue: credit_card.verification_value,
226
+ Token: false
227
+ }
228
+ else
229
+ {}
230
+ end
231
+ end
232
+ post[:paymentMethod] = payment_method.compact
233
+ end
234
+
235
+ def names_from_address(address, payment_method)
236
+ split_names(address[:name]).tap do |names|
237
+ names[0] = payment_method&.first_name unless names[0].present? || payment_method.is_a?(String)
238
+ names[1] = payment_method&.last_name unless names[1].present? || payment_method.is_a?(String)
239
+ end
240
+ end
241
+
242
+ def phone_from(options)
243
+ options[:phone] || options.dig(:billing_address, :phone_number)
244
+ end
245
+
246
+ def access_token_valid?
247
+ @options[:access_token].present? && @options.fetch(:token_expires, 0).to_i > DateTime.now.strftime('%Q').to_i
248
+ end
249
+
250
+ def fetch_access_token
251
+ params = { AppKey: @options[:app_key], AppSecret: @options[:app_secret] }
252
+ response = parse(ssl_post(url(:authenticate), params.to_json, headers))
253
+
254
+ @options[:access_token] = response[:accessToken]
255
+ @options[:token_expires] = response[:expires]
256
+ @options[:new_credentials] = true
257
+ success = response[:accessToken].present?
258
+ Response.new(
259
+ success,
260
+ message_from(response, success),
261
+ response,
262
+ test: test?,
263
+ error_code: response[:statusCode]
264
+ )
265
+ rescue ResponseError => e
266
+ raise OAuthResponseError.new(e)
267
+ end
268
+
269
+ def url(action, id = nil)
270
+ "#{test? ? test_url : live_url}#{ENDPOINTS_MAPPING[action] % id}"
271
+ end
272
+
273
+ def headers
274
+ { 'Content-Type' => 'application/json' }.tap do |headers|
275
+ headers['Authorization'] = "Bearer #{@options[:access_token]}" if @options[:access_token]
276
+ end
277
+ end
278
+
279
+ def parse(body)
280
+ body = '{}' if body.blank?
281
+
282
+ JSON.parse(body).with_indifferent_access
283
+ rescue JSON::ParserError
284
+ {
285
+ errors: body,
286
+ status: 'Unable to parse JSON response'
287
+ }.with_indifferent_access
288
+ end
289
+
290
+ def commit(action, post, authorization = nil, method = :post, options = {})
291
+ MultiResponse.run do |r|
292
+ r.process { fetch_access_token } unless access_token_valid?
293
+ r.process do
294
+ api_request(action, post, authorization, method, options).tap do |response|
295
+ response.params.merge!(@options.slice(:access_token, :token_expires)) if @options[:new_credentials]
296
+ end
297
+ end
298
+ end
299
+ end
300
+
301
+ def api_request(action, post, authorization = nil, method = :post, options = {})
302
+ response = parse ssl_request(method, url(action, authorization), post.to_json, headers)
303
+ success = success_from(action, response, options)
304
+ Response.new(
305
+ success,
306
+ message_from(response, success),
307
+ response,
308
+ authorization: authorization_from(action, response, post),
309
+ test: test?,
310
+ error_code: error_code_from(success, response)
311
+ )
312
+ rescue ResponseError => e
313
+ response = parse(e.response.body)
314
+ # if current access_token is invalid then clean it
315
+ if e.response.code == '401'
316
+ @options[:access_token] = ''
317
+ @options[:new_credentials] = true
318
+ end
319
+ Response.new(false, message_from(response, false), response, test: test?)
320
+ end
321
+
322
+ def success_from(action, response, options)
323
+ case action
324
+ when :store then response.dig(:transaction, :payment_method, :token).present?
325
+ when :inquire then response[:id].present? && SUCCESS_MESSAGES.include?(response[:statusName])
326
+ when :void then response.empty?
327
+ else
328
+ response[:success] && SUCCESS_MESSAGES.reject { |msg| msg == 'CHALLENGE' && options[:async] }.include?(response[:status])
329
+ end
330
+ end
331
+
332
+ def message_from(response, success_status)
333
+ return extract_error(response) unless success_status || response['TraceId'].nil?
334
+
335
+ response[:title] || response[:responseMessage] || response[:statusName] || response[:status]
336
+ end
337
+
338
+ def authorization_from(action, response, options)
339
+ if action == :store
340
+ response.dig(:transaction, :payment_method, :token)
341
+ elsif success_from(action, response, options)
342
+ [response[:orderId], options[:currency] || default_currency].compact.join('#')
343
+ end
344
+ end
345
+
346
+ def error_code_from(success, response)
347
+ (response[:statusName] || response[:status]) unless success
348
+ end
349
+
350
+ def cast_bool(value)
351
+ ![false, 0, '', '0', 'f', 'F', 'false', 'FALSE'].include?(value)
352
+ end
353
+
354
+ def extract_error(response)
355
+ response.except(*NO_ERROR_KEYS).to_json
356
+ end
357
+ end
358
+ end
359
+ end
@@ -1,5 +1,5 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class Flo2cashGateway < Gateway
4
4
  self.display_name = 'Flo2Cash'
5
5
  self.homepage_url = 'http://www.flo2cash.co.nz/'
@@ -160,6 +160,8 @@ module ActiveMerchant #:nodoc:
160
160
 
161
161
  def parse(body, action)
162
162
  response = {}
163
+ return response if body.blank?
164
+
163
165
  xml = REXML::Document.new(body)
164
166
  root = (REXML::XPath.first(xml, "//#{action}Response") || REXML::XPath.first(xml, '//detail'))
165
167
 
@@ -1,5 +1,5 @@
1
- module ActiveMerchant #:nodoc:
2
- module Billing #:nodoc:
1
+ module ActiveMerchant # :nodoc:
2
+ module Billing # :nodoc:
3
3
  class Flo2cashSimpleGateway < Flo2cashGateway
4
4
  self.display_name = 'Flo2Cash Simple'
5
5
 
@@ -1,12 +1,14 @@
1
1
  require 'json'
2
2
 
3
- module ActiveMerchant #:nodoc:
4
- module Billing #:nodoc:
3
+ module ActiveMerchant # :nodoc:
4
+ module Billing # :nodoc:
5
5
  class ForteGateway < Gateway
6
6
  include Empty
7
7
 
8
- self.test_url = 'https://sandbox.forte.net/api/v2'
9
- self.live_url = 'https://api.forte.net/v2'
8
+ version 'v2'
9
+
10
+ self.test_url = "https://sandbox.forte.net/api/#{fetch_version}"
11
+ self.live_url = "https://api.forte.net/#{fetch_version}"
10
12
 
11
13
  self.supported_countries = ['US']
12
14
  self.default_currency = 'USD'