activemerchant 1.45.0 → 1.126.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (288) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +2167 -2
  3. data/CONTRIBUTORS +57 -0
  4. data/README.md +62 -41
  5. data/lib/active_merchant/billing/avs_result.rb +25 -28
  6. data/lib/active_merchant/billing/base.rb +11 -35
  7. data/lib/active_merchant/billing/check.rb +28 -24
  8. data/lib/active_merchant/billing/compatibility.rb +10 -12
  9. data/lib/active_merchant/billing/credit_card.rb +141 -69
  10. data/lib/active_merchant/billing/credit_card_formatting.rb +4 -4
  11. data/lib/active_merchant/billing/credit_card_methods.rb +348 -52
  12. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  13. data/lib/active_merchant/billing/gateway.rb +125 -61
  14. data/lib/active_merchant/billing/gateways/adyen.rb +633 -127
  15. data/lib/active_merchant/billing/gateways/airwallex.rb +341 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +205 -0
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +883 -195
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +31 -24
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +104 -103
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +179 -0
  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 +24 -13
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +397 -0
  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 +143 -62
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +45 -13
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +13 -10
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +549 -506
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +623 -0
  33. data/lib/active_merchant/billing/gateways/bogus.rb +82 -36
  34. data/lib/active_merchant/billing/gateways/borgun.rb +61 -40
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +277 -0
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +21 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +3 -3
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +592 -203
  40. data/lib/active_merchant/billing/gateways/braintree_orange.rb +3 -4
  41. data/lib/active_merchant/billing/gateways/bridge_pay.rb +116 -61
  42. data/lib/active_merchant/billing/gateways/cams.rb +230 -0
  43. data/lib/active_merchant/billing/gateways/card_connect.rb +320 -0
  44. data/lib/active_merchant/billing/gateways/card_save.rb +7 -9
  45. data/lib/active_merchant/billing/gateways/card_stream.rb +248 -97
  46. data/lib/active_merchant/billing/gateways/cardknox.rb +327 -0
  47. data/lib/active_merchant/billing/gateways/cardprocess.rb +256 -0
  48. data/lib/active_merchant/billing/gateways/cashnet.rb +70 -26
  49. data/lib/active_merchant/billing/gateways/cc5.rb +14 -17
  50. data/lib/active_merchant/billing/gateways/cecabank.rb +73 -53
  51. data/lib/active_merchant/billing/gateways/cenpos.rb +328 -0
  52. data/lib/active_merchant/billing/gateways/checkout.rb +32 -33
  53. data/lib/active_merchant/billing/gateways/checkout_v2.rb +340 -0
  54. data/lib/active_merchant/billing/gateways/citrus_pay.rb +21 -0
  55. data/lib/active_merchant/billing/gateways/clearhaus.rb +219 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +11 -12
  57. data/lib/active_merchant/billing/gateways/conekta.rb +55 -34
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +272 -0
  59. data/lib/active_merchant/billing/gateways/credorax.rb +506 -0
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +269 -0
  61. data/lib/active_merchant/billing/gateways/culqi.rb +279 -0
  62. data/lib/active_merchant/billing/gateways/cyber_source.rb +637 -221
  63. data/lib/active_merchant/billing/gateways/d_local.rb +303 -0
  64. data/lib/active_merchant/billing/gateways/data_cash.rb +57 -355
  65. data/lib/active_merchant/billing/gateways/decidir.rb +347 -0
  66. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  67. data/lib/active_merchant/billing/gateways/dibs.rb +199 -0
  68. data/lib/active_merchant/billing/gateways/digitzs.rb +295 -0
  69. data/lib/active_merchant/billing/gateways/ebanx.rb +334 -0
  70. data/lib/active_merchant/billing/gateways/efsnet.rb +46 -50
  71. data/lib/active_merchant/billing/gateways/elavon.rb +377 -250
  72. data/lib/active_merchant/billing/gateways/element.rb +386 -0
  73. data/lib/active_merchant/billing/gateways/epay.rb +92 -71
  74. data/lib/active_merchant/billing/gateways/evo_ca.rb +13 -14
  75. data/lib/active_merchant/billing/gateways/eway.rb +85 -73
  76. data/lib/active_merchant/billing/gateways/eway_managed.rb +85 -87
  77. data/lib/active_merchant/billing/gateways/eway_rapid.rb +134 -80
  78. data/lib/active_merchant/billing/gateways/exact.rb +37 -36
  79. data/lib/active_merchant/billing/gateways/ezic.rb +195 -0
  80. data/lib/active_merchant/billing/gateways/fat_zebra.rb +124 -74
  81. data/lib/active_merchant/billing/gateways/federated_canada.rb +11 -13
  82. data/lib/active_merchant/billing/gateways/finansbank.rb +4 -5
  83. data/lib/active_merchant/billing/gateways/first_giving.rb +23 -23
  84. data/lib/active_merchant/billing/gateways/first_pay.rb +45 -23
  85. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +184 -87
  86. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +505 -0
  87. data/lib/active_merchant/billing/gateways/flo2cash.rb +215 -0
  88. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +20 -0
  89. data/lib/active_merchant/billing/gateways/forte.rb +286 -0
  90. data/lib/active_merchant/billing/gateways/garanti.rb +31 -32
  91. data/lib/active_merchant/billing/gateways/global_collect.rb +507 -0
  92. data/lib/active_merchant/billing/gateways/global_transport.rb +25 -15
  93. data/lib/active_merchant/billing/gateways/hdfc.rb +55 -57
  94. data/lib/active_merchant/billing/gateways/hps.rb +252 -68
  95. data/lib/active_merchant/billing/gateways/iats_payments.rb +99 -38
  96. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +15 -0
  97. data/lib/active_merchant/billing/gateways/inspire.rb +48 -48
  98. data/lib/active_merchant/billing/gateways/instapay.rb +10 -14
  99. data/lib/active_merchant/billing/gateways/ipg.rb +415 -0
  100. data/lib/active_merchant/billing/gateways/ipp.rb +176 -0
  101. data/lib/active_merchant/billing/gateways/iridium.rb +254 -244
  102. data/lib/active_merchant/billing/gateways/itransact.rb +14 -14
  103. data/lib/active_merchant/billing/gateways/iveri.rb +254 -0
  104. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  105. data/lib/active_merchant/billing/gateways/jetpay.rb +200 -80
  106. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +432 -0
  107. data/lib/active_merchant/billing/gateways/komoju.rb +115 -0
  108. data/lib/active_merchant/billing/gateways/kushki.rb +277 -0
  109. data/lib/active_merchant/billing/gateways/latitude19.rb +412 -0
  110. data/lib/active_merchant/billing/gateways/linkpoint.rb +95 -85
  111. data/lib/active_merchant/billing/gateways/litle.rb +371 -94
  112. data/lib/active_merchant/billing/gateways/mastercard.rb +293 -0
  113. data/lib/active_merchant/billing/gateways/maxipago.rb +146 -123
  114. data/lib/active_merchant/billing/gateways/mercado_pago.rb +331 -0
  115. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +47 -23
  116. data/lib/active_merchant/billing/gateways/merchant_one.rb +16 -20
  117. data/lib/active_merchant/billing/gateways/merchant_partners.rb +245 -0
  118. data/lib/active_merchant/billing/gateways/merchant_ware.rb +54 -60
  119. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +60 -44
  120. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +76 -23
  121. data/lib/active_merchant/billing/gateways/mercury.rb +73 -54
  122. data/lib/active_merchant/billing/gateways/metrics_global.rb +33 -43
  123. data/lib/active_merchant/billing/gateways/micropayment.rb +182 -0
  124. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  125. data/lib/active_merchant/billing/gateways/migs.rb +101 -37
  126. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  127. data/lib/active_merchant/billing/gateways/modern_payments.rb +3 -3
  128. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +30 -34
  129. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  130. data/lib/active_merchant/billing/gateways/monei.rb +422 -0
  131. data/lib/active_merchant/billing/gateways/moneris.rb +236 -72
  132. data/lib/active_merchant/billing/gateways/money_movers.rb +11 -13
  133. data/lib/active_merchant/billing/gateways/mundipagg.rb +363 -0
  134. data/lib/active_merchant/billing/gateways/nab_transact.rb +87 -68
  135. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +163 -0
  136. data/lib/active_merchant/billing/gateways/net_registry.rb +12 -12
  137. data/lib/active_merchant/billing/gateways/netaxept.rb +33 -34
  138. data/lib/active_merchant/billing/gateways/netbanx.rb +376 -0
  139. data/lib/active_merchant/billing/gateways/netbilling.rb +82 -43
  140. data/lib/active_merchant/billing/gateways/netpay.rb +10 -10
  141. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -11
  142. data/lib/active_merchant/billing/gateways/nmi.rb +279 -174
  143. data/lib/active_merchant/billing/gateways/ogone.rb +96 -50
  144. data/lib/active_merchant/billing/gateways/omise.rb +323 -0
  145. data/lib/active_merchant/billing/gateways/openpay.rb +58 -23
  146. data/lib/active_merchant/billing/gateways/opp.rb +394 -0
  147. data/lib/active_merchant/billing/gateways/optimal_payment.rb +87 -69
  148. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +5 -7
  149. data/lib/active_merchant/billing/gateways/orbital.rb +771 -328
  150. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +31 -32
  151. data/lib/active_merchant/billing/gateways/pagarme.rb +239 -0
  152. data/lib/active_merchant/billing/gateways/pago_facil.rb +12 -14
  153. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  154. data/lib/active_merchant/billing/gateways/pay_conex.rb +245 -0
  155. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +84 -68
  156. data/lib/active_merchant/billing/gateways/pay_hub.rb +213 -0
  157. data/lib/active_merchant/billing/gateways/pay_junction.rb +37 -37
  158. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +206 -0
  159. data/lib/active_merchant/billing/gateways/pay_secure.rb +15 -17
  160. data/lib/active_merchant/billing/gateways/pay_trace.rb +404 -0
  161. data/lib/active_merchant/billing/gateways/paybox_direct.rb +85 -49
  162. data/lib/active_merchant/billing/gateways/payeezy.rb +458 -0
  163. data/lib/active_merchant/billing/gateways/payex.rb +39 -42
  164. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +67 -41
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +11 -8
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +3 -3
  167. data/lib/active_merchant/billing/gateways/payflow.rb +215 -46
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +64 -68
  169. data/lib/active_merchant/billing/gateways/payflow_express_uk.rb +2 -3
  170. data/lib/active_merchant/billing/gateways/payflow_uk.rb +5 -6
  171. data/lib/active_merchant/billing/gateways/payment_express.rb +78 -58
  172. data/lib/active_merchant/billing/gateways/paymentez.rb +353 -0
  173. data/lib/active_merchant/billing/gateways/paymill.rb +163 -75
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +55 -7
  175. data/lib/active_merchant/billing/gateways/paypal/paypal_recurring_api.rb +1 -1
  176. data/lib/active_merchant/billing/gateways/paypal.rb +37 -18
  177. data/lib/active_merchant/billing/gateways/paypal_ca.rb +2 -2
  178. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +5 -5
  179. data/lib/active_merchant/billing/gateways/paypal_express.rb +12 -6
  180. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +3 -3
  181. data/lib/active_merchant/billing/gateways/paysafe.rb +412 -0
  182. data/lib/active_merchant/billing/gateways/payscout.rb +10 -13
  183. data/lib/active_merchant/billing/gateways/paystation.rb +96 -91
  184. data/lib/active_merchant/billing/gateways/payu_in.rb +249 -0
  185. data/lib/active_merchant/billing/gateways/payu_latam.rb +479 -0
  186. data/lib/active_merchant/billing/gateways/payway.rb +27 -27
  187. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  188. data/lib/active_merchant/billing/gateways/pin.rb +113 -37
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +82 -82
  190. data/lib/active_merchant/billing/gateways/priority.rb +369 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +325 -0
  192. data/lib/active_merchant/billing/gateways/psigate.rb +55 -44
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +32 -40
  194. data/lib/active_merchant/billing/gateways/qbms.rb +86 -76
  195. data/lib/active_merchant/billing/gateways/quantum.rb +21 -23
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +377 -0
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +184 -0
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +297 -0
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +226 -0
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +10 -353
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +305 -0
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +258 -0
  203. data/lib/active_merchant/billing/gateways/realex.rb +154 -52
  204. data/lib/active_merchant/billing/gateways/redsys.rb +488 -161
  205. data/lib/active_merchant/billing/gateways/s5.rb +247 -0
  206. data/lib/active_merchant/billing/gateways/safe_charge.rb +298 -0
  207. data/lib/active_merchant/billing/gateways/sage.rb +404 -133
  208. data/lib/active_merchant/billing/gateways/sage_pay.rb +145 -109
  209. data/lib/active_merchant/billing/gateways/sallie_mae.rb +13 -15
  210. data/lib/active_merchant/billing/gateways/secure_net.rb +62 -54
  211. data/lib/active_merchant/billing/gateways/secure_pay.rb +32 -42
  212. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +36 -27
  213. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +14 -16
  214. data/lib/active_merchant/billing/gateways/securion_pay.rb +265 -0
  215. data/lib/active_merchant/billing/gateways/simetrik.rb +362 -0
  216. data/lib/active_merchant/billing/gateways/skip_jack.rb +52 -54
  217. data/lib/active_merchant/billing/gateways/smart_ps.rb +51 -60
  218. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +29 -29
  219. data/lib/active_merchant/billing/gateways/spreedly_core.rb +108 -43
  220. data/lib/active_merchant/billing/gateways/stripe.rb +536 -120
  221. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +516 -0
  222. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +19 -25
  223. data/lib/active_merchant/billing/gateways/telr.rb +273 -0
  224. data/lib/active_merchant/billing/gateways/tns.rb +16 -217
  225. data/lib/active_merchant/billing/gateways/trans_first.rb +148 -34
  226. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +612 -0
  227. data/lib/active_merchant/billing/gateways/transact_pro.rb +222 -0
  228. data/lib/active_merchant/billing/gateways/transax.rb +6 -8
  229. data/lib/active_merchant/billing/gateways/transnational.rb +1 -2
  230. data/lib/active_merchant/billing/gateways/trexle.rb +221 -0
  231. data/lib/active_merchant/billing/gateways/trust_commerce.rb +162 -89
  232. data/lib/active_merchant/billing/gateways/usa_epay.rb +5 -6
  233. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +332 -236
  234. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +185 -72
  235. data/lib/active_merchant/billing/gateways/vanco.rb +294 -0
  236. data/lib/active_merchant/billing/gateways/verifi.rb +52 -53
  237. data/lib/active_merchant/billing/gateways/viaklix.rb +19 -31
  238. data/lib/active_merchant/billing/gateways/visanet_peru.rb +250 -0
  239. data/lib/active_merchant/billing/gateways/vpos.rb +220 -0
  240. data/lib/active_merchant/billing/gateways/webpay.rb +9 -9
  241. data/lib/active_merchant/billing/gateways/wepay.rb +108 -62
  242. data/lib/active_merchant/billing/gateways/wirecard.rb +52 -43
  243. data/lib/active_merchant/billing/gateways/wompi.rb +193 -0
  244. data/lib/active_merchant/billing/gateways/world_net.rb +345 -0
  245. data/lib/active_merchant/billing/gateways/worldpay.rb +725 -121
  246. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +208 -0
  247. data/lib/active_merchant/billing/gateways/worldpay_us.rb +79 -39
  248. data/lib/active_merchant/billing/gateways.rb +8 -11
  249. data/lib/active_merchant/billing/model.rb +2 -2
  250. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +39 -0
  251. data/lib/active_merchant/billing/payment_token.rb +1 -1
  252. data/lib/active_merchant/billing/rails.rb +1 -1
  253. data/lib/active_merchant/billing/response.rb +19 -13
  254. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  255. data/lib/active_merchant/billing.rb +3 -0
  256. data/lib/active_merchant/connection.rb +196 -0
  257. data/lib/active_merchant/country.rb +13 -8
  258. data/lib/active_merchant/errors.rb +6 -0
  259. data/lib/active_merchant/net_http_ssl_connection.rb +11 -0
  260. data/lib/active_merchant/network_connection_retries.rb +78 -0
  261. data/lib/active_merchant/post_data.rb +26 -0
  262. data/lib/active_merchant/posts_data.rb +92 -0
  263. data/lib/active_merchant/version.rb +1 -1
  264. data/lib/active_merchant.rb +14 -59
  265. data/lib/activemerchant.rb +1 -1
  266. data/lib/certs/cacert.pem +3214 -0
  267. data/lib/support/gateway_support.rb +8 -10
  268. data/lib/support/outbound_hosts.rb +13 -10
  269. data/lib/support/ssl_verify.rb +9 -14
  270. data/lib/support/ssl_version.rb +86 -0
  271. metadata +136 -94
  272. checksums.yaml.gz.sig +0 -1
  273. data/lib/active_merchant/billing/gateways/app55.rb +0 -176
  274. data/lib/active_merchant/billing/gateways/barclays_epdq.rb +0 -314
  275. data/lib/active_merchant/billing/gateways/certo_direct.rb +0 -278
  276. data/lib/active_merchant/billing/gateways/ideal/ideal_base.rb +0 -246
  277. data/lib/active_merchant/billing/gateways/ideal/ideal_rabobank.pem +0 -13
  278. data/lib/active_merchant/billing/gateways/ideal/ideal_response.rb +0 -29
  279. data/lib/active_merchant/billing/gateways/ideal_rabobank.rb +0 -66
  280. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -291
  281. data/lib/active_merchant/billing/gateways/sage/sage_bankcard.rb +0 -87
  282. data/lib/active_merchant/billing/gateways/sage/sage_core.rb +0 -114
  283. data/lib/active_merchant/billing/gateways/sage/sage_vault.rb +0 -149
  284. data/lib/active_merchant/billing/gateways/sage/sage_virtual_check.rb +0 -102
  285. data/lib/active_merchant/billing/gateways/vindicia.rb +0 -385
  286. data/lib/active_merchant/offsite_payments_shim.rb +0 -19
  287. data.tar.gz.sig +0 -0
  288. metadata.gz.sig +0 -0
