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
@@ -269,7 +269,7 @@ module ActiveMerchant
269
269
  end
270
270
 
271
271
  def format_date(month, year)
272
- "#{format(month,:two_digits)}/#{format(year, :two_digits)}"
272
+ "#{format(month, :two_digits)}/#{format(year, :two_digits)}"
273
273
  end
274
274
 
275
275
  def parse(body)
@@ -286,7 +286,7 @@ module ActiveMerchant
286
286
 
287
287
  def parse_element(response, node)
288
288
  if node.has_elements?
289
- node.elements.each{|e| parse_element(response, e) }
289
+ node.elements.each { |e| parse_element(response, e) }
290
290
  else
291
291
  response[node.name.underscore.to_sym] = node.text
292
292
  end
@@ -87,7 +87,7 @@ module ActiveMerchant #:nodoc:
87
87
 
88
88
  private
89
89
 
90
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
90
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
91
91
  CURRENCY_CODES['USD'] = '840'
92
92
  CURRENCY_CODES['DKK'] = '208'
93
93
  CURRENCY_CODES['NOK'] = '578'
@@ -159,7 +159,7 @@ module ActiveMerchant #:nodoc:
159
159
  end
160
160
 
161
161
  def add_hmac(post)
162
- data = post.sort.collect { |key, value| "#{key}=#{value.to_s}" }.join('&')
162
+ data = post.sort.collect { |key, value| "#{key}=#{value}" }.join('&')
163
163
  digest = OpenSSL::Digest.new('sha256')
164
164
  key = [@options[:secret_key]].pack('H*')
165
165
  post[:MAC] = OpenSSL::HMAC.hexdigest(digest, key, data)
@@ -36,7 +36,7 @@ module ActiveMerchant #:nodoc:
36
36
  def store(payment, options = {})
37
37
  MultiResponse.run do |r|
38
38
  r.process { commit('auth/token', app_token_request(options)) }
39
- options.merge!({ app_token: app_token_from(r) })
39
+ options[:app_token] = app_token_from(r)
40
40
 
41
41
  if options[:customer_id].present?
42
42
  customer_id = check_customer_exists(options)
@@ -197,7 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
 
198
198
  def add_customer_with_credit_card(payment, options = {})
199
199
  customer_response = commit('customers', create_customer_request(payment, options), options)
200
- options.merge!({customer_id: customer_response.authorization})
200
+ options[:customer_id] = customer_response.authorization
201
201
  commit('tokens', create_token_request(payment, options), options)
202
202
  end
203
203
 
@@ -228,7 +228,7 @@ module ActiveMerchant #:nodoc:
228
228
  def message_from(response)
229
229
  return response['message'] if response['message']
230
230
  return 'Success' if success_from(response)
231
- response['errors'].map {|error_hash| error_hash['detail'] }.join(', ')
231
+ response['errors'].map { |error_hash| error_hash['detail'] }.join(', ')
232
232
  end
233
233
 
234
234
  def authorization_from(response)
@@ -257,13 +257,13 @@ module ActiveMerchant #:nodoc:
257
257
  'x-api-key' => @options[:api_key]
258
258
  }
259
259
 
260
- headers.merge!({'Authorization' => "Bearer #{options[:app_token]}"}) if options[:app_token]
260
+ headers['Authorization'] = "Bearer #{options[:app_token]}" if options[:app_token]
261
261
  headers
262
262
  end
263
263
 
264
264
  def error_code_from(response)
265
265
  unless success_from(response)
266
- response['errors'].nil? ? response['message'] : response['errors'].map {|error_hash| error_hash['code'] }.join(', ')
266
+ response['errors'].nil? ? response['message'] : response['errors'].map { |error_hash| error_hash['code'] }.join(', ')
267
267
  end
268
268
  end
269
269
 
@@ -147,7 +147,7 @@ module ActiveMerchant #:nodoc:
147
147
 
148
148
  def add_customer_responsible_person(post, payment, options)
149
149
  post[:payment][:person_type] = options[:person_type] if options[:person_type]
150
- if options[:person_type] && options[:person_type].downcase == 'business'
150
+ if options[:person_type]&.casecmp('business')&.zero?
151
151
  post[:payment][:responsible] = {}
152
152
  post[:payment][:responsible][:name] = options[:responsible_name] if options[:responsible_name]
