activemerchant 1.100.0 → 1.133.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1057 -0
  3. data/README.md +11 -9
  4. data/lib/active_merchant/billing/avs_result.rb +9 -9
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +49 -17
  7. data/lib/active_merchant/billing/compatibility.rb +5 -4
  8. data/lib/active_merchant/billing/credit_card.rb +55 -8
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  10. data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +38 -36
  13. data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
  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 +14 -14
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
  21. data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
  24. data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
  33. data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
  34. data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
  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 +387 -175
  40. data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
  41. data/lib/active_merchant/billing/gateways/cams.rb +10 -10
  42. data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
  43. data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
  45. data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
  46. data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
  47. data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
  48. data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
  50. data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
  51. data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
  52. data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
  53. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
  54. data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
  55. data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
  57. data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
  59. data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
  61. data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
  62. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  63. data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
  64. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  65. data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
  66. data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
  67. data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
  68. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
  73. data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
  74. data/lib/active_merchant/billing/gateways/element.rb +71 -21
  75. data/lib/active_merchant/billing/gateways/epay.rb +43 -43
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
  77. data/lib/active_merchant/billing/gateways/eway.rb +9 -9
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
  80. data/lib/active_merchant/billing/gateways/exact.rb +19 -20
  81. data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/forte.rb +38 -22
  92. data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
  96. data/lib/active_merchant/billing/gateways/hps.rb +171 -50
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
  100. data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
  101. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  102. data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
  103. data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
  104. data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
  105. data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
  106. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  107. data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
  108. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
  109. data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
  110. data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
  111. data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
  112. data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
  113. data/lib/active_merchant/billing/gateways/litle.rb +181 -45
  114. data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
  115. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  116. data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
  117. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
  118. data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
  119. data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
  120. data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
  121. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
  122. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
  123. data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
  124. data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
  125. data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
  126. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/migs.rb +18 -21
  128. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  129. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
  130. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/monei.rb +236 -150
  132. data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
  133. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
  135. data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
  136. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
  137. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
  138. data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
  139. data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
  140. data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
  141. data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
  142. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
  143. data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
  144. data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
  145. data/lib/active_merchant/billing/gateways/omise.rb +15 -16
  146. data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
  147. data/lib/active_merchant/billing/gateways/opp.rb +39 -33
  148. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
  149. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
  150. data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
  151. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
  152. data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
  153. data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
  154. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  155. data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
  156. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
  157. data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
  158. data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
  159. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
  160. data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
  161. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  162. data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
  163. data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
  164. data/lib/active_merchant/billing/gateways/payex.rb +24 -25
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  167. data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
  172. data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  175. data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
  176. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  177. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  178. data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
  179. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  180. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  181. data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
  182. data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
  183. data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
  184. data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
  185. data/lib/active_merchant/billing/gateways/payway.rb +22 -22
  186. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  187. data/lib/active_merchant/billing/gateways/pin.rb +60 -21
  188. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
  190. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
  192. data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
  194. data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
  195. data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  203. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  204. data/lib/active_merchant/billing/gateways/realex.rb +42 -16
  205. data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
  206. data/lib/active_merchant/billing/gateways/s5.rb +10 -9
  207. data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
  208. data/lib/active_merchant/billing/gateways/sage.rb +19 -21
  209. data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
  210. data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
  211. data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
  212. data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
  213. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
  214. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
  215. data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
  216. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  217. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  218. data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
  219. data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
  220. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
  221. data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
  222. data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
  223. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
  224. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
  225. data/lib/active_merchant/billing/gateways/telr.rb +17 -18
  226. data/lib/active_merchant/billing/gateways/tns.rb +3 -7
  227. data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
  228. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
  229. data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
  230. data/lib/active_merchant/billing/gateways/transax.rb +1 -2
  231. data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
  232. data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
  233. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
  234. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
  235. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
  236. data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
  237. data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
  238. data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
  239. data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
  240. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  241. data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
  242. data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
  243. data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
  244. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  245. data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
  246. data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
  247. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
  248. data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
  250. data/lib/active_merchant/billing/response.rb +25 -6
  251. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  252. data/lib/active_merchant/billing.rb +1 -0
  253. data/lib/active_merchant/connection.rb +14 -15
  254. data/lib/active_merchant/country.rb +3 -1
  255. data/lib/active_merchant/errors.rb +4 -1
  256. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  257. data/lib/active_merchant/network_connection_retries.rb +15 -17
  258. data/lib/active_merchant/post_data.rb +3 -2
  259. data/lib/active_merchant/posts_data.rb +2 -2
  260. data/lib/active_merchant/version.rb +1 -1
  261. data/lib/active_merchant.rb +2 -2
  262. data/lib/certs/cacert.pem +1587 -2361
  263. data/lib/support/gateway_support.rb +1 -1
  264. data/lib/support/ssl_verify.rb +3 -7
  265. data/lib/support/ssl_version.rb +2 -3
  266. metadata +86 -34
  267. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -4,12 +4,12 @@ module ActiveMerchant #:nodoc:
