activemerchant 1.79.2 → 1.129.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (279) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +1391 -0
  3. data/README.md +29 -14
  4. data/lib/active_merchant/billing/avs_result.rb +25 -28
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +55 -22
  7. data/lib/active_merchant/billing/compatibility.rb +10 -12
  8. data/lib/active_merchant/billing/credit_card.rb +82 -62
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  10. data/lib/active_merchant/billing/credit_card_methods.rb +328 -58
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +61 -56
  13. data/lib/active_merchant/billing/gateways/adyen.rb +562 -87
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +35 -36
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +297 -196
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +94 -98
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +64 -66
  21. data/lib/active_merchant/billing/gateways/balanced.rb +72 -65
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +222 -0
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +16 -16
  24. data/lib/active_merchant/billing/gateways/banwire.rb +12 -12
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +140 -69
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +7 -7
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +7 -7
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +115 -115
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +39 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -2
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +87 -58
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +405 -104
  33. data/lib/active_merchant/billing/gateways/bogus.rb +34 -30
  34. data/lib/active_merchant/billing/gateways/borgun.rb +97 -47
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +20 -20
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +9 -3
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +561 -259
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +53 -54
  42. data/lib/active_merchant/billing/gateways/cams.rb +31 -31
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +85 -33
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +187 -169
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +24 -25
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +9 -7
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +43 -27
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +62 -52
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +63 -62
  52. data/lib/active_merchant/billing/gateways/checkout.rb +21 -23
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +391 -113
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -3
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +40 -41
  56. data/lib/active_merchant/billing/gateways/commerce_hub.rb +361 -0
  57. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  58. data/lib/active_merchant/billing/gateways/conekta.rb +35 -30
  59. data/lib/active_merchant/billing/gateways/creditcall.rb +59 -59
  60. data/lib/active_merchant/billing/gateways/credorax.rb +326 -145
  61. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  62. data/lib/active_merchant/billing/gateways/culqi.rb +53 -53
  63. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  64. data/lib/active_merchant/billing/gateways/cyber_source.rb +566 -208
  65. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +456 -0
  66. data/lib/active_merchant/billing/gateways/d_local.rb +342 -0
  67. data/lib/active_merchant/billing/gateways/data_cash.rb +40 -56
  68. data/lib/active_merchant/billing/gateways/decidir.rb +358 -0
  69. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  70. data/lib/active_merchant/billing/gateways/dibs.rb +34 -40
  71. data/lib/active_merchant/billing/gateways/digitzs.rb +48 -45
  72. data/lib/active_merchant/billing/gateways/ebanx.rb +110 -60
  73. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  74. data/lib/active_merchant/billing/gateways/elavon.rb +351 -189
  75. data/lib/active_merchant/billing/gateways/element.rb +106 -56
  76. data/lib/active_merchant/billing/gateways/epay.rb +74 -64
  77. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  78. data/lib/active_merchant/billing/gateways/eway.rb +74 -73
  79. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  80. data/lib/active_merchant/billing/gateways/eway_rapid.rb +105 -60
  81. data/lib/active_merchant/billing/gateways/exact.rb +29 -37
  82. data/lib/active_merchant/billing/gateways/ezic.rb +21 -22
  83. data/lib/active_merchant/billing/gateways/fat_zebra.rb +70 -48
  84. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  85. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -4
  86. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  87. data/lib/active_merchant/billing/gateways/first_pay.rb +33 -13
  88. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +106 -105
  89. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  90. data/lib/active_merchant/billing/gateways/flo2cash.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/forte.rb +70 -40
  93. data/lib/active_merchant/billing/gateways/garanti.rb +24 -31
  94. data/lib/active_merchant/billing/gateways/global_collect.rb +378 -154
  95. data/lib/active_merchant/billing/gateways/global_transport.rb +12 -13
  96. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  97. data/lib/active_merchant/billing/gateways/hps.rb +236 -69
  98. data/lib/active_merchant/billing/gateways/iats_payments.rb +61 -39
  99. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  100. data/lib/active_merchant/billing/gateways/inspire.rb +41 -47
  101. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  102. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  103. data/lib/active_merchant/billing/gateways/ipp.rb +25 -24
  104. data/lib/active_merchant/billing/gateways/iridium.rb +243 -244
  105. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  106. data/lib/active_merchant/billing/gateways/iveri.rb +73 -34
  107. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  108. data/lib/active_merchant/billing/gateways/jetpay.rb +145 -152
  109. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +154 -159
  110. data/lib/active_merchant/billing/gateways/komoju.rb +16 -16
  111. data/lib/active_merchant/billing/gateways/kushki.rb +127 -57
  112. data/lib/active_merchant/billing/gateways/latitude19.rb +111 -115
  113. data/lib/active_merchant/billing/gateways/linkpoint.rb +82 -85
  114. data/lib/active_merchant/billing/gateways/litle.rb +247 -53
  115. data/lib/active_merchant/billing/gateways/mastercard.rb +41 -23
  116. data/lib/active_merchant/billing/gateways/maxipago.rb +5 -5
  117. data/lib/active_merchant/billing/gateways/mercado_pago.rb +135 -49
  118. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +62 -29
  119. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  120. data/lib/active_merchant/billing/gateways/merchant_partners.rb +40 -40
  121. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  122. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +42 -44
  123. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +52 -14
  124. data/lib/active_merchant/billing/gateways/mercury.rb +47 -51
  125. data/lib/active_merchant/billing/gateways/metrics_global.rb +32 -42
  126. data/lib/active_merchant/billing/gateways/micropayment.rb +42 -45
  127. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  128. data/lib/active_merchant/billing/gateways/migs.rb +45 -40
  129. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  130. data/lib/active_merchant/billing/gateways/modern_payments.rb +2 -2
  131. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +29 -31
  132. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  133. data/lib/active_merchant/billing/gateways/monei.rb +255 -138
  134. data/lib/active_merchant/billing/gateways/moneris.rb +226 -88
  135. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  136. data/lib/active_merchant/billing/gateways/mundipagg.rb +117 -43
  137. data/lib/active_merchant/billing/gateways/nab_transact.rb +28 -31
  138. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +13 -15
  139. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  140. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  141. data/lib/active_merchant/billing/gateways/netbanx.rb +167 -80
  142. data/lib/active_merchant/billing/gateways/netbilling.rb +27 -30
  143. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  144. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  145. data/lib/active_merchant/billing/gateways/nmi.rb +134 -48
  146. data/lib/active_merchant/billing/gateways/ogone.rb +88 -58
  147. data/lib/active_merchant/billing/gateways/omise.rb +30 -31
  148. data/lib/active_merchant/billing/gateways/openpay.rb +45 -26
  149. data/lib/active_merchant/billing/gateways/opp.rb +166 -144
  150. data/lib/active_merchant/billing/gateways/optimal_payment.rb +67 -64
  151. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  152. data/lib/active_merchant/billing/gateways/orbital.rb +726 -382
  153. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +26 -27
  154. data/lib/active_merchant/billing/gateways/pagarme.rb +47 -56
  155. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  156. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  157. data/lib/active_merchant/billing/gateways/pay_conex.rb +39 -40
  158. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +65 -65
  159. data/lib/active_merchant/billing/gateways/pay_hub.rb +39 -39
  160. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  161. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +70 -54
  162. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  163. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  164. data/lib/active_merchant/billing/gateways/paybox_direct.rb +71 -47
  165. data/lib/active_merchant/billing/gateways/payeezy.rb +159 -32
  166. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  167. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +41 -36
  168. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  169. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  170. data/lib/active_merchant/billing/gateways/payflow.rb +178 -54
  171. data/lib/active_merchant/billing/gateways/payflow_express.rb +61 -65
  172. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +0 -1
  173. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -2
  174. data/lib/active_merchant/billing/gateways/payment_express.rb +66 -58
  175. data/lib/active_merchant/billing/gateways/paymentez.rb +114 -25
  176. data/lib/active_merchant/billing/gateways/paymill.rb +134 -133
  177. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  178. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  179. data/lib/active_merchant/billing/gateways/paypal.rb +27 -14
  180. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  181. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +2 -2
  182. data/lib/active_merchant/billing/gateways/paypal_express.rb +5 -2
  183. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  184. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  185. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  186. data/lib/active_merchant/billing/gateways/paystation.rb +79 -82
  187. data/lib/active_merchant/billing/gateways/payu_in.rb +59 -58
  188. data/lib/active_merchant/billing/gateways/payu_latam.rb +139 -97
  189. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  190. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  191. data/lib/active_merchant/billing/gateways/pin.rb +87 -34
  192. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  193. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  194. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  195. data/lib/active_merchant/billing/gateways/pro_pay.rb +139 -140
  196. data/lib/active_merchant/billing/gateways/psigate.rb +44 -44
  197. data/lib/active_merchant/billing/gateways/psl_card.rb +29 -37
  198. data/lib/active_merchant/billing/gateways/qbms.rb +75 -76
  199. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  200. data/lib/active_merchant/billing/gateways/quickbooks.rb +142 -55
  201. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +103 -107
  202. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +156 -158
  203. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +7 -8
  204. data/lib/active_merchant/billing/gateways/quickpay.rb +1 -3
  205. data/lib/active_merchant/billing/gateways/qvalent.rb +137 -68
  206. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  207. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  208. data/lib/active_merchant/billing/gateways/realex.rb +132 -50
  209. data/lib/active_merchant/billing/gateways/redsys.rb +382 -186
  210. data/lib/active_merchant/billing/gateways/s5.rb +16 -16
  211. data/lib/active_merchant/billing/gateways/safe_charge.rb +83 -47
  212. data/lib/active_merchant/billing/gateways/sage.rb +49 -48
  213. data/lib/active_merchant/billing/gateways/sage_pay.rb +76 -83
  214. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  215. data/lib/active_merchant/billing/gateways/secure_net.rb +32 -40
  216. data/lib/active_merchant/billing/gateways/secure_pay.rb +30 -40
  217. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +23 -26
  218. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  219. data/lib/active_merchant/billing/gateways/securion_pay.rb +69 -31
  220. data/lib/active_merchant/billing/gateways/shift4.rb +342 -0
  221. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  222. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -53
  223. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  224. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  225. data/lib/active_merchant/billing/gateways/spreedly_core.rb +66 -47
  226. data/lib/active_merchant/billing/gateways/stripe.rb +309 -148
  227. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +556 -0
  228. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +18 -23
  229. data/lib/active_merchant/billing/gateways/telr.rb +46 -48
  230. data/lib/active_merchant/billing/gateways/tns.rb +8 -7
  231. data/lib/active_merchant/billing/gateways/trans_first.rb +37 -37
  232. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +249 -245
  233. data/lib/active_merchant/billing/gateways/transact_pro.rb +25 -27
  234. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  235. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  236. data/lib/active_merchant/billing/gateways/trexle.rb +22 -18
  237. data/lib/active_merchant/billing/gateways/trust_commerce.rb +161 -88
  238. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  239. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +231 -238
  240. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +129 -55
  241. data/lib/active_merchant/billing/gateways/vanco.rb +42 -33
  242. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  243. data/lib/active_merchant/billing/gateways/viaklix.rb +18 -22
  244. data/lib/active_merchant/billing/gateways/visanet_peru.rb +115 -74
  245. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  246. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  247. data/lib/active_merchant/billing/gateways/wepay.rb +38 -41
  248. data/lib/active_merchant/billing/gateways/wirecard.rb +36 -37
  249. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  250. data/lib/active_merchant/billing/gateways/world_net.rb +39 -38
  251. data/lib/active_merchant/billing/gateways/worldpay.rb +756 -142
  252. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +73 -83
  253. data/lib/active_merchant/billing/gateways/worldpay_us.rb +31 -31
  254. data/lib/active_merchant/billing/model.rb +2 -2
  255. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +3 -3
  256. data/lib/active_merchant/billing/rails.rb +1 -1
  257. data/lib/active_merchant/billing/response.rb +32 -13
  258. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  259. data/lib/active_merchant/billing.rb +1 -0
  260. data/lib/active_merchant/connection.rb +24 -38
  261. data/lib/active_merchant/country.rb +9 -5
  262. data/lib/active_merchant/errors.rb +4 -1
  263. data/lib/active_merchant/net_http_ssl_connection.rb +2 -0
  264. data/lib/active_merchant/network_connection_retries.rb +28 -31
  265. data/lib/active_merchant/post_data.rb +5 -3
  266. data/lib/active_merchant/posts_data.rb +5 -7
  267. data/lib/active_merchant/version.rb +1 -1
  268. data/lib/active_merchant.rb +3 -3
  269. data/lib/activemerchant.rb +1 -1
  270. data/lib/certs/cacert.pem +1592 -2329
  271. data/lib/support/gateway_support.rb +8 -10
  272. data/lib/support/ssl_verify.rb +9 -14
  273. data/lib/support/ssl_version.rb +9 -10
  274. metadata +98 -37
  275. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  278. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  279. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -309
