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
@@ -31,18 +31,18 @@ module ActiveMerchant #:nodoc:
31
31
 
32
32
  self.default_currency = 'USD'
33
33
 
34
- self.supported_countries = ['US', 'CA', 'GB']
35
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
34
+ self.supported_countries = %w[US CA GB]
35
+ self.supported_cardtypes = %i[visa master american_express discover diners_club jcb]
36
36
  self.homepage_url = 'http://www.authorize.net/'
37
37
  self.display_name = 'Authorize.Net'
38
38
 
39
39
  AUTHORIZE_NET_ARB_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
40
40
 
41
41
  RECURRING_ACTIONS = {
42
- :create => 'ARBCreateSubscription',
43
- :update => 'ARBUpdateSubscription',
44
- :cancel => 'ARBCancelSubscription',
45
- :status => 'ARBGetSubscriptionStatus'
42
+ create: 'ARBCreateSubscription',
43
+ update: 'ARBUpdateSubscription',
44
+ cancel: 'ARBCancelSubscription',
45
+ status: 'ARBGetSubscriptionStatus'
46
46
  }
47
47
 
48
48
  # Creates a new AuthorizeNetArbGateway
@@ -57,7 +57,7 @@ module ActiveMerchant #:nodoc:
57
57
  # * <tt>:test</tt> -- +true+ or +false+. If true, perform transactions against the test server.
58
58
  # Otherwise, perform transactions against the production server.
59
59
  def initialize(options = {})
60
- ActiveMerchant.deprecated "ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it."
60
+ ActiveMerchant.deprecated 'ARB functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.'
61
61
  requires!(options, :login, :password)
62
62
  super
63
63
  end
@@ -82,9 +82,9 @@ module ActiveMerchant #:nodoc:
82
82
  # +:interval => { :unit => :months, :length => 3 }+ (REQUIRED)
83
83
  # * <tt>:duration</tt> -- A hash containing keys for the <tt>:start_date</tt> the subscription begins (also the date the
84
84
  # initial billing occurs) and the total number of billing <tt>:occurrences</tt> or payments for the subscription. (REQUIRED)
85
- def recurring(money, creditcard, options={})
85
+ def recurring(money, creditcard, options = {})
86
86
  requires!(options, :interval, :duration, :billing_address)
87
- requires!(options[:interval], :length, [:unit, :days, :months])
87
+ requires!(options[:interval], :length, %i[unit days months])
88
88
  requires!(options[:duration], :start_date, :occurrences)
89
89
  requires!(options[:billing_address], :first_name, :last_name)
90
90
 
@@ -110,7 +110,7 @@ module ActiveMerchant #:nodoc:
110
110
  #
111
111
  # * <tt>:subscription_id</tt> -- A string containing the <tt>:subscription_id</tt> of the recurring payment already in place
112
112
  # for a given credit card. (REQUIRED)
113
- def update_recurring(options={})
113
+ def update_recurring(options = {})
114
114
  requires!(options, :subscription_id)
115
115
  request = build_recurring_request(:update, options)
116
116
  recurring_commit(:update, request)
@@ -126,7 +126,7 @@ module ActiveMerchant #:nodoc:
126
126
  # * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
127
127
  # for a given credit card. (REQUIRED)
128
128
  def cancel_recurring(subscription_id)
129
- request = build_recurring_request(:cancel, :subscription_id => subscription_id)
129
+ request = build_recurring_request(:cancel, subscription_id: subscription_id)
130
130
  recurring_commit(:cancel, request)
131
131
  end
132
132
 
@@ -139,7 +139,7 @@ module ActiveMerchant #:nodoc:
139
139
  # * <tt>subscription_id</tt> -- A string containing the +subscription_id+ of the recurring payment already in place
140
140
  # for a given credit card. (REQUIRED)
141
141
  def status_recurring(subscription_id)
142
- request = build_recurring_request(:status, :subscription_id => subscription_id)
142
+ request = build_recurring_request(:status, subscription_id: subscription_id)
143
143
  recurring_commit(:status, request)
144
144
  end
145
145
 