@@ -4,7 +4,7 @@ module ActiveMerchant #:nodoc:
4
4
  self.live_url = self.test_url = 'https://secure.networkmerchants.com/api/transact.php'
5
5
 
6
6
  self.supported_countries = ['US']
7
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
7
+ self.supported_cardtypes = %i[visa master american_express discover]
8
8
 
9
9
  self.homepage_url = 'http://www.nmi.com/'
10
10
  self.display_name = 'Network Merchants (NMI)'
@@ -190,7 +190,7 @@ module ActiveMerchant #:nodoc:
190
190
  end
191
191
 
192
192
  def commit_vault(action, parameters)
193
- commit(nil, parameters.merge(:customer_vault => action))
193
+ commit(nil, parameters.merge(customer_vault: action))
194
194
  end
195
195
 
196
196
  def commit(action, parameters)
@@ -201,11 +201,10 @@ module ActiveMerchant #:nodoc:
201
201
  authorization = authorization_from(success, parameters, raw)
202
202
 
203
203
  Response.new(success, raw['responsetext'], raw,
204
- :test => test?,
205
- :authorization => authorization,
206
- :avs_result => { :code => raw['avsresponse']},
207
- :cvv_result => raw['cvvresponse']
208
- )
204
+ test: test?,
205
+ authorization: authorization,
206
+ avs_result: { code: raw['avsresponse'] },
207
+ cvv_result: raw['cvvresponse'])
209
208
  end
