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
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
 
9
9
  self.supported_countries = %w(CA PR US)
10
10
  self.default_currency = 'USD'
11
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
11
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
12
12
 
13
13
  self.homepage_url = 'https://www.globalpaymentsinc.com'
14
14
  self.display_name = 'Global Transport'
@@ -20,12 +20,12 @@ module ActiveMerchant #:nodoc:
20
20
  # :global_password - Your Global password
21
21
  # :term_type - 3 character field assigned by Global Transport after
22
22
  # - your application is certified.
23
- def initialize(options={})
23
+ def initialize(options = {})
24
24
  requires!(options, :global_user_name, :global_password, :term_type)
25
25
  super
26
26
  end
27
27
 
28
- def purchase(money, payment_method, options={})
28
+ def purchase(money, payment_method, options = {})
29
29
  post = {}
30
30
  add_invoice(post, money, options)
31
31
  add_payment_method(post, payment_method)
@@ -34,7 +34,7 @@ module ActiveMerchant #:nodoc:
34
34
  commit('Sale', post, options)
35
35
  end
36
36
 
37
- def authorize(money, payment_method, options={})
37
+ def authorize(money, payment_method, options = {})
38
38
  post = {}
39
39
  add_invoice(post, money, options)
40
40
  add_payment_method(post, payment_method)
@@ -43,7 +43,7 @@ module ActiveMerchant #:nodoc:
43
43
  commit('Auth', post, options)
44
44
  end
45
45
 
46
- def capture(money, authorization, options={})
46
+ def capture(money, authorization, options = {})
47
47
  post = {}
48
48
  add_invoice(post, money, options)
49
49
  add_auth(post, authorization)
@@ -51,7 +51,7 @@ module ActiveMerchant #:nodoc:
51
51
  commit('Force', post, options)
52
52
  end
53
53
 
54
- def refund(money, authorization, options={})
54
+ def refund(money, authorization, options = {})
55
55
  post = {}
56
56
  add_invoice(post, money, options)
57
57
  add_auth(post, authorization)
@@ -59,14 +59,14 @@ module ActiveMerchant #:nodoc:
59
59
  commit('Return', post, options)
60
60
  end
61
61
 
62
- def void(authorization, options={})
62
+ def void(authorization, options = {})
63
63
  post = {}
64
64
  add_auth(post, authorization)
65
65
 
66
66
  commit('Void', post, options)
67
67
  end
68
68
 
69
- def verify(payment_method, options={})
69
+ def verify(payment_method, options = {})
70
70
  post = {}
71
71
  add_payment_method(post, payment_method)
72
72
  add_address(post, options)
@@ -188,7 +188,6 @@ module ActiveMerchant #:nodoc:
188
188
  ExtData: ''
189
189
  }
190
190
  end
191
-
192
191
  end
193
192
  end
194
193
  end
@@ -12,14 +12,14 @@ module ActiveMerchant #:nodoc:
12
12
  self.supported_countries = ['IN']
13
13
  self.default_currency = 'INR'
14
14
  self.money_format = :dollars
15
- self.supported_cardtypes = [:visa, :master, :discover, :diners_club]
15
+ self.supported_cardtypes = %i[visa master discover diners_club]
16
16
 
17
- def initialize(options={})
17
+ def initialize(options = {})
18
18
  requires!(options, :login, :password)
19
19
  super
20
20
  end
21
21
 
22
- def purchase(amount, payment_method, options={})
22
+ def purchase(amount, payment_method, options = {})
23
23
  post = {}
24
24
  add_invoice(post, amount, options)
25
25
  add_payment_method(post, payment_method)
@@ -28,7 +28,7 @@ module ActiveMerchant #:nodoc:
28
28
  commit('purchase', post)
29
29
  end
30
30
 
31
- def authorize(amount, payment_method, options={})
31
+ def authorize(amount, payment_method, options = {})
32
32
  post = {}
33
33
  add_invoice(post, amount, options)
34
34
  add_payment_method(post, payment_method)
@@ -37,7 +37,7 @@ module ActiveMerchant #:nodoc:
37
37
  commit('authorize', post)
38
38
  end
39
39
 
40
- def capture(amount, authorization, options={})
40
+ def capture(amount, authorization, options = {})
41
41
  post = {}
42
42
  add_invoice(post, amount, options)
43
43
  add_reference(post, authorization)
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  commit('capture', post)
47
47
  end