@@ -147,13 +147,11 @@ module ActiveMerchant #:nodoc:
147
147
 
148
148
  # Builds recurring billing request
149
149
  def build_recurring_request(action, options = {})
150
- unless RECURRING_ACTIONS.include?(action)
151
- raise StandardError, "Invalid Automated Recurring Billing Action: #{action}"
152
- end
150
+ raise StandardError, "Invalid Automated Recurring Billing Action: #{action}" unless RECURRING_ACTIONS.include?(action)
153
151
 
154
- xml = Builder::XmlMarkup.new(:indent => 2)
155
- xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
156
- xml.tag!("#{RECURRING_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_ARB_NAMESPACE) do
152
+ xml = Builder::XmlMarkup.new(indent: 2)
153
+ xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
154
+ xml.tag!("#{RECURRING_ACTIONS[action]}Request", xmlns: AUTHORIZE_NET_ARB_NAMESPACE) do
157
155
  add_merchant_authentication(xml)
158
156
  # Merchant-assigned reference ID for the request
159
157
  xml.tag!('refId', options[:ref_id]) if options[:ref_id]
@@ -232,6 +230,7 @@ module ActiveMerchant #:nodoc:
232
230
  def add_interval(xml, options)
233
231
  interval = options[:interval]
234
232
  return unless interval
233
+
235
234
  xml.tag!('interval') do
236
235
  # The measurement of time, in association with the Interval Unit,
237
236
  # that is used to define the frequency of the billing occurrences
@@ -246,6 +245,7 @@ module ActiveMerchant #:nodoc:
246
245
  def add_duration(xml, options)
247
246
  duration = options[:duration]
248
247
  return unless duration
248
+
249
249
  # The date the subscription begins
250
250
  # (also the date the initial billing occurs)
251
251
  xml.tag!('startDate', duration[:start_date]) if duration[:start_date]
@@ -255,6 +255,7 @@ module ActiveMerchant #:nodoc:
255
255
 
256
256
  def add_payment_schedule(xml, options)
257
257
  return unless options[:interval] || options[:duration]
258
+
258
259
  xml.tag!('paymentSchedule') do
259
260
  # Contains information about the interval of time between payments
260
261
  add_interval(xml, options)
@@ -269,6 +270,7 @@ module ActiveMerchant #:nodoc:
269
270
  # Adds customer's credit card or bank account payment information
270
271
  def add_payment(xml, options)
271
272
  return unless options[:credit_card] || options[:bank_account]
273
+
272
274
  xml.tag!('payment') do
273
275
  # Contains the customer’s credit card information
274
276
  add_credit_card(xml, options)
@@ -283,6 +285,7 @@ module ActiveMerchant #:nodoc:
283
285
  def add_credit_card(xml, options)
284
286
  credit_card = options[:credit_card]
285
287
  return unless credit_card
288
+
286
289
  xml.tag!('creditCard') do
287
290
  # The credit card number used for payment of the subscription
288
291
  xml.tag!('cardNumber', credit_card.number)
@@ -297,6 +300,7 @@ module ActiveMerchant #:nodoc:
297
300
  def add_bank_account(xml, options)
298
301
  bank_account = options[:bank_account]
299
302
  return unless bank_account
303
+
300
304
  xml.tag!('bankAccount') do
301
305
  # The type of bank account used for payment of the subscription
302
306
  xml.tag!('accountType', bank_account[:account_type])
@@ -319,6 +323,7 @@ module ActiveMerchant #:nodoc:
319
323
  def add_order(xml, options)
320
324
  order = options[:order]
321
325
  return unless order
326
+
322
327
  xml.tag!('order') do
323
328
  # Merchant-assigned invoice number for the subscription (optional)
324
329
  xml.tag!('invoiceNumber', order[:invoice_number])
@@ -331,6 +336,7 @@ module ActiveMerchant #:nodoc:
331
336
  def add_customer(xml, options)
332
337
  customer = options[:customer]
333
338
  return unless customer
339
+
334
340
  xml.tag!('customer') do
335
341
  xml.tag!('type', customer[:type]) if customer[:type]
336
342
  xml.tag!('id', customer[:id]) if customer[:id]
@@ -346,6 +352,7 @@ module ActiveMerchant #:nodoc:
346
352
  def add_drivers_license(xml, options)
347
353
  return unless customer = options[:customer]
348
354
  return unless drivers_license = customer[:drivers_license]
355
+
349
356
  xml.tag!('driversLicense') do
350
357
  # The customer's driver's license number
351
358
  xml.tag!('number', drivers_license[:number])
@@ -359,6 +366,7 @@ module ActiveMerchant #:nodoc:
359
366
  # Adds address information
360
367
  def add_address(xml, container_name, address)
361
368
  return if address.blank?
369
+
362
370
  xml.tag!(container_name) do
363
371
  xml.tag!('firstName', address[:first_name])
364
372
  xml.tag!('lastName', address[:last_name])
@@ -377,7 +385,7 @@ module ActiveMerchant #:nodoc:
377
385
 
378
386
  def recurring_commit(action, request)
379
387
  url = test? ? test_url : live_url
380
- xml = ssl_post(url, request, "Content-Type" => "text/xml")
388
+ xml = ssl_post(url, request, 'Content-Type' => 'text/xml')
381
389
 
382
390
  response = recurring_parse(action, xml)
383
391
 
@@ -386,16 +394,15 @@ module ActiveMerchant #:nodoc:
386
394
  success = response[:result_code] == 'Ok'
387
395
 
388
396
  Response.new(success, message, response,
389
- :test => test_mode,
390
- :authorization => response[:subscription_id]
391
- )
397
+ test: test_mode,
398
+ authorization: response[:subscription_id])
392
399
  end