@@ -10,26 +10,26 @@ module ActiveMerchant #:nodoc:
10
10
 
11
11
  self.ignore_http_status = true
12
12
 
13
- CARD_CODE_ERRORS = %w( N S )
14
- AVS_ERRORS = %w( A E N R W Z )
13
+ CARD_CODE_ERRORS = %w(N S)
14
+ AVS_ERRORS = %w(A E N R W Z)
15
15
  AVS_REASON_CODES = %w(27 45)
16
16
 
17
17
  FIELD_MAP = {
18
18
  'TRANS_ID' => :transaction_id,
19
19
  'STATUS' => :response_code,
20
20
  'AVS' => :avs_result_code,
21
- 'CVV2'=> :card_code,
21
+ 'CVV2' => :card_code,
22
22
  'AUTH_CODE' => :authorization,
23
23
  'MESSAGE' => :message,
24
24
  'REBID' => :rebid,
25
25
  'TRANS_TYPE' => :trans_type,
26
26
  'PAYMENT_ACCOUNT_MASK' => :acct_mask,
27
- 'CARD_TYPE' => :card_type,
27
+ 'CARD_TYPE' => :card_type
28
28
  }
29
29
 
30
30
  REBILL_FIELD_MAP = {
31
31
  'REBILL_ID' => :rebill_id,
32
- 'ACCOUNT_ID'=> :account_id,
32
+ 'ACCOUNT_ID' => :account_id,
33
33
  'USER_ID' => :user_id,
34
34
  'TEMPLATE_ID' => :template_id,
35
35
  'STATUS' => :status,
@@ -41,10 +41,11 @@ module ActiveMerchant #:nodoc:
41
41
  'REB_AMOUNT' => :rebill_amount,
42
42
  'NEXT_AMOUNT' => :next_amount,
43
43
  'USUAL_DATE' => :undoc_usual_date, # Not found in the bp20rebadmin API doc.
44
+ 'CUST_TOKEN' => :cust_token
44
45
  }
