activemerchant 1.83.0 → 1.84.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (146) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +19 -0
  3. data/lib/active_merchant/billing/base.rb +1 -1
  4. data/lib/active_merchant/billing/check.rb +3 -2
  5. data/lib/active_merchant/billing/compatibility.rb +2 -4
  6. data/lib/active_merchant/billing/credit_card.rb +6 -39
  7. data/lib/active_merchant/billing/credit_card_formatting.rb +0 -1
  8. data/lib/active_merchant/billing/credit_card_methods.rb +67 -44
  9. data/lib/active_merchant/billing/gateway.rb +1 -8
  10. data/lib/active_merchant/billing/gateways/adyen.rb +1 -1
  11. data/lib/active_merchant/billing/gateways/allied_wallet.rb +0 -1
  12. data/lib/active_merchant/billing/gateways/authorize_net.rb +0 -1
  13. data/lib/active_merchant/billing/gateways/axcessms.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/balanced.rb +9 -9
  15. data/lib/active_merchant/billing/gateways/banwire.rb +5 -5
  16. data/lib/active_merchant/billing/gateways/barclaycard_smartpay.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/beanstream.rb +1 -0
  18. data/lib/active_merchant/billing/gateways/beanstream/beanstream_core.rb +0 -1
  19. data/lib/active_merchant/billing/gateways/blue_snap.rb +5 -7
  20. data/lib/active_merchant/billing/gateways/braintree_blue.rb +12 -6
  21. data/lib/active_merchant/billing/gateways/bridge_pay.rb +0 -1
  22. data/lib/active_merchant/billing/gateways/card_connect.rb +2 -2
  23. data/lib/active_merchant/billing/gateways/card_save.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/card_stream.rb +9 -18
  25. data/lib/active_merchant/billing/gateways/cardknox.rb +8 -9
  26. data/lib/active_merchant/billing/gateways/cc5.rb +0 -1
  27. data/lib/active_merchant/billing/gateways/cecabank.rb +0 -1
  28. data/lib/active_merchant/billing/gateways/cenpos.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/checkout_v2.rb +6 -6
  30. data/lib/active_merchant/billing/gateways/citrus_pay.rb +1 -1
  31. data/lib/active_merchant/billing/gateways/commercegate.rb +0 -1
  32. data/lib/active_merchant/billing/gateways/conekta.rb +6 -8
  33. data/lib/active_merchant/billing/gateways/creditcall.rb +1 -2
  34. data/lib/active_merchant/billing/gateways/ct_payment.rb +1 -1
  35. data/lib/active_merchant/billing/gateways/culqi.rb +8 -10
  36. data/lib/active_merchant/billing/gateways/cyber_source.rb +1 -2
  37. data/lib/active_merchant/billing/gateways/data_cash.rb +16 -29
  38. data/lib/active_merchant/billing/gateways/dibs.rb +1 -7
  39. data/lib/active_merchant/billing/gateways/digitzs.rb +1 -1
  40. data/lib/active_merchant/billing/gateways/efsnet.rb +0 -4
  41. data/lib/active_merchant/billing/gateways/element.rb +1 -1
  42. data/lib/active_merchant/billing/gateways/epay.rb +8 -9
  43. data/lib/active_merchant/billing/gateways/eway.rb +1 -0
  44. data/lib/active_merchant/billing/gateways/eway_managed.rb +2 -3
  45. data/lib/active_merchant/billing/gateways/exact.rb +0 -2
  46. data/lib/active_merchant/billing/gateways/ezic.rb +0 -1
  47. data/lib/active_merchant/billing/gateways/fat_zebra.rb +9 -11
  48. data/lib/active_merchant/billing/gateways/federated_canada.rb +1 -1
  49. data/lib/active_merchant/billing/gateways/first_giving.rb +3 -3
  50. data/lib/active_merchant/billing/gateways/first_pay.rb +5 -0
  51. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +2 -2
  52. data/lib/active_merchant/billing/gateways/garanti.rb +4 -5
  53. data/lib/active_merchant/billing/gateways/global_collect.rb +6 -7
  54. data/lib/active_merchant/billing/gateways/iats_payments.rb +1 -1
  55. data/lib/active_merchant/billing/gateways/inspire.rb +2 -2
  56. data/lib/active_merchant/billing/gateways/ipp.rb +1 -1
  57. data/lib/active_merchant/billing/gateways/iridium.rb +3 -3
  58. data/lib/active_merchant/billing/gateways/iveri.rb +1 -1
  59. data/lib/active_merchant/billing/gateways/komoju.rb +1 -1
  60. data/lib/active_merchant/billing/gateways/kushki.rb +7 -9
  61. data/lib/active_merchant/billing/gateways/latitude19.rb +29 -34
  62. data/lib/active_merchant/billing/gateways/linkpoint.rb +1 -3
  63. data/lib/active_merchant/billing/gateways/litle.rb +1 -1
  64. data/lib/active_merchant/billing/gateways/mastercard.rb +1 -2
  65. data/lib/active_merchant/billing/gateways/mercado_pago.rb +0 -1
  66. data/lib/active_merchant/billing/gateways/merchant_e_solutions.rb +0 -1
  67. data/lib/active_merchant/billing/gateways/merchant_one.rb +1 -1
  68. data/lib/active_merchant/billing/gateways/merchant_ware.rb +3 -3
  69. data/lib/active_merchant/billing/gateways/merchant_ware_version_four.rb +3 -3
  70. data/lib/active_merchant/billing/gateways/mercury.rb +1 -1
  71. data/lib/active_merchant/billing/gateways/micropayment.rb +0 -2
  72. data/lib/active_merchant/billing/gateways/modern_payments.rb +1 -0
  73. data/lib/active_merchant/billing/gateways/modern_payments_cim.rb +4 -3
  74. data/lib/active_merchant/billing/gateways/moneris.rb +0 -1
  75. data/lib/active_merchant/billing/gateways/moneris_us.rb +1 -2
  76. data/lib/active_merchant/billing/gateways/money_movers.rb +1 -1
  77. data/lib/active_merchant/billing/gateways/mundipagg.rb +9 -9
  78. data/lib/active_merchant/billing/gateways/nab_transact.rb +0 -1
  79. data/lib/active_merchant/billing/gateways/net_registry.rb +1 -0
  80. data/lib/active_merchant/billing/gateways/nmi.rb +1 -2
  81. data/lib/active_merchant/billing/gateways/ogone.rb +9 -10
  82. data/lib/active_merchant/billing/gateways/openpay.rb +7 -8
  83. data/lib/active_merchant/billing/gateways/opp.rb +110 -112
  84. data/lib/active_merchant/billing/gateways/optimal_payment.rb +1 -4
  85. data/lib/active_merchant/billing/gateways/orbital.rb +1 -2
  86. data/lib/active_merchant/billing/gateways/pagarme.rb +3 -5
  87. data/lib/active_merchant/billing/gateways/pay_conex.rb +0 -1
  88. data/lib/active_merchant/billing/gateways/pay_junction_v2.rb +10 -12
  89. data/lib/active_merchant/billing/gateways/pay_secure.rb +1 -1
  90. data/lib/active_merchant/billing/gateways/paybox_direct.rb +0 -1
  91. data/lib/active_merchant/billing/gateways/payeezy.rb +15 -4
  92. data/lib/active_merchant/billing/gateways/payex.rb +5 -6
  93. data/lib/active_merchant/billing/gateways/payflow.rb +0 -4
  94. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -2
  95. data/lib/active_merchant/billing/gateways/payflow/payflow_response.rb +1 -1
  96. data/lib/active_merchant/billing/gateways/payflow_express.rb +54 -55
  97. data/lib/active_merchant/billing/gateways/payflow_uk.rb +1 -1
  98. data/lib/active_merchant/billing/gateways/payment_express.rb +0 -6
  99. data/lib/active_merchant/billing/gateways/paymill.rb +0 -2
  100. data/lib/active_merchant/billing/gateways/paypal.rb +0 -8
  101. data/lib/active_merchant/billing/gateways/payscout.rb +0 -1
  102. data/lib/active_merchant/billing/gateways/paystation.rb +2 -2
  103. data/lib/active_merchant/billing/gateways/payu_latam.rb +37 -32
  104. data/lib/active_merchant/billing/gateways/pin.rb +2 -2
  105. data/lib/active_merchant/billing/gateways/plugnpay.rb +1 -0
  106. data/lib/active_merchant/billing/gateways/psl_card.rb +3 -10
  107. data/lib/active_merchant/billing/gateways/quantum.rb +4 -4
  108. data/lib/active_merchant/billing/gateways/quickpay/quickpay_common.rb +0 -3
  109. data/lib/active_merchant/billing/gateways/quickpay/quickpay_v10.rb +3 -7
  110. data/lib/active_merchant/billing/gateways/realex.rb +6 -8
  111. data/lib/active_merchant/billing/gateways/redsys.rb +1 -0
  112. data/lib/active_merchant/billing/gateways/s5.rb +0 -1
  113. data/lib/active_merchant/billing/gateways/safe_charge.rb +4 -4
  114. data/lib/active_merchant/billing/gateways/sage.rb +16 -13
  115. data/lib/active_merchant/billing/gateways/sage_pay.rb +2 -9
  116. data/lib/active_merchant/billing/gateways/secure_net.rb +0 -1
  117. data/lib/active_merchant/billing/gateways/securion_pay.rb +3 -6
  118. data/lib/active_merchant/billing/gateways/skip_jack.rb +2 -2
  119. data/lib/active_merchant/billing/gateways/smart_ps.rb +2 -4
  120. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +5 -5
  121. data/lib/active_merchant/billing/gateways/spreedly_core.rb +1 -2
  122. data/lib/active_merchant/billing/gateways/stripe.rb +60 -15
  123. data/lib/active_merchant/billing/gateways/telr.rb +5 -6
  124. data/lib/active_merchant/billing/gateways/tns.rb +1 -1
  125. data/lib/active_merchant/billing/gateways/trans_first.rb +0 -1
  126. data/lib/active_merchant/billing/gateways/trexle.rb +6 -5
  127. data/lib/active_merchant/billing/gateways/trust_commerce.rb +1 -0
  128. data/lib/active_merchant/billing/gateways/usa_epay_advanced.rb +2 -2
  129. data/lib/active_merchant/billing/gateways/usa_epay_transaction.rb +0 -1
  130. data/lib/active_merchant/billing/gateways/vanco.rb +1 -1
  131. data/lib/active_merchant/billing/gateways/viaklix.rb +1 -0
  132. data/lib/active_merchant/billing/gateways/visanet_peru.rb +28 -32
  133. data/lib/active_merchant/billing/gateways/wepay.rb +0 -1
  134. data/lib/active_merchant/billing/gateways/wirecard.rb +2 -1
  135. data/lib/active_merchant/billing/gateways/worldpay.rb +1 -4
  136. data/lib/active_merchant/billing/gateways/worldpay_online_payments.rb +5 -8
  137. data/lib/active_merchant/connection.rb +0 -2
  138. data/lib/active_merchant/country.rb +1 -0
  139. data/lib/active_merchant/net_http_ssl_connection.rb +1 -1
  140. data/lib/active_merchant/network_connection_retries.rb +1 -0
  141. data/lib/active_merchant/post_data.rb +1 -0
  142. data/lib/active_merchant/posts_data.rb +0 -2
  143. data/lib/active_merchant/version.rb +1 -1
  144. data/lib/support/gateway_support.rb +3 -4
  145. data/lib/support/ssl_verify.rb +0 -1
  146. metadata +2 -2
