activemerchant 1.86.0 → 1.87.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (164) hide show
  1. checksums.yaml +5 -5
  2. data/CHANGELOG +22 -0
  3. data/lib/active_merchant/billing/avs_result.rb +0 -1
  4. data/lib/active_merchant/billing/check.rb +1 -1
  5. data/lib/active_merchant/billing/compatibility.rb +3 -3
  6. data/lib/active_merchant/billing/credit_card.rb +1 -1
  7. data/lib/active_merchant/billing/credit_card_formatting.rb +3 -3
  8. data/lib/active_merchant/billing/credit_card_methods.rb +6 -4
  9. data/lib/active_merchant/billing/gateway.rb +9 -9
  10. data/lib/active_merchant/billing/gateways/adyen.rb +48 -7
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +1 -1
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +8 -8
  13. data/lib/active_merchant/billing/gateways/authorize_net_arb.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/authorize_net_cim.rb +15 -15
  15. data/lib/active_merchant/billing/gateways/axcessms.rb +2 -2
  16. data/lib/active_merchant/billing/gateways/balanced.rb +11 -11
  17. data/lib/active_merchant/billing/gateways/bank_frick.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +5 -5
  19. data/lib/active_merchant/billing/gateways/beanstream.rb +3 -2
  20. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +5 -5
  21. data/lib/active_merchant/billing/gateways/blue_pay.rb +5 -5
  22. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -5
  23. data/lib/active_merchant/billing/gateways/bogus.rb +3 -3
  24. data/lib/active_merchant/billing/gateways/borgun.rb +5 -6
  25. data/lib/active_merchant/billing/gateways/braintree_blue.rb +18 -12
  26. data/lib/active_merchant/billing/gateways/bridge_pay.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/cams.rb +12 -12
  28. data/lib/active_merchant/billing/gateways/card_stream.rb +9 -9
  29. data/lib/active_merchant/billing/gateways/cardknox.rb +4 -4
  30. data/lib/active_merchant/billing/gateways/cardprocess.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/cashnet.rb +2 -2
  32. data/lib/active_merchant/billing/gateways/cc5.rb +2 -2
  33. data/lib/active_merchant/billing/gateways/cenpos.rb +2 -2
  34. data/lib/active_merchant/billing/gateways/checkout.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/clearhaus.rb +12 -12
  36. data/lib/active_merchant/billing/gateways/commercegate.rb +3 -3
  37. data/lib/active_merchant/billing/gateways/creditcall.rb +2 -2
  38. data/lib/active_merchant/billing/gateways/credorax.rb +13 -3
  39. data/lib/active_merchant/billing/gateways/ct_payment.rb +6 -6
  40. data/lib/active_merchant/billing/gateways/culqi.rb +1 -1
  41. data/lib/active_merchant/billing/gateways/cyber_source.rb +8 -8
  42. data/lib/active_merchant/billing/gateways/data_cash.rb +2 -2
  43. data/lib/active_merchant/billing/gateways/dibs.rb +2 -2
  44. data/lib/active_merchant/billing/gateways/digitzs.rb +5 -5
  45. data/lib/active_merchant/billing/gateways/ebanx.rb +1 -1
  46. data/lib/active_merchant/billing/gateways/efsnet.rb +4 -4
  47. data/lib/active_merchant/billing/gateways/elavon.rb +3 -3
  48. data/lib/active_merchant/billing/gateways/element.rb +4 -4
  49. data/lib/active_merchant/billing/gateways/epay.rb +1 -1
  50. data/lib/active_merchant/billing/gateways/eway.rb +2 -2
  51. data/lib/active_merchant/billing/gateways/eway_managed.rb +5 -5
  52. data/lib/active_merchant/billing/gateways/eway_rapid.rb +1 -1
  53. data/lib/active_merchant/billing/gateways/exact.rb +1 -1
  54. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -1
  55. data/lib/active_merchant/billing/gateways/first_giving.rb +1 -1
  56. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +7 -7
  57. data/lib/active_merchant/billing/gateways/flo2cash.rb +2 -2
  58. data/lib/active_merchant/billing/gateways/forte.rb +11 -7
  59. data/lib/active_merchant/billing/gateways/garanti.rb +5 -5
  60. data/lib/active_merchant/billing/gateways/global_collect.rb +2 -3
  61. data/lib/active_merchant/billing/gateways/hdfc.rb +2 -2
  62. data/lib/active_merchant/billing/gateways/hps.rb +3 -3
  63. data/lib/active_merchant/billing/gateways/inspire.rb +7 -7
  64. data/lib/active_merchant/billing/gateways/iridium.rb +14 -14
  65. data/lib/active_merchant/billing/gateways/itransact.rb +4 -4
  66. data/lib/active_merchant/billing/gateways/iveri.rb +3 -3
  67. data/lib/active_merchant/billing/gateways/jetpay.rb +2 -2
  68. data/lib/active_merchant/billing/gateways/jetpay_v2.rb +2 -2
  69. data/lib/active_merchant/billing/gateways/latitude19.rb +1 -1
  70. data/lib/active_merchant/billing/gateways/linkpoint.rb +3 -3
  71. data/lib/active_merchant/billing/gateways/litle.rb +2 -2
  72. data/lib/active_merchant/billing/gateways/maxipago.rb +1 -1
  73. data/lib/active_merchant/billing/gateways/mercado_pago.rb +7 -13
  74. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +3 -3
  75. data/lib/active_merchant/billing/gateways/merchant_one.rb +4 -4
  76. data/lib/active_merchant/billing/gateways/merchant_partners.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/merchant_warrior.rb +3 -3
  78. data/lib/active_merchant/billing/gateways/mercury.rb +2 -2
  79. data/lib/active_merchant/billing/gateways/metrics_global.rb +2 -2
  80. data/lib/active_merchant/billing/gateways/micropayment.rb +1 -1
  81. data/lib/active_merchant/billing/gateways/migs.rb +4 -6
  82. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +2 -2
  83. data/lib/active_merchant/billing/gateways/moneris.rb +85 -56
  84. data/lib/active_merchant/billing/gateways/moneris_us.rb +9 -9
  85. data/lib/active_merchant/billing/gateways/money_movers.rb +1 -1
  86. data/lib/active_merchant/billing/gateways/mundipagg.rb +1 -1
  87. data/lib/active_merchant/billing/gateways/nab_transact.rb +1 -1
  88. data/lib/active_merchant/billing/gateways/net_registry.rb +2 -2
  89. data/lib/active_merchant/billing/gateways/netaxept.rb +6 -6
  90. data/lib/active_merchant/billing/gateways/netbanx.rb +36 -36
  91. data/lib/active_merchant/billing/gateways/netbilling.rb +2 -2
  92. data/lib/active_merchant/billing/gateways/netpay.rb +1 -1
  93. data/lib/active_merchant/billing/gateways/nmi.rb +2 -2
  94. data/lib/active_merchant/billing/gateways/ogone.rb +7 -7
  95. data/lib/active_merchant/billing/gateways/omise.rb +6 -6
  96. data/lib/active_merchant/billing/gateways/opp.rb +1 -1
  97. data/lib/active_merchant/billing/gateways/optimal_payment.rb +5 -0
  98. data/lib/active_merchant/billing/gateways/orbital.rb +9 -7
  99. data/lib/active_merchant/billing/gateways/pac_net_raven.rb +6 -6
  100. data/lib/active_merchant/billing/gateways/pagarme.rb +1 -1
  101. data/lib/active_merchant/billing/gateways/pay_conex.rb +1 -1
  102. data/lib/active_merchant/billing/gateways/pay_gate_xml.rb +8 -5
  103. data/lib/active_merchant/billing/gateways/pay_hub.rb +2 -2
  104. data/lib/active_merchant/billing/gateways/pay_junction.rb +2 -2
  105. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +2 -2
  106. data/lib/active_merchant/billing/gateways/pay_secure.rb +3 -3
  107. data/lib/active_merchant/billing/gateways/paybox_direct.rb +8 -8
  108. data/lib/active_merchant/billing/gateways/payeezy.rb +1 -1
  109. data/lib/active_merchant/billing/gateways/payex.rb +8 -8
  110. data/lib/active_merchant/billing/gateways/payflow.rb +13 -13
  111. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +4 -4
  112. data/lib/active_merchant/billing/gateways/payflow_express.rb +1 -1
  113. data/lib/active_merchant/billing/gateways/payment_express.rb +10 -10
  114. data/lib/active_merchant/billing/gateways/paymentez.rb +3 -0
  115. data/lib/active_merchant/billing/gateways/paymill.rb +4 -4
  116. data/lib/active_merchant/billing/gateways/payscout.rb +1 -1
  117. data/lib/active_merchant/billing/gateways/paystation.rb +1 -1
  118. data/lib/active_merchant/billing/gateways/payu_in.rb +3 -3
  119. data/lib/active_merchant/billing/gateways/payu_latam.rb +1 -1
  120. data/lib/active_merchant/billing/gateways/payway.rb +2 -2
  121. data/lib/active_merchant/billing/gateways/plugnpay.rb +2 -2
  122. data/lib/active_merchant/billing/gateways/pro_pay.rb +2 -2
  123. data/lib/active_merchant/billing/gateways/psigate.rb +1 -1
  124. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -3
  125. data/lib/active_merchant/billing/gateways/qbms.rb +1 -1
  126. data/lib/active_merchant/billing/gateways/quantum.rb +7 -7
  127. data/lib/active_merchant/billing/gateways/quickbooks.rb +6 -6
  128. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +1 -1
  129. data/lib/active_merchant/billing/gateways/qvalent.rb +2 -2
  130. data/lib/active_merchant/billing/gateways/realex.rb +33 -13
  131. data/lib/active_merchant/billing/gateways/redsys.rb +2 -2
  132. data/lib/active_merchant/billing/gateways/safe_charge.rb +2 -2
  133. data/lib/active_merchant/billing/gateways/sage.rb +6 -6
  134. data/lib/active_merchant/billing/gateways/sage_pay.rb +7 -7
  135. data/lib/active_merchant/billing/gateways/secure_net.rb +1 -1
  136. data/lib/active_merchant/billing/gateways/secure_pay.rb +2 -2
  137. data/lib/active_merchant/billing/gateways/secure_pay_au.rb +1 -1
  138. data/lib/active_merchant/billing/gateways/secure_pay_tech.rb +1 -1
  139. data/lib/active_merchant/billing/gateways/skip_jack.rb +5 -6
  140. data/lib/active_merchant/billing/gateways/smart_ps.rb +7 -7
  141. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +1 -1
  142. data/lib/active_merchant/billing/gateways/stripe.rb +5 -5
  143. data/lib/active_merchant/billing/gateways/swipe_checkout.rb +2 -2
  144. data/lib/active_merchant/billing/gateways/telr.rb +1 -1
  145. data/lib/active_merchant/billing/gateways/trans_first_transaction_express.rb +2 -2
  146. data/lib/active_merchant/billing/gateways/transact_pro.rb +5 -5
  147. data/lib/active_merchant/billing/gateways/transax.rb +1 -1
  148. data/lib/active_merchant/billing/gateways/trust_commerce.rb +7 -7
  149. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +17 -16
  150. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +2 -2
  151. data/lib/active_merchant/billing/gateways/vanco.rb +2 -2
  152. data/lib/active_merchant/billing/gateways/verifi.rb +1 -1
  153. data/lib/active_merchant/billing/gateways/viaklix.rb +4 -4
  154. data/lib/active_merchant/billing/gateways/visanet_peru.rb +4 -4
  155. data/lib/active_merchant/billing/gateways/wirecard.rb +2 -2
  156. data/lib/active_merchant/billing/gateways/worldpay.rb +24 -13
  157. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +2 -2
  158. data/lib/active_merchant/billing/response.rb +7 -7
  159. data/lib/active_merchant/country.rb +4 -4
  160. data/lib/active_merchant/network_connection_retries.rb +7 -9
  161. data/lib/active_merchant/version.rb +1 -1
  162. data/lib/support/gateway_support.rb +3 -3
  163. data/lib/support/ssl_verify.rb +1 -1
  164. metadata +3 -3
