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
@@ -0,0 +1,376 @@
1
+ module ActiveMerchant #:nodoc:
2
+ module Billing #:nodoc:
3
+ class NetbanxGateway < Gateway
4
+ # Netbanx is the new REST based API for Optimal Payments / Paysafe
5
+ self.test_url = 'https://api.test.netbanx.com/'
6
+ self.live_url = 'https://api.netbanx.com/'
7
+
8
+ self.supported_countries = %w(AF AX AL DZ AS AD AO AI AQ AG AR AM AW AU AT AZ BS BH BD BB BY BE BZ BJ BM BT BO BQ BA BW BV BR IO BN BG BF BI KH CM CA CV KY CF TD CL CN CX CC CO KM CG CD CK CR CI HR CU CW CY CZ DK DJ DM DO EC EG SV GQ ER EE ET FK FO FJ FI FR GF PF TF GA GM GE DE GH GI GR GL GD GP GU GT GG GN GW GY HT HM HN HK HU IS IN ID IR IQ IE IM IL IT JM JP JE JO KZ KE KI KP KR KW KG LA LV LB LS LR LY LI LT LU MO MK MG MW MY MV ML MT MH MQ MR MU YT MX FM MD MC MN ME MS MA MZ MM NA NR NP NC NZ NI NE NG NU NF MP NO OM PK PW PS PA PG PY PE PH PN PL PT PR QA RE RO RU RW BL SH KN LC MF VC WS SM ST SA SN RS SC SL SG SX SK SI SB SO ZA GS SS ES LK PM SD SR SJ SZ SE CH SY TW TJ TZ TH NL TL TG TK TO TT TN TR TM TC TV UG UA AE GB US UM UY UZ VU VA VE VN VG VI WF EH YE ZM ZW)
9
+ self.default_currency = 'CAD'
10
+ self.supported_cardtypes = %i[
11
+ american_express
12
+ diners_club
13
+ discover
14
+ jcb
15
+ master
16
+ maestro
17
+ visa
18
+ ]
19
+
20
+ self.money_format = :cents
21
+
22
+ self.homepage_url = 'https://processing.paysafe.com/'
23
+ self.display_name = 'Netbanx by PaySafe'
24
+
25
+ AVS_CODE_CONVERTER = {
26
+ 'MATCH' => 'X',
27
+ 'MATCH_ADDRESS_ONLY' => 'A',
28
+ 'MATCH_ZIP_ONLY' => 'Z',
29
+ 'NO_MATCH' => 'N',
30
+ 'NOT_PROCESSED' => 'U',
31
+ 'UNKNOWN' => 'Q'
32
+ }
33
+
34
+ CVV_CODE_CONVERTER = {
35
+ 'MATCH' => 'M',
36
+ 'NO_MATCH' => 'N',
37
+ 'NOT_PROCESSED' => 'P',
38
+ 'UNKNOWN' => 'U'
39
+ }
40
+
41
+ def initialize(options = {})
42
+ requires!(options, :account_number, :api_key)
43
+ super
44
+ end
45
+
46
+ def purchase(money, payment, options = {})
47
+ # Do a Verification with AVS prior to purchase
48
+ verification_response = verify(payment, options)
49
+ return verification_response if verification_response.message != 'OK'
50
+
51
+ post = {}
52
+ add_invoice(post, money, options)
53
+ add_settle_with_auth(post)
54
+ add_payment(post, payment, options)
55
+ add_customer_detail_data(post, options)
56
+
57
+ commit(:post, 'auths', post)
58
+ end
59
+
60
+ def authorize(money, payment, options = {})
61
+ # Do a Verification with AVS prior to Auth + Settle
62
+ verification_response = verify(payment, options)
63
+ return verification_response if verification_response.message != 'OK'
64
+
65
+ post = {}
66
+ add_invoice(post, money, options)
67
+ add_payment(post, payment, options)
68
+ add_customer_detail_data(post, options)
69
+
70
+ commit(:post, 'auths', post)
71
+ end
72
+
73
+ def capture(money, authorization, options = {})
74
+ post = {}
75
+ add_invoice(post, money, options)
76
+
77
+ commit(:post, "auths/#{authorization}/settlements", post)
78
+ end
79
+
80
+ def refund(money, authorization, options = {})
81
+ # If the transactions that are pending, API call needs to be Cancellation
82
+ settlement_data = get_settlement(authorization)
83
+ return settlement_data if settlement_data.message != 'OK'
84
+
85
+ post = {}
86
+ if settlement_data.params['status'] == 'PENDING' && money == settlement_data.params['amount']
87
+ post[:status] = 'CANCELLED'
88
+ commit(:put, "settlements/#{authorization}", post)
89
+ elsif settlement_data.params['status'] == 'PENDING' && (money < settlement_data.params['amount'] || money > settlement_data.params['amount'])
90
+ return Response.new(false, 'Transaction not settled. Either do a full refund or try partial refund after settlement.')
91
+ else
92
+ add_invoice(post, money, options)
93
+
94
+ # Setting merchantRefNumber to a unique id for each refund
95
+ # This is to support multiple partial refunds for the same order
96
+ post[:merchantRefNum] = SecureRandom.uuid
97
+
98
+ commit(:post, "settlements/#{authorization}/refunds", post)
99
+ end
100
+ end
101
+
102
+ def get_settlement(authorization)
103
+ post = {}
104
+ commit(:get, "settlements/#{authorization}", post)
105
+ end
106
+
107
+ def void(authorization, options = {})
108
+ post = {}
109
+ add_order_id(post, options)
110
+
111
+ commit(:post, "auths/#{authorization}/voidauths", post)
112
+ end
113
+
114
+ def verify(credit_card, options = {})
115
+ post = {}
116
+ add_payment(post, credit_card, options)
117
+ add_order_id(post, options)
118
+
119
+ commit(:post, 'verifications', post)
120
+ end
121
+
122
+ # note: when passing options[:customer] we only attempt to add the
123
+ # card to the profile_id passed as the options[:customer]
124
+ def store(credit_card, options = {})
125
+ # locale can only be one of en_US, fr_CA, en_GB
126
+ requires!(options, :locale)
127
+ post = {}
128
+ add_credit_card(post, credit_card, options)
129
+ add_customer_data(post, options)
130
+
131
+ commit(:post, 'customervault/v1/profiles', post)
132
+ end
133
+
134
+ def unstore(identification, options = {})
135
+ customer_id, card_id = identification.split('|')
136
+
137
+ if card_id.nil?
138
+ # deleting the profile
139
+ commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}", nil)
140
+ else
141
+ # deleting the card from the profile
142
+ commit(:delete, "customervault/v1/profiles/#{CGI.escape(customer_id)}/cards/#{CGI.escape(card_id)}", nil)
143
+ end
144
+ end
145
+
146
+ def supports_scrubbing?
147
+ true
148
+ end
149
+
150
+ def scrub(transcript)
151
+ transcript.
152
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
153
+ gsub(%r(("card\\?":{\\?"cardNum\\?":\\?")\d+), '\1[FILTERED]').
154
+ gsub(%r(("cvv\\?":\\?")\d+), '\1[FILTERED]')
155
+ end
156
+
157
+ private
158
+
159
+ def add_settle_with_auth(post)
160
+ post[:settleWithAuth] = true
161
+ end
162
+
163
+ def add_customer_data(post, options)
164
+ post[:merchantCustomerId] = (options[:merchant_customer_id] || SecureRandom.uuid)
165
+ post[:locale] = options[:locale]
166
+ end
167
+
168
+ def add_customer_detail_data(post, options)
169
+ post[:profile] ||= {}
170
+ post[:profile][:email] = options[:email] if options[:email]
171
+ post[:customerIp] = options[:ip] if options[:ip]
172
+ if (billing_address = options[:billing_address])
173
+ post[:profile][:firstName], post[:profile][:lastName] = split_names(billing_address[:name])
174
+ end
175
+ end
176
+
177
+ def add_credit_card(post, credit_card, options = {})
178
+ post[:card] ||= {}
179
+ post[:card][:cardNum] = credit_card.number
180
+ post[:card][:holderName] = credit_card.name
181
+ post[:card][:cvv] = credit_card.verification_value
182
+ post[:card][:cardExpiry] = expdate(credit_card)
183
+
184
+ post[:authentication] = map_3ds(options[:three_d_secure]) if options[:three_d_secure]
185
+ post[:card][:billingAddress] = map_address(options[:billing_address]) if options[:billing_address]
186
+ end
187
+
188
+ def add_invoice(post, money, options)
189
+ post[:amount] = amount(money)
190
+ add_order_id(post, options)
191
+ end
192
+
193
+ def add_payment(post, credit_card_reference, options = {})
194
+ post[:card] ||= {}
195
+ if credit_card_reference.is_a?(String)
196
+ post[:card][:paymentToken] = credit_card_reference
197
+ else
198
+ post[:card][:cardNum] = credit_card_reference.number
199
+ post[:card][:cvv] = credit_card_reference.verification_value
200
+ post[:card][:cardExpiry] = expdate(credit_card_reference)
201
+ end
202
+
203
+ post[:currencyCode] = options[:currency] if options[:currency]
204
+ post[:billingDetails] = map_address(options[:billing_address]) if options[:billing_address]
205
+ post[:authentication] = map_3ds(options[:three_d_secure]) if options[:three_d_secure]
206
+ end
207
+
208
+ def expdate(credit_card)
209
+ year = format(credit_card.year, :four_digits)
210
+ month = format(credit_card.month, :two_digits)
211
+
212
+ # returns a hash (necessary in the card JSON object)
213
+ { month: month, year: year }
214
+ end
215
+
216
+ def add_order_id(post, options)
217
+ post[:merchantRefNum] = (options[:order_id] || SecureRandom.uuid)
218
+ end
219
+
220
+ def map_address(address)
221
+ return {} if address.nil?
222
+
223
+ country = Country.find(address[:country]) if address[:country]
224
+ mapped = {
225
+ street: address[:address1],
226
+ city: address[:city],
227
+ zip: address[:zip],
228
+ state: address[:state]
229
+ }
230
+ mapped[:country] = country.code(:alpha2).value unless country.blank?
231
+
232
+ mapped
233
+ end
234
+
235
+ def map_3ds(three_d_secure_options)
236
+ mapped = {
237
+ eci: three_d_secure_options[:eci],
238
+ cavv: three_d_secure_options[:cavv],
239
+ xid: three_d_secure_options[:xid],
240
+ threeDResult: three_d_secure_options[:directory_response_status],
241
+ threeDSecureVersion: three_d_secure_options[:version],
242
+ directoryServerTransactionId: three_d_secure_options[:ds_transaction_id]
243
+ }
244
+
245
+ mapped
246
+ end
247
+
248
+ def parse(body)
249
+ body.blank? ? {} : JSON.parse(body)
250
+ end
251
+
252
+ def commit(method, uri, parameters)
253
+ params = parameters.to_json unless parameters.nil?
254
+ response =
255
+ begin
256
+ if method == :get
257
+ parse(ssl_request(method, get_url(uri), nil, headers))
258
+ else
259
+ parse(ssl_request(method, get_url(uri), params, headers))
260
+ end
261
+ rescue ResponseError => e
262
+ return Response.new(false, 'Invalid Login') if e.response.code == '401'
263
+
264
+ parse(e.response.body)
265
+ end
266
+
267
+ success = success_from(response)
268
+ Response.new(
269
+ success,
270
+ message_from(success, response),
271
+ response,
272
+ test: test?,
273
+ error_code: error_code_from(response),
274
+ authorization: authorization_from(success, get_url(uri), method, response),
275
+ avs_result: avs_result(response),
276
+ cvv_result: cvv_result(response)
277
+ )
278
+ end
279
+
280
+ def avs_result(response)
281
+ AVSResult.new(code: AVS_CODE_CONVERTER[response['avsResponse']])
282
+ end
283
+
284
+ def cvv_result(response)
285
+ CVVResult.new(CVV_CODE_CONVERTER[response['cvvVerification']])
286
+ end
287
+
288
+ def get_url(uri)
289
+ url = (test? ? test_url : live_url)
290
+ if /^customervault/.match?(uri)
291
+ "#{url}#{uri}"
292
+ else
293
+ "#{url}cardpayments/v1/accounts/#{@options[:account_number]}/#{uri}"
294
+ end
295
+ end
296
+
297
+ def success_from(response)
298
+ response.blank? || !response.key?('error')
299
+ end
300
+
301
+ def message_from(success, response)
302
+ success ? 'OK' : (response['error']['message'] || 'Unknown error - please contact Netbanx-Paysafe')
303
+ end
304
+
305
+ def authorization_from(success, url, method, response)
306
+ if success && response.present? && url.match(/cardpayments\/v1\/accounts\/.*\//)
307
+ response['id']
308
+ elsif method == :post && url.match(/customervault\/.*\//)
309
+ # auth for tokenised customer vault is returned as
310
+ # customer_profile_id|card_id|payment_method_token
311
+ #
312
+ # customer_profile_id is the uuid that identifies the customer
313
+ # card_id is the uuid that identifies the card
314
+ # payment_method_token is the token that needs to be used when
315
+ # calling purchase with a token
316
+ #
317
+ # both id's are used to unstore, the payment token is only used for
318
+ # purchase transactions
319
+ [response['id'], response['cards'].first['id'], response['cards'].first['paymentToken']].join('|')
320
+ end
321
+ end
322
+
323
+ # Builds the auth and U-A headers for the request
324
+ def headers
325
+ {
326
+ 'Accept' => 'application/json',
327
+ 'Content-type' => 'application/json',
328
+ 'Authorization' => "Basic #{Base64.strict_encode64(@options[:api_key].to_s)}",
329
+ 'User-Agent' => "Netbanx-Paysafe v1.0/ActiveMerchant #{ActiveMerchant::VERSION}"
330
+ }
331
+ end
332
+
333
+ def error_code_from(response)
334
+ unless success_from(response)
335
+ case response['errorCode']
336
+ when '3002' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid card number or brand or combination of card number and brand with your request.
337
+ when '3004' then STANDARD_ERROR_CODE[:incorrect_zip] # The zip/postal code must be provided for an AVS check request.
338
+ when '3005' then STANDARD_ERROR_CODE[:incorrect_cvc] # You submitted an incorrect CVC value with your request.
339
+ when '3006' then STANDARD_ERROR_CODE[:expired_card] # You submitted an expired credit card number with your request.
340
+ when '3009' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank.
341
+ when '3011' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the card used is a restricted card. Contact the cardholder's credit card company for further investigation.
342
+ when '3012' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank because the credit card expiry date submitted is invalid.
343
+ when '3013' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to problems with the credit card account.
344
+ when '3014' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined - the issuing bank has returned an unknown response. Contact the card holder's credit card company for further investigation.
345
+ when '3015' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you process the transaction manually by calling the cardholder's credit card company.
346
+ when '3016' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – it may be a lost or stolen card.
347
+ when '3017' then STANDARD_ERROR_CODE[:invalid_number] # You submitted an invalid credit card number with your request.
348
+ when '3022' then STANDARD_ERROR_CODE[:card_declined] # The card has been declined due to insufficient funds.
349
+ when '3023' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank due to its proprietary card activity regulations.
350
+ when '3024' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the issuing bank does not permit the transaction for this card.
351
+ when '3032' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined by the issuing bank or external gateway because the card is probably in one of their negative databases.
352
+ when '3035' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to exceeded PIN attempts.
353
+ when '3036' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid issuer.
354
+ when '3037' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because it is invalid.
355
+ when '3038' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to customer cancellation.
356
+ when '3039' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to an invalid authentication value.
357
+ when '3040' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined because the request type is not permitted on the card.
358
+ when '3041' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a timeout.
359
+ when '3042' then STANDARD_ERROR_CODE[:card_declined] # Your request has been declined due to a cryptographic error.
360
+ when '3045' then STANDARD_ERROR_CODE[:invalid_expiry_date] # You submitted an invalid date format for this request.
361
+ when '3046' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount was set to zero.
362
+ when '3047' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount exceeds the floor limit.
363
+ when '3048' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined because the amount is less than the floor limit.
364
+ when '3049' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card has expired.
365
+ when '3050' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – fraudulent activity is suspected.
366
+ when '3051' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – contact the acquirer for more information.
367
+ when '3052' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – the credit card is restricted.
368
+ when '3053' then STANDARD_ERROR_CODE[:card_declined] # The bank has requested that you retrieve the card from the cardholder – please call the acquirer.
369
+ when '3054' then STANDARD_ERROR_CODE[:card_declined] # The transaction was declined due to suspected fraud.
370
+ else STANDARD_ERROR_CODE[:processing_error]
371
+ end
372
+ end
373
+ end
374
+ end
375
+ end
376
+ end
@@ -1,18 +1,29 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
+ # To perform PCI Compliant Repeat Billing
4
+ #
5
+ # Ensure that PCI Compliant Repeat Billing is enabled on your merchant account:
6
+ # "Enable PCI Compliant Repeat Billing, Up-selling and Cross-selling" in Step 6 of the Credit Cards setup page
7
+ #
8
+ # Instead of passing a credit_card to authorize or purchase, pass the transaction id (res.authorization)
9
+ # of a past Netbilling transaction
10
+ #
11
+ # To store billing information without performing an operation, use the 'store' method
12
+ # which invokes the tran_type 'Q' (Quasi) operation and returns a transaction id to use in future Repeat Billing operations
3
13
  class NetbillingGateway < Gateway
4
14
  self.live_url = self.test_url = 'https://secure.netbilling.com:1402/gw/sas/direct3.1'
5
15
 
6
16
  TRANSACTIONS = {
7
- :authorization => 'A',
8
- :purchase => 'S',
9
- :refund => 'R',
10
- :credit => 'C',
11
- :capture => 'D',
12
- :void => 'U'
17
+ authorization: 'A',
18
+ purchase: 'S',
19
+ refund: 'R',
20
+ credit: 'C',
21
+ capture: 'D',
22
+ void: 'U',
23
+ quasi: 'Q'
13
24
  }
14
25
 
15
- SUCCESS_CODES = [ '1', 'T' ]
26
+ SUCCESS_CODES = %w[1 T]
16
27
  SUCCESS_MESSAGE = 'The transaction was approved'
17
28
  FAILURE_MESSAGE = 'The transaction failed'
18
29
  TEST_LOGIN = '104901072025'
@@ -20,31 +31,33 @@ module ActiveMerchant #:nodoc:
20
31
  self.display_name = 'NETbilling'
21
32
  self.homepage_url = 'http://www.netbilling.com'
22
33
  self.supported_countries = ['US']
23
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :diners_club]
34
+ self.supported_cardtypes = %i[visa master american_express discover jcb diners_club]
24
35
 
25
36
  def initialize(options = {})
26
37
  requires!(options, :login)
27
38
  super
28
39
  end
29
40
 
30
- def authorize(money, credit_card, options = {})
41
+ def authorize(money, payment_source, options = {})
31
42
  post = {}
32
43
  add_amount(post, money)
33
44
  add_invoice(post, options)
34
- add_credit_card(post, credit_card)
35
- add_address(post, credit_card, options)
45
+ add_payment_source(post, payment_source)
46
+ add_address(post, payment_source, options)
36
47
  add_customer_data(post, options)
48
+ add_user_data(post, options)
37
49
 
38
50
  commit(:authorization, post)
39
51
  end
40
52
 
41
- def purchase(money, credit_card, options = {})
53
+ def purchase(money, payment_source, options = {})
42
54
  post = {}
43
55
  add_amount(post, money)
44
56
  add_invoice(post, options)
45
- add_credit_card(post, credit_card)
46
- add_address(post, credit_card, options)
57
+ add_payment_source(post, payment_source)
58
+ add_address(post, payment_source, options)
47
59
  add_customer_data(post, options)
60
+ add_user_data(post, options)
48
61
 
49
62
  commit(:purchase, post)
50
63
  end
@@ -69,6 +82,7 @@ module ActiveMerchant #:nodoc:
69
82
  add_credit_card(post, credit_card)
70
83
  add_address(post, credit_card, options)
71
84
  add_customer_data(post, options)
85
+ add_user_data(post, options)
72
86
 
73
87
  commit(:credit, post)
74
88
  end
@@ -79,10 +93,31 @@ module ActiveMerchant #:nodoc:
79
93
  commit(:void, post)
80
94
  end
81
95
 
96
+ def store(credit_card, options = {})
97
+ post = {}
98
+ add_amount(post, 0)
99
+ add_payment_source(post, credit_card)
100
+ add_address(post, credit_card, options)
101
+ add_customer_data(post, options)
102
+
103
+ commit(:quasi, post)
104
+ end
105
+
82
106
  def test?
83
107
  (@options[:login] == TEST_LOGIN || super)
84
108
  end
85
109
 
110
+ def supports_scrubbing
111
+ true
112
+ end
113
+
114
+ def scrub(transcript)
115
+ transcript.
116
+ gsub(%r((Authorization: Basic )\w+), '\1[FILTERED]').
117
+ gsub(%r((&?card_number=)[^&]*), '\1[FILTERED]').
118
+ gsub(%r((&?card_cvv2=)[^&]*), '\1[FILTERED]')
119
+ end
120
+
86
121
  private
87
122
 
88
123
  def add_amount(post, money)
@@ -108,23 +143,36 @@ module ActiveMerchant #:nodoc:
108
143
  post[:bill_state] = billing_address[:state]
109
144
  end
110
145
 
111
- if shipping_address = options[:shipping_address]
112
- first_name, last_name = parse_first_and_last_name(shipping_address[:name])
113
-
114
- post[:ship_name1] = first_name
115
- post[:ship_name2] = last_name
116
- post[:ship_street] = shipping_address[:address1]
117
- post[:ship_zip] = shipping_address[:zip]
118
- post[:ship_city] = shipping_address[:city]
119
- post[:ship_country] = shipping_address[:country]
120
- post[:ship_state] = shipping_address[:state]
121
- end
146
+ if shipping_address = options[:shipping_address]
147
+ post[:ship_name1], post[:ship_name2] = split_names(shipping_address[:name])
148
+ post[:ship_street] = shipping_address[:address1]
149
+ post[:ship_zip] = shipping_address[:zip]
150
+ post[:ship_city] = shipping_address[:city]
151
+ post[:ship_country] = shipping_address[:country]
152
+ post[:ship_state] = shipping_address[:state]
153
+ end
122
154
  end
123
155
 
124
156
  def add_invoice(post, options)
125
157
  post[:description] = options[:description]
126
158
  end
127
159
 
160
+ def add_payment_source(params, source)
161
+ if source.is_a?(String)
162
+ add_transaction_id(params, source)
163
+ else
164
+ add_credit_card(params, source)
165
+ end
166
+ end
167
+
168
+ def add_user_data(post, options)
169
+ post[:user_data] = "order_id:#{options[:order_id]}" if options[:order_id]
170
+ end
171
+
172
+ def add_transaction_id(post, transaction_id)
173
+ post[:card_number] = 'CS:' + transaction_id
174
+ end
175
+
128
176
  def add_credit_card(post, credit_card)
129
177
  post[:bill_name1] = credit_card.first_name
130
178
  post[:bill_name2] = credit_card.last_name
@@ -136,7 +184,7 @@ module ActiveMerchant #:nodoc:
136
184
  def parse(body)
137
185
  results = {}
138
186
  body.split(/&/).each do |pair|
139
- key,val = pair.split(/\=/)
187
+ key, val = pair.split(/\=/)
140
188
  results[key.to_sym] = CGI.unescape(val)
141
189
  end
142
190
  results
@@ -146,14 +194,14 @@ module ActiveMerchant #:nodoc:
146
194
  response = parse(ssl_post(self.live_url, post_data(action, parameters)))
147
195
 
148
196
  Response.new(success?(response), message_from(response), response,
149
- :test => test_response?(response),
150
- :authorization => response[:trans_id],
151
- :avs_result => { :code => response[:avs_code]},
152
- :cvv_result => response[:cvv2_code]
153
- )
197
+ test: test_response?(response),
198
+ authorization: response[:trans_id],
199
+ avs_result: { code: response[:avs_code] },
200
+ cvv_result: response[:cvv2_code])
154
201
  rescue ActiveMerchant::ResponseError => e
155
- raise unless(e.response.code =~ /^[67]\d\d$/)
156
- return Response.new(false, e.response.message, {:status_code => e.response.code}, :test => test?)
202
+ raise unless e.response.code =~ /^[67]\d\d$/
203
+
204
+ return Response.new(false, e.response.message, { status_code: e.response.code }, test: test?)
157
205
  end
158
206
 
159
207
  def test_response?(response)
@@ -174,17 +222,8 @@ module ActiveMerchant #:nodoc:
174
222
  parameters[:pay_type] = 'C'
175
223
  parameters[:tran_type] = TRANSACTIONS[action]
176
224
 
177
- parameters.reject{|k,v| v.blank?}.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
178
- end
179
-
180
- def parse_first_and_last_name(value)
181
- name = value.to_s.split(' ')
182
-
183
- last_name = name.pop || ''
184
- first_name = name.join(' ')
185
- [ first_name, last_name ]
225
+ parameters.reject { |_k, v| v.blank? }.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
186
226
  end
187
227
  end
188
228
  end
189
229
  end
190
-
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  self.default_currency = 'MXN'
43
43
 
44
44
  # The card types supported by the payment gateway
45
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club]
45
+ self.supported_cardtypes = %i[visa master american_express diners_club]
46
46
 
47
47
  # The homepage URL of the gateway
48
48
  self.homepage_url = 'http://www.netpay.com.mx'
@@ -51,11 +51,11 @@ module ActiveMerchant #:nodoc:
51
51
  self.display_name = 'NETPAY Gateway'
52
52
 
53
53
  CURRENCY_CODES = {
54
- "MXN" => '484'
54
+ 'MXN' => '484'
55
55
  }
56
56
 
57
57
  # The header keys that we will provide in the response params hash
58
- RESPONSE_KEYS = ['ResponseMsg', 'ResponseText', 'ResponseCode', 'TimeIn', 'TimeOut', 'AuthCode', 'OrderId', 'CardTypeName', 'MerchantId', 'IssuerAuthDate']
58
+ RESPONSE_KEYS = %w[ResponseMsg ResponseText ResponseCode TimeIn TimeOut AuthCode OrderId CardTypeName MerchantId IssuerAuthDate]
59
59
 
60
60
  def initialize(options = {})
61
61
  requires!(options, :store_id, :login, :password)
@@ -110,7 +110,6 @@ module ActiveMerchant #:nodoc:
110
110
  add_order_id(post, order_id_from(authorization))
111
111
  add_amount(post, money, options)
112
112
 
113
- #commit('Refund', post, options)
114
113
  commit('Credit', post, options)
115
114
  end
116
115
 
@@ -157,7 +156,7 @@ module ActiveMerchant #:nodoc:
157
156
  end
158
157
 
159
158
  def split_authorization(authorization)
160
- order_id, amount, currency = authorization.split("|")
159
+ order_id, amount, currency = authorization.split('|')
161
160
  [order_id, amount, currency]
162
161
  end
163
162
 
@@ -166,8 +165,8 @@ module ActiveMerchant #:nodoc:
166
165
  end
167
166
 
168
167
  def expdate(credit_card)
169
- year = sprintf("%.4i", credit_card.year)
170
- month = sprintf("%.2i", credit_card.month)
168
+ year = sprintf('%.4i', credit_card.year)
169
+ month = sprintf('%.2i', credit_card.month)
171
170
 
172
171
  "#{month}/#{year[-2..-1]}"
173
172
  end
@@ -181,8 +180,8 @@ module ActiveMerchant #:nodoc:
181
180
 
182
181
  success = (response_params['ResponseCode'] == '00')
183
182
  message = response_params['ResponseText'] || response_params['ResponseMsg']
184
- options = @options.merge(:test => test?,
185
- :authorization => build_authorization(request_params, response_params))
183
+ options = @options.merge(test: test?,
184
+ authorization: build_authorization(request_params, response_params))
186
185
 
187
186
  Response.new(success, message, response_params, options)
188
187
  end
@@ -191,7 +190,7 @@ module ActiveMerchant #:nodoc:
191
190
  add_login_data(parameters)
192
191
  add_action(parameters, action, options)
193
192
 
194
- post = parameters.collect{|key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join("&")
193
+ post = parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
195
194
  parse(ssl_post(url, post), parameters)
196
195
  end
197
196
 
@@ -216,6 +215,7 @@ module ActiveMerchant #:nodoc:
216
215
 
217
216
  def currency_code(currency)
218
217
  return currency if currency =~ /^\d+$/
218
+
219
219
  CURRENCY_CODES[currency]
220
220
  end
221
221
  end