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
@@ -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
@@ -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])
@@ -386,9 +394,8 @@ 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)
@@ -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)
@@ -33,55 +34,55 @@ module ActiveMerchant #:nodoc:
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
  #
@@ -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
 
@@ -575,6 +576,7 @@ module ActiveMerchant #:nodoc:
575
576
  xml.tag!('customerProfileId', options[:customer_profile_id])
576
577
  xml.tag!('customerPaymentProfileId', options[:customer_payment_profile_id])
577
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]
578
580
  xml.target!
579
581
  end
580
582
 
@@ -657,9 +659,7 @@ module ActiveMerchant #:nodoc:
657
659
  end
658
660
 
659
661
  def add_transaction(xml, transaction)
660
- unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
661
- raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}"
662
- end
662
+ raise StandardError, "Invalid Customer Information Manager Transaction Type: #{transaction[:type]}" unless CIM_TRANSACTION_TYPES.include?(transaction[:type])
663
663
 
664
664
  xml.tag!('transaction') do
665
665
  xml.tag!(CIM_TRANSACTION_TYPES[transaction[:type]]) do
@@ -695,12 +695,10 @@ module ActiveMerchant #:nodoc:
695
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))
@@ -857,7 +856,7 @@ module ActiveMerchant #:nodoc:
857
856
 
858
857
  response_params = parse(action, xml)
859
858
 
860
- message_element= response_params['messages']['message']
859
+ message_element = response_params['messages']['message']
861
860
  first_error = message_element.is_a?(Array) ? message_element.first : message_element
862
861
  message = first_error['text']
863
862
  test_mode = @options[:test_requests] || message =~ /Test Mode/
@@ -883,7 +882,7 @@ module ActiveMerchant #:nodoc:
883
882
 
884
883
  def parse_direct_response(params)
885
884
  delimiter = @options[:delimiter] || ','
886
- direct_response = {'raw' => params}
885
+ direct_response = { 'raw' => params }
887
886
  direct_response_fields = params.split(delimiter)
888
887
  direct_response.merge(
889
888
  {
@@ -933,7 +932,7 @@ module ActiveMerchant #:nodoc:
933
932
  'card_type' => direct_response_fields[51] || '',
934
933
  'split_tender_id' => direct_response_fields[52] || '',
935
934
  'requested_amount' => direct_response_fields[53] || '',
936
- 'balance_on_card' => direct_response_fields[54] || '',
935
+ 'balance_on_card' => direct_response_fields[54] || ''
937
936
  }
938
937
  )
939
938
  end
@@ -942,9 +941,7 @@ module ActiveMerchant #:nodoc:
942
941
  xml = REXML::Document.new(xml)
943
942
  root = REXML::XPath.first(xml, "//#{CIM_ACTIONS[action]}Response") ||
944
943
  REXML::XPath.first(xml, '//ErrorResponse')
945
- if root
946
- response = parse_element(root)
947
- end
944
+ response = parse_element(root) if root
948
945
 
949
946
  response
950
947
  end
@@ -8,7 +8,7 @@ module ActiveMerchant #:nodoc:
8
8
  GI GR HR HU IE IL IM IS IT LI LT LU LV MC MT MX NL
9
9
  NO PL PT RO RU SE SI SK TR US VA)
10
10
 
11
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :jcb, :maestro]
11
+ self.supported_cardtypes = %i[visa master american_express discover jcb maestro]
12
12
 
13
13
  self.homepage_url = 'http://www.axcessms.com/'
14
14
  self.display_name = 'Axcess MS'
@@ -23,33 +23,33 @@ module ActiveMerchant #:nodoc:
23
23
  PAYMENT_CODE_REFUND = 'CC.RF'
24
24
  PAYMENT_CODE_REBILL = 'CC.RB'
25
25
 
26
- def initialize(options={})
26
+ def initialize(options = {})
27
27
  requires!(options, :sender, :login, :password, :channel)
28
28
  super
29
29
  end
30
30
 
31
- def purchase(money, payment, options={})
31
+ def purchase(money, payment, options = {})
32
32
  payment_code = payment.respond_to?(:number) ? PAYMENT_CODE_DEBIT : PAYMENT_CODE_REBILL
33
33
  commit(payment_code, money, payment, options)
34
34
  end
35
35
 
36
- def authorize(money, authorization, options={})
36
+ def authorize(money, authorization, options = {})
37
37
  commit(PAYMENT_CODE_PREAUTHORIZATION, money, authorization, options)