@@ -432,7 +432,7 @@ module ActiveMerchant #:nodoc:
432
432
  def validate_signature(data)
433
433
  if sha256_authentication?
434
434
  sig = Base64.strict_encode64(mac256(get_key(data[:ds_order].to_s), xml_signed_fields(data)))
435
- sig.upcase == data[:ds_signature].to_s.upcase
435
+ sig.casecmp(data[:ds_signature].to_s).zero?
436
436
  else
437
437
  str = data[:ds_amount] +
438
438
  data[:ds_order].to_s +
@@ -523,7 +523,7 @@ module ActiveMerchant #:nodoc:
523
523
  xml_signed_fields += data[:ds_cardnumber]
524
524
  end
525
525
 
526
- xml_signed_fields += data[:ds_transactiontype] + data[:ds_securepayment]
526
+ xml_signed_fields + data[:ds_transactiontype] + data[:ds_securepayment]
527
527
  end
528
528
 
529
529
  def get_key(order_id)
@@ -252,8 +252,8 @@ module ActiveMerchant #:nodoc:
252
252
 
253
253
  def underscore(camel_cased_word)
254
254
  camel_cased_word.to_s.gsub(/::/, '/').
255
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
256
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
255
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
256
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
257
257
  tr('-', '_').
258
258
  downcase