210
209
 
211
210
  def build_request(action, parameters)
@@ -218,9 +217,7 @@ module ActiveMerchant #:nodoc:
218
217
  return nil unless success
219
218
 
220
219
  authorization = response['transactionid']
221
- if(parameters[:customer_vault] && (authorization.nil? || authorization.empty?))
222
- authorization = response['customer_vault_id']
223
- end
220
+ authorization = response['customer_vault_id'] if parameters[:customer_vault] && (authorization.nil? || authorization.empty?)
224
221
 
225
222
  authorization
226
223
  end
@@ -239,4 +236,3 @@ module ActiveMerchant #:nodoc:
239
236
  end
240
237
  end
241
238
  end
242
-
@@ -1,256 +1,361 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
3
  class NmiGateway < Gateway
4
- API_VERSION = '3.1'
4
+ include Empty
5
5
 
6
- self.test_url = 'https://secure.networkmerchants.com/gateway/transact.dll'
7
- self.live_url = 'https://secure.networkmerchants.com/gateway/transact.dll'
8
-
9
- class_attribute :duplicate_window
10
-
11
- APPROVED, DECLINED, ERROR, FRAUD_REVIEW = 1, 2, 3, 4
12
-
13
- RESPONSE_CODE, RESPONSE_REASON_CODE, RESPONSE_REASON_TEXT, AUTHORIZATION_CODE = 0, 2, 3, 4
14
- AVS_RESULT_CODE, TRANSACTION_ID, CARD_CODE_RESPONSE_CODE, CARDHOLDER_AUTH_CODE = 5, 6, 38, 39
6
+ DUP_WINDOW_DEPRECATION_MESSAGE = 'The class-level duplicate_window variable is deprecated. Please use the :dup_seconds transaction option instead.'
15
7
 