45
46
 
46
- self.supported_countries = ['US', 'CA']
47
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
47
+ self.supported_countries = %w[US CA]
48
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
48
49
  self.homepage_url = 'http://www.bluepay.com/'
49
50
  self.display_name = 'BluePay'
50
51
  self.money_format = :dollars
@@ -83,8 +84,9 @@ module ActiveMerchant #:nodoc:
83
84
  add_customer_data(post, options)
84
85
  add_rebill(post, options) if options[:rebill]
85
86
  add_duplicate_override(post, options)
86
- post[:TRANS_TYPE] = 'AUTH'
87
- commit('AUTH_ONLY', money, post)
87
+ add_stored_credential(post, options)
88
+ post[:TRANS_TYPE] = 'AUTH'
89
+ commit('AUTH_ONLY', money, post, options)
88
90
  end
89
91
 
90
92
  # Perform a purchase, which is essentially an authorization and capture in a single operation.
@@ -106,8 +108,9 @@ module ActiveMerchant #:nodoc:
106
108
  add_customer_data(post, options)
107
109
  add_rebill(post, options) if options[:rebill]
108
110
  add_duplicate_override(post, options)
109
- post[:TRANS_TYPE] = 'SALE'
110
- commit('AUTH_CAPTURE', money, post)
111
+ add_stored_credential(post, options)
112
+ post[:TRANS_TYPE] = 'SALE'
113
+ commit('AUTH_CAPTURE', money, post, options)
111
114
  end
