activemerchant 1.100.0 → 1.133.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (267) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +1057 -0
  3. data/README.md +11 -9
  4. data/lib/active_merchant/billing/avs_result.rb +9 -9
  5. data/lib/active_merchant/billing/base.rb +0 -13
  6. data/lib/active_merchant/billing/check.rb +49 -17
  7. data/lib/active_merchant/billing/compatibility.rb +5 -4
  8. data/lib/active_merchant/billing/credit_card.rb +55 -8
  9. data/lib/active_merchant/billing/credit_card_formatting.rb +1 -0
  10. data/lib/active_merchant/billing/credit_card_methods.rb +209 -36
  11. data/lib/active_merchant/billing/cvv_result.rb +0 -1
  12. data/lib/active_merchant/billing/gateway.rb +38 -36
  13. data/lib/active_merchant/billing/gateways/adyen.rb +399 -78
  14. data/lib/active_merchant/billing/gateways/airwallex.rb +370 -0
  15. data/lib/active_merchant/billing/gateways/alelo.rb +256 -0
  16. data/lib/active_merchant/billing/gateways/allied_wallet.rb +14 -14
  17. data/lib/active_merchant/billing/gateways/authorize_net.rb +200 -130
  18. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +27 -20
  19. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +48 -51
  20. data/lib/active_merchant/billing/gateways/axcessms.rb +13 -15
  21. data/lib/active_merchant/billing/gateways/balanced.rb +43 -36
  22. data/lib/active_merchant/billing/gateways/bambora_apac.rb +16 -20
  23. data/lib/active_merchant/billing/gateways/bank_frick.rb +13 -13
  24. data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
  25. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +43 -30
  26. data/lib/active_merchant/billing/gateways/barclays_epdq_extra_plus.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/be2bill.rb +5 -5
  28. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +37 -36
  29. data/lib/active_merchant/billing/gateways/beanstream.rb +21 -3
  30. data/lib/active_merchant/billing/gateways/beanstream_interac.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/blue_pay.rb +53 -28
  32. data/lib/active_merchant/billing/gateways/blue_snap.rb +176 -54
  33. data/lib/active_merchant/billing/gateways/bogus.rb +24 -20
  34. data/lib/active_merchant/billing/gateways/borgun.rb +92 -38
  35. data/lib/active_merchant/billing/gateways/bpoint.rb +15 -15
  36. data/lib/active_merchant/billing/gateways/braintree/braintree_common.rb +8 -2
  37. data/lib/active_merchant/billing/gateways/braintree/token_nonce.rb +113 -0
  38. data/lib/active_merchant/billing/gateways/braintree.rb +1 -1
  39. data/lib/active_merchant/billing/gateways/braintree_blue.rb +387 -175
  40. data/lib/active_merchant/billing/gateways/bridge_pay.rb +13 -13
  41. data/lib/active_merchant/billing/gateways/cams.rb +10 -10
  42. data/lib/active_merchant/billing/gateways/card_connect.rb +33 -14
  43. data/lib/active_merchant/billing/gateways/card_save.rb +3 -4
  44. data/lib/active_merchant/billing/gateways/card_stream.rb +67 -40
  45. data/lib/active_merchant/billing/gateways/cardknox.rb +13 -13
  46. data/lib/active_merchant/billing/gateways/cardprocess.rb +4 -2
  47. data/lib/active_merchant/billing/gateways/cashnet.rb +28 -12
  48. data/lib/active_merchant/billing/gateways/cc5.rb +9 -9
  49. data/lib/active_merchant/billing/gateways/cecabank.rb +38 -38
  50. data/lib/active_merchant/billing/gateways/cenpos.rb +29 -28
  51. data/lib/active_merchant/billing/gateways/checkout.rb +7 -9
  52. data/lib/active_merchant/billing/gateways/checkout_v2.rb +316 -68
  53. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -2
  54. data/lib/active_merchant/billing/gateways/clearhaus.rb +32 -33
  55. data/lib/active_merchant/billing/gateways/commerce_hub.rb +370 -0
  56. data/lib/active_merchant/billing/gateways/commercegate.rb +4 -4
  57. data/lib/active_merchant/billing/gateways/conekta.rb +8 -6
  58. data/lib/active_merchant/billing/gateways/creditcall.rb +18 -17
  59. data/lib/active_merchant/billing/gateways/credorax.rb +152 -63
  60. data/lib/active_merchant/billing/gateways/ct_payment.rb +15 -14
  61. data/lib/active_merchant/billing/gateways/culqi.rb +30 -28
  62. data/lib/active_merchant/billing/gateways/cyber_source/cyber_source_common.rb +36 -0
  63. data/lib/active_merchant/billing/gateways/cyber_source.rb +496 -187
  64. data/lib/active_merchant/billing/gateways/cyber_source_rest.rb +454 -0
  65. data/lib/active_merchant/billing/gateways/d_local.rb +148 -31
  66. data/lib/active_merchant/billing/gateways/data_cash.rb +34 -37
  67. data/lib/active_merchant/billing/gateways/decidir.rb +134 -21
  68. data/lib/active_merchant/billing/gateways/decidir_plus.rb +344 -0
  69. data/lib/active_merchant/billing/gateways/dibs.rb +10 -10
  70. data/lib/active_merchant/billing/gateways/digitzs.rb +11 -8
  71. data/lib/active_merchant/billing/gateways/ebanx.rb +90 -40
  72. data/lib/active_merchant/billing/gateways/efsnet.rb +36 -36
  73. data/lib/active_merchant/billing/gateways/elavon.rb +349 -194
  74. data/lib/active_merchant/billing/gateways/element.rb +71 -21
  75. data/lib/active_merchant/billing/gateways/epay.rb +43 -43
  76. data/lib/active_merchant/billing/gateways/evo_ca.rb +12 -13
  77. data/lib/active_merchant/billing/gateways/eway.rb +9 -9
  78. data/lib/active_merchant/billing/gateways/eway_managed.rb +55 -56
  79. data/lib/active_merchant/billing/gateways/eway_rapid.rb +37 -22
  80. data/lib/active_merchant/billing/gateways/exact.rb +19 -20
  81. data/lib/active_merchant/billing/gateways/ezic.rb +9 -9
  82. data/lib/active_merchant/billing/gateways/fat_zebra.rb +24 -19
  83. data/lib/active_merchant/billing/gateways/federated_canada.rb +6 -7
  84. data/lib/active_merchant/billing/gateways/finansbank.rb +3 -3
  85. data/lib/active_merchant/billing/gateways/first_giving.rb +5 -4
  86. data/lib/active_merchant/billing/gateways/first_pay.rb +7 -7
  87. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +39 -38
  88. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +51 -31
  89. data/lib/active_merchant/billing/gateways/flo2cash.rb +24 -24
  90. data/lib/active_merchant/billing/gateways/flo2cash_simple.rb +1 -1
  91. data/lib/active_merchant/billing/gateways/forte.rb +38 -22
  92. data/lib/active_merchant/billing/gateways/garanti.rb +12 -15
  93. data/lib/active_merchant/billing/gateways/global_collect.rb +333 -89
  94. data/lib/active_merchant/billing/gateways/global_transport.rb +8 -9
  95. data/lib/active_merchant/billing/gateways/hdfc.rb +22 -23
  96. data/lib/active_merchant/billing/gateways/hps.rb +171 -50
  97. data/lib/active_merchant/billing/gateways/iats_payments.rb +47 -25
  98. data/lib/active_merchant/billing/gateways/in_context_paypal_express.rb +1 -1
  99. data/lib/active_merchant/billing/gateways/inspire.rb +22 -27
  100. data/lib/active_merchant/billing/gateways/instapay.rb +5 -8
  101. data/lib/active_merchant/billing/gateways/ipg.rb +420 -0
  102. data/lib/active_merchant/billing/gateways/ipp.rb +9 -9
  103. data/lib/active_merchant/billing/gateways/iridium.rb +30 -31
  104. data/lib/active_merchant/billing/gateways/itransact.rb +11 -10
  105. data/lib/active_merchant/billing/gateways/iveri.rb +62 -23
  106. data/lib/active_merchant/billing/gateways/ixopay.rb +320 -0
  107. data/lib/active_merchant/billing/gateways/jetpay.rb +10 -17
  108. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +13 -18
  109. data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
  110. data/lib/active_merchant/billing/gateways/kushki.rb +100 -22
  111. data/lib/active_merchant/billing/gateways/latitude19.rb +20 -19
  112. data/lib/active_merchant/billing/gateways/linkpoint.rb +71 -72
  113. data/lib/active_merchant/billing/gateways/litle.rb +181 -45
  114. data/lib/active_merchant/billing/gateways/mastercard.rb +16 -22
  115. data/lib/active_merchant/billing/gateways/maxipago.rb +2 -2
  116. data/lib/active_merchant/billing/gateways/mercado_pago.rb +89 -18
  117. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +58 -24
  118. data/lib/active_merchant/billing/gateways/merchant_one.rb +7 -10
  119. data/lib/active_merchant/billing/gateways/merchant_partners.rb +19 -19
  120. data/lib/active_merchant/billing/gateways/merchant_ware.rb +18 -22
  121. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +15 -17
  122. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +46 -8
  123. data/lib/active_merchant/billing/gateways/mercury.rb +19 -23
  124. data/lib/active_merchant/billing/gateways/metrics_global.rb +24 -33
  125. data/lib/active_merchant/billing/gateways/micropayment.rb +11 -12
  126. data/lib/active_merchant/billing/gateways/migs/migs_codes.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/migs.rb +18 -21
  128. data/lib/active_merchant/billing/gateways/mit.rb +260 -0
  129. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +10 -12
  130. data/lib/active_merchant/billing/gateways/moka.rb +290 -0
  131. data/lib/active_merchant/billing/gateways/monei.rb +236 -150
  132. data/lib/active_merchant/billing/gateways/moneris.rb +122 -53
  133. data/lib/active_merchant/billing/gateways/money_movers.rb +6 -7
  134. data/lib/active_merchant/billing/gateways/mundipagg.rb +69 -23
  135. data/lib/active_merchant/billing/gateways/nab_transact.rb +18 -20
  136. data/lib/active_merchant/billing/gateways/ncr_secure_pay.rb +10 -12
  137. data/lib/active_merchant/billing/gateways/net_registry.rb +8 -9
  138. data/lib/active_merchant/billing/gateways/netaxept.rb +12 -12
  139. data/lib/active_merchant/billing/gateways/netbanx.rb +128 -46
  140. data/lib/active_merchant/billing/gateways/netbilling.rb +18 -21
  141. data/lib/active_merchant/billing/gateways/netpay.rb +5 -4
  142. data/lib/active_merchant/billing/gateways/network_merchants.rb +7 -10
  143. data/lib/active_merchant/billing/gateways/nmi.rb +69 -27
  144. data/lib/active_merchant/billing/gateways/ogone.rb +62 -31
  145. data/lib/active_merchant/billing/gateways/omise.rb +15 -16
  146. data/lib/active_merchant/billing/gateways/openpay.rb +33 -15
  147. data/lib/active_merchant/billing/gateways/opp.rb +39 -33
  148. data/lib/active_merchant/billing/gateways/optimal_payment.rb +43 -42
  149. data/lib/active_merchant/billing/gateways/orbital/orbital_soft_descriptors.rb +3 -5
  150. data/lib/active_merchant/billing/gateways/orbital.rb +623 -362
  151. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +20 -20
  152. data/lib/active_merchant/billing/gateways/pagarme.rb +16 -23
  153. data/lib/active_merchant/billing/gateways/pago_facil.rb +4 -6
  154. data/lib/active_merchant/billing/gateways/pay_arc.rb +392 -0
  155. data/lib/active_merchant/billing/gateways/pay_conex.rb +17 -17
  156. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +30 -33
  157. data/lib/active_merchant/billing/gateways/pay_hub.rb +10 -10
  158. data/lib/active_merchant/billing/gateways/pay_junction.rb +31 -31
  159. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +36 -18
  160. data/lib/active_merchant/billing/gateways/pay_secure.rb +10 -11
  161. data/lib/active_merchant/billing/gateways/pay_trace.rb +450 -0
  162. data/lib/active_merchant/billing/gateways/paybox_direct.rb +64 -40
  163. data/lib/active_merchant/billing/gateways/payeezy.rb +130 -27
  164. data/lib/active_merchant/billing/gateways/payex.rb +24 -25
  165. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +17 -17
  166. data/lib/active_merchant/billing/gateways/payflow/payflow_express_response.rb +1 -1
  167. data/lib/active_merchant/billing/gateways/payflow.rb +103 -25
  168. data/lib/active_merchant/billing/gateways/payflow_express.rb +4 -4
  169. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
  170. data/lib/active_merchant/billing/gateways/payment_express.rb +22 -18
  171. data/lib/active_merchant/billing/gateways/paymentez.rb +89 -24
  172. data/lib/active_merchant/billing/gateways/paymill.rb +14 -16
  173. data/lib/active_merchant/billing/gateways/paypal/paypal_common_api.rb +2 -1
  174. data/lib/active_merchant/billing/gateways/paypal/paypal_express_response.rb +4 -0
  175. data/lib/active_merchant/billing/gateways/paypal.rb +13 -5
  176. data/lib/active_merchant/billing/gateways/paypal_ca.rb +1 -1
  177. data/lib/active_merchant/billing/gateways/paypal_digital_goods.rb +1 -1
  178. data/lib/active_merchant/billing/gateways/paypal_express.rb +4 -1
  179. data/lib/active_merchant/billing/gateways/paypal_express_common.rb +1 -1
  180. data/lib/active_merchant/billing/gateways/paysafe.rb +420 -0
  181. data/lib/active_merchant/billing/gateways/payscout.rb +8 -9
  182. data/lib/active_merchant/billing/gateways/paystation.rb +6 -9
  183. data/lib/active_merchant/billing/gateways/payu_in.rb +20 -19
  184. data/lib/active_merchant/billing/gateways/payu_latam.rb +70 -37
  185. data/lib/active_merchant/billing/gateways/payway.rb +22 -22
  186. data/lib/active_merchant/billing/gateways/payway_dot_com.rb +253 -0
  187. data/lib/active_merchant/billing/gateways/pin.rb +60 -21
  188. data/lib/active_merchant/billing/gateways/plexo.rb +308 -0
  189. data/lib/active_merchant/billing/gateways/plugnpay.rb +20 -21
  190. data/lib/active_merchant/billing/gateways/priority.rb +392 -0
  191. data/lib/active_merchant/billing/gateways/pro_pay.rb +13 -14
  192. data/lib/active_merchant/billing/gateways/psigate.rb +29 -29
  193. data/lib/active_merchant/billing/gateways/psl_card.rb +7 -8
  194. data/lib/active_merchant/billing/gateways/qbms.rb +25 -26
  195. data/lib/active_merchant/billing/gateways/quantum.rb +9 -11
  196. data/lib/active_merchant/billing/gateways/quickbooks.rb +126 -39
  197. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +98 -98
  198. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +19 -23
  199. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v4to7.rb +3 -3
  200. data/lib/active_merchant/billing/gateways/quickpay.rb +0 -1
  201. data/lib/active_merchant/billing/gateways/qvalent.rb +36 -20
  202. data/lib/active_merchant/billing/gateways/rapyd.rb +319 -0
  203. data/lib/active_merchant/billing/gateways/reach.rb +277 -0
  204. data/lib/active_merchant/billing/gateways/realex.rb +42 -16
  205. data/lib/active_merchant/billing/gateways/redsys.rb +191 -86
  206. data/lib/active_merchant/billing/gateways/s5.rb +10 -9
  207. data/lib/active_merchant/billing/gateways/safe_charge.rb +70 -33
  208. data/lib/active_merchant/billing/gateways/sage.rb +19 -21
  209. data/lib/active_merchant/billing/gateways/sage_pay.rb +57 -57
  210. data/lib/active_merchant/billing/gateways/sallie_mae.rb +3 -4
  211. data/lib/active_merchant/billing/gateways/secure_net.rb +19 -26
  212. data/lib/active_merchant/billing/gateways/secure_pay.rb +24 -33
  213. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +18 -20
  214. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +4 -5
  215. data/lib/active_merchant/billing/gateways/securion_pay.rb +48 -7
  216. data/lib/active_merchant/billing/gateways/shift4.rb +345 -0
  217. data/lib/active_merchant/billing/gateways/simetrik.rb +368 -0
  218. data/lib/active_merchant/billing/gateways/skip_jack.rb +19 -19
  219. data/lib/active_merchant/billing/gateways/smart_ps.rb +26 -32
  220. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +24 -25
  221. data/lib/active_merchant/billing/gateways/spreedly_core.rb +27 -21
  222. data/lib/active_merchant/billing/gateways/stripe.rb +126 -53
  223. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +441 -113
  224. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +7 -8
  225. data/lib/active_merchant/billing/gateways/telr.rb +17 -18
  226. data/lib/active_merchant/billing/gateways/tns.rb +3 -7
  227. data/lib/active_merchant/billing/gateways/trans_first.rb +10 -9
  228. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +28 -24
  229. data/lib/active_merchant/billing/gateways/transact_pro.rb +13 -15
  230. data/lib/active_merchant/billing/gateways/transax.rb +1 -2
  231. data/lib/active_merchant/billing/gateways/trexle.rb +5 -2
  232. data/lib/active_merchant/billing/gateways/trust_commerce.rb +57 -47
  233. data/lib/active_merchant/billing/gateways/usa_epay.rb +1 -2
  234. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +176 -184
  235. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +60 -48
  236. data/lib/active_merchant/billing/gateways/vanco.rb +17 -8
  237. data/lib/active_merchant/billing/gateways/verifi.rb +13 -14
  238. data/lib/active_merchant/billing/gateways/viaklix.rb +9 -14
  239. data/lib/active_merchant/billing/gateways/visanet_peru.rb +26 -21
  240. data/lib/active_merchant/billing/gateways/vpos.rb +223 -0
  241. data/lib/active_merchant/billing/gateways/webpay.rb +4 -4
  242. data/lib/active_merchant/billing/gateways/wepay.rb +14 -16
  243. data/lib/active_merchant/billing/gateways/wirecard.rb +14 -16
  244. data/lib/active_merchant/billing/gateways/wompi.rb +197 -0
  245. data/lib/active_merchant/billing/gateways/world_net.rb +36 -35
  246. data/lib/active_merchant/billing/gateways/worldpay.rb +556 -190
  247. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +47 -54
  248. data/lib/active_merchant/billing/gateways/worldpay_us.rb +16 -16
  249. data/lib/active_merchant/billing/network_tokenization_credit_card.rb +2 -2
  250. data/lib/active_merchant/billing/response.rb +25 -6
  251. data/lib/active_merchant/billing/three_d_secure_eci_mapper.rb +27 -0
  252. data/lib/active_merchant/billing.rb +1 -0
  253. data/lib/active_merchant/connection.rb +14 -15
  254. data/lib/active_merchant/country.rb +3 -1
  255. data/lib/active_merchant/errors.rb +4 -1
  256. data/lib/active_merchant/net_http_ssl_connection.rb +1 -0
  257. data/lib/active_merchant/network_connection_retries.rb +15 -17
  258. data/lib/active_merchant/post_data.rb +3 -2
  259. data/lib/active_merchant/posts_data.rb +2 -2
  260. data/lib/active_merchant/version.rb +1 -1
  261. data/lib/active_merchant.rb +2 -2
  262. data/lib/certs/cacert.pem +1587 -2361
  263. data/lib/support/gateway_support.rb +1 -1
  264. data/lib/support/ssl_verify.rb +3 -7
  265. data/lib/support/ssl_version.rb +2 -3
  266. metadata +86 -34
  267. data/lib/active_merchant/billing/gateways/moneris_us.rb +0 -352
