activemerchant 1.86.0 → 1.87.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
@@ -33,7 +33,7 @@ module ActiveMerchant #:nodoc:
33
33
  def authorize(money, creditcard, options = {})
34
34
  post = {}
35
35
  add_invoice(post, options)
36
- add_payment_source(post, creditcard,options)
36
+ add_payment_source(post, creditcard, options)
37
37
  add_address(post, creditcard, options)
38
38
  add_customer_data(post, options)
39
39
 
@@ -136,11 +136,11 @@ module ActiveMerchant #:nodoc:
136
136
  end
137
137
  end
138
138
 
139
- def add_customer_vault_id(params,vault_id)
139
+ def add_customer_vault_id(params, vault_id)
140
140
  params[:customer_vault_id] = vault_id
141
141
  end
142
142
 
143
- def add_creditcard(post, creditcard,options)
143
+ def add_creditcard(post, creditcard, options)
144
144
  if options[:store]
145
145
  post[:customer_vault] = 'add_customer'
146
146
  post[:customer_vault_id] = options[:store] unless options[:store] == true
@@ -164,7 +164,7 @@ module ActiveMerchant #:nodoc:
164
164
  def parse(body)
165
165
  results = {}
166
166
  body.split(/&/).each do |pair|
167
- key,val = pair.split(%r{=})
167
+ key, val = pair.split(%r{=})
168
168
  results[key] = val
169
169
  end
170
170
 
@@ -174,7 +174,7 @@ module ActiveMerchant #:nodoc:
174
174
  def commit(action, money, parameters)
175
175
  parameters[:amount] = amount(money) if money
176
176
 
177
- response = parse( ssl_post(self.live_url, post_data(action,parameters)) )
177
+ response = parse(ssl_post(self.live_url, post_data(action, parameters)))
178
178
 