393
400
 
394
401
  def recurring_parse(action, xml)
395
402
  response = {}
396
403
  xml = REXML::Document.new(xml)
397
404
  root = REXML::XPath.first(xml, "//#{RECURRING_ACTIONS[action]}Response") ||
398
- REXML::XPath.first(xml, "//ErrorResponse")
405
+ REXML::XPath.first(xml, '//ErrorResponse')
399
406
  if root
400
407
  root.elements.to_a.each do |node|
401
408
  recurring_parse_element(response, node)
@@ -407,7 +414,7 @@ module ActiveMerchant #:nodoc:
407
414
 
408
415
  def recurring_parse_element(response, node)
409
416
  if node.has_elements?
410
- node.elements.each{|e| recurring_parse_element(response, e) }
417
+ node.elements.each { |e| recurring_parse_element(response, e) }
411
418
  else
412
419
  response[node.name.underscore.to_sym] = node.text
413
420
  end
@@ -1,4 +1,5 @@
1
1
  # -*- coding: utf-8 -*-
2
+
2
3
  module ActiveMerchant #:nodoc:
3
4
  module Billing #:nodoc:
4
5
  # ==== Customer Information Manager (CIM)
@@ -28,60 +29,60 @@ module ActiveMerchant #:nodoc:
28
29
  # 5. Click Submit
29
30
  class AuthorizeNetCimGateway < Gateway
30
31
  self.test_url = 'https://apitest.authorize.net/xml/v1/request.api'
31
- self.live_url = 'https://api.authorize.net/xml/v1/request.api'
32
+ self.live_url = 'https://api2.authorize.net/xml/v1/request.api'
32
33
 
33
34
  AUTHORIZE_NET_CIM_NAMESPACE = 'AnetApi/xml/v1/schema/AnetApiSchema.xsd'
34
35
 