48
48
 
49
- def refund(amount, authorization, options={})
49
+ def refund(amount, authorization, options = {})
50
50
  post = {}
51
51
  add_invoice(post, amount, options)
52
52
  add_reference(post, authorization)
@@ -57,7 +57,7 @@ module ActiveMerchant #:nodoc:
57
57
 
58
58
  private
59
59
 
60
- CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
60
+ CURRENCY_CODES = Hash.new { |_h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
61
61
  CURRENCY_CODES['AED'] = '784'
62
62
  CURRENCY_CODES['AUD'] = '036'
63
63
  CURRENCY_CODES['CAD'] = '124'
@@ -81,14 +81,14 @@ module ActiveMerchant #:nodoc:
81
81
  post[:udf2] = escape(options[:email]) if options[:email]
82
82
  if address = (options[:billing_address] || options[:address])
83
83
  post[:udf3] = escape(address[:phone]) if address[:phone]
84
- post[:udf4] = escape(<<EOA)
85
- #{address[:name]}
86
- #{address[:company]}
87
- #{address[:address1]}
88
- #{address[:address2]}
89
- #{address[:city]} #{address[:state]} #{address[:zip]}
90
- #{address[:country]}
91
- EOA
84
+ post[:udf4] = escape(<<~ADDRESS)
85
+ #{address[:name]}
86
+ #{address[:company]}
87
+ #{address[:address1]}
88
+ #{address[:address2]}
89
+ #{address[:city]} #{address[:state]} #{address[:zip]}
90
+ #{address[:country]}
91
+ ADDRESS
92
92
  end
93
93
  end
94
94
 
@@ -134,7 +134,7 @@ EOA
134
134
  'purchase' => '1',
135
135
  'refund' => '2',
136
136
  'authorize' => '4',
137
- 'capture' => '5',
137
+ 'capture' => '5'
138
138
  }
139
139
 
140
140
  def commit(action, post)
@@ -149,13 +149,13 @@ EOA
149
149
  succeeded,
150
150
  message_from(succeeded, raw),
151
151
  raw,
152
- :authorization => authorization_from(post, raw),
153
- :test => test?
152
+ authorization: authorization_from(post, raw),
153
+ test: test?
154
154
  )
155
155
  end
156
156
 
157
157
  def build_request(post)
158
- xml = Builder::XmlMarkup.new :indent => 2
158
+ xml = Builder::XmlMarkup.new indent: 2
159
159
  xml.instruct!
160
160
  post.each do |field, value|
161
161
  xml.tag!(field, value)
@@ -194,11 +194,10 @@ EOA
194
194
  [tranid, member]
195
195
  end
196
196
 
197
- def escape(string, max_length=250)
197
+ def escape(string, max_length = 250)
198
198
  return '' unless string
199
- if max_length
200
- string = string[0...max_length]
201
- end
199
+
200
+ string = string[0...max_length] if max_length
202
201
  string.gsub(/[^A-Za-z0-9 \-_@\.\n]/, '')
203
202
  end
204
203
  end
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
 
9
9
  self.supported_countries = ['US']
10
10
  self.default_currency = 'USD'
11
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jbc, :diners_club]
11
+ self.supported_cardtypes = %i[visa master american_express discover jbc diners_club]
12
12
 
13
13
  self.homepage_url = 'http://developer.heartlandpaymentsystems.com/SecureSubmit/'
14
14
  self.display_name = 'Heartland Payment Systems'
@@ -21,65 +21,81 @@ module ActiveMerchant #:nodoc:
21
21
  visa: 'Visa 3DSecure',
22
22
  american_express: 'AMEX 3DSecure',
23
23
  discover: 'Discover 3DSecure',
24
+ android_pay: 'GooglePayApp',
25
+ google_pay: 'GooglePayApp'
24
26
  }
25
27
 
26
- def initialize(options={})
28
+ def initialize(options = {})
27
29
  requires!(options, :secret_api_key)
28
30
  super
29
31
  end
30
32
 
31
- def authorize(money, card_or_token, options={})
33
+ def authorize(money, card_or_token, options = {})
32
34
  commit('CreditAuth') do |xml|
33
35
  add_amount(xml, money)
34
36
  add_allow_dup(xml)
35
- add_customer_data(xml, card_or_token, options)
37
+ add_card_or_token_customer_data(xml, card_or_token, options)
36
38
  add_details(xml, options)