259
259
  end
@@ -179,9 +179,9 @@ module ActiveMerchant #:nodoc:
179
179
 
180
180
  def parse_check(data)
181
181
  response = {}
182
- response[:success] = data[1,1]
183
- response[:code] = data[2,6].strip
184
- response[:message] = data[8,32].strip
182
+ response[:success] = data[1, 1]
183
+ response[:code] = data[2, 6].strip
184
+ response[:message] = data[8, 32].strip
185
185
  response[:risk] = data[40, 2]
186
186
  response[:reference] = data[42, 10]
187
187
 
@@ -194,9 +194,9 @@ module ActiveMerchant #:nodoc:
194
194
 
195
195
  def parse_credit_card(data)
196
196
  response = {}
197
- response[:success] = data[1,1]
198
- response[:code] = data[2,6]
199
- response[:message] = data[8,32].strip
197
+ response[:success] = data[1, 1]
198
+ response[:code] = data[2, 6]
199
+ response[:message] = data[8, 32].strip
200
200
  response[:front_end] = data[40, 2]
201
201
  response[:cvv_result] = data[42, 1]
202
202
  response[:avs_result] = data[43, 1].strip
@@ -343,16 +343,16 @@ module ActiveMerchant #:nodoc:
343
343
  end
344
344
 
345
345
  def commit(action, parameters)
346
- response = parse( ssl_post(url_for(action), post_data(action, parameters)) )
346
+ response = parse(ssl_post(url_for(action), post_data(action, parameters)))
347
347
 