4
4
  self.test_url = 'https://gateway.test.clearhaus.com'
5
5
  self.live_url = 'https://gateway.clearhaus.com'
6
6
 
7
- self.supported_countries = ['DK', 'NO', 'SE', 'FI', 'DE', 'CH', 'NL', 'AD', 'AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'FO', 'GL', 'EE', 'FR', 'GR',
8
- 'HU', 'IS', 'IE', 'IT', 'LV', 'LI', 'LT', 'LU', 'MT', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'GB']
7
+ self.supported_countries = %w[DK NO SE FI DE CH NL AD AT BE BG HR CY CZ FO GL EE FR GR
8
+ HU IS IE IT LV LI LT LU MT PL PT RO SK SI ES GB]
9
9
 
10
10
  self.default_currency = 'EUR'
11
- self.currencies_without_fractions = %w(BIF BYR DJF GNF JPY KMF KRW PYG RWF VND VUV XAF XOF XPF)
12
- self.supported_cardtypes = [:visa, :master]
11
+ self.currencies_without_fractions = %w(BIF CLP DJF GNF JPY KMF KRW PYG RWF UGX VND VUV XAF XOF XPF)
12
+ self.supported_cardtypes = %i[visa master]
13
13
 
14
14
  self.homepage_url = 'https://www.clearhaus.com'
15
15
  self.display_name = 'Clearhaus'
@@ -36,31 +36,32 @@ module ActiveMerchant #:nodoc:
36
36
  50000 => 'Clearhaus error'
37
37
  }
38
38
 
39
- def initialize(options={})
39
+ def initialize(options = {})
40
40
  requires!(options, :api_key)
41
41
  options[:private_key] = options[:private_key].strip if options[:private_key]
42
42
  super
43
43
  end
44
44
 
45
- def purchase(amount, payment, options={})
45
+ def purchase(amount, payment, options = {})
46
46
  MultiResponse.run(:use_first_response) do |r|
47
47
  r.process { authorize(amount, payment, options) }
48
48
  r.process { capture(amount, r.authorization, options) }
49
49
  end
50
50
  end
51
51
 
52
- def authorize(amount, payment, options={})
52
+ def authorize(amount, payment, options = {})
53
53
  post = {}
54
54
  add_invoice(post, amount, options)
55
55
 
56
- action = if payment.respond_to?(:number)
57
- add_payment(post, payment)
58
- '/authorizations'
59
- elsif payment.kind_of?(String)
60
- "/cards/#{payment}/authorizations"
61
- else
62
- raise ArgumentError.new("Unknown payment type #{payment.inspect}")
63
- end
56
+ action =
57
+ if payment.respond_to?(:number)
58
+ add_payment(post, payment)
59
+ '/authorizations'
60
+ elsif payment.kind_of?(String)
61
+ "/cards/#{payment}/authorizations"
62
+ else
63
+ raise ArgumentError.new("Unknown payment type #{payment.inspect}")
64
+ end
64
65
 
65
66
  post[:recurring] = options[:recurring] if options[:recurring]