@@ -9,11 +9,13 @@ module ActiveMerchant #:nodoc:
9
9
  # Response Values", available at Moneris' {eSelect Plus Documentation
10
10
  # Centre}[https://www3.moneris.com/connect/en/documents/index.html].
11
11
  class MonerisGateway < Gateway
12
+ WALLETS = %w(APP GPP)
13
+
12
14
  self.test_url = 'https://esqa.moneris.com/gateway2/servlet/MpgRequest'
13
15
  self.live_url = 'https://www3.moneris.com/gateway2/servlet/MpgRequest'
14
16
 
15
17
  self.supported_countries = ['CA']
16
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :discover]
18
+ self.supported_cardtypes = %i[visa master american_express diners_club discover]
17
19
  self.homepage_url = 'http://www.moneris.com/'
18
20
  self.display_name = 'Moneris'
19
21
 
@@ -47,18 +49,19 @@ module ActiveMerchant #:nodoc:
47
49
  post = {}
48
50
  add_payment_source(post, creditcard_or_datakey, options)
49
51
  post[:amount] = amount(money)
50
- post[:order_id] = options[:order_id]
52
+ post[:order_id] = format_order_id(post[:wallet_indicator], options[:order_id])
51
53
  post[:address] = options[:billing_address] || options[:address]