35
36
  CIM_ACTIONS = {
36
- :create_customer_profile => 'createCustomerProfile',
37
- :create_customer_payment_profile => 'createCustomerPaymentProfile',
38
- :create_customer_shipping_address => 'createCustomerShippingAddress',
39
- :get_customer_profile => 'getCustomerProfile',
40
- :get_customer_profile_ids => 'getCustomerProfileIds',
41
- :get_customer_payment_profile => 'getCustomerPaymentProfile',
42
- :get_customer_shipping_address => 'getCustomerShippingAddress',
43
- :delete_customer_profile => 'deleteCustomerProfile',
44
- :delete_customer_payment_profile => 'deleteCustomerPaymentProfile',
45
- :delete_customer_shipping_address => 'deleteCustomerShippingAddress',
46
- :update_customer_profile => 'updateCustomerProfile',
47
- :update_customer_payment_profile => 'updateCustomerPaymentProfile',
48
- :update_customer_shipping_address => 'updateCustomerShippingAddress',
49
- :create_customer_profile_transaction => 'createCustomerProfileTransaction',
50
- :validate_customer_payment_profile => 'validateCustomerPaymentProfile'
37
+ create_customer_profile: 'createCustomerProfile',
38
+ create_customer_payment_profile: 'createCustomerPaymentProfile',
39
+ create_customer_shipping_address: 'createCustomerShippingAddress',
40
+ get_customer_profile: 'getCustomerProfile',
41
+ get_customer_profile_ids: 'getCustomerProfileIds',
42
+ get_customer_payment_profile: 'getCustomerPaymentProfile',
43
+ get_customer_shipping_address: 'getCustomerShippingAddress',
44
+ delete_customer_profile: 'deleteCustomerProfile',
45
+ delete_customer_payment_profile: 'deleteCustomerPaymentProfile',
46
+ delete_customer_shipping_address: 'deleteCustomerShippingAddress',
47
+ update_customer_profile: 'updateCustomerProfile',
48
+ update_customer_payment_profile: 'updateCustomerPaymentProfile',
49
+ update_customer_shipping_address: 'updateCustomerShippingAddress',
50
+ create_customer_profile_transaction: 'createCustomerProfileTransaction',
51
+ validate_customer_payment_profile: 'validateCustomerPaymentProfile'
51
52
  }
52
53
 
53
54
  CIM_TRANSACTION_TYPES = {
54
- :auth_capture => 'profileTransAuthCapture',
55
- :auth_only => 'profileTransAuthOnly',
56
- :capture_only => 'profileTransCaptureOnly',
57
- :prior_auth_capture => 'profileTransPriorAuthCapture',
58
- :refund => 'profileTransRefund',
59
- :void => 'profileTransVoid'
55
+ auth_capture: 'profileTransAuthCapture',
56
+ auth_only: 'profileTransAuthOnly',
57
+ capture_only: 'profileTransCaptureOnly',
58
+ prior_auth_capture: 'profileTransPriorAuthCapture',
59
+ refund: 'profileTransRefund',
60
+ void: 'profileTransVoid'
60
61
  }
61
62
 
62
63
  CIM_VALIDATION_MODES = {
63
- :none => 'none',
64
- :test => 'testMode',
65
- :live => 'liveMode',
66
- :old => 'oldLiveMode'
64
+ none: 'none',
65
+ test: 'testMode',
66
+ live: 'liveMode',
67
+ old: 'oldLiveMode'
67
68
  }
68
69
 
69
70
  BANK_ACCOUNT_TYPES = {
70
- :checking => 'checking',
71
- :savings => 'savings',
72
- :business_checking => 'businessChecking'
71
+ checking: 'checking',
72
+ savings: 'savings',
73
+ business_checking: 'businessChecking'
73
74
  }
74
75
 
75
76
  ECHECK_TYPES = {
76
- :ccd => 'CCD',
77
- :ppd => 'PPD',
78
- :web => 'WEB'
77
+ ccd: 'CCD',
78
+ ppd: 'PPD',
79
+ web: 'WEB'
79
80
  }
80
81
 
81
82
  self.homepage_url = 'http://www.authorize.net/'
82
83
  self.display_name = 'Authorize.Net CIM'
83
84
  self.supported_countries = ['US']
84
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
85
+ self.supported_cardtypes = %i[visa master american_express discover]
85
86
 
86
87
  # Creates a new AuthorizeNetCimGateway
87
88
  #
@@ -379,19 +380,19 @@ module ActiveMerchant #:nodoc:
379
380
  requires!(options, :transaction)
380
381
  requires!(options[:transaction], :type)
381
382
  case options[:transaction][:type]