348
348
  Response.new(response['Status'] == APPROVED, message_from(response), response,
349
349
  :test => test?,
350
350
  :authorization => authorization_from(response, parameters, action),
351
351
  :avs_result => {
352
- :street_match => AVS_CODE[ response['AddressResult'] ],
353
- :postal_match => AVS_CODE[ response['PostCodeResult'] ],
352
+ :street_match => AVS_CODE[response['AddressResult']],
353
+ :postal_match => AVS_CODE[response['PostCodeResult']],
354
354
  },
355
- :cvv_result => CVV_CODE[ response['CV2Result'] ]
355
+ :cvv_result => CVV_CODE[response['CV2Result']]
356
356
  )
357
357
  end
358
358
 
@@ -380,9 +380,9 @@ module ActiveMerchant #:nodoc:
380
380
 
381
381
  def build_url(action)
382
382
  endpoint = case action
383
- when :purchase, :authorization then 'vspdirect-register'
384
- when :store then 'directtoken'
385
- else TRANSACTIONS[action].downcase
383
+ when :purchase, :authorization then 'vspdirect-register'
384
+ when :store then 'directtoken'
385
+ else TRANSACTIONS[action].downcase
386
386
  end
387
387
  "#{test? ? self.test_url : self.live_url}/#{endpoint}.vsp"
388
388
  end
@@ -247,7 +247,7 @@ module ActiveMerchant #:nodoc:
247
247
 
248
248
  def recurring_parse_element(response, node)
249
249
  if node.has_elements?
250
- node.elements.each{|e| recurring_parse_element(response, e) }
250
+ node.elements.each { |e| recurring_parse_element(response, e) }
251
251
  else
252
252
  response[node.name.underscore.to_sym] = node.text
253
253
  end
@@ -183,9 +183,9 @@ module ActiveMerchant #:nodoc:
183
183
 
184
184
  def message_from(results)
185
185
  if results[:response_code] == DECLINED
186
- return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
186
+ return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
187
187
  if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
188
- return AVSResult.messages[ results[:avs_result_code] ]
188
+ return AVSResult.messages[results[:avs_result_code]]
189
189
  end
190
190
  end
191
191
 
@@ -276,7 +276,7 @@ module ActiveMerchant #:nodoc:
276
276
 
277
277
  def parse_element(response, node)
278
278
  if node.has_elements?
279
- node.elements.each{|element| parse_element(response, element) }
279
+ node.elements.each { |element| parse_element(response, element) }
280
280
  else
281
281
  response[node.name.underscore.to_sym] = node.text
282
282
  end
@@ -82,7 +82,7 @@ module ActiveMerchant #:nodoc:
82
82
  end
83
83
 
84
84
  def commit(action, post)
85
- response = parse( ssl_post(self.live_url, post_data(action, post) ) )
85
+ response = parse(ssl_post(self.live_url, post_data(action, post)))
86
86
 