112
115
 
113
116
  # Captures the funds from an authorize transaction.
@@ -123,7 +126,7 @@ module ActiveMerchant #:nodoc:
123
126
  add_customer_data(post, options)
124
127
  post[:MASTER_ID] = identification
125
128
  post[:TRANS_TYPE] = 'CAPTURE'
126
- commit('PRIOR_AUTH_CAPTURE', money, post)
129
+ commit('PRIOR_AUTH_CAPTURE', money, post, options)
127
130
  end
128
131
 
129
132
  # Void a previous transaction
@@ -136,7 +139,7 @@ module ActiveMerchant #:nodoc:
136
139
  post = {}
137
140
  post[:MASTER_ID] = identification
138
141
  post[:TRANS_TYPE] = 'VOID'
139
- commit('VOID', nil, post)
142
+ commit('VOID', nil, post, options)
140
143
  end
141
144
 
142
145
  # Performs a credit.
@@ -154,8 +157,8 @@ module ActiveMerchant #:nodoc:
154
157
  # If the payment_object is either a CreditCard or Check object, then the transaction type will be an unmatched credit placing funds in the specified account. This is referred to a CREDIT transaction in BluePay.
155
158
  # * <tt>options</tt> -- A hash of parameters.
156
159
  def refund(money, identification, options = {})