38
38
  end
39
39
 
40
- def capture(money, authorization, options={})
40
+ def capture(money, authorization, options = {})
41
41
  commit(PAYMENT_CODE_CAPTURE, money, authorization, options)
42
42
  end
43
43
 
44
- def refund(money, authorization, options={})
44
+ def refund(money, authorization, options = {})
45
45
  commit(PAYMENT_CODE_REFUND, money, authorization, options)
46
46
  end
47
47
 
48
- def void(authorization, options={})
48
+ def void(authorization, options = {})
49
49
  commit(PAYMENT_CODE_REVERSAL, nil, authorization, options)
50
50
  end
51
51
 
52
- def verify(credit_card, options={})
52
+ def verify(credit_card, options = {})
53
53
  MultiResponse.run(:use_first_response) do |r|
54
54
  r.process { authorize(100, credit_card, options) }
55
55
  r.process(:ignore_result) { void(r.authorization, options) }
@@ -72,9 +72,8 @@ module ActiveMerchant #:nodoc:
72
72
  authorization = response[:unique_id]
73
73
 
74
74
  Response.new(success, message, response,
75
- :authorization => authorization,
76
- :test => (response[:mode] != 'LIVE')
77
- )
75
+ authorization: authorization,
76
+ test: (response[:mode] != 'LIVE'))
78
77
  end
79
78
 
80
79
  def parse(body)
@@ -93,9 +92,7 @@ module ActiveMerchant #:nodoc:
93
92
  end
94
93
 
95
94
  def parse_element(response, node)
96
- if node.has_attributes?
97
- node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value }
98
- end
95
+ node.attributes.each { |name, value| response["#{node.name}_#{name}".underscore.to_sym] = value } if node.has_attributes?
99
96
 
100
97
  if node.has_elements?
101
98
  node.elements.each { |element| parse_element(response, element) }
@@ -105,7 +102,7 @@ module ActiveMerchant #:nodoc:
105
102
  end
106
103
 
107
104
  def build_request(payment_code, money, payment, options)
108
- xml = Builder::XmlMarkup.new :indent => 2
105
+ xml = Builder::XmlMarkup.new indent: 2
109
106
  xml.instruct!
110
107
  xml.tag! 'Request', 'version' => API_VERSION do
111
108
  xml.tag! 'Header' do
@@ -168,6 +165,7 @@ module ActiveMerchant #:nodoc:
168
165
 
169
166
  def add_address(xml, address)
170
167
  raise ArgumentError.new('Address is required') unless address
168
+
171
169
  xml.tag! 'Address' do
172
170
  xml.tag! 'Street', "#{address[:address1]} #{address[:address2]}".strip
173
171
  xml.tag! 'City', address[:city]
@@ -22,7 +22,7 @@ module ActiveMerchant #:nodoc:
22
22
  self.live_url = 'https://api.balancedpayments.com'
23
23
 
24
24
  self.supported_countries = ['US']
25
- self.supported_cardtypes = [:visa, :master, :american_express, :discover]
25
+ self.supported_cardtypes = %i[visa master american_express discover]
26
26
  self.homepage_url = 'https://www.balancedpayments.com/'
27
27
  self.display_name = 'Balanced'
28
28
  self.money_format = :cents
@@ -44,12 +44,13 @@ module ActiveMerchant #:nodoc:
44
44
  add_common_params(post, options)
45
45
 
46
46
  MultiResponse.run do |r|
47
- identifier = if(payment_method.respond_to?(:number))
48
- r.process { store(payment_method, options) }
49
- r.authorization
50
- else
51
- payment_method
52
- end
47
+ identifier =
48
+ if payment_method.respond_to?(:number)
49
+ r.process { store(payment_method, options) }
50
+ r.authorization
51
+ else
52
+ payment_method
53
+ end
53
54
  r.process { commit('debits', "cards/#{card_identifier_from(identifier)}/debits", post) }
54
55
  end
55
56
  end
@@ -61,12 +62,13 @@ module ActiveMerchant #:nodoc:
61
62
  add_common_params(post, options)
62
63
 
63
64
  MultiResponse.run do |r|
64
- identifier = if(payment_method.respond_to?(:number))
65
- r.process { store(payment_method, options) }
66
- r.authorization
67
- else
68
- payment_method
69
- end
65
+ identifier =
66
+ if payment_method.respond_to?(:number)
67
+ r.process { store(payment_method, options) }
68
+ r.authorization
69
+ else
70
+ payment_method
71
+ end
70
72
  r.process { commit('card_holds', "cards/#{card_identifier_from(identifier)}/card_holds", post) }