37
39
  add_descriptor_name(xml, options)
38
- add_payment(xml, card_or_token, options)
40
+ add_card_or_token_payment(xml, card_or_token, options)
39
41
  add_three_d_secure(xml, card_or_token, options)
42
+ add_stored_credentials(xml, options)
40
43
  end
41
44
  end
42
45
 
43
- def capture(money, transaction_id, options={})
44
- commit('CreditAddToBatch') do |xml|
46
+ def capture(money, transaction_id, options = {})
47
+ commit('CreditAddToBatch', transaction_id) do |xml|
45
48
  add_amount(xml, money)
46
49
  add_reference(xml, transaction_id)
47
50
  end
48
51
  end
49
52
 
50
- def purchase(money, card_or_token, options={})
51
- commit('CreditSale') do |xml|
53
+ def purchase(money, payment_method, options = {})
54
+ if payment_method.is_a?(Check)
55
+ commit_check_sale(money, payment_method, options)
56
+ elsif options.dig(:stored_credential, :reason_type) == 'recurring'
57
+ commit_recurring_billing_sale(money, payment_method, options)
58
+ else
59
+ commit_credit_sale(money, payment_method, options)
60
+ end
61
+ end
62
+
63
+ def refund(money, transaction_id, options = {})
64
+ commit('CreditReturn') do |xml|
52
65
  add_amount(xml, money)
53
66
  add_allow_dup(xml)
54
- add_customer_data(xml, card_or_token, options)
67
+ add_reference(xml, transaction_id)
68
+ add_card_or_token_customer_data(xml, transaction_id, options)
55
69
  add_details(xml, options)
56
- add_descriptor_name(xml, options)
57
- add_payment(xml, card_or_token, options)
58
- add_three_d_secure(xml, card_or_token, options)
59
70
  end
60
71
  end
61
72
 
62
- def refund(money, transaction_id, options={})
73
+ def credit(money, payment_method, options = {})
63
74
  commit('CreditReturn') do |xml|
64
75
  add_amount(xml, money)
65
76
  add_allow_dup(xml)
66
- add_reference(xml, transaction_id)
67
- add_customer_data(xml, transaction_id, options)
77
+ add_card_or_token_payment(xml, payment_method, options)
68
78
  add_details(xml, options)
69
79
  end
70
80
  end
71
81
 
72
- def verify(card_or_token, options={})
82
+ def verify(card_or_token, options = {})
73
83
  commit('CreditAccountVerify') do |xml|
74
- add_customer_data(xml, card_or_token, options)
84
+ add_card_or_token_customer_data(xml, card_or_token, options)
75
85
  add_descriptor_name(xml, options)
76
- add_payment(xml, card_or_token, options)
86
+ add_card_or_token_payment(xml, card_or_token, options)
77
87
  end
78
88
  end
79
89
 
80
- def void(transaction_id, options={})
81
- commit('CreditVoid') do |xml|
82
- add_reference(xml, transaction_id)
90
+ def void(transaction_id, options = {})
91
+ if options[:check_void]
92
+ commit('CheckVoid') do |xml|
93
+ add_reference(xml, transaction_id)
94
+ end
95
+ else
96
+ commit('CreditVoid') do |xml|
97
+ add_reference(xml, transaction_id)
98
+ end
83
99
  end
84
100
  end
85
101
 
@@ -92,20 +108,60 @@ module ActiveMerchant #:nodoc:
92
108
  gsub(%r((<hps:CardNbr>)[^<]*(<\/hps:CardNbr>))i, '\1[FILTERED]\2').
93
109
  gsub(%r((<hps:CVV2>)[^<]*(<\/hps:CVV2>))i, '\1[FILTERED]\2').
94
110
  gsub(%r((<hps:SecretAPIKey>)[^<]*(<\/hps:SecretAPIKey>))i, '\1[FILTERED]\2').