157
- if(identification && !identification.kind_of?(String))
158
- ActiveMerchant.deprecated "refund should only be used to refund a referenced transaction"
160
+ if identification && !identification.kind_of?(String)
161
+ ActiveMerchant.deprecated 'refund should only be used to refund a referenced transaction'
159
162
  return credit(money, identification, options)
160
163
  end
161
164
 
@@ -163,18 +166,19 @@ module ActiveMerchant #:nodoc:
163
166
  post[:PAYMENT_ACCOUNT] = ''
164
167
  post[:MASTER_ID] = identification
165
168
  post[:TRANS_TYPE] = 'REFUND'
166
- post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
169
+ post[:DOC_TYPE] = options[:doc_type] if options[:doc_type]
170
+ post[:NAME1] = options[:first_name] || ''
167
171
  post[:NAME2] = options[:last_name] if options[:last_name]
168
172
  post[:ZIP] = options[:zip] if options[:zip]
169
173
  add_invoice(post, options)
170
174
  add_address(post, options)
171
175
  add_customer_data(post, options)
172
- commit('CREDIT', money, post)
176
+ commit('CREDIT', money, post, options)
173
177
  end
174
178
 
175
179
  def credit(money, payment_object, options = {})
176
- if(payment_object && payment_object.kind_of?(String))
177
- ActiveMerchant.deprecated "credit should only be used to credit a payment method"
180
+ if payment_object&.kind_of?(String)
181
+ ActiveMerchant.deprecated 'credit should only be used to credit a payment method'
178
182
  return refund(money, payment_object, options)
179
183
  end
180
184
 
@@ -182,14 +186,15 @@ module ActiveMerchant #:nodoc:
182
186
  post[:PAYMENT_ACCOUNT] = ''
183
187
  add_payment_method(post, payment_object)
184
188
  post[:TRANS_TYPE] = 'CREDIT'
189
+ post[:DOC_TYPE] = options[:doc_type] if options[:doc_type]
185
190
 
186
- post[:NAME1] = (options[:first_name] ? options[:first_name] : "")
191
+ post[:NAME1] = options[:first_name] || ''
187
192
  post[:NAME2] = options[:last_name] if options[:last_name]
188
193
  post[:ZIP] = options[:zip] if options[:zip]
189
194
  add_invoice(post, options)
190
195
  add_address(post, options)
191
196
  add_customer_data(post, options)