8
+ self.test_url = self.live_url = 'https://secure.networkmerchants.com/api/transact.php'
16
9
  self.default_currency = 'USD'
17
-
10
+ self.money_format = :dollars
18
11
  self.supported_countries = ['US']
19
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
12
+ self.supported_cardtypes = %i[visa master american_express discover]
20
13
  self.homepage_url = 'http://nmi.com/'
21
14
  self.display_name = 'NMI'
22
15
 
23
- CARD_CODE_ERRORS = %w( N S )
24
- AVS_ERRORS = %w( A E N R W Z )
25
- AVS_REASON_CODES = %w(27 45)
26
- TRANSACTION_ALREADY_ACTIONED = %w(310 311)
16
+ def self.duplicate_window=(seconds)
17
+ ActiveMerchant.deprecated(DUP_WINDOW_DEPRECATION_MESSAGE)
18
+ @dup_seconds = seconds
19
+ end
20
+
21
+ def self.duplicate_window
22
+ instance_variable_defined?(:@dup_seconds) ? @dup_seconds : nil
23
+ end
27
24
 
28
25
  def initialize(options = {})
29
- requires!(options, :login, :password)
26
+ if options.has_key?(:security_key)
27
+ requires!(options, :security_key)
28
+ else
29
+ requires!(options, :login, :password)
30
+ end
30
31
  super