95
- gsub(%r((<hps:PaymentData>)[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2')
111
+ gsub(%r((<hps:PaymentData>)[^<]*(<\/hps:PaymentData>))i, '\1[FILTERED]\2').
112
+ gsub(%r((<hps:RoutingNumber>)[^<]*(<\/hps:RoutingNumber>))i, '\1[FILTERED]\2').
113
+ gsub(%r((<hps:AccountNumber>)[^<]*(<\/hps:AccountNumber>))i, '\1[FILTERED]\2')
96
114
  end
97
115
 
98
116
  private
99
117
 
118
+ def commit_check_sale(money, check, options)
119
+ commit('CheckSale') do |xml|
120
+ add_check_payment(xml, check, options)
121
+ add_amount(xml, money)
122
+ add_sec_code(xml, options)
123
+ add_check_customer_data(xml, check, options)
124
+ add_details(xml, options)
125
+ end
126
+ end
127
+
128
+ def commit_credit_sale(money, card_or_token, options)
129
+ commit('CreditSale') do |xml|
130
+ add_amount(xml, money)
131
+ add_allow_dup(xml)
132
+ add_card_or_token_customer_data(xml, card_or_token, options)
133
+ add_details(xml, options)
134
+ add_descriptor_name(xml, options)
135
+ add_card_or_token_payment(xml, card_or_token, options)
136
+ add_three_d_secure(xml, card_or_token, options)
137
+ add_stored_credentials(xml, options)
138
+ end
139
+ end
140
+
141
+ def commit_recurring_billing_sale(money, card_or_token, options)
142
+ commit('RecurringBilling') do |xml|
143
+ add_amount(xml, money)
144
+ add_allow_dup(xml)
145
+ add_card_or_token_customer_data(xml, card_or_token, options)
146
+ add_details(xml, options)
147
+ add_descriptor_name(xml, options)
148
+ add_card_or_token_payment(xml, card_or_token, options)
149
+ add_three_d_secure(xml, card_or_token, options)
150
+ add_stored_credentials(xml, options)
151
+ add_stored_credentials_for_recurring_billing(xml, options)
152
+ end
153
+ end
154
+
100
155
  def add_reference(xml, transaction_id)
101
- xml.hps :GatewayTxnId, transaction_id
156
+ reference = transaction_id.to_s.include?('|') ? transaction_id.split('|').first : transaction_id
157
+ xml.hps :GatewayTxnId, reference
102
158
  end
103
159
 
104
160
  def add_amount(xml, money)
105
161
  xml.hps :Amt, amount(money) if money
106
162
  end
107
163
 
108
- def add_customer_data(xml, credit_card, options)
164
+ def add_card_or_token_customer_data(xml, credit_card, options)
109
165
  xml.hps :CardHolderData do
110
166
  if credit_card.respond_to?(:number)
111
167
  xml.hps :CardHolderFirstName, credit_card.first_name if credit_card.first_name
@@ -115,20 +171,28 @@ module ActiveMerchant #:nodoc:
115
171
  xml.hps :CardHolderEmail, options[:email] if options[:email]
116
172
  xml.hps :CardHolderPhone, options[:phone] if options[:phone]
117
173
 
118
- if(billing_address = (options[:billing_address] || options[:address]))
174
+ if (billing_address = (options[:billing_address] || options[:address]))
119
175
  xml.hps :CardHolderAddr, billing_address[:address1] if billing_address[:address1]
120
176
  xml.hps :CardHolderCity, billing_address[:city] if billing_address[:city]
121
177
  xml.hps :CardHolderState, billing_address[:state] if billing_address[:state]
122
- xml.hps :CardHolderZip, billing_address[:zip] if billing_address[:zip]
178
+ xml.hps :CardHolderZip, alphanumeric_zip(billing_address[:zip]) if billing_address[:zip]
123
179
  end
124
180
  end
125
181
  end
126
182
 
127
- def add_payment(xml, card_or_token, options)
183
+ def add_check_customer_data(xml, check, options)
184
+ xml.hps :ConsumerInfo do
185
+ xml.hps :FirstName, check.first_name
186
+ xml.hps :LastName, check.last_name
187
+ xml.hps :CheckName, options[:company_name] if options[:company_name]
188
+ end
189
+ end
190
+
191
+ def add_card_or_token_payment(xml, card_or_token, options)
128
192
  xml.hps :CardData do
129
193
  if card_or_token.respond_to?(:number)
130
194
  if card_or_token.track_data
131
- xml.tag!('hps:TrackData', 'method'=>'swipe') do
195
+ xml.tag!('hps:TrackData', 'method' => 'swipe') do
132
196
  xml.text! card_or_token.track_data
133
197
  end
134
198
  if options[:encryption_type]
@@ -159,14 +223,29 @@ module ActiveMerchant #:nodoc:
159
223
  end
160
224
  end
161
225
 
226
+ def add_check_payment(xml, check, options)
227
+ xml.hps :CheckAction, 'SALE'
228
+ xml.hps :AccountInfo do
229
+ xml.hps :RoutingNumber, check.routing_number
230
+ xml.hps :AccountNumber, check.account_number
231
+ xml.hps :CheckNumber, check.number
232
+ xml.hps :AccountType, check.account_type&.upcase
233
+ end
234
+ xml.hps :CheckType, check.account_holder_type&.upcase
235
+ end
236
+
162
237
  def add_details(xml, options)
163
238
  xml.hps :AdditionalTxnFields do
164
239
  xml.hps :Description, options[:description] if options[:description]
165
- xml.hps :InvoiceNbr, options[:order_id] if options[:order_id]
240
+ xml.hps :InvoiceNbr, options[:order_id][0..59] if options[:order_id]
166
241
  xml.hps :CustomerID, options[:customer_id] if options[:customer_id]
167
242
  end
168
243
  end
169
244
 
245
+ def add_sec_code(xml, options)
246
+ xml.hps :SECCode, options[:sec_code] || 'WEB'
247
+ end
248
+
170
249
  def add_allow_dup(xml)
171
250
  xml.hps :AllowDup, 'Y'
172
251
  end
@@ -181,7 +260,7 @@ module ActiveMerchant #:nodoc:
181
260
  source: card_or_token.source,
182
261
  cavv: card_or_token.payment_cryptogram,
183
262
  eci: card_or_token.eci,
184
- xid: card_or_token.transaction_id,
263
+ xid: card_or_token.transaction_id
185
264
  })
186
265
  elsif options[:three_d_secure]
187
266
  options[:three_d_secure][:source] ||= card_brand(card_or_token)
@@ -204,8 +283,41 @@ module ActiveMerchant #:nodoc:
204
283
  end
205
284
  end
206
285
 
286
+ # We do not currently support installments on this gateway.
287
+ # The HPS gateway treats recurring transactions as a seperate transaction type
288
+ def add_stored_credentials(xml, options)
289
+ return unless options[:stored_credential]
290
+
291
+ xml.hps :CardOnFileData do
292
+ if options[:stored_credential][:initiator] == 'customer'
293
+ xml.hps :CardOnFile, 'C'
294
+ elsif options[:stored_credential][:initiator] == 'merchant'
295
+ xml.hps :CardOnFile, 'M'
296
+ else
297
+ return
298
+ end
299
+
300
+ if options[:stored_credential][:network_transaction_id]
301
+ xml.hps :CardBrandTxnId, options[:stored_credential][:network_transaction_id]
302
+ else
303
+ return
304
+ end
305
+ end
306
+ end
307
+
308
+ def add_stored_credentials_for_recurring_billing(xml, options)
309
+ xml.hps :RecurringData do
310
+ if options[:stored_credential][:reason_type] = 'recurring'
311
+ xml.hps :OneTime, 'N'
312
+ else
313
+ xml.hps :OneTime, 'Y'
314
+ end
315
+ end
316
+ end
317
+
207
318
  def strip_leading_zero(value)
208
319
  return value unless value[0] == '0'
320
+
209
321
  value[1, 1]
210
322
  end
211
323
 
@@ -213,8 +325,8 @@ module ActiveMerchant #:nodoc:
213
325
  xml = Builder::XmlMarkup.new(encoding: 'UTF-8')
214
326
  xml.instruct!(:xml, encoding: 'UTF-8')
215
327
  xml.SOAP :Envelope, {
216
- 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
217
- 'xmlns:hps' => 'http://Hps.Exchange.PosGateway'
328
+ 'xmlns:SOAP' => 'http://schemas.xmlsoap.org/soap/envelope/',
329
+ 'xmlns:hps' => 'http://Hps.Exchange.PosGateway'
218
330
  } do
219
331
  xml.SOAP :Body do
220
332
  xml.hps :PosRequest do
@@ -248,7 +360,7 @@ module ActiveMerchant #:nodoc:
248
360
 
249
361
  doc = Nokogiri::XML(raw)
250
362
  doc.remove_namespaces!
251
- if(header = doc.xpath('//Header').first)
363
+ if (header = doc.xpath('//Header').first)
252
364
  header.elements.each do |node|
253
365
  if node.elements.size == 0
254
366
  response[node.name] = node.text
@@ -259,33 +371,34 @@ module ActiveMerchant #:nodoc:
259
371
  end
260
372
  end
261
373
  end
262
- if(transaction = doc.xpath('//Transaction/*[1]').first)
374
+ if (transaction = doc.xpath('//Transaction/*[1]').first)
263
375
  transaction.elements.each do |node|
264
376
  response[node.name] = node.text
265
377
  end
266
378
  end
267
- if(fault = doc.xpath('//Fault/Reason/Text').first)
379
+ if (fault = doc.xpath('//Fault/Reason/Text').first)
268
380
  response['Fault'] = fault.text
269
381
  end
270
382
 
271
383
  response
272
384
  end
273
385
 
274
- def commit(action, &request)
386
+ def commit(action, reference = nil, &request)
275
387
  data = build_request(action, &request)
276
388
 
277
- response = begin
278
- parse(ssl_post((test? ? test_url : live_url), data, 'Content-Type' => 'text/xml'))
279
- rescue ResponseError => e
280
- parse(e.response.body)
281
- end
389
+ response =
390
+ begin
391
+ parse(ssl_post((test? ? test_url : live_url), data, 'Content-Type' => 'text/xml'))
392
+ rescue ResponseError => e
393
+ parse(e.response.body)
394
+ end
282
395
 
283
396
  ActiveMerchant::Billing::Response.new(
284
397
  successful?(response),
285
398
  message_from(response),
286
399
  response,
287
400
  test: test?,
288
- authorization: authorization_from(response),
401
+ authorization: authorization_from(response, reference),
289
402
  avs_result: {
290
403
  code: response['AVSRsltCode'],
291
404
  message: response['AVSRsltText']
@@ -294,28 +407,31 @@ module ActiveMerchant #:nodoc:
294
407
  )
295
408
  end
296
409
 
410
+ SUCCESSFUL_RESPONSE_CODES = %w(0 00 85)
297
411
  def successful?(response)
298
412
  (
299
413
  (response['GatewayRspCode'] == '0') &&
300
- ((response['RspCode'] || '00') == '00' || response['RspCode'] == '85')
414
+ ((SUCCESSFUL_RESPONSE_CODES.include? response['RspCode']) || !response['RspCode'])
301
415
  )
302
416
  end
303
417
 
304
418
  def message_from(response)
305
- if(response['Fault'])
419
+ if response['Fault']
306
420
  response['Fault']
307
- elsif(response['GatewayRspCode'] == '0')
308
- if(response['RspCode'] != '00' && response['RspCode'] != '85')
309
- issuer_message(response['RspCode'])
310
- else
421
+ elsif response['GatewayRspCode'] == '0'
422
+ if SUCCESSFUL_RESPONSE_CODES.include? response['RspCode']
311
423
  response['GatewayRspMsg']
424
+ else
425
+ issuer_message(response['RspCode'])
312
426
  end
313
427
  else
314
428
  (GATEWAY_MESSAGES[response['GatewayRspCode']] || response['GatewayRspMsg'])
315
429
  end
316
430
  end
317
431
 
318
- def authorization_from(response)
432
+ def authorization_from(response, reference)
433
+ return [reference, response['GatewayTxnId']].join('|') if reference
434
+
319
435
  response['GatewayTxnId']
320
436
  end
321
437
 
@@ -323,6 +439,10 @@ module ActiveMerchant #:nodoc:
323
439
  @options[:secret_api_key]&.include?('_cert_')
324
440
  end
325
441
 
442
+ def alphanumeric_zip(zip)
443
+ zip.gsub(/[^0-9a-z]/i, '')
444
+ end
445
+
326
446
  ISSUER_MESSAGES = {
327
447
  '13' => 'Must be greater than or equal 0.',
328
448
  '14' => 'The card number is incorrect.',
@@ -336,6 +456,7 @@ module ActiveMerchant #:nodoc:
336
456
  return 'The card was declined.' if %w(02 03 04 05 41 43 44 51 56 61 62 63 65 78).include?(code)
337
457
  return 'An error occurred while processing the card.' if %w(06 07 12 15 19 12 52 53 57 58 76 77 91 96 EC).include?(code)
338
458
  return "The card's security code is incorrect." if %w(EB N7).include?(code)
459
+
339
460
  ISSUER_MESSAGES[code]
340
461
  end
341
462