87
87
  Response.new(response[:result_code] == 1, message_from(response), response,
88
88
  :test => test?,
@@ -1,4 +1,3 @@
1
- #!ruby19
2
1
  # encoding: utf-8
3
2
 
4
3
  module ActiveMerchant #:nodoc:
@@ -261,7 +260,7 @@ module ActiveMerchant #:nodoc:
261
260
  end
262
261
 
263
262
  def commit(action, money, parameters)
264
- response = parse( ssl_post( url_for(action), post_data(action, money, parameters) ), action )
263
+ response = parse(ssl_post(url_for(action), post_data(action, money, parameters)), action)
265
264
 
266
265
  # Pass along the original transaction id in the case an update transaction
267
266
  Response.new(response[:success], message_from(response, action), response,
@@ -275,7 +274,7 @@ module ActiveMerchant #:nodoc:
275
274
  def url_for(action)
276
275
  result = test? ? self.test_url : self.live_url
277
276
  result += advanced? && action == :authorization ? ADVANCED_PATH : BASIC_PATH
278
- result += "?#{ACTIONS[action]}"
277
+ result + "?#{ACTIONS[action]}"
279
278
  end
280
279
 
281
280
  def add_credentials(params, action)
@@ -354,8 +353,8 @@ module ActiveMerchant #:nodoc:
354
353
  def post_data(action, money, params = {})
355
354
  add_credentials(params, action)
356
355
  add_amount(params, action, money)
357
- sorted_params = params.to_a.sort{|a,b| a.to_s <=> b.to_s}.reverse
358
- sorted_params.collect { |key, value| "#{key.to_s}=#{CGI.escape(value.to_s)}" }.join('&')
356
+ sorted_params = params.to_a.sort_by(&:to_s).reverse
357
+ sorted_params.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
359
358
  end
360
359
 
361
360
  def add_transaction_id(post, transaction_id)
@@ -369,7 +368,7 @@ module ActiveMerchant #:nodoc:
369
368
  post[:OrderDescription] = options[:description]
370
369
 
371
370
  if order_items = options[:items]
372
- post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~','-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||"}.join
371
+ post[:OrderString] = order_items.collect { |item| "#{item[:sku]}~#{item[:description].tr('~', '-')}~#{item[:declared_value]}~#{item[:quantity]}~#{item[:taxable]}~~~~~~~~#{item[:tax_rate]}~||" }.join
373
372
  else
374
373
  post[:OrderString] = '1~None~0.00~0~N~||'
375
374
  end
@@ -23,7 +23,7 @@ module ActiveMerchant #:nodoc:
23
23
  def authorize(money, creditcard, options = {})
24
24
  post = {}
25
25
  add_invoice(post, options)
26
- add_payment_source(post, creditcard,options)
26
+ add_payment_source(post, creditcard, options)
27
27
  add_address(post, options[:billing_address] || options[:address])
28
28
  add_address(post, options[:shipping_address], 'shipping')
29
29
  add_customer_data(post, options)
@@ -65,7 +65,7 @@ module ActiveMerchant #:nodoc:
65
65
  add_payment_source(post, payment_source, options)
66
66
  add_address(post, options[:billing_address] || options[:address])
67
67
  add_customer_data(post, options)
68
- add_sku(post,options)
68
+ add_sku(post, options)
69
69
  add_currency(post, money, options)
70
70
  add_processor(post, options)
71
71
  commit('credit', money, post)
@@ -138,7 +138,7 @@ module ActiveMerchant #:nodoc:
138
138
  end
139
139
  end
140
140
 
141
- def add_address(post, address,prefix='')
141
+ def add_address(post, address, prefix='')
142
142
  prefix +='_' unless prefix.blank?
143
143
  unless address.blank? or address.values.blank?
144
144
  post[prefix+'address1'] = address[:address1].to_s
@@ -206,7 +206,7 @@ module ActiveMerchant #:nodoc:
206
206
  post[:account_type] = check.account_type # The customer's type of ACH account
207
207
  end
208
208
 
209
- def add_sku(post,options)
209
+ def add_sku(post, options)
210
210
  post['product_sku_#'] = options[:sku] || options['product_sku_#']
211
211
  end
212
212
 
@@ -221,7 +221,7 @@ module ActiveMerchant #:nodoc:
221
221
  def parse(body)
222
222
  results = {}
223
223
  body.split(/&/).each do |pair|
224
- key,val = pair.split(/=/)
224
+ key, val = pair.split(/=/)
225
225
  results[key] = val
226
226
  end
227
227
 
@@ -230,7 +230,7 @@ module ActiveMerchant #:nodoc:
230
230
 
231
231
  def commit(action, money, parameters)
232
232
  parameters[:amount] = localized_amount(money, parameters[:currency] || default_currency) if money
233
- response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
233
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
234
234
  Response.new(response['response'] == '1', message_from(response), response,
235
235
  :authorization => (response['transactionid'] || response['customer_vault_id']),
236
236
  :test => test?,
@@ -263,7 +263,7 @@ module ActiveMerchant #:nodoc:
263
263
  post[:password] = @options[:password]
264
264
  post[:type] = action if action
265
265
 
266
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
266
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
267
267
  request
268
268
  end
269
269
 
@@ -114,7 +114,7 @@ module ActiveMerchant #:nodoc:
114
114
  def fill_cardholder(soap, card, options)
115
115
  ch_info = options[:billing_address] || options[:address]
116
116
 
117
- soap.tag!('customerIP',options[:ip].to_s)
117
+ soap.tag!('customerIP', options[:ip].to_s)
118
118
  name = card.name || ch_info[:name]
119
119
  soap.tag!('cardHolderName', name.to_s)
120
120
  address = ch_info[:address1] || ''
@@ -177,7 +177,7 @@ module ActiveMerchant #:nodoc:
177
177
 
178
178
  post = {}
179
179
  add_amount(post, money, options)
180
- options.merge!(:key => @fee_refund_api_key) if @fee_refund_api_key
180
+ options[:key] = @fee_refund_api_key if @fee_refund_api_key
181
181
  options.delete(:stripe_account)
182
182
 
183
183
  refund_fee = commit(:post, "application_fees/#{CGI.escape(identification)}/refunds", post, options)
@@ -474,7 +474,7 @@ module ActiveMerchant #:nodoc:
474
474
 
475
475
  def add_flags(post, options)
476
476
  post[:uncaptured] = true if options[:uncaptured]
477
- post[:recurring] = true if (options[:eci] == 'recurring' || options[:recurring])
477
+ post[:recurring] = true if options[:eci] == 'recurring' || options[:recurring]
478
478
  end
479
479
 
480
480
  def add_metadata(post, options = {})
@@ -491,7 +491,7 @@ module ActiveMerchant #:nodoc:
491
491
  end
492
492
 
493
493
  def fetch_application_fee(identification, options = {})
494
- options.merge!(:key => @fee_refund_api_key)
494
+ options[:key] = @fee_refund_api_key
495
495
 
496
496
  fetch_charge = commit(:get, "charges/#{CGI.escape(identification)}", nil, options)
497
497
  application_fee_response!(fetch_charge, "Application fee id could not be retrieved: #{fetch_charge.message}")
@@ -549,8 +549,8 @@ module ActiveMerchant #:nodoc:
549
549
  'X-Stripe-Client-User-Agent' => stripe_client_user_agent(options),
550
550
  'X-Stripe-Client-User-Metadata' => {:ip => options[:ip]}.to_json
551
551
  }
552
- headers.merge!('Idempotency-Key' => idempotency_key) if idempotency_key
553
- headers.merge!('Stripe-Account' => options[:stripe_account]) if options[:stripe_account]
552
+ headers['Idempotency-Key'] = idempotency_key if idempotency_key
553
+ headers['Stripe-Account'] = options[:stripe_account] if options[:stripe_account]
554
554
  headers
555
555
  end
556
556
 
@@ -117,8 +117,8 @@ module ActiveMerchant #:nodoc:
117
117
  rescue ResponseError => e
118
118
  build_error_response("ssl_post() with url #{url} raised ResponseError: #{e}")
119
119
  rescue JSON::ParserError => e
120
- msg = 'Invalid response received from the Swipe Checkout API. ' +
121
- 'Please contact support@optimizerhq.com if you continue to receive this message.' +
120
+ msg = 'Invalid response received from the Swipe Checkout API. ' \
121
+ 'Please contact support@optimizerhq.com if you continue to receive this message.' \
122
122
  " (Full error message: #{e})"
123
123
  build_error_response(msg)
124
124
  end
@@ -215,7 +215,7 @@ module ActiveMerchant #:nodoc:
215
215
 
216
216
  doc = Nokogiri::XML(xml)
217
217
  doc.root&.xpath('*')&.each do |node|
218
- if (node.elements.size == 0)
218
+ if node.elements.size == 0
219
219
  response[node.name.downcase.to_sym] = node.text
220
220
  else
221
221
  node.elements.each do |childnode|
@@ -321,7 +321,7 @@ module ActiveMerchant #:nodoc:
321
321
 
322
322
  private
323
323
 
324
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
324
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
325
325
  CURRENCY_CODES['USD'] = '840'
326
326
 
327
327
  def headers
@@ -539,7 +539,7 @@ module ActiveMerchant #:nodoc:
539
539
  if (billing_address = options[:billing_address])
540
540
  if billing_address[:phone]
541
541
  doc['v1'].phone do
542
- doc['v1'].type (options[:phone_number_type] || '4')
542
+ doc['v1'].type(options[:phone_number_type] || '4')
543
543
  doc['v1'].nr billing_address[:phone].gsub(/\D/, '')
544
544
  end
545
545
  end
@@ -32,7 +32,7 @@ module ActiveMerchant #:nodoc:
32
32
  post[:rs] = @options[:terminal]
33
33
 
34
34
  MultiResponse.run do |r|
35
- r.process{commit('init', post)}
35
+ r.process { commit('init', post) }
36
36
  r.process do
37
37
  post = PostData.new
38
38
  post[:init_transaction_id] = r.authorization
@@ -54,7 +54,7 @@ module ActiveMerchant #:nodoc:
54
54
  post[:rs] = @options[:terminal]
55
55
 
56
56
  MultiResponse.run do |r|
57
- r.process{commit('init_dms', post)}
57
+ r.process { commit('init_dms', post) }
58
58
  r.process do
59
59
  post = PostData.new
60
60
  post[:init_transaction_id] = r.authorization
@@ -165,7 +165,7 @@ module ActiveMerchant #:nodoc:
165
165
 
166
166
  def parse(body)
167
167
  if body =~ /^ID:/
168
- body.split('~').reduce(Hash.new) { |h,v|
168
+ body.split('~').reduce(Hash.new) { |h, v|
169
169
  m = v.match('(.*?):(.*)')
170
170
  h.merge!(m[1].underscore.to_sym => m[2])
171
171
  }
@@ -174,13 +174,13 @@ module ActiveMerchant #:nodoc:
174
174
  { status: 'success', id: m[2] } :
175
175
  { status: 'failure', message: m[2] }
176
176
  else
177
- Hash[ status: body ]
177
+ Hash[status: body]
178
178
  end
179
179
  end
180
180
 
181
181
  def commit(action, parameters, amount=nil)
182
182
  url = (test? ? test_url : live_url)
183
- response = parse(ssl_post(url, post_data(action,parameters)))
183
+ response = parse(ssl_post(url, post_data(action, parameters)))
184
184
 
185
185
  Response.new(
186
186
  success_from(response),
@@ -1,4 +1,4 @@
1
- require File.join(File.dirname(__FILE__),'smart_ps.rb')
1
+ require File.join(File.dirname(__FILE__), 'smart_ps.rb')
2
2
 
3
3
  module ActiveMerchant #:nodoc:
4
4
  module Billing #:nodoc:
@@ -237,7 +237,7 @@ module ActiveMerchant #:nodoc:
237
237
  def recurring(money, creditcard, options = {})
238
238
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
239
239
 
240
- requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily] )
240
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily])
241
241
 