31
32
  end
32
33
 
33
- def authorize(money, paysource, options = {})
34
+ def purchase(amount, payment_method, options = {})
34
35
  post = {}
35
- add_currency_code(post, money, options)
36
- add_invoice(post, options)
37
- add_payment_source(post, paysource, options)
38
- add_address(post, options)
36
+ add_invoice(post, amount, options)
37
+ add_payment_method(post, payment_method, options)
38
+ add_stored_credential(post, options)
39
39
  add_customer_data(post, options)
40
- add_duplicate_window(post)
40
+ add_vendor_data(post, options)
41
+ add_merchant_defined_fields(post, options)
42
+ add_level3_fields(post, options)
43
+ add_three_d_secure(post, options)
41
44
 
42
- commit('AUTH_ONLY', money, post)
45
+ commit('sale', post)
43
46
  end
44
47
 
45
- def purchase(money, paysource, options = {})
48
+ def authorize(amount, payment_method, options = {})
46
49
  post = {}
47
- add_currency_code(post, money, options)
48
- add_invoice(post, options)
49
- add_payment_source(post, paysource, options)
50
- add_address(post, options)
50
+ add_invoice(post, amount, options)
51
+ add_payment_method(post, payment_method, options)
52
+ add_stored_credential(post, options)
51
53
  add_customer_data(post, options)
52
- add_duplicate_window(post)
53
-
54
- commit('AUTH_CAPTURE', money, post)
54
+ add_vendor_data(post, options)
55
+ add_merchant_defined_fields(post, options)
56
+ add_level3_fields(post, options)
57
+ add_three_d_secure(post, options)
58
+ commit('auth', post)
55
59
  end
56
60
 
57
- def capture(money, authorization, options = {})
58
- post = {:trans_id => authorization}
59
- add_customer_data(post, options)
60
- add_invoice(post, options)
61
- commit('PRIOR_AUTH_CAPTURE', money, post)
61
+ def capture(amount, authorization, options = {})
62
+ post = {}
63
+ add_invoice(post, amount, options)
64
+ add_reference(post, authorization)
65
+ add_merchant_defined_fields(post, options)
66
+
67
+ commit('capture', post)
62
68
  end
63
69
 
64
70
  def void(authorization, options = {})
65
- post = {:trans_id => authorization}
66
- add_duplicate_window(post)
67
- commit('VOID', nil, post)
71
+ post = {}
72
+ add_reference(post, authorization)
73
+ add_payment_type(post, authorization)
74
+
75
+ commit('void', post)
68
76
  end
69
77
 
70
- def refund(money, identification, options = {})
71
- requires!(options, :card_number)
78
+ def refund(amount, authorization, options = {})
79
+ post = {}
80
+ add_invoice(post, amount, options)
81
+ add_reference(post, authorization)
82
+ add_payment_type(post, authorization)
72
83
 
73
- post = { :trans_id => identification,
74
- :card_num => options[:card_number]
75
- }
84
+ commit('refund', post)
85
+ end
76
86
 
77
- post[:first_name] = options[:first_name] if options[:first_name]
78
- post[:last_name] = options[:last_name] if options[:last_name]
79
- post[:zip] = options[:zip] if options[:zip]
87
+ def credit(amount, payment_method, options = {})
88
+ post = {}
89
+ add_invoice(post, amount, options)
90
+ add_payment_method(post, payment_method, options)
91
+ add_customer_data(post, options)
92
+ add_vendor_data(post, options)
93
+ add_level3_fields(post, options)
80
94
 
81
- add_invoice(post, options)
82
- add_duplicate_window(post)
95
+ commit('credit', post)
96
+ end
83
97
 
84
- commit('CREDIT', money, post)
98
+ def verify(payment_method, options = {})
99
+ post = {}
100
+ add_payment_method(post, payment_method, options)
101
+ add_customer_data(post, options)
102
+ add_vendor_data(post, options)
103
+ add_merchant_defined_fields(post, options)
104
+ add_level3_fields(post, options)
105
+
106
+ commit('validate', post)
85
107
  end
86
108
 