66
67
  post[:card][:pares] = options[:pares] if options[:pares]
@@ -68,14 +69,14 @@ module ActiveMerchant #:nodoc:
68
69
  commit(action, post)
69
70
  end
70
71
 
71
- def capture(amount, authorization, options={})
72
+ def capture(amount, authorization, options = {})
72
73
  post = {}
73
74
  add_invoice(post, amount, options)
74
75
 
75
76
  commit("/authorizations/#{authorization}/captures", post)
76
77
  end
77
78
 
78
- def refund(amount, authorization, options={})
79
+ def refund(amount, authorization, options = {})
79
80
  post = {}
80
81
  add_amount(post, amount, options)
81
82
 
@@ -86,14 +87,14 @@ module ActiveMerchant #:nodoc:
86
87
  commit("/authorizations/#{authorization}/voids", options)
87
88
  end
88
89
 
89
- def verify(credit_card, options={})
90
+ def verify(credit_card, options = {})
90
91
  MultiResponse.run(:use_first_response) do |r|
91
92
  r.process { authorize(0, credit_card, options) }
92
93
  r.process(:ignore_result) { void(r.authorization, options) }
93
94
  end
94
95
  end
95
96
 
96
- def store(credit_card, options={})
97
+ def store(credit_card, options = {})
97
98
  post = {}
98
99
  add_payment(post, credit_card)
99
100
 
@@ -127,12 +128,10 @@ module ActiveMerchant #:nodoc:
127
128
  def add_payment(post, payment)
128
129
  card = {}
129
130
  card[:pan] = payment.number
130
- card[:expire_month] = '%02d'% payment.month
131
+ card[:expire_month] = '%02d' % payment.month
131
132
  card[:expire_year] = payment.year
132
133
 
133
- if payment.verification_value?
134
- card[:csc] = payment.verification_value
135
- end
134
+ card[:csc] = payment.verification_value if payment.verification_value?
136
135
 
137
136
  post[:card] = card if card.any?
138
137
  end
@@ -161,12 +160,14 @@ module ActiveMerchant #:nodoc:
161
160
  end
162
161
  end
163
162
 
164
- response = begin
165
- parse(ssl_post(url, body, headers))
166
- rescue ResponseError => e
167
- raise unless(e.response.code.to_s =~ /400/)
168
- parse(e.response.body)
169
- end
163
+ response =
164
+ begin
165
+ parse(ssl_post(url, body, headers))
166
+ rescue ResponseError => e
167
+ raise unless e.response.code.to_s =~ /400/
168
+
169
+ parse(e.response.body)
170
+ end
170
171
 