52
54
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
55
+ add_external_mpi_fields(post, options)
53
56
  add_stored_credential(post, options)
54
- action = if post[:cavv]
57
+ action = if post[:cavv] || options[:three_d_secure]
55
58
  'cavv_preauth'
56
59
  elsif post[:data_key].blank?
57
60
  'preauth'
58
61
  else
59
62
  'res_preauth_cc'
60
63
  end
61
- commit(action, post)
64
+ commit(action, post, options)
62
65
  end
63
66
 
64
67
  # This action verifies funding on a customer's card and readies them for
@@ -70,18 +73,19 @@ module ActiveMerchant #:nodoc:
70
73
  post = {}
71
74
  add_payment_source(post, creditcard_or_datakey, options)
72
75
  post[:amount] = amount(money)
73
- post[:order_id] = options[:order_id]
76
+ post[:order_id] = format_order_id(post[:wallet_indicator], options[:order_id])
74
77
  post[:address] = options[:billing_address] || options[:address]
75
78
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
79
+ add_external_mpi_fields(post, options)
76
80
  add_stored_credential(post, options)
77
- action = if post[:cavv]
81
+ action = if post[:cavv] || options[:three_d_secure]
78
82
  'cavv_purchase'
79
83
  elsif post[:data_key].blank?
80
84
  'purchase'