153
153
  post[:payment][:responsible][:document] = options[:responsible_document] if options[:responsible_document]
@@ -99,16 +99,16 @@ module ActiveMerchant #:nodoc:
99
99
  :client_ip_address => options[:ip]
100
100
 
101
101
  }
102
- add_creditcard(post,creditcard)
103
- add_address(post,options)
102
+ add_creditcard(post, creditcard)
103
+ add_address(post, options)
104
104
  post
105
105
  end
106
106
 
107
107
  def format_reference_number(number)
108
- number.to_s.slice(0,12)
108
+ number.to_s.slice(0, 12)
109
109
  end
110
110
 
111
- def add_address(post,options)
111
+ def add_address(post, options)
112
112
  if address = options[:billing_address] || options[:address]
113
113
  if address[:address2]
114
114
  post[:billing_address] = address[:address1].to_s << ' ' << address[:address2].to_s
@@ -149,7 +149,7 @@ module ActiveMerchant #:nodoc:
149
149
 
150
150
  private
151
151
 
152
- def add_invoice(form,options)
152
+ def add_invoice(form, options)
153
153
  form[:invoice_number] = truncate((options[:order_id] || options[:invoice]), 10)
154
154
  form[:description] = truncate(options[:description], 255)
155
155
  end
@@ -256,7 +256,7 @@ module ActiveMerchant #:nodoc:
256
256
  parameters[:amount] = amount(money)
257
257
  parameters[:transaction_type] = self.actions[action]
258
258
 
259
- response = parse( ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)) )
259
+ response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(parameters, options)))
260
260
 
261
261
  Response.new(response['result'] == '0', message_from(response), response,
262
262
  :test => @options[:test] || test?,
@@ -299,7 +299,7 @@ module ActiveMerchant #:nodoc:
299
299
 
300
300
  def parse(msg)
301
301
  resp = {}
302
- msg.split(self.delimiter).collect{|li|
302
+ msg.split(self.delimiter).collect { |li|
303
303
  key, value = li.split('=')
304
304
  resp[key.to_s.strip.gsub(/^ssl_/, '')] = value.to_s.strip
305
305
  }
@@ -54,7 +54,7 @@ module ActiveMerchant #:nodoc:
54
54
 
55
55
  def capture(money, authorization, options={})
56
56
  trans_id, _ = split_authorization(authorization)
57
- options.merge!({trans_id: trans_id})
57
+ options[:trans_id] = trans_id
58
58
 
59
59
  request = build_soap_request do |xml|
60
60
  xml.CreditCardAuthorizationCompletion(xmlns: 'https://transaction.elementexpress.com') do
@@ -69,7 +69,7 @@ module ActiveMerchant #:nodoc:
69
69
 
70
70
  def refund(money, authorization, options={})
71
71
  trans_id, _ = split_authorization(authorization)
72
- options.merge!({trans_id: trans_id})
72
+ options[:trans_id] = trans_id
73
73
 
74
74
  request = build_soap_request do |xml|
75
75
  xml.CreditCardReturn(xmlns: 'https://transaction.elementexpress.com') do
@@ -334,9 +334,9 @@ module ActiveMerchant #:nodoc:
334
334
 
335
335
  def url(action)
336
336
  if action == 'PaymentAccountCreate'
337
- url = (test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL)
337
+ test? ? SERVICE_TEST_URL : SERVICE_LIVE_URL
338
338
  else
339
- url = (test? ? test_url : live_url)
339
+ test? ? test_url : live_url
340
340
  end
341
341
  end
342
342
 
@@ -208,7 +208,7 @@ module ActiveMerchant #:nodoc:
208
208
  end
209
209
 
210
210
  result = {}
211
- query.each_pair do |k,v|
211
+ query.each_pair do |k, v|
212
212
  result[k] = v.is_a?(Array) && v.size == 1 ? v[0] : v # make values like ['v'] into 'v'
213
213
  end
214
214
  result
@@ -66,7 +66,7 @@ module ActiveMerchant #:nodoc:
66
66
  private
67
67
 
68
68
  def requires_address!(options)
69
- raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless (options.has_key?(:address) or options.has_key?(:billing_address))
69
+ raise ArgumentError.new('Missing eWay required parameters: address or billing_address') unless options.has_key?(:address) or options.has_key?(:billing_address)
70
70
  end
71
71
 
72
72
  def add_creditcard(post, creditcard)
@@ -145,7 +145,7 @@ module ActiveMerchant #:nodoc:
145
145
 
146
146
  def message_from(message)
147
147
  return '' if message.blank?
148
- MESSAGES[message[0,2]] || message
148
+ MESSAGES[message[0, 2]] || message
149
149
  end
150
150
 
151
151
  def purchase_url(cvn)
@@ -165,7 +165,7 @@ module ActiveMerchant #:nodoc:
165
165
  reply[:success]=true
166
166
  else
167
167
  if root = REXML::XPath.first(xml, '//UpdateCustomerResult') then
168
- if root.text.downcase == 'true' then
168
+ if root.text.casecmp('true').zero? then
169
169
  reply[:message]='OK'
170
170
  reply[:success]=true
171
171
  else
@@ -231,13 +231,13 @@ module ActiveMerchant #:nodoc:
231
231
  def soap_request(arguments, action)
232
232
  # eWay demands all fields be sent, but contain an empty string if blank
233
233
  post = case action
234
- when 'QueryCustomer'
234
+ when 'QueryCustomer'
235
235
  arguments
236
- when 'ProcessPayment'
236
+ when 'ProcessPayment'
237
237
  default_payment_fields.merge(arguments)
238
- when 'CreateCustomer'
238
+ when 'CreateCustomer'
239
239
  default_customer_fields.merge(arguments)
240
- when 'UpdateCustomer'
240
+ when 'UpdateCustomer'
241
241
  default_customer_fields.merge(arguments)
242
242
  end
243
243
 
@@ -299,7 +299,7 @@ module ActiveMerchant #:nodoc:
299
299
  end
300
300
 
301
301
  def parse_errors(message)
302
- errors = message.split(',').collect{|code| MESSAGES[code.strip]}.flatten.join(',')
302
+ errors = message.split(',').collect { |code| MESSAGES[code.strip] }.flatten.join(',')
303
303
  errors.presence || message
304
304
  end
305
305
 
@@ -211,7 +211,7 @@ module ActiveMerchant #:nodoc:
211
211
  parse_elements(response, root)
212
212
  end
213
213
 
214
- response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
214
+ response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) }
215
215
  end