171
172
  Response.new(
172
173
  success_from(response),
@@ -205,15 +206,13 @@ module ActiveMerchant #:nodoc:
205
206
 
206
207
  def generate_signature(body)
207
208
  key = OpenSSL::PKey::RSA.new(@options[:private_key])
208
- hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack('H*').first
209
+ hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack1('H*')
209
210
 
210
211
  "#{@options[:signing_key]} RS256-hex #{hex}"
211
212
  end
212
213
 
213
214
  def error_code_from(response)
214
- unless success_from(response)
215
- response['status']['code']
216
- end
215
+ response['status']['code'] unless success_from(response)
217
216
  end
218
217
  end
219
218
  end
@@ -0,0 +1,370 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class CommerceHubGateway < Gateway
4
+ self.test_url = 'https://cert.api.fiservapps.com/ch'
5
+ self.live_url = 'https://prod.api.fiservapps.com/ch'
6
+
7
+ self.supported_countries = ['US']
8
+ self.default_currency = 'USD'
9
+ self.supported_cardtypes = %i[visa master american_express discover]
10
+
11
+ self.homepage_url = 'https://developer.fiserv.com/product/CommerceHub'
12
+ self.display_name = 'CommerceHub'
13
+
14
+ STANDARD_ERROR_CODE_MAPPING = {}
15
+
16
+ SCHEDULED_REASON_TYPES = %w(recurring installment)
17
+ ENDPOINTS = {
18
+ 'sale' => '/payments/v1/charges',
19
+ 'void' => '/payments/v1/cancels',
20
+ 'refund' => '/payments/v1/refunds',
21
+ 'vault' => '/payments-vas/v1/tokens',
22
+ 'verify' => '/payments-vas/v1/accounts/verification'
23
+ }
24
+
25
+ def initialize(options = {})
26
+ requires!(options, :api_key, :api_secret, :merchant_id, :terminal_id)
27
+ super
28
+ end
29
+
30
+ def purchase(money, payment, options = {})
31
+ post = {}
32
+ options[:capture_flag] = true
33
+ options[:create_token] = false
34
+
35
+ add_transaction_details(post, options, 'sale')
36
+ build_purchase_and_auth_request(post, money, payment, options)
37
+
38
+ commit('sale', post, options)
39
+ end
40
+
41
+ def authorize(money, payment, options = {})
42
+ post = {}
43
+ options[:capture_flag] = false
44
+ options[:create_token] = false
45
+
46
+ add_transaction_details(post, options, 'sale')
47
+ build_purchase_and_auth_request(post, money, payment, options)
48
+
49
+ commit('sale', post, options)
50
+ end
51
+
52
+ def capture(money, authorization, options = {})
53
+ post = {}
54
+ options[:capture_flag] = true
55
+ add_invoice(post, money, options)
56
+ add_transaction_details(post, options, 'capture')
57
+ add_reference_transaction_details(post, authorization, options, :capture)
58
+
59
+ commit('sale', post, options)
60
+ end
61
+
62
+ def refund(money, authorization, options = {})
63
+ post = {}
64
+ add_invoice(post, money, options) if money
65
+ add_transaction_details(post, options)
66
+ add_reference_transaction_details(post, authorization, options, :refund)
67
+
68
+ commit('refund', post, options)
69
+ end
70
+
71
+ def void(authorization, options = {})
72
+ post = {}
73
+ add_transaction_details(post, options)
74
+ add_reference_transaction_details(post, authorization, options, :void)
75
+
76
+ commit('void', post, options)
77
+ end
78
+
79
+ def store(credit_card, options = {})
80
+ post = {}
81
+ add_payment(post, credit_card, options)
82
+ add_billing_address(post, credit_card, options)
83
+ add_transaction_details(post, options)
84
+ add_transaction_interaction(post, options)
85
+
86
+ commit('vault', post, options)
87
+ end
88
+
89
+ def verify(credit_card, options = {})
90
+ post = {}
91
+ add_payment(post, credit_card, options)
92
+ add_billing_address(post, credit_card, options)
93
+
94
+ commit('verify', post, options)
95
+ end
96
+
97
+ def supports_scrubbing?
98
+ true
99
+ end
100
+
101
+ def scrub(transcript)
102
+ transcript.
103
+ gsub(%r((Authorization: )[a-zA-Z0-9+./=]+), '\1[FILTERED]').
104
+ gsub(%r((Api-Key: )\w+), '\1[FILTERED]').
105
+ gsub(%r(("cardData\\?":\\?")\d+), '\1[FILTERED]').
106
+ gsub(%r(("securityCode\\?":\\?")\d+), '\1[FILTERED]').
107
+ gsub(%r(("cavv\\?":\\?")\w+), '\1[FILTERED]')
108
+ end
109
+
110
+ private
111
+
112
+ def add_transaction_interaction(post, options)
113
+ post[:transactionInteraction] = {}
114
+ post[:transactionInteraction][:origin] = options[:origin] || 'ECOM'
115
+ post[:transactionInteraction][:eciIndicator] = options[:eci_indicator] || 'CHANNEL_ENCRYPTED'
116
+ post[:transactionInteraction][:posConditionCode] = options[:pos_condition_code] || 'CARD_NOT_PRESENT_ECOM'
117
+ post[:transactionInteraction][:posEntryMode] = (options[:pos_entry_mode] || 'MANUAL') unless options[:encryption_data].present?
118
+ post[:transactionInteraction][:additionalPosInformation] = {}
119
+ post[:transactionInteraction][:additionalPosInformation][:dataEntrySource] = options[:data_entry_source] || 'UNSPECIFIED'
120
+ end
121
+
122
+ def add_transaction_details(post, options, action = nil)
123
+ details = {
124
+ captureFlag: options[:capture_flag],
125
+ createToken: options[:create_token],
126
+ physicalGoodsIndicator: [true, 'true'].include?(options[:physical_goods_indicator])
127
+ }
128
+
129
+ if options[:order_id].present? && action == 'sale'
130
+ details[:merchantOrderId] = options[:order_id]
131
+ details[:merchantTransactionId] = options[:order_id]
132
+ end
133
+
134
+ if action != 'capture'
135
+ details[:merchantInvoiceNumber] = options[:merchant_invoice_number] || rand.to_s[2..13]
136
+ details[:primaryTransactionType] = options[:primary_transaction_type]
137
+ details[:accountVerification] = options[:account_verification]
138
+ end
139
+
140
+ post[:transactionDetails] = details.compact
141
+ end
142
+
143
+ def add_billing_address(post, payment, options)
144
+ return unless billing = options[:billing_address]
145
+
146
+ billing_address = {}
147
+ if payment.is_a?(CreditCard)
148
+ billing_address[:firstName] = payment.first_name if payment.first_name
149
+ billing_address[:lastName] = payment.last_name if payment.last_name
150
+ end
151
+ address = {}
152
+ address[:street] = billing[:address1] if billing[:address1]
153
+ address[:houseNumberOrName] = billing[:address2] if billing[:address2]
154
+ address[:recipientNameOrAddress] = billing[:name] if billing[:name]
155
+ address[:city] = billing[:city] if billing[:city]
156
+ address[:stateOrProvince] = billing[:state] if billing[:state]
157
+ address[:postalCode] = billing[:zip] if billing[:zip]
158
+ address[:country] = billing[:country] if billing[:country]
159
+
160
+ billing_address[:address] = address unless address.empty?
161
+ if billing[:phone_number]
162
+ billing_address[:phone] = {}
163
+ billing_address[:phone][:phoneNumber] = billing[:phone_number]
164
+ end
165
+ post[:billingAddress] = billing_address
166
+ end
167
+
168
+ def add_shipping_address(post, options)
169
+ return unless shipping = options[:shipping_address]
170
+
171
+ shipping_address = {}
172
+ address = {}
173
+ address[:street] = shipping[:address1] if shipping[:address1]
174
+ address[:houseNumberOrName] = shipping[:address2] if shipping[:address2]
175
+ address[:recipientNameOrAddress] = shipping[:name] if shipping[:name]
176
+ address[:city] = shipping[:city] if shipping[:city]
177
+ address[:stateOrProvince] = shipping[:state] if shipping[:state]
178
+ address[:postalCode] = shipping[:zip] if shipping[:zip]
179
+ address[:country] = shipping[:country] if shipping[:country]
180
+
181
+ shipping_address[:address] = address unless address.empty?
182
+ if shipping[:phone_number]
183
+ shipping_address[:phone] = {}
184
+ shipping_address[:phone][:phoneNumber] = shipping[:phone_number]
185
+ end
186
+ post[:shippingAddress] = shipping_address
187
+ end
188
+
189
+ def build_purchase_and_auth_request(post, money, payment, options)
190
+ add_invoice(post, money, options)
191
+ add_payment(post, payment, options)
192
+ add_stored_credentials(post, options)
193
+ add_transaction_interaction(post, options)
194
+ add_billing_address(post, payment, options)
195
+ add_shipping_address(post, options)
196
+ end
197
+
198
+ def add_reference_transaction_details(post, authorization, options, action = nil)
199
+ reference_details = {}
200
+ _merchant_reference, transaction_id = authorization.include?('|') ? authorization.split('|') : [nil, authorization]
201
+
202
+ reference_details[:referenceTransactionId] = transaction_id
203
+ reference_details[:referenceTransactionType] = (options[:reference_transaction_type] || 'CHARGES') unless action == :capture
204
+ post[:referenceTransactionDetails] = reference_details.compact
205
+ end
206
+
207
+ def add_invoice(post, money, options)
208
+ post[:amount] = {
209
+ total: amount(money).to_f,
210
+ currency: options[:currency] || self.default_currency
211
+ }
212
+ end
213
+
214
+ def add_stored_credentials(post, options)
215
+ return unless stored_credential = options[:stored_credential]
216
+
217
+ post[:storedCredentials] = {}
218
+ post[:storedCredentials][:sequence] = stored_credential[:initial_transaction] ? 'FIRST' : 'SUBSEQUENT'
219
+ post[:storedCredentials][:initiator] = stored_credential[:initiator] == 'merchant' ? 'MERCHANT' : 'CARD_HOLDER'
220
+ post[:storedCredentials][:scheduled] = SCHEDULED_REASON_TYPES.include?(stored_credential[:reason_type])
221
+ post[:storedCredentials][:schemeReferenceTransactionId] = options[:scheme_reference_transaction_id] || stored_credential[:network_transaction_id]
222
+ end
223
+
224
+ def add_credit_card(source, payment, options)
225
+ source[:sourceType] = 'PaymentCard'
226
+ source[:card] = {}
227
+ source[:card][:cardData] = payment.number
228
+ source[:card][:expirationMonth] = format(payment.month, :two_digits) if payment.month
229
+ source[:card][:expirationYear] = format(payment.year, :four_digits) if payment.year
230
+ if payment.verification_value
231
+ source[:card][:securityCode] = payment.verification_value
232
+ source[:card][:securityCodeIndicator] = 'PROVIDED'
233
+ end
234
+ end
235
+
236
+ def add_payment_token(source, payment, options)
237
+ source[:sourceType] = 'PaymentToken'
238
+ source[:tokenData] = payment
239
+ source[:tokenSource] = options[:token_source] if options[:token_source]
240
+ if options[:card_expiration_month] || options[:card_expiration_year]
241
+ source[:card] = {}
242
+ source[:card][:expirationMonth] = options[:card_expiration_month] if options[:card_expiration_month]
243
+ source[:card][:expirationYear] = options[:card_expiration_year] if options[:card_expiration_year]
244
+ end
245
+ end
246
+
247
+ def add_decrypted_wallet(source, payment, options)
248
+ source[:sourceType] = 'DecryptedWallet'
249
+ source[:card] = {}
250
+ source[:card][:cardData] = payment.number
251
+ source[:card][:expirationMonth] = format(payment.month, :two_digits)
252
+ source[:card][:expirationYear] = format(payment.year, :four_digits)
253
+ source[:cavv] = payment.payment_cryptogram
254
+ source[:walletType] = payment.source.to_s.upcase
255
+ end
256
+
257
+ def add_payment(post, payment, options = {})
258
+ source = {}
259
+ case payment
260
+ when NetworkTokenizationCreditCard
261
+ add_decrypted_wallet(source, payment, options)
262
+ when CreditCard
263
+ if options[:encryption_data].present?
264
+ source[:sourceType] = 'PaymentCard'
265
+ source[:encryptionData] = options[:encryption_data]
266
+ else
267
+ add_credit_card(source, payment, options)
268
+ end
269
+ when String
270
+ add_payment_token(source, payment, options)
271
+ end
272
+ post[:source] = source
273
+ end
274
+
275
+ def parse(body)
276
+ JSON.parse(body)
277
+ end
278
+
279
+ def headers(request, options)
280
+ time = DateTime.now.strftime('%Q').to_s
281
+ client_request_id = options[:client_request_id] || rand.to_s[2..8]
282
+ raw_signature = @options[:api_key] + client_request_id.to_s + time + request
283
+ hmac = OpenSSL::HMAC.digest('sha256', @options[:api_secret], raw_signature)
284
+ signature = Base64.strict_encode64(hmac.to_s).to_s
285
+
286
+ {
287
+ 'Client-Request-Id' => client_request_id,
288
+ 'Api-Key' => @options[:api_key],
289
+ 'Timestamp' => time,
290
+ 'Accept-Language' => 'application/json',
291
+ 'Auth-Token-Type' => 'HMAC',
292
+ 'Content-Type' => 'application/json',
293
+ 'Accept' => 'application/json',
294
+ 'Authorization' => signature
295
+ }
296
+ end
297
+
298
+ def add_merchant_details(post)
299
+ post[:merchantDetails] = {}
300
+ post[:merchantDetails][:terminalId] = @options[:terminal_id]
301
+ post[:merchantDetails][:merchantId] = @options[:merchant_id]
302
+ end
303
+
304
+ def commit(action, parameters, options)
305
+ url = (test? ? test_url : live_url) + ENDPOINTS[action]
306
+ add_merchant_details(parameters)
307
+ response = parse(ssl_post(url, parameters.to_json, headers(parameters.to_json, options)))
308
+
309
+ Response.new(
310
+ success_from(response, action),
311
+ message_from(response, action),
312
+ response,
313
+ authorization: authorization_from(action, response, options),
314
+ test: test?,
315
+ error_code: error_code_from(response, action),
316
+ avs_result: AVSResult.new(code: get_avs_cvv(response, 'avs')),
317
+ cvv_result: CVVResult.new(get_avs_cvv(response, 'cvv'))
318
+ )
319
+ end
320
+
321
+ def get_avs_cvv(response, type = 'avs')
322
+ response.dig(
323
+ 'paymentReceipt',
324
+ 'processorResponseDetails',
325
+ 'bankAssociationDetails',
326
+ 'avsSecurityCodeResponse',
327
+ 'association',
328
+ type == 'avs' ? 'avsCode' : 'securityCodeResponse'
329
+ )
330
+ end
331
+
332
+ def handle_response(response)
333
+ case response.code.to_i
334
+ when 200...300, 400, 401, 429
335
+ response.body
336
+ else
337
+ raise ResponseError.new(response)
338
+ end
339
+ end
340
+
341
+ def success_from(response, action = nil)
342
+ return message_from(response, action) == 'VERIFIED' if action == 'verify'
343
+
344
+ (response.dig('paymentReceipt', 'processorResponseDetails', 'responseCode') || response.dig('paymentTokens', 0, 'tokenResponseCode')) == '000'
345
+ end
346
+
347
+ def message_from(response, action = nil)
348
+ return response.dig('error', 0, 'message') if response['error'].present?
349
+ return response.dig('gatewayResponse', 'transactionState') if action == 'verify'
350
+
351
+ response.dig('paymentReceipt', 'processorResponseDetails', 'responseMessage') || response.dig('gatewayResponse', 'transactionType')
352
+ end
353
+
354
+ def authorization_from(action, response, options)
355
+ case action
356
+ when 'vault'
357
+ response.dig('paymentTokens', 0, 'tokenData')
358
+ when 'sale'
359
+ [options[:order_id] || '', response.dig('gatewayResponse', 'transactionProcessingDetails', 'transactionId')].join('|')
360
+ else
361
+ response.dig('gatewayResponse', 'transactionProcessingDetails', 'transactionId')
362
+ end
363
+ end
364
+
365
+ def error_code_from(response, action)
366
+ response.dig('error', 0, 'code') unless success_from(response, action)
367
+ end
368
+ end
369
+ end
370
+ end
@@ -11,7 +11,7 @@ module ActiveMerchant #:nodoc:
11
11
 
12
12
  self.money_format = :dollars
13
13
  self.default_currency = 'EUR'
14
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
14
+ self.supported_cardtypes = %i[visa master american_express discover]
15
15
  self.homepage_url = 'http://www.commercegate.com/'
16
16
  self.display_name = 'CommerceGate'
17
17
 
@@ -74,8 +74,8 @@ module ActiveMerchant #:nodoc:
74
74
  post[:customerIP] = options[:ip] || '127.0.0.1'
75
75
  post[:amount] = amount(money)
76
76
  post[:email] = options[:email] || 'unknown@example.com'
77
- post[:currencyCode]= options[:currency] || currency(money)
78
- post[:merchAcct] = options[:merchant]
77
+ post[:currencyCode] = options[:currency] || currency(money)
78
+ post[:merchAcct] = options[:merchant]
79
79
  end
80
80
 
81
81
  def add_creditcard(params, creditcard)
@@ -102,7 +102,7 @@ module ActiveMerchant #:nodoc:
102
102
  response,
103
103
  authorization: response['transID'],
104
104
  test: test?,
105
- avs_result: {code: response['avsCode']},
105
+ avs_result: { code: response['avsCode'] },
106
106
  cvv_result: response['cvvCode']
107
107
  )
108
108
  end
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  self.live_url = 'https://api.conekta.io/'
5
5
 
6
6
  self.supported_countries = ['MX']
7
- self.supported_cardtypes = [:visa, :master, :american_express, :carnet]
7
+ self.supported_cardtypes = %i[visa master american_express carnet]
8
8
  self.homepage_url = 'https://conekta.io/'
9
9
  self.display_name = 'Conekta Gateway'
10
10
  self.money_format = :cents
@@ -105,7 +105,7 @@ module ActiveMerchant #:nodoc:
105
105
  end
106
106
 
107
107
  def add_shipment_address(post, options)
108
- if(address = options[:shipping_address])
108
+ if (address = options[:shipping_address])
109
109
  post[:address] = {}
110
110
  post[:address][:street1] = address[:address1] if address[:address1]
111
111
  post[:address][:street2] = address[:address2] if address[:address2]
@@ -124,7 +124,7 @@ module ActiveMerchant #:nodoc:
124
124
  end
125
125
 
126
126
  def add_billing_address(post, options)
127
- if(address = (options[:billing_address] || options[:address]))
127
+ if (address = (options[:billing_address] || options[:address]))
128
128
  post[:billing_address] = {}
129
129
  post[:billing_address][:street1] = address[:address1] if address[:address1]
130
130
  post[:billing_address][:street2] = address[:address2] if address[:address2]
@@ -142,7 +142,7 @@ module ActiveMerchant #:nodoc:
142
142
  end
143
143
 
144
144
  def add_address(post, options)
145
- if(address = (options[:billing_address] || options[:address]))
145
+ if (address = (options[:billing_address] || options[:address]))
146
146
  post[:address] = {}
147
147
  post[:address][:street1] = address[:address1] if address[:address1]
148
148
  post[:address][:street2] = address[:address2] if address[:address2]
@@ -170,6 +170,7 @@ module ActiveMerchant #:nodoc:
170
170
 
171
171
  def parse(body)
172
172
  return {} unless body
173
+
173
174
  JSON.parse(body)
174
175
  end
175
176
 
@@ -179,7 +180,7 @@ module ActiveMerchant #:nodoc:
179
180
  'Accept-Language' => 'es',
180
181
  'Authorization' => 'Basic ' + Base64.encode64("#{@options[:key]}:"),
181
182
  'RaiseHtmlError' => 'false',
182
- 'Conekta-Client-User-Agent' => {'agent'=>"Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}"}.to_json,
183
+ 'Conekta-Client-User-Agent' => { 'agent' => "Conekta ActiveMerchantBindings/#{ActiveMerchant::VERSION}" }.to_json,
183
184
  'X-Conekta-Client-User-Agent' => conekta_client_user_agent(options),
184
185
  'X-Conekta-Client-User-Metadata' => options[:meta].to_json
185
186
  }
@@ -187,7 +188,8 @@ module ActiveMerchant #:nodoc:
187
188
 
188
189
  def conekta_client_user_agent(options)
189
190
  return user_agent unless options[:application]
190
- JSON.dump(JSON.parse(user_agent).merge!({application: options[:application]}))
191
+
192
+ JSON.dump(JSON.parse(user_agent).merge!({ application: options[:application] }))
191
193
  end
192
194
 
193
195
  def commit(method, url, parameters, options = {})