81
85
  else
82
86
  'res_purchase_cc'
83
87
  end
84
- commit(action, post)
88
+ commit(action, post, options)
85
89
  end
86
90
 
87
91
  # This method retrieves locked funds from a customer's account (from a
@@ -92,7 +96,7 @@ module ActiveMerchant #:nodoc:
92
96
  # gateways the two numbers are concatenated together with a ; separator as
93
97
  # the authorization number returned by authorization
94
98
  def capture(money, authorization, options = {})
95
- commit 'completion', crediting_params(authorization, :comp_amount => amount(money))
99
+ commit 'completion', crediting_params(authorization, comp_amount: amount(money))
96
100
  end
97
101
 
98
102
  # Voiding requires the original transaction ID and order ID of some open
@@ -130,22 +134,43 @@ module ActiveMerchant #:nodoc:
130
134
  end
131
135
 
132
136
  def refund(money, authorization, options = {})
133
- commit 'refund', crediting_params(authorization, :amount => amount(money))
137
+ commit 'refund', crediting_params(authorization, amount: amount(money))
134
138
  end
135
139
 
136
- def verify(credit_card, options={})
137
- MultiResponse.run(:use_first_response) do |r|
138
- r.process { authorize(100, credit_card, options) }
139
- r.process(:ignore_result) { void(r.authorization, options) }
140
- end
140
+ def verify(credit_card, options = {})
141
+ requires!(options, :order_id)
142
+ post = {}
143
+ add_payment_source(post, credit_card, options)
144
+ post[:order_id] = options[:order_id]
145
+ post[:address] = options[:billing_address] || options[:address]
146
+ post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
147
+ add_stored_credential(post, options)
148
+ action = if post[:data_key].blank?
149
+ 'card_verification'
150
+ else
151
+ 'res_card_verification_cc'
152
+ end
153
+ commit(action, post)
141
154
  end
142
155
 
156
+ # When passing a :duration option (time in seconds) you can create a
157
+ # temporary vault record to avoid incurring Moneris vault storage fees
158
+ #
159
+ # https://developer.moneris.com/Documentation/NA/E-Commerce%20Solutions/API/Vault#vaulttokenadd
143
160
  def store(credit_card, options = {})
144
161
  post = {}
145
162
  post[:pan] = credit_card.number
146
163
  post[:expdate] = expdate(credit_card)
164
+ post[:address] = options[:billing_address] || options[:address]
147
165
  post[:crypt_type] = options[:crypt_type] || @options[:crypt_type]
148
- commit('res_add_cc', post)
166
+ add_stored_credential(post, options)
167
+
168
+ if options[:duration]
169
+ post[:duration] = options[:duration]
170
+ commit('res_temp_add', post)
171
+ else
172
+ commit('res_add_cc', post)
173
+ end
149
174
  end