@@ -318,7 +318,7 @@ module ActiveMerchant #:nodoc:
318
318
  def authorize_response_map(body)
319
319
  lines = split_lines(body)
320
320
  keys, values = split_line(lines[0]), split_line(lines[1])
321
- Hash[*(keys.zip(values).flatten)].symbolize_keys
321
+ Hash[*keys.zip(values).flatten].symbolize_keys
322
322
  end
323
323
 
324
324
  def parse_authorization_response(body)
@@ -333,7 +333,7 @@ module ActiveMerchant #:nodoc:
333
333
  keys = [ :szSerialNumber, :szErrorCode, :szNumberRecords]
334
334
  values = split_line(lines[0])[0..2]
335
335
 
336
- result = Hash[*(keys.zip(values).flatten)]
336
+ result = Hash[*keys.zip(values).flatten]
337
337
 
338
338
  result[:szErrorMessage] = ''
339
339
  result[:success] = (result[:szErrorCode] == '0')
@@ -106,7 +106,6 @@ module ActiveMerchant #:nodoc:
106
106
  commit('update', nil, post)
107
107
  end
108
108
 
109
-
110
109
  def delete(vault_id)
111
110
  post = {}
112
111
  post[:customer_vault] = 'delete_customer'
@@ -128,6 +127,7 @@ module ActiveMerchant #:nodoc:
128
127
  alias_method :unstore, :delete