87
- def credit(money, identification, options = {})
88
- ActiveMerchant.deprecated CREDIT_DEPRECATION_MESSAGE
89
- refund(money, identification, options)
109
+ def store(payment_method, options = {})
110
+ post = {}
111
+ add_invoice(post, nil, options)
112
+ add_payment_method(post, payment_method, options)
113
+ add_customer_data(post, options)
114
+ add_vendor_data(post, options)
115
+ add_merchant_defined_fields(post, options)
116
+
117
+ commit('add_customer', post)
90
118
  end
91
119
 
92
- def verify(credit_card, options = {})
93
- MultiResponse.run(:use_first_response) do |r|
94
- r.process { authorize(100, credit_card, options) }
95
- r.process(:ignore_result) { void(r.authorization, options) }
96
- end
120
+ def verify_credentials
121
+ response = void('0')
122
+ response.message != 'Authentication Failed'
97
123
  end
98
124
 
99
- private
125
+ def supports_scrubbing?
126
+ true
127
+ end
100
128
 
101
- def commit(action, money, parameters)
102
- parameters[:amount] = amount(money) unless action == 'VOID'
129
+ def scrub(transcript)
130
+ transcript.
131
+ gsub(%r((password=)[^&\n]*), '\1[FILTERED]').
132
+ gsub(%r((security_key=)[^&\n]*), '\1[FILTERED]').
133
+ gsub(%r((ccnumber=)\d+), '\1[FILTERED]').
134
+ gsub(%r((cvv=)\d+), '\1[FILTERED]').
135
+ gsub(%r((checkaba=)\d+), '\1[FILTERED]').
136
+ gsub(%r((checkaccount=)\d+), '\1[FILTERED]').
137
+ gsub(%r((cryptogram=)[^&]+(&?)), '\1[FILTERED]\2')
138
+ end
103
139
 
104
- url = test? ? self.test_url : self.live_url
105
- data = ssl_post(url, post_data(action, parameters))
140
+ def supports_network_tokenization?
141
+ true
142
+ end
106
143
 
107
- response = parse(data)
108
- response[:action] = action
144
+ private
109
145
 
110
- message = message_from(response)
146
+ def add_level3_fields(post, options)
147
+ add_fields_to_post_if_present(post, options, %i[tax shipping ponumber])
148
+ end
111
149
 
112
- Response.new(success?(response), message, response,
113
- :test => test?,
114
- :authorization => response[:transaction_id],
115
- :fraud_review => fraud_review?(response),
116
- :avs_result => { :code => response[:avs_result_code] },
117
- :cvv_result => response[:card_code]
118
- )
150
+ def add_invoice(post, money, options)
151
+ post[:amount] = amount(money)
152
+ post[:orderid] = options[:order_id]
153
+ post[:orderdescription] = options[:description]
154
+ post[:currency] = options[:currency] || currency(money)
155
+ post[:billing_method] = 'recurring' if options[:recurring]
156
+ if (dup_seconds = (options[:dup_seconds] || self.class.duplicate_window))
157
+ post[:dup_seconds] = dup_seconds
158
+ end
119
159
  end
120
160
 
121
- def success?(response)
122
- response[:response_code] == APPROVED && TRANSACTION_ALREADY_ACTIONED.exclude?(response[:response_reason_code])
161
+ def add_payment_method(post, payment_method, options)
162
+ if payment_method.is_a?(String)
163
+ customer_vault_id, = split_authorization(payment_method)
164
+ post[:customer_vault_id] = customer_vault_id
165
+ elsif payment_method.is_a?(NetworkTokenizationCreditCard)
166
+ post[:ccnumber] = payment_method.number
167
+ post[:ccexp] = exp_date(payment_method)
168
+ post[:token_cryptogram] = payment_method.payment_cryptogram
169
+ elsif card_brand(payment_method) == 'check'
170
+ post[:payment] = 'check'
171
+ post[:firstname] = payment_method.first_name
172
+ post[:lastname] = payment_method.last_name
173
+ post[:checkname] = payment_method.name
174
+ post[:checkaba] = payment_method.routing_number
175
+ post[:checkaccount] = payment_method.account_number
176
+ post[:account_holder_type] = payment_method.account_holder_type
177
+ post[:account_type] = payment_method.account_type
178
+ post[:sec_code] = options[:sec_code] || 'WEB'
179
+ else
180
+ post[:payment] = 'creditcard'
181
+ post[:firstname] = payment_method.first_name
182
+ post[:lastname] = payment_method.last_name
183
+ post[:ccnumber] = payment_method.number
184
+ post[:cvv] = payment_method.verification_value unless empty?(payment_method.verification_value)
185
+ post[:ccexp] = exp_date(payment_method)
186
+ end
123
187
  end
124
188
 
125
- def fraud_review?(response)
126
- response[:response_code] == FRAUD_REVIEW
189
+ def add_stored_credential(post, options)
190
+ return unless (stored_credential = options[:stored_credential])
191
+
192
+ if stored_credential[:initiator] == 'cardholder'
193
+ post[:initiated_by] = 'customer'
194
+ else
195
+ post[:initiated_by] = 'merchant'
196
+ end
197
+
198
+ # :reason_type, when provided, overrides anything previously set in
199
+ # post[:billing_method] (see `add_invoice` and the :recurring) option
200
+ case stored_credential[:reason_type]
201
+ when 'recurring'
202
+ post[:billing_method] = 'recurring'
203
+ when 'installment'
204
+ post[:billing_method] = 'installment'
205
+ when 'unscheduled'
206
+ post.delete(:billing_method)
207
+ end
208
+
209
+ if stored_credential[:initial_transaction]
210
+ post[:stored_credential_indicator] = 'stored'
211
+ else
212
+ post[:stored_credential_indicator] = 'used'
213
+ # should only send :initial_transaction_id if it is a MIT
214
+ post[:initial_transaction_id] = stored_credential[:network_transaction_id] if post[:initiated_by] == 'merchant'
215
+ end
127
216
  end