150
175
 
151
176
  def unstore(data_key, options = {})
@@ -182,6 +207,21 @@ module ActiveMerchant #:nodoc:
182
207
  sprintf('%.4i', creditcard.year)[-2..-1] + sprintf('%.2i', creditcard.month)
183
208
  end
184
209
 
210
+ def add_external_mpi_fields(post, options)
211
+ # See these pages:
212
+ # https://developer.moneris.com/livedemo/3ds2/cavv_purchase/tool/php
213
+ # https://developer.moneris.com/livedemo/3ds2/cavv_preauth/guide/php
214
+ return unless options[:three_d_secure]
215
+
216
+ three_d_secure_options = options[:three_d_secure]
217
+
218
+ post[:threeds_version] = three_d_secure_options[:version]
219
+ post[:crypt_type] = three_d_secure_options[:eci]
220
+ post[:cavv] = three_d_secure_options[:cavv]
221
+ post[:threeds_server_trans_id] = three_d_secure_options[:three_ds_server_trans_id]
222
+ post[:ds_trans_id] = three_d_secure_options[:ds_transaction_id]
223
+ end
224
+
185
225
  def add_payment_source(post, payment_method, options)
186
226
  if payment_method.is_a?(String)
187
227
  post[:data_key] = payment_method
@@ -213,6 +253,7 @@ module ActiveMerchant #:nodoc:
213
253
  # if any of :issuer_id, :payment_information, or :payment_indicator is not passed,
214
254
  # then check for :stored credential options
215
255
  return unless (stored_credential = options[:stored_credential]) && !cof_details_present?(options)
256
+
216
257
  if stored_credential[:initial_transaction]
217
258
  add_stored_credential_initial(post, options)
218
259
  else
@@ -253,9 +294,9 @@ module ActiveMerchant #:nodoc:
253
294
  # Common params used amongst the +credit+, +void+ and +capture+ methods
254
295
  def crediting_params(authorization, options = {})
255
296
  {
256
- :txn_number => split_authorization(authorization).first,
257
- :order_id => split_authorization(authorization).last,
258
- :crypt_type => options[:crypt_type] || @options[:crypt_type]
297
+ txn_number: split_authorization(authorization).first,
298
+ order_id: split_authorization(authorization).last,
299
+ crypt_type: options[:crypt_type] || @options[:crypt_type]
259
300
  }.merge(options)
260
301
  end
261
302
 
@@ -269,38 +310,47 @@ module ActiveMerchant #:nodoc:
269
310
  end
270
311
  end
271
312
 
272
- def commit(action, parameters = {})
313
+ def commit(action, parameters = {}, options = {})
314
+ threed_ds_transaction = options[:three_d_secure].present?
315
+
273
316
  data = post_data(action, parameters)
274
317
  url = test? ? self.test_url : self.live_url
275
318
  raw = ssl_post(url, data)
276
319
  response = parse(raw)
277
320
 
278
321
  Response.new(
279
- successful?(response),
322
+ successful?(action, response, threed_ds_transaction),
280
323
  message_from(response[:message]),
281
324
  response,
282
- :test => test?,
283
- :avs_result => {:code => response[:avs_result_code]},
284
- :cvv_result => response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
285
- :authorization => authorization_from(response))
325
+ test: test?,
326
+ avs_result: { code: response[:avs_result_code] },
327
+ cvv_result: response[:cvd_result_code] && response[:cvd_result_code][-1, 1],
328
+ authorization: authorization_from(response)
329
+ )
286
330
  end
287
331
 
288
332
  # Generates a Moneris authorization string of the form 'trans_id;receipt_id'.
289
333
  def authorization_from(response = {})
290
- if response[:trans_id] && response[:receipt_id]
291
- "#{response[:trans_id]};#{response[:receipt_id]}"
292
- end
334
+ "#{response[:trans_id]};#{response[:receipt_id]}" if response[:trans_id] && response[:receipt_id]
293
335
  end
294
336
 
295
337
  # Tests for a successful response from Moneris' servers
296
- def successful?(response)
297
- response[:response_code] &&
298
- response[:complete] &&
299
- (0..49).cover?(response[:response_code].to_i)
338
+ def successful?(action, response, threed_ds_transaction = false)
339
+ # See 9.4 CAVV Result Codes in https://developer.moneris.com/livedemo/3ds2/reference/guide/php
340
+ cavv_accepted = if threed_ds_transaction
341
+ response[:cavv_result_code] && response[:cavv_result_code] == '2'
342
+ else
343
+ true
344
+ end
345
+
346
+ cavv_accepted &&
347
+ response[:response_code] &&
348
+ response[:complete] &&
349
+ (0..49).cover?(response[:response_code].to_i)
300
350
  end
301
351
 
302
352
  def parse(xml)
303
- response = { :message => 'Global Error Receipt', :complete => false }
353
+ response = { message: 'Global Error Receipt', complete: false }
304
354
  hashify_xml!(xml, response)
305
355
  response
306
356
  end
@@ -308,6 +358,7 @@ module ActiveMerchant #:nodoc:
308
358
  def hashify_xml!(xml, response)
309
359
  xml = REXML::Document.new(xml)
310
360
  return if xml.root.nil?
361
+
311
362
  xml.elements.each('//receipt/*') do |node|
312
363
  response[node.name.underscore.to_sym] = normalize(node.text)
313
364
  end
@@ -382,36 +433,54 @@ module ActiveMerchant #:nodoc:
382
433
  end
383
434
 
384
435
  def wallet_indicator(token_source)
385
- return 'APP' if token_source == 'apple_pay'
386
- return 'ANP' if token_source == 'android_pay'
387
- nil
436
+ return {
437
+ 'apple_pay' => 'APP',
438
+ 'google_pay' => 'GPP',
439
+ 'android_pay' => 'ANP'
440
+ }[token_source]
441
+ end
442
+
443
+ def format_order_id(wallet_indicator_code, order_id = nil)
444
+ # Truncate (max 100 characters) order id for
445
+ # google pay and apple pay (specific wallets / token sources)
446
+ return truncate_order_id(order_id) if WALLETS.include?(wallet_indicator_code)
447
+
448
+ order_id
449
+ end
450
+
451
+ def truncate_order_id(order_id = nil)
452
+ order_id.present? ? order_id[0, 100] : SecureRandom.alphanumeric(100)
388
453
  end