192
- commit('CREDIT', money, post)
197
+ commit('CREDIT', money, post, options)
193
198
  end
194
199
 
195
200
  # Create a new recurring payment.
@@ -313,10 +318,11 @@ module ActiveMerchant #:nodoc:
313
318
 
314
319
  private
315
320
 
316
- def commit(action, money, fields)
317
- fields[:AMOUNT] = amount(money) unless(fields[:TRANS_TYPE] == 'VOID' || action == 'rebill')
321
+ def commit(action, money, fields, options = {})
322
+ fields[:AMOUNT] = amount(money) unless fields[:TRANS_TYPE] == 'VOID' || action == 'rebill'
318
323
  fields[:MODE] = (test? ? 'TEST' : 'LIVE')
319
324
  fields[:ACCOUNT_ID] = @options[:login]
325
+ fields[:CUSTOMER_IP] = options[:ip] if options[:ip]
320
326
 
321
327
  if action == 'rebill'
322
328
  url = rebilling_url
@@ -328,9 +334,9 @@ module ActiveMerchant #:nodoc:
328
334
  parse(ssl_post(url, post_data(action, fields)))
329
335
  end
330
336
 
331
- def parse_recurring(response_fields, opts={}) # expected status?
337
+ def parse_recurring(response_fields, opts = {}) # expected status?
332
338
  parsed = {}
333
- response_fields.each do |k,v|
339
+ response_fields.each do |k, v|
334
340
  mapped_key = REBILL_FIELD_MAP.include?(k) ? REBILL_FIELD_MAP[k] : k
335
341
  parsed[mapped_key] = v
336
342
  end
@@ -339,20 +345,18 @@ module ActiveMerchant #:nodoc:
339
345
  message = parsed[:status]
340
346
 
341
347
  Response.new(success, message, parsed,
342
- :test => test?,
343
- :authorization => parsed[:rebill_id])
348
+ test: test?,
349
+ authorization: parsed[:rebill_id])
344
350
  end
345
351
 
346
352
  def parse(body)
347
353
  # The bp20api has max one value per form field.
348
- response_fields = Hash[CGI::parse(body).map{|k,v| [k.upcase,v.first]}]
354
+ response_fields = Hash[CGI::parse(body).map { |k, v| [k.upcase, v.first] }]
349
355
 
350
- if response_fields.include? "REBILL_ID"
351
- return parse_recurring(response_fields)
352
- end
356
+ return parse_recurring(response_fields) if response_fields.include? 'REBILL_ID'
353
357
 
354
358
  parsed = {}
355
- response_fields.each do |k,v|
359
+ response_fields.each do |k, v|
356
360
  mapped_key = FIELD_MAP.include?(k) ? FIELD_MAP[k] : k
357
361
  parsed[mapped_key] = v
358
362
  end
@@ -361,29 +365,28 @@ module ActiveMerchant #:nodoc:
361
365
  message = message_from(parsed)
362
366
  success = parsed[:response_code] == '1'