216
216
 
217
217
  def parse_elements(response, root)
@@ -152,7 +152,7 @@ module ActiveMerchant #:nodoc:
152
152
  parameters[:type] = action
153
153
  parameters[:username] = @options[:login]
154
154
  parameters[:password] = @options[:password]
155
- parameters.map{|k, v| "#{k}=#{CGI.escape(v.to_s)}"}.join('&')
155
+ parameters.map { |k, v| "#{k}=#{CGI.escape(v.to_s)}" }.join('&')
156
156
  end
157
157
  end
158
158
  end
@@ -116,7 +116,7 @@ module ActiveMerchant #:nodoc:
116
116
  end
117
117
 
118
118
  def encode(hash)
119
- hash.collect{|(k,v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}"}.join('&')
119
+ hash.collect { |(k, v)| "#{CGI.escape(k.to_s)}=#{CGI.escape(v.to_s)}" }.join('&')
120
120
  end
121
121
 
122
122
  def creditcard_brand(brand)
@@ -246,12 +246,12 @@ module ActiveMerchant #:nodoc:
246
246
 
247
247
  def add_credit_card_eci(xml, credit_card, options)
248
248
  eci = if credit_card.is_a?(NetworkTokenizationCreditCard) && credit_card.source == :apple_pay && card_brand(credit_card) == 'discover'
249
- # Discover requires any Apple Pay transaction, regardless of in-app
250
- # or web, and regardless of the ECI contained in the PKPaymentToken,
251
- # to have an ECI value explicitly of 04.
252
- '04'
253
- else
254
- (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
249
+ # Discover requires any Apple Pay transaction, regardless of in-app
250
+ # or web, and regardless of the ECI contained in the PKPaymentToken,
251
+ # to have an ECI value explicitly of 04.
252
+ '04'
253
+ else
254
+ (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
255
255
  end
256
256
 
257
257
  xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci
@@ -438,7 +438,7 @@ module ActiveMerchant #:nodoc:
438
438
  parse_elements(response, root)
439
439
  end
440
440
 
441
- response.delete_if{ |k,v| SENSITIVE_FIELDS.include?(k) }
441
+ response.delete_if { |k, v| SENSITIVE_FIELDS.include?(k) }
442
442
  end
443
443
 
444
444
  def parse_elements(response, root)
@@ -71,7 +71,7 @@ module ActiveMerchant #:nodoc:
71
71
 
72
72
  private
73
73
 
74
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency: #{k}")}
74
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency: #{k}") }
75
75
  CURRENCY_CODES['NZD'] = '554'
76
76
 
77
77
  def add_invoice(post, money, options)
@@ -172,7 +172,7 @@ module ActiveMerchant #:nodoc:
172
172
 
173
173
  def parse_element(response, node)
174
174
  if node.has_elements?
175
- node.elements.each{|element| parse_element(response, element) }
175
+ node.elements.each { |element| parse_element(response, element) }
176
176
  else
177
177
  response[node.name.underscore.to_sym] = node.text
178
178
  end
@@ -191,7 +191,7 @@ module ActiveMerchant #:nodoc:
191
191
  success_from(response),
192
192
  message_from(response),
193
193
  response,
194
- authorization: authorization_from(response),
194
+ authorization: authorization_from(response, parameters),
195
195
  avs_result: AVSResult.new(code: response['response']['avs_result']),
196
196
  cvv_result: CVVResult.new(response['response']['cvv_code']),
197
197
  test: test?
@@ -219,8 +219,12 @@ module ActiveMerchant #:nodoc:
219
219
  response['response']['response_desc']
220
220
  end
221
221
 
222
- def authorization_from(response)
223
- [response.try(:[], 'transaction_id'), response.try(:[], 'response').try(:[], 'authorization_code')].join('#')
222
+ def authorization_from(response, parameters)
223
+ if parameters[:action] == 'capture'
224
+ [response['transaction_id'], response.dig('response', 'authorization_code'), parameters[:transaction_id], parameters[:authorization_code]].join('#')
225
+ else
226
+ [response['transaction_id'], response.dig('response', 'authorization_code')].join('#')
227
+ end
224
228
  end
225
229
 
226
230
  def endpoint
@@ -253,13 +257,13 @@ module ActiveMerchant #:nodoc:
253
257
  end
254
258
 
255
259
  def authorization_code_from(authorization)
256
- _, authorization_code = split_authorization(authorization)
257
- authorization_code
260
+ _, authorization_code, _, original_auth_authorization_code = split_authorization(authorization)
261
+ original_auth_authorization_code.present? ? original_auth_authorization_code : authorization_code
258
262
  end
259
263
 
260
264
  def transaction_id_from(authorization)
261
- transaction_id, _ = split_authorization(authorization)
262
- transaction_id
265
+ transaction_id, _, original_auth_transaction_id, _= split_authorization(authorization)
266
+ original_auth_transaction_id.present? ? original_auth_transaction_id : transaction_id
263
267
  end
264
268
  end
265
269
  end
@@ -5,7 +5,7 @@ module ActiveMerchant #:nodoc:
5
5
  self.test_url = 'https://sanalposprovtest.garanti.com.tr/VPServlet'
6
6
 
7
7
  # The countries the gateway supports merchants from as 2 digit ISO country codes
8
- self.supported_countries = ['US','TR']
8
+ self.supported_countries = ['US', 'TR']
9
9
 
10
10
  # The card types supported by the payment gateway
11
11
  self.supported_cardtypes = [:visa, :master, :american_express, :discover]
@@ -181,7 +181,7 @@ module ActiveMerchant #:nodoc:
181
181
  def add_address(xml, address)
182
182
  xml.tag! 'Name', normalize(address[:name])
183
183
  address_text = address[:address1]
184
- address_text << " #{ address[:address2]}" if address[:address2]
184
+ address_text << " #{address[:address2]}" if address[:address2]
185
185
  xml.tag! 'Text', normalize(address_text)
186
186
  xml.tag! 'City', normalize(address[:city])
187
187
  xml.tag! 'District', normalize(address[:state])
@@ -195,7 +195,7 @@ module ActiveMerchant #:nodoc:
195
195
  return unless text
196
196
 
197
197
  if ActiveSupport::Inflector.method(:transliterate).arity == -2
198
- ActiveSupport::Inflector.transliterate(text,'')
198
+ ActiveSupport::Inflector.transliterate(text, '')
199
199
  else
200
200
  text.gsub(/[^\x00-\x7F]+/, '')
201
201
  end
@@ -214,7 +214,7 @@ module ActiveMerchant #:nodoc:
214
214
  CURRENCY_CODES[currency] || CURRENCY_CODES[default_currency]
215
215
  end
216
216
 
217
- def commit(money,request)
217
+ def commit(money, request)
218
218
  url = test? ? self.test_url : self.live_url
219
219
  raw_response = ssl_post(url, 'data=' + request)
220
220
  response = parse(raw_response)
@@ -240,7 +240,7 @@ module ActiveMerchant #:nodoc:
240
240
 
241
241
  def parse_element(response, node)
242
242
  if node.has_elements?
243
- node.elements.each{|element| parse_element(response, element) }
243
+ node.elements.each { |element| parse_element(response, element) }
244
244
  else
245
245
  response[node.name.underscore.to_sym] = node.text
246
246
  end
@@ -170,7 +170,6 @@ module ActiveMerchant #:nodoc:
170
170
  end
171
171
 
172
172
  def add_address(post, creditcard, options)
173
- billing_address = options[:billing_address] || options[:address]
174
173
  shipping_address = options[:shipping_address]
175
174
  if billing_address = options[:billing_address] || options[:address]
176
175
  post['order']['customer']['billingAddress'] = {
@@ -201,7 +200,7 @@ module ActiveMerchant #:nodoc:
201
200
  def add_fraud_fields(post, options)
202
201
  fraud_fields = {}
203
202
  fraud_fields.merge!(options[:fraud_fields]) if options[:fraud_fields]
204
- fraud_fields.merge!({customerIpAddress: options[:ip]}) if options[:ip]
203
+ fraud_fields[:customerIpAddress] = options[:ip] if options[:ip]
205
204
 
206
205
  post['fraudFields'] = fraud_fields unless fraud_fields.empty?
207
206
  end
@@ -330,7 +329,7 @@ EOS
330
329
  end
331
330
 
332
331
  def nestable_hash
333
- Hash.new {|h,k| h[k] = Hash.new(&h.default_proc) }
332
+ Hash.new { |h, k| h[k] = Hash.new(&h.default_proc) }
334
333
  end
335
334
 
336
335
  def capture_requested?(response)
@@ -57,7 +57,7 @@ module ActiveMerchant #:nodoc:
57
57
 
58
58
  private
59
59
 
60
- CURRENCY_CODES = Hash.new{|h,k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}")}
60
+ CURRENCY_CODES = Hash.new { |h, k| raise ArgumentError.new("Unsupported currency for HDFC: #{k}") }
61
61
  CURRENCY_CODES['AED'] = '784'
62
62
  CURRENCY_CODES['AUD'] = '036'
63
63
  CURRENCY_CODES['CAD'] = '124'
@@ -113,7 +113,7 @@ EOA
113
113
  doc.children.each do |node|
114
114
  if node.text?
115
115
  next
116
- elsif (node.elements.size == 0)
116
+ elsif node.elements.size == 0
117
117
  response[node.name.downcase.to_sym] = node.text
118
118
  else
119
119
  node.elements.each do |childnode|
@@ -42,7 +42,7 @@ module ActiveMerchant #:nodoc:
42
42
  commit('CreditSale') do |xml|
43
43
  add_amount(xml, money)
44
44
  add_allow_dup(xml)
45
- add_customer_data(xml, card_or_token,options)
45
+ add_customer_data(xml, card_or_token, options)
46
46
  add_details(xml, options)
47
47
  add_descriptor_name(xml, options)
48
48
  add_payment(xml, card_or_token, options)
@@ -54,7 +54,7 @@ module ActiveMerchant #:nodoc:
54
54
  add_amount(xml, money)
55
55
  add_allow_dup(xml)
56
56
  add_reference(xml, transaction_id)
57
- add_customer_data(xml, transaction_id,options)
57
+ add_customer_data(xml, transaction_id, options)
58
58
  add_details(xml, options)
59
59
  end
60
60
  end
@@ -204,7 +204,7 @@ module ActiveMerchant #:nodoc:
204
204
  doc.remove_namespaces!
205
205
  if(header = doc.xpath('//Header').first)
206
206
  header.elements.each do |node|
207
- if (node.elements.size == 0)
207
+ if node.elements.size == 0
208
208
  response[node.name] = node.text
209
209
  else
210
210
  node.elements.each do |childnode|