389
454
 
390
455
  def message_from(message)
391
456
  return 'Unspecified error' if message.blank?
457
+
392
458
  message.gsub(/[^\w]/, ' ').split.join(' ').capitalize
393
459
  end
394
460
 
395
461
  def actions
396
462
  {
397
- 'purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
398
- 'preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type, :avs_info, :cvd_info, :track2, :pos_code, :cof_info],
399
- 'command' => [:order_id],
400
- 'refund' => [:order_id, :amount, :txn_number, :crypt_type],
401
- 'indrefund' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
402
- 'completion' => [:order_id, :comp_amount, :txn_number, :crypt_type],
403
- 'purchasecorrection' => [:order_id, :txn_number, :crypt_type],
404
- 'cavv_preauth' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
405
- 'cavv_purchase' => [:order_id, :cust_id, :amount, :pan, :expdate, :cavv, :crypt_type, :wallet_indicator],
406
- 'transact' => [:order_id, :cust_id, :amount, :pan, :expdate, :crypt_type],
407
- 'Batchcloseall' => [],
408
- 'opentotals' => [:ecr_number],
409
- 'batchclose' => [:ecr_number],
410
- 'res_add_cc' => [:pan, :expdate, :crypt_type, :cof_info],
411
- 'res_delete' => [:data_key],
412
- 'res_update_cc' => [:data_key, :pan, :expdate, :crypt_type],
413
- 'res_purchase_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info],
414
- 'res_preauth_cc' => [:data_key, :order_id, :cust_id, :amount, :crypt_type, :cof_info]
463
+ 'purchase' => %i[order_id cust_id amount pan expdate crypt_type avs_info cvd_info track2 pos_code cof_info],
464
+ 'preauth' => %i[order_id cust_id amount pan expdate crypt_type avs_info cvd_info track2 pos_code cof_info],
465
+ 'command' => [:order_id],
466
+ 'refund' => %i[order_id amount txn_number crypt_type],
467
+ 'indrefund' => %i[order_id cust_id amount pan expdate crypt_type],
468
+ 'completion' => %i[order_id comp_amount txn_number crypt_type],
469
+ 'purchasecorrection' => %i[order_id txn_number crypt_type],
470
+ 'cavv_preauth' => %i[order_id cust_id amount pan expdate cavv crypt_type wallet_indicator],
471
+ 'cavv_purchase' => %i[order_id cust_id amount pan expdate cavv crypt_type wallet_indicator],
472
+ 'card_verification' => %i[order_id cust_id pan expdate crypt_type avs_info cvd_info cof_info],
473
+ 'transact' => %i[order_id cust_id amount pan expdate crypt_type],
474
+ 'Batchcloseall' => [],
475
+ 'opentotals' => [:ecr_number],
476
+ 'batchclose' => [:ecr_number],
477
+ 'res_add_cc' => %i[pan expdate crypt_type avs_info cof_info],
478
+ 'res_temp_add' => %i[pan expdate crypt_type duration],
479
+ 'res_delete' => [:data_key],
480
+ 'res_update_cc' => %i[data_key pan expdate crypt_type avs_info cof_info],
481
+ 'res_purchase_cc' => %i[data_key order_id cust_id amount crypt_type cof_info],
482
+ 'res_preauth_cc' => %i[data_key order_id cust_id amount crypt_type cof_info],
483
+ 'res_card_verification_cc' => %i[order_id data_key expdate crypt_type cof_info]
415
484
  }
416
485
  end
417
486
  end
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  self.homepage_url = 'http://mmoa.us/'
9
9
  self.display_name = 'MoneyMovers'
10
10
  self.supported_countries = ['US']
11
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
11
+ self.supported_cardtypes = %i[visa master american_express discover]
12
12
 
13
13
  def initialize(options = {})
14
14
  requires!(options, :login, :password)
@@ -45,7 +45,7 @@ module ActiveMerchant #:nodoc:
45
45
  end
46
46
 
47
47
  def refund(money, authorization, options = {})
48
- commit('refund', money, options.merge(:transactionid => authorization))
48
+ commit('refund', money, options.merge(transactionid: authorization))
49
49
  end
50
50
 
51
51
  def credit(money, authorization, options = {})
@@ -114,11 +114,10 @@ module ActiveMerchant #:nodoc:
114
114
  message = message_from(response)
115
115
 
116
116
  Response.new(success?(response), message, response,
117
- :test => test?,
118
- :authorization => response['transactionid'],
119
- :avs_result => {:code => response['avsresponse']},
120
- :cvv_result => response['cvvresponse']
121
- )
117
+ test: test?,
118
+ authorization: response['transactionid'],
119
+ avs_result: { code: response['avsresponse'] },
120
+ cvv_result: response['cvvresponse'])
122
121
  end
123
122
 
124
123
  def success?(response)
@@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc:
5
5
 
6
6
  self.supported_countries = ['US']
7
7
  self.default_currency = 'USD'
8
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :alelo]
8
+ self.supported_cardtypes = %i[visa master american_express discover alelo]
9
9
 
10
10
  self.homepage_url = 'https://www.mundipagg.com/'
11
11
  self.display_name = 'Mundipagg'
@@ -28,56 +28,62 @@ module ActiveMerchant #:nodoc:
28
28
  '500' => 'An internal error occurred;'
29
29
  }
30
30
 
31
- def initialize(options={})
31
+ def initialize(options = {})
32
32
  requires!(options, :api_key)
33
33
  super
34
34
  end
35
35
 
36
- def purchase(money, payment, options={})
36
+ def purchase(money, payment, options = {})
37
37
  post = {}
38
38
  add_invoice(post, money, options)
39
39
  add_customer_data(post, options) unless payment.is_a?(String)
40
40
  add_shipping_address(post, options)
41
41
  add_payment(post, payment, options)
42
-
42
+ add_submerchant(post, options)
43
+ add_auth_key(post, options)
43
44
  commit('sale', post)
44
45
  end
45
46
 
46
- def authorize(money, payment, options={})
47
+ def authorize(money, payment, options = {})
47
48
  post = {}
48
49
  add_invoice(post, money, options)
49
50
  add_customer_data(post, options) unless payment.is_a?(String)
50
51
  add_shipping_address(post, options)
51
52
  add_payment(post, payment, options)
52
53
  add_capture_flag(post, payment)