128
217
 
129
- def parse(body)
130
- fields = split(body)
131
-
132
- results = {
133
- :response_code => fields[RESPONSE_CODE].to_i,
134
- :response_reason_code => fields[RESPONSE_REASON_CODE],
135
- :response_reason_text => fields[RESPONSE_REASON_TEXT],
136
- :avs_result_code => fields[AVS_RESULT_CODE],
137
- :transaction_id => fields[TRANSACTION_ID],
138
- :card_code => fields[CARD_CODE_RESPONSE_CODE],
139
- :authorization_code => fields[AUTHORIZATION_CODE],
140
- :cardholder_authentication_code => fields[CARDHOLDER_AUTH_CODE]
141
- }
142
- results
143
- end
144
-
145
- def post_data(action, parameters = {})
146
- post = {}
218
+ def add_customer_data(post, options)
219
+ post[:email] = options[:email]
220
+ post[:ipaddress] = options[:ip]
221
+ post[:customer_id] = options[:customer_id] || options[:customer]
222
+
223
+ if (billing_address = options[:billing_address] || options[:address])
224
+ post[:company] = billing_address[:company]
225
+ post[:address1] = billing_address[:address1]
226
+ post[:address2] = billing_address[:address2]
227
+ post[:city] = billing_address[:city]
228
+ post[:state] = billing_address[:state]
229
+ post[:country] = billing_address[:country]
230
+ post[:zip] = billing_address[:zip]
231
+ post[:phone] = billing_address[:phone]
232
+ end
147
233
 
148
- post[:version] = API_VERSION
149
- post[:login] = @options[:login]
150
- post[:tran_key] = @options[:password]
151
- post[:relay_response] = "FALSE"
152
- post[:type] = action
153
- post[:delim_data] = "TRUE"
154
- post[:delim_char] = ","
155
- post[:encap_char] = "$"
156
- post[:solution_ID] = application_id if application_id.present? && application_id != "ActiveMerchant"
234
+ if (shipping_address = options[:shipping_address])
235
+ post[:shipping_company] = shipping_address[:company]
236
+ post[:shipping_address1] = shipping_address[:address1]
237
+ post[:shipping_address2] = shipping_address[:address2]
238
+ post[:shipping_city] = shipping_address[:city]
239
+ post[:shipping_state] = shipping_address[:state]
240
+ post[:shipping_country] = shipping_address[:country]
241
+ post[:shipping_zip] = shipping_address[:zip]
242
+ post[:shipping_phone] = shipping_address[:phone]
243
+ end
157
244
 
158
- request = post.merge(parameters).collect { |key, value| "x_#{key}=#{CGI.escape(value.to_s)}" }.join("&")
159
- request
245
+ if (descriptor = options[:descriptors])
246
+ post[:descriptor] = descriptor[:descriptor]
247
+ post[:descriptor_phone] = descriptor[:descriptor_phone]
248
+ post[:descriptor_address] = descriptor[:descriptor_address]
249
+ post[:descriptor_city] = descriptor[:descriptor_city]
250
+ post[:descriptor_state] = descriptor[:descriptor_state]
251
+ post[:descriptor_postal] = descriptor[:descriptor_postal]
252
+ post[:descriptor_country] = descriptor[:descriptor_country]
253
+ post[:descriptor_mcc] = descriptor[:descriptor_mcc]
254
+ post[:descriptor_merchant_id] = descriptor[:descriptor_merchant_id]
255
+ post[:descriptor_url] = descriptor[:descriptor_url]
256
+ end
160
257
  end
161
258
 
162
- def add_currency_code(post, money, options)
163
- post[:currency_code] = options[:currency] || currency(money)
259
+ def add_vendor_data(post, options)
260
+ post[:vendor_id] = options[:vendor_id] if options[:vendor_id]
261
+ post[:processor_id] = options[:processor_id] if options[:processor_id]
164
262
  end
165
263
 
166
- def add_invoice(post, options)
167
- post[:invoice_num] = options[:order_id]
168
- post[:description] = options[:description]
264
+ def add_merchant_defined_fields(post, options)
265
+ (1..20).each do |each|
266
+ key = "merchant_defined_field_#{each}".to_sym
267
+ post[key] = options[key] if options[key]
268
+ end
169
269
  end
170
270
 
171
- def add_creditcard(post, creditcard, options={})
172
- post[:card_num] = creditcard.number
173
- post[:card_code] = creditcard.verification_value if creditcard.verification_value?
174
- post[:exp_date] = expdate(creditcard)
175
- post[:first_name] = creditcard.first_name
176
- post[:last_name] = creditcard.last_name
271
+ def add_three_d_secure(post, options)
272
+ three_d_secure = options[:three_d_secure]
273
+ return unless three_d_secure
177
274
 