382
- when :void
383
- requires!(options[:transaction], :trans_id)
384
- when :refund
385
- requires!(options[:transaction], :trans_id) &&
386
- (
387
- (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
388
- options[:transaction][:credit_card_number_masked] ||
389
- (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
390
- )
391
- when :prior_auth_capture
392
- requires!(options[:transaction], :amount, :trans_id)
393
- else
394
- requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
383
+ when :void
384
+ requires!(options[:transaction], :trans_id)
385
+ when :refund
386
+ requires!(options[:transaction], :trans_id) &&
387
+ (
388
+ (options[:transaction][:customer_profile_id] && options[:transaction][:customer_payment_profile_id]) ||
389
+ options[:transaction][:credit_card_number_masked] ||
390
+ (options[:transaction][:bank_routing_number_masked] && options[:transaction][:bank_account_number_masked])
391
+ )
392
+ when :prior_auth_capture
393
+ requires!(options[:transaction], :amount, :trans_id)
394
+ else
395
+ requires!(options[:transaction], :amount, :customer_profile_id, :customer_payment_profile_id)
395
396
  end
396
397
  request = build_request(:create_customer_profile_transaction, options)
397
398
  commit(:create_customer_profile_transaction, request)
@@ -485,13 +486,11 @@ module ActiveMerchant #:nodoc:
485
486
  end
486
487
 
487
488
  def build_request(action, options = {})
488
- unless CIM_ACTIONS.include?(action)
489
- raise StandardError, "Invalid Customer Information Manager Action: #{action}"
490
- end
489
+ raise StandardError, "Invalid Customer Information Manager Action: #{action}" unless CIM_ACTIONS.include?(action)
491
490
 
492
- xml = Builder::XmlMarkup.new(:indent => 2)
493
- xml.instruct!(:xml, :version => '1.0', :encoding => 'utf-8')
494
- xml.tag!("#{CIM_ACTIONS[action]}Request", :xmlns => AUTHORIZE_NET_CIM_NAMESPACE) do
491
+ xml = Builder::XmlMarkup.new(indent: 2)
492
+ xml.instruct!(:xml, version: '1.0', encoding: 'utf-8')
493
+ xml.tag!("#{CIM_ACTIONS[action]}Request", xmlns: AUTHORIZE_NET_CIM_NAMESPACE) do
495
494
  add_merchant_authentication(xml)
496
495
  # Merchant-assigned reference ID for the request
497
496
  xml.tag!('refId', options[:ref_id]) if options[:ref_id]
@@ -564,6 +563,8 @@ module ActiveMerchant #:nodoc:
564
563
 
565
564
  def build_get_customer_profile_request(xml, options)
566
565
  xml.tag!('customerProfileId', options[:customer_profile_id])
566
+ xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
567
+ xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
567
568
  xml.target!
568
569
  end
569
570
 
@@ -574,6 +575,8 @@ module ActiveMerchant #:nodoc:
574
575
  def build_get_customer_payment_profile_request(xml, options)
575
576
  xml.tag!('customerProfileId', options[:customer_profile_id])
576
577
  xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
578
+ xml.tag!('unmaskExpirationDate', options[:unmask_expiration_date]) if options[:unmask_expiration_date]
579
+ xml.tag!('includeIssuerInfo', options[:include_issuer_info]) if options[:include_issuer_info]
577
580
  xml.target!
578
581
  end
579
582
 
@@ -613,7 +616,7 @@ module ActiveMerchant #:nodoc:
613
616
 
614
617
  def build_create_customer_profile_transaction_request(xml, options)
615
618
  options[:extra_options] ||= {}
616
- options[:extra_options].merge!('x_delim_char' => @options[:delimiter]) if @options[:delimiter]
619
+ options[:extra_options]['x_delim_char'] = @options[:delimiter] if @options[:delimiter]
617
620
 
618
621
  add_transaction(xml, options[:transaction])
619
622
  xml.tag!('extraOptions') do
@@ -656,51 +659,46 @@ module ActiveMerchant #:nodoc:
656
659
  end
657
660
 
658
661
  def add_transaction(xml, transaction)
659
- unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
660
- raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
661
- end
662
+ raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
662
663
 
663
664
  xml.tag!('transaction') do
664
665
  xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
665
666
  # The amount to be billed to the customer
666
667
  case transaction[:type]
667
- when :void
668
- tag_unless_blank(xml,'customerProfileId', transaction[:customer_profile_id])
669
- tag_unless_blank(xml,'customerPaymentProfileId', transaction[:customer_payment_profile_id])
670
- tag_unless_blank(xml,'customerShippingAddressId', transaction[:customer_shipping_address_id])
671
- xml.tag!('transId', transaction[:trans_id])
672
- when :refund
673
- #TODO - add lineItems field
674
- xml.tag!('amount', transaction[:amount])
675
- tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
676
- tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
677
- tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
678
- tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
679
- tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
680
- tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
681
- add_order(xml, transaction[:order]) if transaction[:order].present?
682
- xml.tag!('transId', transaction[:trans_id])
683
- add_tax(xml, transaction[:tax]) if transaction[:tax]
684
- add_duty(xml, transaction[:duty]) if transaction[:duty]
685
- add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
686
- when :prior_auth_capture
687
- xml.tag!('amount', transaction[:amount])
688
- add_order(xml, transaction[:order]) if transaction[:order].present?
689
- xml.tag!('transId', transaction[:trans_id])
690
- else
691
- xml.tag!('amount', transaction[:amount])
692
- xml.tag!('customerProfileId', transaction[:customer_profile_id])
693
- xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
694
- xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
695
- add_order(xml, transaction[:order]) if transaction[:order].present?
668
+ when :void
669
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
670
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
671
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
672
+ xml.tag!('transId', transaction[:trans_id])
673
+ when :refund
674
+ xml.tag!('amount', transaction[:amount])
675
+ tag_unless_blank(xml, 'customerProfileId', transaction[:customer_profile_id])
676
+ tag_unless_blank(xml, 'customerPaymentProfileId', transaction[:customer_payment_profile_id])
677
+ tag_unless_blank(xml, 'customerShippingAddressId', transaction[:customer_shipping_address_id])
678
+ tag_unless_blank(xml, 'creditCardNumberMasked', transaction[:credit_card_number_masked])
679
+ tag_unless_blank(xml, 'bankRoutingNumberMasked', transaction[:bank_routing_number_masked])
680
+ tag_unless_blank(xml, 'bankAccountNumberMasked', transaction[:bank_account_number_masked])
681
+ add_order(xml, transaction[:order]) if transaction[:order].present?
682
+ xml.tag!('transId', transaction[:trans_id])
683
+ add_tax(xml, transaction[:tax]) if transaction[:tax]
684
+ add_duty(xml, transaction[:duty]) if transaction[:duty]
685
+ add_shipping(xml, transaction[:shipping]) if transaction[:shipping]
686
+ when :prior_auth_capture
687
+ xml.tag!('amount', transaction[:amount])
688
+ add_order(xml, transaction[:order]) if transaction[:order].present?
689
+ xml.tag!('transId', transaction[:trans_id])
690
+ else
691
+ xml.tag!('amount', transaction[:amount])
692
+ xml.tag!('customerProfileId', transaction[:customer_profile_id])
693
+ xml.tag!('customerPaymentProfileId', transaction[:customer_payment_profile_id])
694
+ xml.tag!('approvalCode', transaction[:approval_code]) if transaction[:type] == :capture_only
695
+ add_order(xml, transaction[:order]) if transaction[:order].present?
696
696
 
697
697
  end
698
- if [:auth_capture, :auth_only, :capture_only].include?(transaction[:type])
698
+ if %i[auth_capture auth_only capture_only].include?(transaction[:type])
699
699
  xml.tag!('recurringBilling', transaction[:recurring_billing]) if transaction.has_key?(:recurring_billing)
700
700
  end
701
- unless [:void,:refund,:prior_auth_capture].include?(transaction[:type])
702
- tag_unless_blank(xml, 'cardCode', transaction[:card_code])
703
- end
701
+ tag_unless_blank(xml, 'cardCode', transaction[:card_code]) unless %i[void refund prior_auth_capture].include?(transaction[:type])
704
702
  end
705
703
  end
706
704
  end
@@ -797,6 +795,7 @@ module ActiveMerchant #:nodoc:
797
795
  # when the payment method is credit card.
798
796
  def add_credit_card(xml, credit_card)
799
797
  return unless credit_card
798
+
800
799
  xml.tag!('creditCard') do
801
800
  # The credit card number used for payment of the subscription
802
801
  xml.tag!('cardNumber', full_or_masked_card_number(credit_card.number))
@@ -853,20 +852,24 @@ module ActiveMerchant #:nodoc:
853
852
 
854
853
  def commit(action, request)
855
854
  url = test? ? test_url : live_url
856
- xml = ssl_post(url, request, "Content-Type" => "text/xml")
855
+ xml = ssl_post(url, request, 'Content-Type' => 'text/xml')
857
856
 
858
857
  response_params = parse(action, xml)
859
858
 
860
- message = response_params['messages']['message']['text']
859
+ message_element = response_params['messages']['message']
860
+ first_error = message_element.is_a?(Array) ? message_element.first : message_element
861
+ message = first_error['text']
861
862
  test_mode = @options[:test_requests] || message =~ /Test Mode/
862
863
  success = response_params['messages']['result_code'] == 'Ok'
863
864
  response_params['direct_response'] = parse_direct_response(response_params['direct_response']) if response_params['direct_response']
864
865
  transaction_id = response_params['direct_response']['transaction_id'] if response_params['direct_response']
865
866
 
866
- Response.new(success, message, response_params,
867
- :test => test_mode,
868
- :authorization => transaction_id || response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil)
869
- )
867
+ response_options = {}
868
+ response_options[:test] = test_mode
869
+ response_options[:authorization] = transaction_id || response_params['customer_profile_id'] || (response_params['profile'] ? response_params['profile']['customer_profile_id'] : nil)
870
+ response_options[:error_code] = first_error['code'] unless success
871
+
872
+ Response.new(success, message, response_params, response_options)
870
873
  end
871
874
 
872
875
  def tag_unless_blank(xml, tag_name, data)
@@ -874,12 +877,12 @@ module ActiveMerchant #:nodoc:
874
877
  end
875
878
 
876
879
  def format_extra_options(options)
877
- options.map{ |k, v| "#{k}=#{v}" }.join('&') unless options.nil?
880
+ options&.map { |k, v| "#{k}=#{v}" }&.join('&')
878
881
  end
879
882
 
880
883
  def parse_direct_response(params)
881
884
  delimiter = @options[:delimiter] || ','
882
- direct_response = {'raw' => params}
885
+ direct_response = { 'raw' => params }
883
886
  direct_response_fields = params.split(delimiter)
884
887
  direct_response.merge(
885
888
  {
@@ -929,7 +932,7 @@ module ActiveMerchant #:nodoc:
929
932
  'card_type' => direct_response_fields[51] || '',
930
933
  'split_tender_id' => direct_response_fields[52] || '',
931
934
  'requested_amount' => direct_response_fields[53] || '',
932
- 'balance_on_card' => direct_response_fields[54] || '',
935
+ 'balance_on_card' => direct_response_fields[54] || ''
933
936
  }
934
937
  )
935
938
  end
@@ -937,10 +940,8 @@ module ActiveMerchant #:nodoc:
937
940
  def parse(action, xml)
938
941
  xml = REXML::Document.new(xml)
939
942
  root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
940
- REXML::XPath.first(xml, "//ErrorResponse")
941
- if root
942
- response = parse_element(root)
943
- end
943
+ REXML::XPath.first(xml, '//ErrorResponse')
944
+ response = parse_element(root) if root
944
945
 
945
946
  response
946
947
  end
@@ -948,7 +949,7 @@ module ActiveMerchant #:nodoc:
948
949
  def parse_element(node)
949
950
  if node.has_elements?
950
951
  response = {}
951
- node.elements.each{ |e|
952
+ node.elements.each { |e|
952
953
  key = e.name.underscore
953
954
  value = parse_element(e)
954
955
  if response.has_key?(key)