54
+ add_submerchant(post, options)
55
+ add_auth_key(post, options)
53
56
  commit('authonly', post)
54
57
  end
55
58
 
56
- def capture(money, authorization, options={})
59
+ def capture(money, authorization, options = {})
57
60
  post = {}
58
61
  post[:code] = authorization
59
62
  add_invoice(post, money, options)
63
+ add_auth_key(post, options)
60
64
  commit('capture', post, authorization)
61
65
  end
62
66
 
63
- def refund(money, authorization, options={})
64
- add_invoice(post={}, money, options)
67
+ def refund(money, authorization, options = {})
68
+ add_invoice(post = {}, money, options)
69
+ add_auth_key(post, options)
65
70
  commit('refund', post, authorization)
66
71
  end
67
72
 
68
- def void(authorization, options={})
73
+ def void(authorization, options = {})
69
74
  commit('void', nil, authorization)
70
75
  end
71
76
 
72
- def store(payment, options={})
77
+ def store(payment, options = {})
73
78
  post = {}
74
79
  options.update(name: payment.name)
75
80
  options = add_customer(options) unless options[:customer_id]
76
81
  add_payment(post, payment, options)
82
+ add_auth_key(post, options)
77
83
  commit('store', post, options[:customer_id])
78
84
  end
79
85
 
80
- def verify(credit_card, options={})
86
+ def verify(credit_card, options = {})
81
87
  MultiResponse.run(:use_first_response) do |r|
82
88
  r.process { authorize(100, credit_card, options) }
83
89
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -198,12 +204,45 @@ module ActiveMerchant #:nodoc:
198
204
 
199
205
  def voucher?(payment)
200
206
  return false if payment.is_a?(String)
207
+
201
208
  %w[sodexo vr].include? card_brand(payment)
202
209
  end
203
210
 
204
- def headers
211
+ def add_submerchant(post, options)
212
+ if submerchant = options[:submerchant]
213
+ post[:SubMerchant] = {}
214
+ post[:SubMerchant][:Merchant_Category_Code] = submerchant[:merchant_category_code] if submerchant[:merchant_category_code]
215
+ post[:SubMerchant][:Payment_Facilitator_Code] = submerchant[:payment_facilitator_code] if submerchant[:payment_facilitator_code]
216
+ post[:SubMerchant][:Code] = submerchant[:code] if submerchant[:code]
217
+ post[:SubMerchant][:Name] = submerchant[:name] if submerchant[:name]
218
+ post[:SubMerchant][:Document] = submerchant[:document] if submerchant[:document]
219
+ post[:SubMerchant][:Type] = submerchant[:type] if submerchant[:type]
220
+ post[:SubMerchant][:Phone] = {}
221
+ post[:SubMerchant][:Phone][:Country_Code] = submerchant[:phone][:country_code] if submerchant.dig(:phone, :country_code)
222
+ post[:SubMerchant][:Phone][:Number] = submerchant[:phone][:number] if submerchant.dig(:phone, :number)
223
+ post[:SubMerchant][:Phone][:Area_Code] = submerchant[:phone][:area_code] if submerchant.dig(:phone, :area_code)
224
+ post[:SubMerchant][:Address] = {}
225
+ post[:SubMerchant][:Address][:Street] = submerchant[:address][:street] if submerchant.dig(:address, :street)
226
+ post[:SubMerchant][:Address][:Number] = submerchant[:address][:number] if submerchant.dig(:address, :number)
227
+ post[:SubMerchant][:Address][:Complement] = submerchant[:address][:complement] if submerchant.dig(:address, :complement)
228
+ post[:SubMerchant][:Address][:Neighborhood] = submerchant[:address][:neighborhood] if submerchant.dig(:address, :neighborhood)
229
+ post[:SubMerchant][:Address][:City] = submerchant[:address][:city] if submerchant.dig(:address, :city)
230
+ post[:SubMerchant][:Address][:State] = submerchant[:address][:state] if submerchant.dig(:address, :state)
231
+ post[:SubMerchant][:Address][:Country] = submerchant[:address][:country] if submerchant.dig(:address, :country)
232
+ post[:SubMerchant][:Address][:Zip_Code] = submerchant[:address][:zip_code] if submerchant.dig(:address, :zip_code)
233
+ end
234
+ end
235
+
236
+ def add_auth_key(post, options)
237
+ if authorization_secret_key = options[:authorization_secret_key]
238
+ post[:authorization_secret_key] = authorization_secret_key
239
+ end
240
+ end
241
+
242
+ def headers(authorization_secret_key = nil)
243
+ basic_token = authorization_secret_key || @options[:api_key]
205
244
  {
206
- 'Authorization' => 'Basic ' + Base64.strict_encode64("#{@options[:api_key]}:"),
245
+ 'Authorization' => 'Basic ' + Base64.strict_encode64("#{basic_token}:"),
207
246
  'Content-Type' => 'application/json',
208
247
  'Accept' => 'application/json'
209
248
  }
@@ -231,22 +270,23 @@ module ActiveMerchant #:nodoc:
231
270
 
232
271
  def commit(action, parameters, auth = nil)
233
272
  url = url_for(action, auth)
273
+ authorization_secret_key = parameters[:authorization_secret_key] if parameters
234
274
  parameters.merge!(parameters[:payment][:credit_card].delete(:card)).delete(:payment) if action == 'store'
235
275
  response = if %w[refund void].include? action
236
- parse(ssl_request(:delete, url, post_data(parameters), headers))
276
+ parse(ssl_request(:delete, url, post_data(parameters), headers(authorization_secret_key)))
237
277
  else
238
- parse(ssl_post(url, post_data(parameters), headers))
278
+ parse(ssl_post(url, post_data(parameters), headers(authorization_secret_key)))
239
279
  end
240
280
 
241
281
  Response.new(
242
- success_from(response),
282
+ success_from(response, action),
243
283
  message_from(response),
244
284
  response,
245
285
  authorization: authorization_from(response, action),
246
286
  avs_result: AVSResult.new(code: response['some_avs_response_key']),
247
287
  cvv_result: CVVResult.new(response['some_cvv_response_key']),
248
288
  test: test?,
249
- error_code: error_code_from(response)
289
+ error_code: error_code_from(response, action)
250
290
  )
251
291
  rescue ResponseError => e
252
292
  message = get_error_messages(e)
@@ -260,8 +300,10 @@ module ActiveMerchant #:nodoc:
260
300
  )