129
128
 
130
129
  private
130
+
131
131
  def add_customer_data(post, options)
132
132
  if options.has_key? :email
133
133
  post[:email] = options[:email]
@@ -237,7 +237,6 @@ module ActiveMerchant #:nodoc:
237
237
  :cvv_result => response['cvvresponse'],
238
238
  :avs_result => { :code => response['avsresponse'] }
239
239
  )
240
-
241
240
  end
242
241
 
243
242
  def expdate(creditcard)
@@ -247,7 +246,6 @@ module ActiveMerchant #:nodoc:
247
246
  "#{month}#{year[-2..-1]}"
248
247
  end
249
248
 
250
-
251
249
  def message_from(response)
252
250
  case response['responsetext']
253
251
  when 'SUCCESS', 'Approved', nil # This is dubious, but responses from UPDATE are nil.
@@ -272,7 +270,7 @@ module ActiveMerchant #:nodoc:
272
270
  def determine_funding_source(source)
273
271
  case
274
272
  when source.is_a?(String) then :vault
275
- when CreditCard.card_companies.keys.include?(card_brand(source)) then :credit_card
273
+ when CreditCard.card_companies.include?(card_brand(source)) then :credit_card
276
274
  when card_brand(source) == 'check' then :check
277
275
  else raise ArgumentError, 'Unsupported funding source provided'