71
73
  end
72
74
  end
@@ -97,7 +99,7 @@ module ActiveMerchant #:nodoc:
97
99
  commit('refunds', "debits/#{reference_identifier_from(identifier)}/refunds", post)
98
100
  end
99
101
 
100
- def store(credit_card, options={})
102
+ def store(credit_card, options = {})
101
103
  post = {}
102
104
 
103
105
  post[:number] = credit_card.number
@@ -137,7 +139,7 @@ module ActiveMerchant #:nodoc:
137
139
 
138
140
  def add_address(post, options)
139
141
  address = (options[:billing_address] || options[:address])
140
- if(address && address[:zip].present?)
142
+ if address && address[:zip].present?
141
143
  post[:address] = {}
142
144
  post[:address][:line1] = address[:address1] if address[:address1]
143
145
  post[:address][:line2] = address[:address2] if address[:address2]
@@ -154,18 +156,22 @@ module ActiveMerchant #:nodoc:
154
156
  post[:meta] = options[:meta]
155
157
  end
156
158
 
157
- def commit(entity_name, path, post, method=:post)
158
- raw_response = begin
159
- parse(ssl_request(
160
- method,
161
- live_url + "/#{path}",
162
- post_data(post),
163
- headers
164
- ))
165
- rescue ResponseError => e
166
- raise unless(e.response.code.to_s =~ /4\d\d/)
167
- parse(e.response.body)
168
- end
159
+ def commit(entity_name, path, post, method = :post)
160
+ raw_response =
161
+ begin
162
+ parse(
163
+ ssl_request(
164
+ method,
165
+ live_url + "/#{path}",
166
+ post_data(post),
167
+ headers
168
+ )
169
+ )
170
+ rescue ResponseError => e
171
+ raise unless e.response.code.to_s =~ /4\d\d/
172
+
173
+ parse(e.response.body)
174
+ end
169
175
 
170
176
  Response.new(
171
177
  success_from(entity_name, raw_response),
@@ -178,13 +184,13 @@ module ActiveMerchant #:nodoc:
178
184
 
179
185
  def success_from(entity_name, raw_response)
180
186
  entity = (raw_response[entity_name] || []).first
181
- if(!entity)
187
+ if !entity
182
188
  false
183
- elsif((entity_name == 'refunds') && entity.include?('status'))
189
+ elsif (entity_name == 'refunds') && entity.include?('status')
184
190
  %w(succeeded pending).include?(entity['status'])
185
- elsif(entity.include?('status'))
191
+ elsif entity.include?('status')
186
192
  (entity['status'] == 'succeeded')
187
- elsif(entity_name == 'cards')
193
+ elsif entity_name == 'cards'
188
194
  !!entity['id']
189
195
  else
190
196
  false
@@ -192,7 +198,7 @@ module ActiveMerchant #:nodoc:
192
198
  end
193
199
 
194
200
  def message_from(raw_response)
195
- if(raw_response['errors'])
201
+ if raw_response['errors']
196
202
  error = raw_response['errors'].first
197
203
  (error['additional'] || error['message'] || error['description'])
198
204
  else
@@ -222,6 +228,7 @@ module ActiveMerchant #:nodoc:
222
228
 
223
229
  params.map do |key, value|
224
230
  next if value.blank?
231
+
225
232
  if value.is_a?(Hash)
226
233
  h = {}
227
234
  value.each do |k, v|
@@ -245,10 +252,10 @@ module ActiveMerchant #:nodoc:
245
252
  )
246
253
 
247
254
  {
248
- 'Authorization' => 'Basic ' + Base64.encode64(@options[:login].to_s + ':').strip,
249
- 'User-Agent' => "Balanced/v1.1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
250
- 'Accept' => 'application/vnd.api+json;revision=1.1',
251
- 'X-Balanced-User-Agent' => @@ua,
255
+ 'Authorization' => 'Basic ' + Base64.encode64(@options[:login].to_s + ':').strip,
256
+ 'User-Agent' => "Balanced/v1.1 ActiveMerchantBindings/#{ActiveMerchant::VERSION}",
257
+ 'Accept' => 'application/vnd.api+json;revision=1.1',
258
+ 'X-Balanced-User-Agent' => @@ua
252
259
  }
253
260
  end
254
261
  end