261
301
  end
262
302
 
263
- def success_from(response)
264
- %w[pending paid processing canceled active].include? response['status']
303
+ def success_from(response, action)
304
+ success = response.try(:[], 'last_transaction').try(:[], 'success') unless action == 'store'
305
+ success = !response.try(:[], 'id').nil? if action == 'store'
306
+ success
265
307
  end
266
308
 
267
309
  def message_from(response)
@@ -274,7 +316,7 @@ module ActiveMerchant #:nodoc:
274
316
  parsed_response_body = parse(error.response.body)
275
317
  message = parsed_response_body['message']
276
318
 
277
- parsed_response_body['errors']&.each do |type, descriptions|
319
+ parsed_response_body['errors']&.each do |_type, descriptions|
278
320
  message += ' | '
279
321
  message += descriptions.join(', ')
280
322
  end
@@ -290,7 +332,7 @@ module ActiveMerchant #:nodoc:
290
332
  error_string = ''
291
333
 
292
334
  response['last_transaction']['gateway_response']['errors']&.each do |error|
293
- error.each do |key, value|
335
+ error.each do |_key, value|
294
336
  error_string += ' | ' unless error_string.blank?
295
337
  error_string += value
296
338
  end
@@ -301,6 +343,7 @@ module ActiveMerchant #:nodoc:
301
343
 
302
344
  def authorization_from(response, action)
303
345
  return "#{response['customer']['id']}|#{response['id']}" if action == 'store'
346
+
304
347
  response['id']
305
348
  end
306
349
 
@@ -312,8 +355,11 @@ module ActiveMerchant #:nodoc:
312
355
  parameters.to_json
313
356
  end
314
357
 
315
- def error_code_from(response)
316
- STANDARD_ERROR_CODE[:processing_error] unless success_from(response)
358
+ def error_code_from(response, action)
359
+ return if success_from(response, action)
360
+ return response['last_transaction']['acquirer_return_code'] if response['last_transaction']
361
+
362
+ STANDARD_ERROR_CODE[:processing_error]
317
363
  end
318
364
  end
319
365
  end
@@ -16,7 +16,7 @@ module ActiveMerchant #:nodoc:
16
16
  self.live_periodic_url = 'https://transact.nab.com.au/xmlapi/periodic'
17
17
 
18
18
  self.supported_countries = ['AU']
19
- self.supported_cardtypes = [:visa, :master, :american_express, :diners_club, :jcb]
19
+ self.supported_cardtypes = %i[visa master american_express diners_club jcb]
20
20
 
21
21
  self.homepage_url = 'http://transact.nab.com.au'
22
22
  self.display_name = 'NAB Transact'
@@ -25,21 +25,21 @@ module ActiveMerchant #:nodoc:
25
25
 
26
26
  # Transactions currently accepted by NAB Transact XML API
27
27
  TRANSACTIONS = {
28
- :purchase => 0, # Standard Payment
29
- :refund => 4, # Refund
30
- :void => 6, # Client Reversal (Void)
31
- :unmatched_refund => 666, # Unmatched Refund
32
- :authorization => 10, # Preauthorise
33
- :capture => 11 # Preauthorise Complete (Advice)
28
+ purchase: 0, # Standard Payment
29
+ refund: 4, # Refund
30
+ void: 6, # Client Reversal (Void)
31
+ unmatched_refund: 666, # Unmatched Refund
32
+ authorization: 10, # Preauthorise
33
+ capture: 11 # Preauthorise Complete (Advice)
34
34
  }
35
35
 
36
36
  PERIODIC_TYPES = {
37
- :addcrn => 5,
38
- :deletecrn => 5,
39
- :trigger => 8
37
+ addcrn: 5,
38
+ deletecrn: 5,
39
+ trigger: 8
40
40
  }
41
41
 
42
- SUCCESS_CODES = [ '00', '08', '11', '16', '77' ]
42
+ SUCCESS_CODES = %w[00 08 11 16 77]
43
43
 
44
44
  def initialize(options = {})
45
45
  requires!(options, :login, :password)
@@ -84,6 +84,7 @@ module ActiveMerchant #:nodoc:
84
84
 
85
85
  def scrub(transcript)
86
86
  return '' if transcript.blank?
87
+
87
88
  transcript.
88
89
  gsub(%r((<cardNumber>)[^<]+(<))i, '\1[FILTERED]\2').
89
90
  gsub(%r((<cvv>)[^<]+(<))i, '\1[FILTERED]\2').
@@ -95,8 +96,8 @@ module ActiveMerchant #:nodoc:
95
96
  def add_metadata(xml, options)
96
97
  if options[:merchant_name] || options[:merchant_location]
97
98
  xml.tag! 'metadata' do
98
- xml.tag! 'meta', :name => 'ca_name', :value => options[:merchant_name] if options[:merchant_name]
99
- xml.tag! 'meta', :name => 'ca_location', :value => options[:merchant_location] if options[:merchant_location]
99
+ xml.tag! 'meta', name: 'ca_name', value: options[:merchant_name] if options[:merchant_name]
100
+ xml.tag! 'meta', name: 'ca_location', value: options[:merchant_location] if options[:merchant_location]
100
101
  end
101
102
  end
102
103
  end
@@ -233,17 +234,15 @@ module ActiveMerchant #:nodoc:
233
234
  response = parse(ssl_post(test? ? self.test_url : self.live_url, build_request(action, request)))
234
235
 
235
236
  Response.new(success?(response), message_from(response), response,
236
- :test => test?,
237
- :authorization => authorization_from(action, response)
238
- )
237
+ test: test?,
238
+ authorization: authorization_from(action, response))
239
239
  end
240
240
 
241
241
  def commit_periodic(action, request)
242
242
  response = parse(ssl_post(test? ? self.test_periodic_url : self.live_periodic_url, build_periodic_request(action, request)))
243
243
  Response.new(success?(response), message_from(response), response,
244
- :test => test?,
245
- :authorization => authorization_from(action, response)
246
- )
244
+ test: test?,
245
+ authorization: authorization_from(action, response))
247
246
  end
248
247
 
249
248
  def success?(response)
@@ -295,7 +294,6 @@ module ActiveMerchant #:nodoc:
295
294
  def request_timeout
296
295
  @options[:request_timeout] || 60
297
296
  end
298
-
299
297
  end
300
298
  end
301
299
  end