278
276
  end
@@ -10,7 +10,7 @@ module ActiveMerchant #:nodoc:
10
10
  'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'GB',
11
11
  'IS', 'NO', 'CH'
12
12
  ]
13
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :solo, :diners_club]
13
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :maestro, :jcb, :diners_club]
14
14
  self.homepage_url = 'http://www.soeasypay.com/'
15
15
  self.display_name = 'SoEasyPay'
16
16
 
@@ -162,10 +162,10 @@ module ActiveMerchant #:nodoc:
162
162
  response_string = ssl_post(test? ? self.test_url : self.live_url, soap, headers)
163
163
  response = parse(response_string, soap_action)
164
164
  return Response.new(response['errorcode'] == '000',
165
- response['errormessage'],
166
- response,
167
- :test => test?,
168
- :authorization => response['transaction_id'])
165
+ response['errormessage'],
166
+ response,
167
+ :test => test?,
168
+ :authorization => response['transaction_id'])
169
169
  end
170
170
 
171
171
  def build_soap(request)
@@ -88,7 +88,6 @@ module ActiveMerchant #:nodoc:
88
88
  commit("transactions/#{authorization}/void.xml", '')
89
89
  end
90
90
 
91
-
92
91
  # Public: Determine whether a credit card is chargeable card and available for purchases.
93
92
  #
94
93
  # payment_method - The CreditCard or the Spreedly payment method token.
@@ -231,7 +230,7 @@ module ActiveMerchant #:nodoc:
231
230
 
232
231
  doc = Nokogiri::XML(xml)
233
232
  doc.root.xpath('*').each do |node|
234
- if (node.elements.empty?)
233
+ if node.elements.empty?
235
234
  response[node.name.downcase.to_sym] = node.text
236
235
  else
237
236
  node.elements.each do |childnode|
@@ -136,6 +136,7 @@ module ActiveMerchant #:nodoc:
136
136
  def void(identification, options = {})
137
137
  post = {}
138
138
  post[:metadata] = options[:metadata] if options[:metadata]
139
+ post[:reason] = options[:reason] if options[:reason]
139
140
  post[:expand] = [:charge]
140
141
  commit(:post, "charges/#{CGI.escape(identification)}/refunds", post, options)
141
142
  end
@@ -323,6 +324,7 @@ module ActiveMerchant #:nodoc:
323
324
  add_application_fee(post, options)
324
325
  add_exchange_rate(post, options)
325
326
  add_destination(post, options)
327
+ add_level_three(post, options)
326
328
  post
327
329
  end
328
330
 
@@ -348,6 +350,21 @@ module ActiveMerchant #:nodoc:
348
350
  end
349
351
  end
350
352
 
353
+ def add_level_three(post, options)
354
+ level_three = {}
355
+
356
+ copy_when_present(level_three, [:merchant_reference], options)
357
+ copy_when_present(level_three, [:customer_reference], options)
358
+ copy_when_present(level_three, [:shipping_address_zip], options)
359
+ copy_when_present(level_three, [:shipping_from_zip], options)
360
+ copy_when_present(level_three, [:shipping_amount], options)
361
+ copy_when_present(level_three, [:line_items], options)
362
+
363
+ unless level_three.empty?
364
+ post[:level3] = level_three
365
+ end
366
+ end
367
+
351
368
  def add_expand_parameters(post, options)