242
242
  cycle = case options[:periodicity]
243
243
  when :monthly
@@ -362,7 +362,7 @@ module ActiveMerchant #:nodoc:
362
362
  # TCLink wants us to send a hash with string keys, and activemerchant pushes everything around with
363
363
  # symbol keys. Before sending our input to TCLink, we convert all our keys to strings and dump the symbol keys.
364
364
  # We also remove any pairs with nil values, as these confuse TCLink.
365
- parameters.keys.reverse.each do |key|
365
+ parameters.keys.reverse_each do |key|
366
366
  if parameters[key]
367
367
  parameters[key.to_s] = parameters[key]
368
368
  end
@@ -371,7 +371,7 @@ module ActiveMerchant #:nodoc:
371
371
  end
372
372
 
373
373
  def post_data(parameters)
374
- parameters.collect { |key, value| "#{key}=#{ CGI.escape(value.to_s)}" }.join('&')
374
+ parameters.collect { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
375
375
  end
376
376
 
377
377
  def commit(action, parameters)
@@ -383,9 +383,9 @@ module ActiveMerchant #:nodoc:
383
383
  clean_and_stringify_params(parameters)
384
384
 
385
385
  data = if tclink?
386
- TCLink.send(parameters)
387
- else
388
- parse( ssl_post(self.live_url, post_data(parameters)) )
386
+ TCLink.send(parameters)
387
+ else
388
+ parse(ssl_post(self.live_url, post_data(parameters)))
389
389
  end
390
390
 
391
391
  # to be considered successful, transaction status must be either "approved" or "accepted"
@@ -403,7 +403,7 @@ module ActiveMerchant #:nodoc:
403
403
  results = {}
404
404
 
405
405
  body.split(/\n/).each do |pair|
406
- key,val = pair.split(/=/)
406
+ key, val = pair.split(/=/)
407
407
  results[key] = val
408
408
  end
409
409
 
@@ -272,8 +272,8 @@ module ActiveMerchant #:nodoc:
272
272
  requires!(options, :login, :password)
273
273
 
274
274
  if options[:software_id]
275
- self.live_url = "#{LIVE_URL_BASE}#{options[:software_id].to_s}"
276
- self.test_url = "#{TEST_URL_BASE}#{options[:software_id].to_s}"
275
+ self.live_url = "#{LIVE_URL_BASE}#{options[:software_id]}"
276
+ self.test_url = "#{TEST_URL_BASE}#{options[:software_id]}"
277
277
  else
278
278
  self.live_url = options[:live_url].to_s
279
279
  self.test_url = options[:test_url].to_s if options[:test_url]
@@ -1297,7 +1297,7 @@ module ActiveMerchant #:nodoc:
1297
1297
 
1298
1298
  def build_customer_data(soap, options)
1299
1299
  soap.CustomerData 'xsi:type' => 'ns1:CustomerObject' do
1300
- CUSTOMER_OPTIONS.each do |k,v|
1300
+ CUSTOMER_OPTIONS.each do |k, v|
1301
1301
  build_tag soap, v[0], v[1], options[k]
1302
1302
  end
1303
1303
  build_billing_address soap, options
@@ -1370,7 +1370,7 @@ module ActiveMerchant #:nodoc:
1370
1370
  def build_customer_transaction(soap, options)
1371
1371
  soap.Parameters 'xsi:type' => 'ns1:CustomerTransactionRequest' do
1372
1372
  build_transaction_detail soap, options
1373
- CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k,v|
1373
+ CUSTOMER_TRANSACTION_REQUEST_OPTIONS.each do |k, v|
1374
1374
  build_tag soap, v[0], v[1], options[k]
1375
1375
  end
1376
1376
  build_custom_fields soap, options
@@ -1382,11 +1382,12 @@ module ActiveMerchant #:nodoc:
1382
1382
 
1383
1383
  def build_transaction_request_object(soap, options, name='Params')
1384
1384
  soap.tag! name, 'xsi:type' => 'ns1:TransactionRequestObject' do
1385
- TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k,v|
1385
+ TRANSACTION_REQUEST_OBJECT_OPTIONS.each do |k, v|
1386
1386
  build_tag soap, v[0], v[1], options[k]
1387
1387
  end
1388
1388
  case
1389
- when options[:payment_method] == nil
1389
+ when options[:payment_method].nil?
1390
+ nil
1390
1391
  when options[:payment_method].kind_of?(ActiveMerchant::Billing::CreditCard)
1391
1392
  build_credit_card_data soap, options
1392
1393
  when options[:payment_method].kind_of?(ActiveMerchant::Billing::Check)
@@ -1405,10 +1406,10 @@ module ActiveMerchant #:nodoc:
1405
1406
 
1406
1407
  def build_transaction_detail(soap, options)
1407
1408
  soap.Details 'xsi:type' => 'ns1:TransactionDetail' do
1408
- TRANSACTION_DETAIL_OPTIONS.each do |k,v|
1409
+ TRANSACTION_DETAIL_OPTIONS.each do |k, v|
1409
1410
  build_tag soap, v[0], v[1], options[k]
1410
1411
  end
1411
- TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k,v|
1412
+ TRANSACTION_DETAIL_MONEY_OPTIONS.each do |k, v|
1412
1413
  build_tag soap, v[0], v[1], amount(options[k])
1413
1414
  end
1414
1415
  end
@@ -1424,7 +1425,7 @@ module ActiveMerchant #:nodoc:
1424
1425
  end
1425
1426
  build_tag soap, :string, 'CardCode', options[:payment_method].verification_value
1426
1427
  build_tag soap, :boolean, 'CardPresent', options[:card_present] || false
1427
- CREDIT_CARD_DATA_OPTIONS.each do |k,v|
1428
+ CREDIT_CARD_DATA_OPTIONS.each do |k, v|
1428
1429
  build_tag soap, v[0], v[1], options[k]
1429
1430
  end
1430
1431
  end
@@ -1444,7 +1445,7 @@ module ActiveMerchant #:nodoc:
1444
1445
  build_tag soap, :string, 'Account', options[:payment_method].account_number
1445
1446
  build_tag soap, :string, 'Routing', options[:payment_method].routing_number
1446
1447
  build_tag soap, :string, 'AccountType', options[:payment_method].account_type.capitalize
1447
- CHECK_DATA_OPTIONS.each do |k,v|
1448
+ CHECK_DATA_OPTIONS.each do |k, v|
1448
1449
  build_tag soap, v[0], v[1], options[k]
1449
1450
  end
1450
1451
  end
@@ -1456,7 +1457,7 @@ module ActiveMerchant #:nodoc:
1456
1457
  build_tag soap, :double, 'Amount', amount(options[:recurring][:amount])
1457
1458
  build_tag soap, :string, 'Next', options[:recurring][:next].strftime('%Y-%m-%d') if options[:recurring][:next]
1458
1459
  build_tag soap, :string, 'Expire', options[:recurring][:expire].strftime('%Y-%m-%d') if options[:recurring][:expire]
1459
- RECURRING_BILLING_OPTIONS.each do |k,v|
1460
+ RECURRING_BILLING_OPTIONS.each do |k, v|
1460
1461
  build_tag soap, v[0], v[1], options[:recurring][k]
1461
1462
  end
1462
1463
  end
@@ -1479,7 +1480,7 @@ module ActiveMerchant #:nodoc:
1479
1480
  options[:billing_address][:first_name], options[:billing_address][:last_name] = split_names(options[:billing_address][:name])
1480
1481
  end
1481
1482
  soap.BillingAddress 'xsi:type' => 'ns1:Address' do
1482
- ADDRESS_OPTIONS.each do |k,v|
1483
+ ADDRESS_OPTIONS.each do |k, v|
1483
1484
  build_tag soap, v[0], v[1], options[:billing_address][k]
1484
1485
  end
1485
1486
  end
@@ -1492,7 +1493,7 @@ module ActiveMerchant #:nodoc:
1492
1493
  options[:shipping_address][:first_name], options[:shipping_address][:last_name] = split_names(options[:shipping_address][:name])
1493
1494
  end
1494
1495
  soap.ShippingAddress 'xsi:type' => 'ns1:Address' do
1495
- ADDRESS_OPTIONS.each do |k,v|
1496
+ ADDRESS_OPTIONS.each do |k, v|
1496
1497
  build_tag soap, v[0], v[1], options[:shipping_address][k]
1497
1498
  end
1498
1499
  end
@@ -1502,7 +1503,7 @@ module ActiveMerchant #:nodoc:
1502
1503
  def build_field_value_array(soap, tag_name, type, custom_data, fields)
1503
1504
  soap.tag! tag_name, 'SOAP-ENC:arryType' => "xsd:#{type}[#{options.length}]", 'xsi:type' => "ns1:#{type}Array" do
1504
1505
  custom_data.each do |k, v|
1505
- build_field_value soap, fields[k][1], v, fields[k][0] if fields.keys.include? k
1506
+ build_field_value soap, fields[k][1], v, fields[k][0] if fields.key?(k)
1506
1507
  end
1507
1508
  end
1508
1509
  end
@@ -1537,7 +1538,7 @@ module ActiveMerchant #:nodoc:
1537
1538
  def build_response(action, soap)
1538
1539
  response_params, success, message, authorization, avs, cvv = parse(action, soap)
1539
1540
 
1540
- response_params.merge!('soap_response' => soap) if @options[:soap_response]
1541
+ response_params['soap_response'] = soap if @options[:soap_response]
1541
1542
 
1542
1543
  Response.new(
1543
1544
  success,
@@ -1552,7 +1553,7 @@ module ActiveMerchant #:nodoc:
1552
1553
 
1553
1554
  def avs_from(avs)
1554
1555
  avs_params = { :code => avs }
1555
- avs_params.merge!(:message => AVS_CUSTOM_MESSAGES[avs]) if AVS_CUSTOM_MESSAGES.key?(avs)
1556
+ avs_params[:message] = AVS_CUSTOM_MESSAGES[avs] if AVS_CUSTOM_MESSAGES.key?(avs)
1556
1557
  avs_params
1557
1558
  end
1558
1559