179
179
  Response.new(response['response'] == '1', message_from(response), response,
180
180
  :authorization => response['transactionid'],
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
186
186
 
187
187
  def message_from(response)
188
188
  case response['responsetext']
189
- when 'SUCCESS','Approved'
189
+ when 'SUCCESS', 'Approved'
190
190
  'This transaction has been approved'
191
191
  when 'DECLINE'
192
192
  'This transaction has been declined'
@@ -201,7 +201,7 @@ module ActiveMerchant #:nodoc:
201
201
  post[:password] = @options[:password]
202
202
  post[:type] = action if action
203
203
 
204
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
204
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
205
205
  request
206
206
  end
207
207
 
@@ -278,7 +278,7 @@ module ActiveMerchant #:nodoc:
278
278
  private
279
279
 
280
280
  def build_purchase_request(type, money, creditcard, options)
281
- options.merge!(:action => 'CardDetailsTransaction')
281
+ options[:action] = 'CardDetailsTransaction'
282
282
  build_request(options) do |xml|
283
283
  add_purchase_data(xml, type, money, options)
284
284
  add_creditcard(xml, creditcard)
@@ -287,7 +287,7 @@ module ActiveMerchant #:nodoc:
287
287
  end
288
288
 
289
289
  def build_reference_request(type, money, authorization, options)
290
- options.merge!(:action => 'CrossReferenceTransaction')
290
+ options[:action] = 'CrossReferenceTransaction'
291
291
  order_id, cross_reference, _ = authorization.split(';')
292
292
  build_request(options) do |xml|
293
293
  if money
@@ -419,39 +419,39 @@ module ActiveMerchant #:nodoc:
419
419
  case node.name
420
420
  when 'CrossReferenceTransactionResult'
421
421
  reply[:transaction_result] = {}
422
- node.attributes.each do |a,b|
422
+ node.attributes.each do |a, b|
423
423
  reply[:transaction_result][a.underscore.to_sym] = b
424
424
  end
425
- node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
425
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
426
426
 
427
427
  when 'CardDetailsTransactionResult'
428
428
  reply[:transaction_result] = {}
429
- node.attributes.each do |a,b|
429
+ node.attributes.each do |a, b|
430
430
  reply[:transaction_result][a.underscore.to_sym] = b
431
431
  end
432
- node.elements.each{|e| parse_element(reply[:transaction_result], e) } if node.has_elements?
432
+ node.elements.each { |e| parse_element(reply[:transaction_result], e) } if node.has_elements?
433
433
 
434
434
  when 'TransactionOutputData'
435
435
  reply[:transaction_output_data] = {}
436
- node.attributes.each{|a,b| reply[:transaction_output_data][a.underscore.to_sym] = b }
437
- node.elements.each{|e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
436
+ node.attributes.each { |a, b| reply[:transaction_output_data][a.underscore.to_sym] = b }
437
+ node.elements.each { |e| parse_element(reply[:transaction_output_data], e) } if node.has_elements?
438
438
  when 'CustomVariables'
439
439
  reply[:custom_variables] = {}
440
- node.attributes.each{|a,b| reply[:custom_variables][a.underscore.to_sym] = b }
441
- node.elements.each{|e| parse_element(reply[:custom_variables], e) } if node.has_elements?
440
+ node.attributes.each { |a, b| reply[:custom_variables][a.underscore.to_sym] = b }
441
+ node.elements.each { |e| parse_element(reply[:custom_variables], e) } if node.has_elements?
442
442
  when 'GatewayEntryPoints'
443
443
  reply[:gateway_entry_points] = {}
444
- node.attributes.each{|a,b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
445
- node.elements.each{|e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
444
+ node.attributes.each { |a, b| reply[:gateway_entry_points][a.underscore.to_sym] = b }
445
+ node.elements.each { |e| parse_element(reply[:gateway_entry_points], e) } if node.has_elements?
446
446
  else
447
447
  k = node.name.underscore.to_sym
448
448
  if node.has_elements?
449
449
  reply[k] = {}
450
- node.elements.each{|e| parse_element(reply[k], e) }
450
+ node.elements.each { |e| parse_element(reply[k], e) }
451
451
  else
452
452
  if node.has_attributes?
453
453
  reply[k] = {}
454
- node.attributes.each{|a,b| reply[k][a.underscore.to_sym] = b }
454
+ node.attributes.each { |a, b| reply[k][a.underscore.to_sym] = b }
455
455
  else
456
456
  reply[k] = node.text
457
457
  end
@@ -302,7 +302,7 @@ module ActiveMerchant #:nodoc:
302
302
  xml.AuthCode options[:force] if options[:force]
303
303
  if options[:order_items].blank?
304
304
  xml.Total(amount(money)) unless(money.nil? || money < 0.01)
305
- xml.Description(options[:description]) unless( options[:description].blank?)
305
+ xml.Description(options[:description]) unless(options[:description].blank?)
306
306
  else
307
307
  xml.OrderItems {
308
308
  options[:order_items].each do |item|
@@ -336,7 +336,7 @@ module ActiveMerchant #:nodoc:
336
336
  xml.AccountInfo {
337
337
  xml.CardAccount {
338
338
  xml.AccountNumber(creditcard.number.to_s)
339
- xml.ExpirationMonth(creditcard.month.to_s.rjust(2,'0'))
339
+ xml.ExpirationMonth(creditcard.month.to_s.rjust(2, '0'))
340
340
  xml.ExpirationYear(creditcard.year.to_s)
341
341
  xml.CVVNumber(creditcard.verification_value.to_s) unless creditcard.verification_value.blank?
342
342
  }
@@ -372,7 +372,7 @@ module ActiveMerchant #:nodoc:
372
372
  def add_vendor_data(xml, options)
373
373
  return if options[:vendor_data].blank?
374
374
  xml.VendorData {
375
- options[:vendor_data].each do |k,v|
375
+ options[:vendor_data].each do |k, v|
376
376
  xml.Element {
377
377
  xml.Name(k)
378
378
  xml.Key(v)
@@ -424,7 +424,7 @@ module ActiveMerchant #:nodoc:
424
424
 
425
425
  def successful?(response)
426
426
  # Turns out the PaymentClearing gateway is not consistent...
427
- response[:status].downcase =='ok'
427
+ response[:status].casecmp('ok').zero?
428
428
  end
429
429
 
430
430
  def test_mode?(response)
@@ -206,7 +206,7 @@ module ActiveMerchant #:nodoc:
206
206
  end
207
207
 
208
208
  if !node.elements.empty?
209
- node.elements.each {|e| parse_element(parsed, e) }
209
+ node.elements.each { |e| parse_element(parsed, e) }
210
210
  else
211
211
  parsed[underscore(node.name)] = node.text
212
212
  end
@@ -241,8 +241,8 @@ module ActiveMerchant #:nodoc:
241
241
 
242
242
  def underscore(camel_cased_word)
243
243
  camel_cased_word.to_s.gsub(/::/, '/').
244
- gsub(/([A-Z]+)([A-Z][a-z])/,'\1_\2').
245
- gsub(/([a-z\d])([A-Z])/,'\1_\2').
244
+ gsub(/([A-Z]+)([A-Z][a-z])/, '\1_\2').
245
+ gsub(/([a-z\d])([A-Z])/, '\1_\2').
246
246
  tr('-', '_').
247
247
  downcase
248
248
  end
@@ -315,7 +315,7 @@ module ActiveMerchant #:nodoc:
315
315
 
316
316
  def parse_element(response, node)
317
317
  if node.has_elements?
318
- node.elements.each{|element| parse_element(response, element) }
318
+ node.elements.each { |element| parse_element(response, element) }
319
319
  else
320
320
  response[node.name.underscore.to_sym] = node.text
321
321
  end
@@ -344,7 +344,7 @@ module ActiveMerchant #:nodoc:
344
344
  xml.tag! 'CardExpYear', format_exp(credit_card.year)
345
345
 
346
346
  if credit_card.first_name || credit_card.last_name
347
- xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ')
347
+ xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ')
348
348
  end
349
349
 
350
350
  unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0)
@@ -324,7 +324,7 @@ module ActiveMerchant #:nodoc:
324
324
 
325
325
  def parse_element(response, node)
326
326
  if node.has_elements?
327
- node.elements.each{|element| parse_element(response, element) }
327
+ node.elements.each { |element| parse_element(response, element) }
328
328
  else
329
329
  response[node.name.underscore.to_sym] = node.text
330
330
  end
@@ -369,7 +369,7 @@ module ActiveMerchant #:nodoc:
369
369
  xml.tag! 'CardExpYear', format_exp(credit_card.year)
370
370
 
371
371
  if credit_card.first_name || credit_card.last_name
372
- xml.tag! 'CardName', [credit_card.first_name,credit_card.last_name].compact.join(' ')
372
+ xml.tag! 'CardName', [credit_card.first_name, credit_card.last_name].compact.join(' ')
373
373
  end
374
374
 
375
375
  unless credit_card.verification_value.nil? || (credit_card.verification_value.length == 0)
@@ -153,7 +153,7 @@ module ActiveMerchant #:nodoc:
153
153
  post[:id] = SecureRandom.hex(16)
154
154
  end
155
155
 
156
- def add_timestamp()
156
+ def add_timestamp
157
157
  Time.now.getutc.strftime('%Y%m%d%H%M%S')
158
158
  end
159
159
 
@@ -169,7 +169,7 @@ module ActiveMerchant #:nodoc:
169
169
  def recurring(money, creditcard, options={})
170
170
  ActiveMerchant.deprecated RECURRING_DEPRECATION_MESSAGE
171
171
 
172
- requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id )
172
+ requires!(options, [:periodicity, :bimonthly, :monthly, :biweekly, :weekly, :yearly, :daily], :installments, :order_id)
173
173
 
174
174
  options.update(
175
175
  :ordertype => 'SALE',
@@ -266,8 +266,8 @@ module ActiveMerchant #:nodoc:
266
266
  Response.new(successful?(response), response[:message], response,
267
267
  :test => test?,
268
268
  :authorization => response[:ordernum],
269
- :avs_result => { :code => response[:avs].to_s[2,1] },
270
- :cvv_result => response[:avs].to_s[3,1]
269
+ :avs_result => { :code => response[:avs].to_s[2, 1] },
270
+ :cvv_result => response[:avs].to_s[3, 1]
271
271
  )
272
272
  end
273
273
 
@@ -268,7 +268,7 @@ module ActiveMerchant #:nodoc:
268
268
  end
269
269
  elsif check?(payment_method)
270
270
  doc.echeck do
271
- doc.accType(payment_method.account_type)
271
+ doc.accType(payment_method.account_type.capitalize)
272
272
  doc.accNum(payment_method.account_number)
273
273
  doc.routingNum(payment_method.routing_number)
274
274
  doc.checkNum(payment_method.number)
@@ -402,7 +402,7 @@ module ActiveMerchant #:nodoc:
402
402
  end
403
403
 
404
404
  def authorization_from(kind, parsed, money)
405
- (kind == :registerToken) ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
405
+ kind == :registerToken ? parsed[:litleToken] : "#{parsed[:litleTxnId]};#{kind};#{money}"
406
406
  end
407
407
 
408
408
  def split_authorization(authorization)
@@ -142,7 +142,7 @@ module ActiveMerchant #:nodoc:
142
142
 
143
143
  def parse_element(response, node)
144
144
  if node.has_elements?
145
- node.elements.each{|element| parse_element(response, element) }
145
+ node.elements.each { |element| parse_element(response, element) }
146
146
  else
147
147
  response[node.name.underscore.to_sym] = node.text
148
148
  end
@@ -10,11 +10,6 @@ module ActiveMerchant #:nodoc:
10
10
  self.display_name = 'Mercado Pago'
11
11
  self.money_format = :dollars
12
12
 
13
- CARD_BRAND = {
14
- 'american_express' => 'amex',
15
- 'diners_club' => 'diners'
16
- }
17
-
18
13
  def initialize(options={})
19
14
  requires!(options, :access_token)
20
15
  super
@@ -23,18 +18,16 @@ module ActiveMerchant #:nodoc:
23
18
  def purchase(money, payment, options={})
24
19
  MultiResponse.run do |r|
25
20
  r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
26
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
27
- options.merge!(card_token: r.authorization.split('|').first)
28
- r.process { commit('purchase', 'payments', purchase_request(money, payment, options) ) }
21
+ options[:card_token] = r.authorization.split('|').first
22
+ r.process { commit('purchase', 'payments', purchase_request(money, payment, options)) }
29
23
  end
30
24
  end
31
25
 
32
26
  def authorize(money, payment, options={})
33
27
  MultiResponse.run do |r|
34
28
  r.process { commit('tokenize', 'card_tokens', card_token_request(money, payment, options)) }
35
- options.merge!(card_brand: (CARD_BRAND[payment.brand] || payment.brand))
36
- options.merge!(card_token: r.authorization.split('|').first)
37
- r.process { commit('authorize', 'payments', authorize_request(money, payment, options) ) }
29
+ options[:card_token] = r.authorization.split('|').first
30
+ r.process { commit('authorize', 'payments', authorize_request(money, payment, options)) }
38
31
  end
39
32
  end
40
33
 
@@ -108,7 +101,7 @@ module ActiveMerchant #:nodoc:
108
101
 
109
102
  def authorize_request(money, payment, options = {})
110
103
  post = purchase_request(money, payment, options)
111
- post.merge!(capture: false)
104
+ post[:capture] = false
112
105
  post
113
106
  end
114
107
 
@@ -181,7 +174,8 @@ module ActiveMerchant #:nodoc:
181
174
 
182
175
  def add_payment(post, options)
183
176
  post[:token] = options[:card_token]
184
- post[:payment_method_id] = options[:card_brand]
177
+ post[:issuer_id] = options[:issuer_id] if options[:issuer_id]
178
+ post[:payment_method_id] = options[:payment_method_id] if options[:payment_method_id]
185
179
  end
186
180
 
187
181
  def parse(body)
@@ -148,7 +148,7 @@ module ActiveMerchant #:nodoc:
148
148
  def parse(body)
149
149
  results = {}
150
150
  body.split(/&/).each do |pair|
151
- key,val = pair.split(/=/)
151
+ key, val = pair.split(/=/)
152
152
  results[key] = val
153
153
  end
154
154
  results
@@ -159,7 +159,7 @@ module ActiveMerchant #:nodoc:
159
159
  parameters[:transaction_amount] = amount(money) if money unless action == 'V'
160
160
 
161
161
  response = begin
162
- parse( ssl_post(url, post_data(action,parameters)) )
162
+ parse(ssl_post(url, post_data(action, parameters)))
163
163
  rescue ActiveMerchant::ResponseError => e
164
164
  { 'error_code' => '404', 'auth_response_text' => e.to_s }
165
165
  end
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
186
186
  post[:profile_key] = @options[:password]
187
187
  post[:transaction_type] = action if action
188
188
 
189
- request = post.merge(parameters).map {|key,value| "#{key}=#{CGI.escape(value.to_s)}"}.join('&')
189
+ request = post.merge(parameters).map { |key, value| "#{key}=#{CGI.escape(value.to_s)}" }.join('&')
190
190
  request
191
191
  end
192
192
  end
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
 
47
47
  def capture(money, authorization, options = {})
48
48
  post = {}
49
- post.merge!(:transactionid => authorization)
49
+ post[:transactionid] = authorization
50
50
  add_amount(post, money, options)
51
51
  commit('capture', money, post)
52
52
  end
@@ -83,11 +83,11 @@ module ActiveMerchant #:nodoc:
83
83
  def commit(action, money, parameters={})
84
84
  parameters['username'] = @options[:username]
85
85
  parameters['password'] = @options[:password]
86
- parse(ssl_post(BASE_URL,post_data(action, parameters)))
86
+ parse(ssl_post(BASE_URL, post_data(action, parameters)))
87
87
  end
88
88
 
89
89
  def post_data(action, parameters = {})
90
- parameters.merge!({:type => action})
90
+ parameters[:type] = action
91
91
  ret = ''
92
92
  for key in parameters.keys
93
93
  ret += "#{key}=#{CGI.escape(parameters[key].to_s)}"
@@ -99,7 +99,7 @@ module ActiveMerchant #:nodoc:
99
99
  end
100
100
 
101
101
  def parse(data)
102
- responses = CGI.parse(data).inject({}){|h,(k, v)| h[k] = v.first; h}
102
+ responses = CGI.parse(data).inject({}) { |h, (k, v)| h[k] = v.first; h }
103
103
  Response.new(
104
104
  (responses['response'].to_i == 1),
105
105
  responses['responsetext'],
@@ -212,7 +212,7 @@ module ActiveMerchant #:nodoc:
212
212
  if node.elements.size == 0
213
213
  response[node.name.downcase.underscore.to_sym] = node.text
214
214
  else
215
- node.elements.each{|element| parse_element(response, element) }
215
+ node.elements.each { |element| parse_element(response, element) }
216
216
  end
217
217
  end
218
218
 
@@ -46,7 +46,7 @@ module ActiveMerchant #:nodoc:
46
46
  post = {}
47
47
  add_amount(post, money, options)
48
48
  add_transaction(post, identification)
49
- post.merge!('captureAmount' => amount(money))
49
+ post['captureAmount'] = amount(money)
50
50
  commit('processCapture', post)
51
51
  end
52
52
 
@@ -158,7 +158,7 @@ module ActiveMerchant #:nodoc:
158
158
 
159
159
  def parse_element(response, node)
160
160
  if node.has_elements?
161
- node.elements.each{|element| parse_element(response, element)}
161
+ node.elements.each { |element| parse_element(response, element) }
162
162
  else
163
163
  response[node.name.underscore.to_sym] = node.text
164
164
  end
@@ -203,7 +203,7 @@ module ActiveMerchant #:nodoc:
203
203
  end
204
204
 
205
205
  def post_data(post)
206
- post.collect{|k,v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
206
+ post.collect { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
207
207
  end
208
208
  end
209
209
  end
@@ -18,7 +18,7 @@ module ActiveMerchant #:nodoc:
18
18
 
19
19
  self.homepage_url = 'http://www.mercurypay.com'
20
20
  self.display_name = 'Mercury'
21
- self.supported_countries = ['US','CA']
21
+ self.supported_countries = ['US', 'CA']
22
22
  self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb]
23
23
  self.default_currency = 'USD'
24
24
 
@@ -349,7 +349,7 @@ module ActiveMerchant #:nodoc:
349
349
  end
350
350
 
351
351
  def unescape_xml(escaped_xml)
352
- escaped_xml.gsub(/\&gt;/,'>').gsub(/\&lt;/,'<')
352
+ escaped_xml.gsub(/\&gt;/, '>').gsub(/\&lt;/, '<')
353
353
  end
354
354
  end
355
355
  end
@@ -286,9 +286,9 @@ module ActiveMerchant #:nodoc:
286
286
 
287
287
  def message_from(results)
288
288
  if results[:response_code] == DECLINED
289
- return CVVResult.messages[ results[:card_code] ] if CARD_CODE_ERRORS.include?(results[:card_code])
289
+ return CVVResult.messages[results[:card_code]] if CARD_CODE_ERRORS.include?(results[:card_code])
290
290
  if AVS_REASON_CODES.include?(results[:response_reason_code]) && AVS_ERRORS.include?(results[:avs_result_code])
291
- return AVSResult.messages[ results[:avs_result_code] ]
291
+ return AVSResult.messages[results[:avs_result_code]]
292
292
  end
293
293
  end
294
294