178
- post[:recurring_billing] = "TRUE" if options[:recurring]
275
+ post[:cardholder_auth] = cardholder_auth(three_d_secure[:authentication_response_status])
276
+ post[:cavv] = three_d_secure[:cavv]
277
+ post[:xid] = three_d_secure[:xid]
278
+ post[:three_ds_version] = three_d_secure[:version]
279
+ post[:directory_server_id] = three_d_secure[:ds_transaction_id]
179
280
  end
180
281
 
181
- def add_payment_source(params, source, options={})
182
- add_creditcard(params, source, options)
282
+ def cardholder_auth(trans_status)
283
+ return nil if trans_status.nil?
284
+
285
+ trans_status == 'Y' ? 'verified' : 'attempted'
183
286
  end
184
287
 
185
- def add_customer_data(post, options)
186
- if options.has_key? :email
187
- post[:email] = options[:email]
188
- post[:email_customer] = false
189
- end
288
+ def add_reference(post, authorization)
289
+ transaction_id, = split_authorization(authorization)
290
+ post[:transactionid] = transaction_id
291
+ end
190
292
 
191
- if options.has_key? :customer
192
- post[:cust_id] = options[:customer] if Float(options[:customer]) rescue nil
193
- end
293
+ def add_payment_type(post, authorization)
294
+ _, payment_type = split_authorization(authorization)
295
+ post[:payment] = payment_type if payment_type
296
+ end
194
297
 
195
- if options.has_key? :ip
196
- post[:customer_ip] = options[:ip]
197
- end
298
+ def exp_date(payment_method)
299
+ "#{format(payment_method.month, :two_digits)}#{format(payment_method.year, :two_digits)}"
300
+ end
198
301
 
199
- if options.has_key? :cardholder_authentication_value
200
- post[:cardholder_authentication_value] = options[:cardholder_authentication_value]
201
- end
302
+ def commit(action, params)
303
+ params[action == 'add_customer' ? :customer_vault : :type] = action
304
+ params[:username] = @options[:login] unless @options[:login].nil?
305
+ params[:password] = @options[:password] unless @options[:password].nil?
306
+ params[:security_key] = @options[:security_key] unless @options[:security_key].nil?
307
+ raw_response = ssl_post(url, post_data(action, params), headers)
308
+ response = parse(raw_response)
309
+ succeeded = success_from(response)
310
+
311
+ Response.new(
312
+ succeeded,
313
+ message_from(succeeded, response),
314
+ response,
315
+ authorization: authorization_from(response, params[:payment], action),
316
+ avs_result: AVSResult.new(code: response[:avsresponse]),
317
+ cvv_result: CVVResult.new(response[:cvvresponse]),
318
+ test: test?
319
+ )
320
+ end
202
321
 
203
- if options.has_key? :authentication_indicator
204
- post[:authentication_indicator] = options[:authentication_indicator]
205
- end
322
+ def authorization_from(response, payment_type, action)
323
+ authorization = (action == 'add_customer' ? response[:customer_vault_id] : response[:transactionid])
324
+ [authorization, payment_type].join('#')
325
+ end
206
326
 
327
+ def split_authorization(authorization)
328
+ authorization.split('#')
207
329
  end
208
330
 
209
- def add_duplicate_window(post)
210
- unless duplicate_window.nil?
211
- post[:duplicate_window] = duplicate_window
212
- end
331
+ def headers
332
+ headers = { 'Content-Type' => 'application/x-www-form-urlencoded;charset=UTF-8' }
333
+ headers
213
334
  end
214
335
 
215
- def add_address(post, options)
216
- if address = options[:billing_address] || options[:address]
217
- post[:address] = address[:address1].to_s
218
- post[:company] = address[:company].to_s
219
- post[:phone] = address[:phone].to_s
220
- post[:zip] = address[:zip].to_s
221
- post[:city] = address[:city].to_s
222
- post[:country] = address[:country].to_s
223
- post[:state] = address[:state].blank? ? 'n/a' : address[:state]
224
- end
336
+ def post_data(action, params)
337
+ params.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
338
+ end
225
339
 
226
- if address = options[:shipping_address]
227
- post[:ship_to_first_name] = address[:first_name].to_s
228
- post[:ship_to_last_name] = address[:last_name].to_s
229
- post[:ship_to_address] = address[:address1].to_s
230
- post[:ship_to_company] = address[:company].to_s
231
- post[:ship_to_phone] = address[:phone].to_s
232
- post[:ship_to_zip] = address[:zip].to_s
233
- post[:ship_to_city] = address[:city].to_s
234
- post[:ship_to_country] = address[:country].to_s
235
- post[:ship_to_state] = address[:state].blank? ? 'n/a' : address[:state]
236
- end
340
+ def url
341
+ test? ? test_url : live_url
237
342
  end
238
343
 
239
- def message_from(results)
240
- if results[:response_code] == DECLINED
241
- return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
242
- if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
243
- return AVSResult.messages[ results[:avs_result_code] ]
244
- end
245
- end
344
+ def parse(body)
345
+ Hash[CGI::parse(body).map { |k, v| [k.intern, v.first] }]
346
+ end
246
347
 
247
- (results[:response_reason_text] ? results[:response_reason_text].chomp('.') : '')
348
+ def success_from(response)
349
+ response[:response] == '1'
248
350
  end
249
351
 
250
- def split(response)
251
- response[1..-2].split(/\$,\$/)
352
+ def message_from(succeeded, response)
353
+ if succeeded
354
+ 'Succeeded'
355
+ else
356
+ response[:responsetext]
357
+ end
252
358
  end
253
359
  end
254
360
  end
255
361
  end
256
-