352
369
  post[:expand] ||= []
353
370
  post[:expand].concat(Array.wrap(options[:expand]).map(&:to_sym)).uniq!
@@ -490,25 +507,39 @@ module ActiveMerchant #:nodoc:
490
507
 
491
508
  def post_data(params)
492
509
  return nil unless params
510
+ flatten_params([], params).join('&')
511
+ end
493
512
 
494
- params.map do |key, value|
513
+ def flatten_params(flattened, params, prefix = nil)
514
+ params.each do |key, value|
495
515
  next if value != false && value.blank?
516
+ flattened_key = prefix.nil? ? key : "#{prefix}[#{key}]"
496
517
  if value.is_a?(Hash)
497
- h = {}
498
- value.each do |k, v|
499
- h["#{key}[#{k}]"] = v unless v.blank?
500
- end
501
- post_data(h)
518
+ flatten_params(flattened, value, flattened_key)
502
519
  elsif value.is_a?(Array)
503
- value.map { |v| "#{key}[]=#{CGI.escape(v.to_s)}" }.join('&')
520
+ flatten_array(flattened, value, flattened_key)
521
+ else
522
+ flattened << "#{flattened_key}=#{CGI.escape(value.to_s)}"
523
+ end
524
+ end
525
+ flattened
526
+ end
527
+
528
+ def flatten_array(flattened, array, prefix)
529
+ array.each_with_index do |item, idx|
530
+ key = "#{prefix}[#{idx}]"
531
+ if item.is_a?(Hash)
532
+ flatten_params(flattened, item, key)
533
+ elsif item.is_a?(Array)
534
+ flatten_array(flattened, item, key)
504
535
  else
505
- "#{key}=#{CGI.escape(value.to_s)}"
536
+ flattened << "#{key}=#{CGI.escape(item.to_s)}"
506
537
  end
507
- end.compact.join('&')
538
+ end
508
539
  end
509
540
 
510
541
  def headers(options = {})
511
- key = options[:key] || @api_key
542
+ key = options[:key] || @api_key
512
543
  idempotency_key = options[:idempotency_key]
513
544
 
514
545
  headers = {
@@ -589,11 +620,9 @@ module ActiveMerchant #:nodoc:
589
620
  end
590
621
 
591
622
  def response_error(raw_response)
592
- begin
593
- parse(raw_response)
594
- rescue JSON::ParserError
595
- json_error(raw_response)
596
- end
623
+ parse(raw_response)
624
+ rescue JSON::ParserError
625
+ json_error(raw_response)
597
626
  end
598
627
 
599
628
  def json_error(raw_response)
@@ -682,6 +711,22 @@ module ActiveMerchant #:nodoc:
682
711
  return 100 unless options[:currency]
683
712
  return MINIMUM_AUTHORIZE_AMOUNTS[options[:currency].upcase] || 100
684
713
  end
714
+
715
+ def copy_when_present(dest, dest_path, source, source_path = nil)
716
+ source_path ||= dest_path
717
+ source_path.each do |key|
718
+ return nil unless source[key]
719
+ source = source[key]
720
+ end
721
+
722
+ if source
723
+ dest_path.first(dest_path.size - 1).each do |key|
724
+ dest[key] ||= {}
725
+ dest = dest[key]
726
+ end
727
+ dest[dest_path.last] = source
728
+ end
729
+ end
685
730
  end
686
731
  end
687
732
  end
@@ -11,7 +11,7 @@ module ActiveMerchant #:nodoc:
11
11
  self.supported_countries = ['AE', 'IN', 'SA']
12
12
  self.default_currency = 'AED'
13
13
  self.money_format = :dollars
14
- self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :solo, :jcb]
14
+ self.supported_cardtypes = [:visa, :master, :american_express, :maestro, :jcb]
15
15
 