363
367
  Response.new(success, message, parsed,
364
- :test => test?,
365
- :authorization => (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
366
- :avs_result => { :code => parsed[:avs_result_code] },
367
- :cvv_result => parsed[:card_code]
368
- )
368
+ test: test?,
369
+ authorization: (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
370
+ avs_result: { code: parsed[:avs_result_code] },
371
+ cvv_result: parsed[:card_code])
369
372
  end
370
373
 
371
374
  def message_from(parsed)
372
375
  message = parsed[:message]
373
- if(parsed[:response_code].to_i == 2)
376
+ if parsed[:response_code].to_i == 2
374
377
  if CARD_CODE_ERRORS.include?(parsed[:card_code])
375
378
  message = CVVResult.messages[parsed[:card_code]]
376
379
  elsif AVS_ERRORS.include?(parsed[:avs_result_code])
377
- message = AVSResult.messages[ parsed[:avs_result_code] ]
380
+ message = AVSResult.messages[parsed[:avs_result_code]]
378
381
  else
379
382
  message = message.chomp('.')
380
383
  end
381
- elsif message == "Missing ACCOUNT_ID"
382
- message = "The merchant login ID or password is invalid"
383
- elsif message =~ /Approved/
384
- message = "This transaction has been approved"
385
- elsif message =~ /Expired/
386
- message = "The credit card has expired"
384
+ elsif message == 'Missing ACCOUNT_ID'
385
+ message = 'The merchant login ID or password is invalid'
386
+ elsif /Approved/.match?(message)
387
+ message = 'This transaction has been approved'
388
+ elsif /Expired/.match?(message)
389
+ message = 'The credit card has expired'
387
390
  end
388
391
  message
389
392
  end
@@ -418,13 +421,13 @@ module ActiveMerchant #:nodoc:
418
421
  end
419
422
 
420
423
  CHECK_ACCOUNT_TYPES = {
421
- "checking" => "C",
422
- "savings" => "S"
424
+ 'checking' => 'C',
425
+ 'savings' => 'S'
423
426
  }
424
427
 
425
428
  def add_check(post, check)
426
429
  post[:PAYMENT_TYPE] = 'ACH'
427
- post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(":")
430
+ post[:PAYMENT_ACCOUNT] = [CHECK_ACCOUNT_TYPES[check.account_type], check.routing_number, check.account_number].join(':')
428
431
  post[:NAME1] = check.first_name
429
432
  post[:NAME2] = check.last_name
430
433
  end
@@ -460,20 +463,47 @@ module ActiveMerchant #:nodoc:
460
463
  post[:REB_CYCLES] = options[:rebill_cycles]
461
464
  end
462
465
 
466
+ def add_stored_credential(post, options)
467
+ post[:cof] = initiator(options)
468
+ post[:cofscheduled] = scheduled(options)
469
+ end
470
+
471
+ def initiator(options)
472
+ return unless initiator = options.dig(:stored_credential, :initiator)
473
+
474
+ case initiator
475
+ when 'merchant'
476
+ 'M'
477
+ when 'cardholder'
478
+ 'C'
479
+ end
480
+ end
481
+
482
+ def scheduled(options)
483
+ return unless reason_type = options.dig(:stored_credential, :reason_type)
484
+
485
+ case reason_type
486
+ when 'recurring', 'installment'
487
+ 'Y'
488
+ when 'unscheduled'
489
+ 'N'
490
+ end
491
+ end
492
+
463
493
  def post_data(action, parameters = {})
464
494
  post = {}
465
495
  post[:version] = '1'
466
496
  post[:login] = ''
467
497
  post[:tran_key] = ''
468
- post[:relay_response] = "FALSE"
498
+ post[:relay_response] = 'FALSE'
469
499
  post[:type] = action
470
- post[:delim_data] = "TRUE"
471
- post[:delim_char] = ","
472
- post[:encap_char] = "$"
500
+ post[:delim_data] = 'TRUE'
501
+ post[:delim_char] = ','
502
+ post[:encap_char] = '$'
473
503
  post[:card_num] = '4111111111111111'
474
504
  post[:exp_date] = '1212'
475
505
  post[:solution_ID] = application_id if application_id
476
- post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
506
+ post.merge(parameters).collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
477
507
  end
478
508
 
479
509
  def expdate(creditcard)
@@ -494,7 +524,7 @@ module ActiveMerchant #:nodoc:
494
524
  post[:MASTER_ID],
495
525
  post[:NAME1],
496
526
  post[:PAYMENT_ACCOUNT]
497
- ].join("")
527
+ ].join('')
498
528
  )
499
529
  end
500
530
 
@@ -505,14 +535,13 @@ module ActiveMerchant #:nodoc:
505
535
  @options[:login],
506
536
  post[:TRANS_TYPE],
507
537
  post[:REBILL_ID]
508
- ].join("")
538
+ ].join('')
509
539
  )
510
540
  end
511
541
 
512
542
  def handle_response(response)
513
- if ignore_http_status || (200...300).include?(response.code.to_i)
514
- return response.body
515
- end
543
+ return response.body if ignore_http_status || (200...300).cover?(response.code.to_i)
544
+
516
545
  raise ResponseError.new(response)
517
546
  end
518
547
  end