16
16
  CVC_CODE_TRANSLATOR = {
17
17
  'Y' => 'M',
@@ -87,9 +87,9 @@ module ActiveMerchant #:nodoc:
87
87
 
88
88
  def scrub(transcript)
89
89
  transcript.
90
- gsub(%r((<Number>)[^<]+(<))i, '\1[FILTERED]\2').
91
- gsub(%r((<CVV>)[^<]+(<))i, '\1[FILTERED]\2').
92
- gsub(%r((<Key>)[^<]+(<))i, '\1[FILTERED]\2')
90
+ gsub(%r((<Number>)[^<]+(<))i, '\1[FILTERED]\2').
91
+ gsub(%r((<CVV>)[^<]+(<))i, '\1[FILTERED]\2').
92
+ gsub(%r((<Key>)[^<]+(<))i, '\1[FILTERED]\2')
93
93
  end
94
94
 
95
95
  private
@@ -190,7 +190,6 @@ module ActiveMerchant #:nodoc:
190
190
  def build_xml_request
191
191
  builder = Nokogiri::XML::Builder.new(encoding: 'UTF-8') do |xml|
192
192
  xml.remote do |doc|
193
-
194
193
  add_authentication(doc)
195
194
  yield(doc)
196
195
  end
@@ -220,7 +219,7 @@ module ActiveMerchant #:nodoc:
220
219
  response[node.name.downcase.to_sym] = node.text
221
220
  else
222
221
  node.elements.each do |childnode|
223
- name = "#{childnode.name.downcase}"
222
+ name = childnode.name.downcase
224
223
  response[name.to_sym] = childnode.text
225
224
  end
226
225
  end
@@ -15,7 +15,7 @@ module ActiveMerchant
15
15
  self.homepage_url = 'http://www.tnsi.com/'
16
16
  self.supported_countries = %w(AR AU BR FR DE HK MX NZ SG GB US)
17
17
  self.default_currency = 'USD'
18
- self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro, :laser]
18
+ self.supported_cardtypes = [:visa, :master, :american_express, :discover, :diners_club, :jcb, :maestro]
19
19
 
20
20
  end
21
21
  end
@@ -1,5 +1,4 @@
1
1
  module ActiveMerchant #:nodoc:
2
-
3
2
  module Billing #:nodoc:
4
3
  class TransFirstGateway < Gateway
5
4
  self.test_url = 'https://ws.cert.transfirst.com'
@@ -90,6 +90,7 @@ module ActiveMerchant #:nodoc:
90
90
  gsub(/(number\\?":\\?")(\d*)/, '\1[FILTERED]').
91
91
  gsub(/(cvc\\?":\\?")(\d*)/, '\1[FILTERED]')
92
92
  end
93
+
93
94
  private
94
95
 
95
96
  def add_amount(post, money, options)
@@ -170,11 +171,11 @@ module ActiveMerchant #:nodoc:
170
171
 
171
172
  response = body['response']
172
173
  Response.new(
173
- true,
174
- response['status_message'],
175
- body,
176
- authorization: token(response),
177
- test: test?
174
+ true,
175
+ response['status_message'],
176
+ body,
177
+ authorization: token(response),
178
+ test: test?
178
179
  )
179
180
  end
180
181
 
@@ -304,6 +304,7 @@ module ActiveMerchant #:nodoc:
304
304
  end
305
305
 
306
306
  private
307
+
307
308
  def add_payment_source(params, source)
308
309
  if source.is_a?(String)
309
310
  add_billing_id(params, source)
@@ -1563,12 +1563,12 @@ module ActiveMerchant #:nodoc:
1563
1563
 
1564
1564
  success, message, authorization, avs, cvv = false, FAILURE_MESSAGE, nil, nil, nil
1565
1565
 
1566
- fault = (!response) || (response.length < 1) || response.has_key?('faultcode')
1566
+ fault = !response || (response.length < 1) || response.has_key?('faultcode')
1567
1567
  return [response, success, response['faultstring'], authorization, avs, cvv] if fault
1568
1568
 
1569
1569
  if response.respond_to?(:[]) && p = response["#{action}_return"]
1570
1570
  if p.respond_to?(:key?) && p.key?('result_code')
1571
- success = p['result_code'] == 'A' ? true : false
1571
+ success = p['result_code'] == 'A'
1572
1572
  authorization = p['ref_num']
1573
1573
  avs = AVS_RESULTS[p['avs_result_code']]
1574
1574
  cvv = p['card_code_result_code']
@@ -1,6 +1,5 @@
1
1
  module ActiveMerchant #:nodoc:
2
2
  module Billing #:nodoc:
3
-
4
3
  class UsaEpayTransactionGateway < Gateway
5
4
  self.live_url = 'https://www.usaepay.com/gate'
6
5
  self.test_url = 'https://sandbox.usaepay.com/gate'
@@ -52,7 +52,7 @@ module ActiveMerchant
52
52
 
53
53
  doc = Nokogiri::XML(xml)
54
54
  doc.root.xpath('*').each do |node|
55
- if (node.elements.empty?)
55
+ if node.elements.empty?
56
56
  response[node.name.downcase.to_sym] = node.text
57
57
  else
58
58
  node.elements.each do |childnode|
@@ -63,6 +63,7 @@ module ActiveMerchant #:nodoc:
63
63
  end
64
64
 
65
65
  private
66
+
66
67
  def add_test_mode(form, options)
67
68
  form[:test_mode] = 'TRUE' if options[:test_mode]
68
69
  end
@@ -140,24 +140,22 @@ module ActiveMerchant #:nodoc:
140
140
  end
141
141
 
142
142
  def commit(action, params, options={})
143
- begin
144
- raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
145
- response = parse(raw_response)
146
- rescue ResponseError => e
147
- raw_response = e.response.body
148
- response_error(raw_response, options, action)
149
- rescue JSON::ParserError
150
- unparsable_response(raw_response)
151
- else
152
- Response.new(
153
- success_from(response),
154
- message_from(response, options, action),
155
- response,
156
- :test => test?,
157
- :authorization => authorization_from(params, response, options),
158
- :error_code => response['errorCode']
159
- )
160
- end
143
+ raw_response = ssl_request(method(action), url(action, params, options), params.to_json, headers)
144
+ response = parse(raw_response)
145
+ rescue ResponseError => e
146
+ raw_response = e.response.body
147
+ response_error(raw_response, options, action)
148
+ rescue JSON::ParserError
149
+ unparsable_response(raw_response)
150
+ else
151
+ Response.new(
152
+ success_from(response),
153
+ message_from(response, options, action),
154
+ response,
155
+ :test => test?,
156
+ :authorization => authorization_from(params, response, options),
157
+ :error_code => response['errorCode']
158
+ )
161
159
  end
162
160
 
163
161
  def headers
@@ -211,20 +209,18 @@ module ActiveMerchant #:nodoc:
211
209
  end
212
210
 
213
211
  def response_error(raw_response, options, action)
214
- begin
215
- response = parse(raw_response)
216
- rescue JSON::ParserError
217
- unparsable_response(raw_response)
218
- else
219
- return Response.new(
220
- false,
221
- message_from(response, options, action),
222
- response,
223
- :test => test?,
224
- :authorization => response['transactionUUID'],
225
- :error_code => response['errorCode']
226
- )
227
- end
212
+ response = parse(raw_response)
213
+ rescue JSON::ParserError
214
+ unparsable_response(raw_response)
215
+ else
216
+ return Response.new(
217
+ false,
218
+ message_from(response, options, action),
219
+ response,
220
+ :test => test?,
221
+ :authorization => response['transactionUUID'],
222
+ :error_code => response['errorCode']
223
+ )
228
224
  end
229
225
 
230
226
  def unparsable_response(raw_response)
@@ -190,7 +190,6 @@ module ActiveMerchant #:nodoc:
190
190
  authorization: authorization_from(response, params),
191
191
  test: test?
192
192
  )
193
-
194
193
  rescue JSON::ParserError
195
194
  return unparsable_response(response)
196
195
  end
@@ -26,7 +26,7 @@ module ActiveMerchant #:nodoc:
26
26
  # number 5551234 within area code 202 (country code 1).
27
27
  VALID_PHONE_FORMAT = /\+\d{1,3}(\(?\d{3}\)?)?\d{3}-\d{4}-\d{3}/
28
28
 
29
- self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb, :switch ]
29
+ self.supported_cardtypes = [ :visa, :master, :american_express, :diners_club, :jcb ]
30
30
  self.supported_countries = %w(AD CY GI IM MT RO CH AT DK GR IT MC SM TR BE EE HU LV NL SK GB BG FI IS LI NO SI VA FR IL LT PL ES CZ DE IE LU PT SE)
31
31
  self.homepage_url = 'http://www.wirecard.com'
32
32
  self.display_name = 'Wirecard'
@@ -138,6 +138,7 @@ module ActiveMerchant #:nodoc:
138
138
  end
139
139
 
140
140
  private
141
+
141
142
  def clean_description(description)
142
143
  description.to_s.slice(0,32).encode('US-ASCII', invalid: :replace, undef: :replace, replace: '?')
143
144
  end