activemerchant 1.107.4 → 1.108.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (33) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG +11 -0
  3. data/README.md +1 -1
  4. data/lib/active_merchant/billing/gateways/authorize_net.rb +1 -1
  5. data/lib/active_merchant/billing/gateways/blue_pay.rb +2 -2
  6. data/lib/active_merchant/billing/gateways/braintree_blue.rb +4 -6
  7. data/lib/active_merchant/billing/gateways/clearhaus.rb +1 -1
  8. data/lib/active_merchant/billing/gateways/cyber_source.rb +6 -2
  9. data/lib/active_merchant/billing/gateways/d_local.rb +13 -3
  10. data/lib/active_merchant/billing/gateways/decidir.rb +24 -0
  11. data/lib/active_merchant/billing/gateways/elavon.rb +4 -3
  12. data/lib/active_merchant/billing/gateways/element.rb +1 -1
  13. data/lib/active_merchant/billing/gateways/firstdata_e4.rb +1 -1
  14. data/lib/active_merchant/billing/gateways/firstdata_e4_v27.rb +1 -1
  15. data/lib/active_merchant/billing/gateways/forte.rb +1 -1
  16. data/lib/active_merchant/billing/gateways/netaxept.rb +1 -1
  17. data/lib/active_merchant/billing/gateways/netbanx.rb +1 -1
  18. data/lib/active_merchant/billing/gateways/opp.rb +1 -1
  19. data/lib/active_merchant/billing/gateways/payflow/payflow_common_api.rb +1 -1
  20. data/lib/active_merchant/billing/gateways/payu_latam.rb +1 -1
  21. data/lib/active_merchant/billing/gateways/pin.rb +1 -1
  22. data/lib/active_merchant/billing/gateways/quantum.rb +1 -1
  23. data/lib/active_merchant/billing/gateways/realex.rb +1 -1
  24. data/lib/active_merchant/billing/gateways/redsys.rb +1 -1
  25. data/lib/active_merchant/billing/gateways/so_easy_pay.rb +1 -1
  26. data/lib/active_merchant/billing/gateways/stripe_payment_intents.rb +1 -1
  27. data/lib/active_merchant/billing/gateways/transact_pro.rb +2 -2
  28. data/lib/active_merchant/billing/gateways/trexle.rb +1 -1
  29. data/lib/active_merchant/billing/gateways/worldpay.rb +1 -1
  30. data/lib/active_merchant/connection.rb +40 -42
  31. data/lib/active_merchant/network_connection_retries.rb +10 -12
  32. data/lib/active_merchant/version.rb +1 -1
  33. metadata +3 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: df13edc6e4df78bc1172d0d699d41e21c6b9941ade9b2594602009cc4b78de66
4
- data.tar.gz: 18c2f0264c1ae1edc34a6da0bf4c1244aa5135dfa72cef2c67f53cc4ea6c43a5
3
+ metadata.gz: 11b837a742d2fd39e941f6aa861b3c3557fe2ddb6142b2e119c48d22e7b39749
4
+ data.tar.gz: 3aa9e72328ca32c4e84c2919dc61f3b58350d806f49fe2ea342fc9acb19a8056
5
5
  SHA512:
6
- metadata.gz: 1e0359cf05cd83b90ef3621b5c9656011e9361f610b7b0b381ee6af749358f2d597c74aace2a63a18d660a7d1842ca8b509b2a18918a637cc2b2ff2206b378e5
7
- data.tar.gz: eeb3bc4faa2b4f4c25115715c16d520f39b5f8eade99c8dc3091b2347839b9fa9fb785d90bcb0b0851c05282d3bebd2ad4f19b070a1a13f38c43d363d7ea089f
6
+ metadata.gz: c5454b152692725df9ee05bf8cfc202642ca7fb535950996d5c521c76788f0bec214f707596293185fac78d38785ef1a53924f3b99fd38137f09014c4339d92d
7
+ data.tar.gz: d724f10b88a939d856454396e0a1b9a80d975fd40d0fe2db4e8a8c0da7cdc434f4fe8c2117f86e16acb40479295d8ba766a691e6accf059973e6af1359b26387
data/CHANGELOG CHANGED
@@ -2,6 +2,17 @@
2
2
 
3
3
  == HEAD
4
4
 
5
+ == Version 1.108.0 (Jun 9, 2020)
6
+ * Cybersource: Send cavv as xid is xid is missing [pi3r] #3658
7
+ * Forte: Change default sec_code value to PPD [molbrown] #3653
8
+ * Elavon: Add merchant initiated unscheduled field [leila-alderman] #3647
9
+ * Decidir: Add aggregate data fields [leila-alderman] #3648
10
+ * Vantiv: Vantiv(Element): add option to send terminal id in transactions [cdmackeyfree] #3654
11
+ * Update supported Ruby and Rails versions [leila-alderman] #3656
12
+ * CI: Drop unused sudo: false Travis directive [olleolleolle] #3616
13
+ * PayU Latam: Prevent blank country in billing_address [britth] #3657
14
+ * DLocal: Fix address field names [molbrown] #3651
15
+
5
16
  == Version 1.107.4 (Jun 2, 2020)
6
17
  * Elavon: Implement true verify action [leila-alderman] #3610
7
18
  * Vantiv Express: Implement true verify [leila-alderman] #3617
data/README.md CHANGED
@@ -244,4 +244,4 @@ Functionality or APIs that are deprecated will be marked as such. Deprecated fun
244
244
 
245
245
  ## Ruby and Rails compatibility policies
246
246
 
247
- Because Active Merchant is a payment library, it needs to take security seriously. For this reason, Active Merchant guarantees compatibility only with actively supported versions of Ruby and Rails. At the time of this writing, that means that Ruby 2.3+ and Rails 4.2+ are supported.
247
+ Because Active Merchant is a payment library, it needs to take security seriously. For this reason, Active Merchant guarantees compatibility only with actively supported versions of Ruby and Rails. At the time of this writing, that means that Ruby 2.5+ and Rails 5.0+ are supported.
@@ -488,7 +488,7 @@ module ActiveMerchant
488
488
 
489
489
  def add_swipe_data(xml, credit_card)
490
490
  TRACKS.each do |key, regex|
491
- if regex.match(credit_card.track_data)
491
+ if regex.match?(credit_card.track_data)
492
492
  @valid_track_data = true
493
493
  xml.payment do
494
494
  xml.trackData do
@@ -382,9 +382,9 @@ module ActiveMerchant #:nodoc:
382
382
  end
383
383
  elsif message == 'Missing ACCOUNT_ID'
384
384
  message = 'The merchant login ID or password is invalid'
385
- elsif message =~ /Approved/
385
+ elsif /Approved/.match?(message)
386
386
  message = 'This transaction has been approved'
387
- elsif message =~ /Expired/
387
+ elsif /Expired/.match?(message)
388
388
  message = 'The credit card has expired'
389
389
  end
390
390
  message
@@ -204,12 +204,10 @@ module ActiveMerchant #:nodoc:
204
204
 
205
205
  def check_customer_exists(customer_vault_id)
206
206
  commit do
207
- begin
208
- @braintree_gateway.customer.find(customer_vault_id)
209
- ActiveMerchant::Billing::Response.new(true, 'Customer found', {exists: true}, authorization: customer_vault_id)
210
- rescue Braintree::NotFoundError
211
- ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false})
212
- end
207
+ @braintree_gateway.customer.find(customer_vault_id)
208
+ ActiveMerchant::Billing::Response.new(true, 'Customer found', {exists: true}, authorization: customer_vault_id)
209
+ rescue Braintree::NotFoundError
210
+ ActiveMerchant::Billing::Response.new(true, 'Customer not found', {exists: false})
213
211
  end
214
212
  end
215
213
 
@@ -206,7 +206,7 @@ module ActiveMerchant #:nodoc:
206
206
 
207
207
  def generate_signature(body)
208
208
  key = OpenSSL::PKey::RSA.new(@options[:private_key])
209
- hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack('H*').first
209
+ hex = key.sign(OpenSSL::Digest.new('sha256'), body).unpack1('H*')
210
210
 
211
211
  "#{@options[:signing_key]} RS256-hex #{hex}"
212
212
  end
@@ -617,7 +617,10 @@ module ActiveMerchant #:nodoc:
617
617
  xml.tag!('directoryServerTransactionID', threeds_2_options[:ds_transaction_id]) if threeds_2_options[:ds_transaction_id]
618
618
  xml.tag!('commerceIndicator', options[:commerce_indicator] || ECI_BRAND_MAPPING[card_brand(payment_method).to_sym])
619
619
  xml.tag!('eciRaw', threeds_2_options[:eci]) if threeds_2_options[:eci]
620
- xml.tag!('xid', threeds_2_options[:xid]) if threeds_2_options[:xid]
620
+
621
+ xid = threeds_2_options[:xid] || threeds_2_options[:cavv]
622
+ xml.tag!('xid', xid) if xid
623
+
621
624
  xml.tag!('veresEnrolled', threeds_2_options[:enrolled]) if threeds_2_options[:enrolled]
622
625
  xml.tag!('paresStatus', threeds_2_options[:authentication_response_status]) if threeds_2_options[:authentication_response_status]
623
626
  end
@@ -820,6 +823,7 @@ module ActiveMerchant #:nodoc:
820
823
 
821
824
  def add_stored_credential_options(xml, options={})
822
825
  return unless options[:stored_credential]
826
+
823
827
  xml.tag! 'subsequentAuth', 'true' if options[:stored_credential][:initiator] == 'merchant'
824
828
  xml.tag! 'subsequentAuthFirst', 'true' if options[:stored_credential][:initial_transaction]
825
829
  xml.tag! 'subsequentAuthTransactionID', options[:stored_credential][:network_transaction_id] if options[:stored_credential][:initiator] == 'merchant'
@@ -912,7 +916,7 @@ module ActiveMerchant #:nodoc:
912
916
  if node.has_elements?
913
917
  node.elements.each { |e| parse_element(reply, e) }
914
918
  else
915
- if node.parent.name =~ /item/
919
+ if /item/.match?(node.parent.name)
916
920
  parent = node.parent.name
917
921
  parent += '_' + node.parent.attributes['id'] if node.parent.attributes['id']
918
922
  parent += '_'
@@ -118,12 +118,22 @@ module ActiveMerchant #:nodoc:
118
118
  address_object = {}
119
119
  address_object[:state] = address[:state] if address[:state]
120
120
  address_object[:city] = address[:city] if address[:city]
121
- address_object[:zip_code] = address[:zip_code] if address[:zip_code]
122
- address_object[:street] = address[:street] if address[:street]
123
- address_object[:number] = address[:number] if address[:number]
121
+ address_object[:zip_code] = address[:zip] if address[:zip]
122
+ address_object[:street] = address[:street] || parse_street(address) if parse_street(address)
123
+ address_object[:number] = address[:number] || parse_house_number(address) if parse_house_number(address)
124
124
  address_object
125
125
  end
126
126
 
127
+ def parse_street(address)
128
+ street = address[:address1].split(/\s+/).keep_if { |x| x !~ /\d/ }.join(' ')
129
+ street.empty? ? nil : street
130
+ end
131
+
132
+ def parse_house_number(address)
133
+ house = address[:address1].split(/\s+/).keep_if { |x| x =~ /\d/ }.join(' ')
134
+ house.empty? ? nil : house
135
+ end
136
+
127
137
  def add_card(post, card, action, options={})
128
138
  post[:card] = {}
129
139
  post[:card][:holder_name] = card.name
@@ -121,6 +121,7 @@ module ActiveMerchant #:nodoc:
121
121
 
122
122
  add_invoice(post, money, options)
123
123
  add_payment(post, credit_card, options)
124
+ add_aggregate_data(post, options) if options[:aggregate_data]
124
125
  end
125
126
 
126
127
  def add_payment_method_id(credit_card, options)
@@ -180,6 +181,29 @@ module ActiveMerchant #:nodoc:
180
181
  post[:card_data] = card_data
181
182
  end
182
183
 
184
+ def add_aggregate_data(post, options)
185
+ aggregate_data = {}
186
+ data = options[:aggregate_data]
187
+ aggregate_data[:indicator] = data[:indicator] if data[:indicator]
188
+ aggregate_data[:identification_number] = data[:identification_number] if data[:identification_number]
189
+ aggregate_data[:bill_to_pay] = data[:bill_to_pay] if data[:bill_to_pay]
190
+ aggregate_data[:bill_to_refund] = data[:bill_to_refund] if data[:bill_to_refund]
191
+ aggregate_data[:merchant_name] = data[:merchant_name] if data[:merchant_name]
192
+ aggregate_data[:street] = data[:street] if data[:street]
193
+ aggregate_data[:number] = data[:number] if data[:number]
194
+ aggregate_data[:postal_code] = data[:postal_code] if data[:postal_code]
195
+ aggregate_data[:category] = data[:category] if data[:category]
196
+ aggregate_data[:channel] = data[:channel] if data[:channel]
197
+ aggregate_data[:geographic_code] = data[:geographic_code] if data[:geographic_code]
198
+ aggregate_data[:city] = data[:city] if data[:city]
199
+ aggregate_data[:merchant_id] = data[:merchant_id] if data[:merchant_id]
200
+ aggregate_data[:province] = data[:province] if data[:province]
201
+ aggregate_data[:country] = data[:country] if data[:country]
202
+ aggregate_data[:merchant_email] = data[:merchant_email] if data[:merchant_email]
203
+ aggregate_data[:merchant_phone] = data[:merchant_phone] if data[:merchant_phone]
204
+ post[:aggregate_data] = aggregate_data
205
+ end
206
+
183
207
  def add_fraud_detection(options = {})
184
208
  {}.tap do |hsh|
185
209
  hsh[:send_to_cs] = options[:send_to_cs] if valid_fraud_detection_option?(options[:send_to_cs]) # true/false
@@ -48,7 +48,7 @@ module ActiveMerchant #:nodoc:
48
48
  add_customer_data(form, options)
49
49
  add_test_mode(form, options)
50
50
  add_ip(form, options)
51
- add_ssl_dynamic_dba(form, options)
51
+ add_auth_purchase_params(form, options)
52
52
  add_level_3_fields(form, options) if options[:level_3_data]
53
53
  commit(:purchase, money, form, options)
54
54
  end
@@ -63,7 +63,7 @@ module ActiveMerchant #:nodoc:
63
63
  add_customer_data(form, options)
64
64
  add_test_mode(form, options)
65
65
  add_ip(form, options)
66
- add_ssl_dynamic_dba(form, options)
66
+ add_auth_purchase_params(form, options)
67
67
  add_level_3_fields(form, options) if options[:level_3_data]
68
68
  commit(:authorize, money, form, options)
69
69
  end
@@ -257,8 +257,9 @@ module ActiveMerchant #:nodoc:
257
257
  form[:cardholder_ip] = options[:ip] if options.has_key?(:ip)
258
258
  end
259
259
 
260
- def add_ssl_dynamic_dba(form, options)
260
+ def add_auth_purchase_params(form, options)
261
261
  form[:dynamic_dba] = options[:dba] if options.has_key?(:dba)
262
+ form[:merchant_initiated_unscheduled] = options[:merchant_initiated_unscheduled] if options.has_key?(:merchant_initiated_unscheduled)
262
263
  end
263
264
 
264
265
  def add_level_3_fields(form, options)
@@ -193,7 +193,7 @@ module ActiveMerchant #:nodoc:
193
193
 
194
194
  def add_terminal(xml, options)
195
195
  xml.terminal do
196
- xml.TerminalID '01'
196
+ xml.TerminalID options[:terminal_id] || '01'
197
197
  xml.CardPresentCode options[:card_present_code] || 'UseDefault'
198
198
  xml.CardholderPresentCode 'UseDefault'
199
199
  xml.CardInputCode 'UseDefault'
@@ -255,7 +255,7 @@ module ActiveMerchant #:nodoc:
255
255
  (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
256
256
  end
257
257
 
258
- xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci
258
+ xml.tag! 'Ecommerce_Flag', /^[0-9]+$/.match?(eci.to_s) ? eci.to_s.rjust(2, '0') : eci
259
259
  end
260
260
 
261
261
  def add_credit_card_verification_strings(xml, credit_card, options)
@@ -229,7 +229,7 @@ module ActiveMerchant #:nodoc:
229
229
  (credit_card.respond_to?(:eci) ? credit_card.eci : nil) || options[:eci] || DEFAULT_ECI
230
230
  end
231
231
 
232
- xml.tag! 'Ecommerce_Flag', eci.to_s =~ /^[0-9]+$/ ? eci.to_s.rjust(2, '0') : eci
232
+ xml.tag! 'Ecommerce_Flag', /^[0-9]+$/.match?(eci.to_s) ? eci.to_s.rjust(2, '0') : eci
233
233
  end
234
234
 
235
235
  def add_credit_card_verification_strings(xml, credit_card, options)
@@ -166,7 +166,7 @@ module ActiveMerchant #:nodoc:
166
166
  post[:echeck][:routing_number] = payment.routing_number
167
167
  post[:echeck][:account_type] = payment.account_type
168
168
  post[:echeck][:check_number] = payment.number
169
- post[:echeck][:sec_code] = options[:sec_code] || "WEB"
169
+ post[:echeck][:sec_code] = options[:sec_code] || 'PPD'
170
170
  end
171
171
 
172
172
  def add_credit_card(post, payment)
@@ -123,7 +123,7 @@ module ActiveMerchant #:nodoc:
123
123
 
124
124
  success = false
125
125
  authorization = (raw['TransactionId'] || parameters[:transactionId])
126
- if raw[:container] =~ /Exception|Error/
126
+ if /Exception|Error/.match?(raw[:container])
127
127
  message = (raw['Message'] || raw['Error']['Message'])
128
128
  elsif raw['Error'] && !raw['Error'].empty?
129
129
  message = (raw['Error']['ResponseText'] || raw['Error']['ResponseCode'])
@@ -222,7 +222,7 @@ module ActiveMerchant #:nodoc:
222
222
 
223
223
  def get_url(uri)
224
224
  url = (test? ? test_url : live_url)
225
- if uri =~ /^customervault/
225
+ if /^customervault/.match?(uri)
226
226
  "#{url}#{uri}"
227
227
  else
228
228
  "#{url}cardpayments/v1/accounts/#{@options[:account_number]}/#{uri}"
@@ -357,7 +357,7 @@ module ActiveMerchant #:nodoc:
357
357
 
358
358
  success_regex = /^(000\.000\.|000\.100\.1|000\.[36])/
359
359
 
360
- if success_regex =~ response['result']['code']
360
+ if success_regex.match?(response['result']['code'])
361
361
  true
362
362
  else
363
363
  false
@@ -181,7 +181,7 @@ module ActiveMerchant #:nodoc:
181
181
  node.xpath('.//*').each { |e| parse_element(payment_result_response, e) }
182
182
  when node.xpath('.//*').to_a.any?
183
183
  node.xpath('.//*').each { |e| parse_element(response, e) }
184
- when node_name.to_s =~ /amt$/
184
+ when /amt$/.match?(node_name.to_s)
185
185
  # *Amt elements don't put the value in the #text - instead they use a Currency attribute
186
186
  response[node_name] = node.attributes['Currency'].to_s
187
187
  when node_name == :ext_data
@@ -186,7 +186,7 @@ module ActiveMerchant #:nodoc:
186
186
  billing_address[:street2] = address[:address2]
187
187
  billing_address[:city] = address[:city]
188
188
  billing_address[:state] = address[:state]
189
- billing_address[:country] = address[:country]
189
+ billing_address[:country] = address[:country] unless address[:country].blank?
190
190
  billing_address[:postalCode] = address[:zip] if @options[:payment_country] == 'MX'
191
191
  billing_address[:phone] = address[:phone]
192
192
  billing_address
@@ -138,7 +138,7 @@ module ActiveMerchant #:nodoc:
138
138
  name: creditcard.name
139
139
  )
140
140
  elsif creditcard.kind_of?(String)
141
- if creditcard =~ /^card_/
141
+ if /^card_/.match?(creditcard)
142
142
  post[:card_token] = get_card_token(creditcard)
143
143
  else
144
144
  post[:customer_token] = creditcard
@@ -253,7 +253,7 @@ module ActiveMerchant #:nodoc:
253
253
  if node.has_elements?
254
254
  node.elements.each { |e| parse_element(reply, e) }
255
255
  else
256
- if node.parent.name =~ /item/
256
+ if /item/.match?(node.parent.name)
257
257
  parent = node.parent.name + (node.parent.attributes['id'] ? '_' + node.parent.attributes['id'] : '')
258
258
  reply[(parent + '_' + node.name).to_sym] = node.text
259
259
  else
@@ -310,7 +310,7 @@ module ActiveMerchant
310
310
 
311
311
  version = three_d_secure.fetch(:version, '')
312
312
  xml.tag! 'mpi' do
313
- if version =~ /^2/
313
+ if /^2/.match?(version)
314
314
  xml.tag! 'authentication_value', three_d_secure[:cavv]
315
315
  xml.tag! 'ds_trans_id', three_d_secure[:ds_transaction_id]
316
316
  else
@@ -565,7 +565,7 @@ module ActiveMerchant #:nodoc:
565
565
 
566
566
  def clean_order_id(order_id)
567
567
  cleansed = order_id.gsub(/[^\da-zA-Z]/, '')
568
- if cleansed =~ /^\d{4}/
568
+ if /^\d{4}/.match?(cleansed)
569
569
  cleansed[0..11]
570
570
  else
571
571
  '%04d%s' % [rand(0..9999), cleansed[0...8]]
@@ -149,7 +149,7 @@ module ActiveMerchant #:nodoc:
149
149
  def parse(response, action)
150
150
  result = {}
151
151
  document = REXML::Document.new(response)
152
- response_element = document.root.get_elements("//[@xsi:type='tns:#{action}Response']").first
152
+ response_element = document.root.get_elements("//*[@xsi:type='tns:#{action}Response']").first
153
153
  response_element.elements.each do |element|
154
154
  result[element.name.underscore] = element.text
155
155
  end
@@ -121,7 +121,7 @@ module ActiveMerchant #:nodoc:
121
121
 
122
122
  if charge_id.nil?
123
123
  error_message = "No associated charge for #{intent['id']}"
124
- error_message << "; payment_intent has a status of #{intent['status']}" if intent.try(:[], 'status') && intent.try(:[], 'status') != 'succeeded'
124
+ error_message << "; payment_intent has a status of #{intent['status']}" if intent.try(:[], 'status') && intent.try(:[], 'status') != 'succeeded'
125
125
  return Response.new(false, error_message, intent)
126
126
  end
127
127
  else
@@ -162,7 +162,7 @@ module ActiveMerchant #:nodoc:
162
162
  end
163
163
 
164
164
  def parse(body)
165
- if body =~ /^ID:/
165
+ if /^ID:/.match?(body)
166
166
  body.split('~').reduce(Hash.new) { |h, v|
167
167
  m = v.match('(.*?):(.*)')
168
168
  h.merge!(m[1].underscore.to_sym => m[2])
@@ -197,7 +197,7 @@ module ActiveMerchant #:nodoc:
197
197
  end
198
198
 
199
199
  def split_authorization(authorization)
200
- if authorization =~ /|/
200
+ if /|/.match?(authorization)
201
201
  identifier, amount = authorization.split('|')
202
202
  [identifier, amount.to_i]
203
203
  else
@@ -137,7 +137,7 @@ module ActiveMerchant #:nodoc:
137
137
  name: creditcard.name
138
138
  )
139
139
  elsif creditcard.kind_of?(String)
140
- if creditcard =~ /^token_/
140
+ if /^token_/.match?(creditcard)
141
141
  post[:card_token] = creditcard
142
142
  else
143
143
  post[:customer_token] = creditcard
@@ -406,7 +406,7 @@ module ActiveMerchant #:nodoc:
406
406
  def add_three_d_secure(three_d_secure, xml)
407
407
  xml.info3DSecure do
408
408
  xml.threeDSVersion three_d_secure[:version]
409
- if three_d_secure[:version] =~ /^2/
409
+ if /^2/.match?(three_d_secure[:version])
410
410
  xml.dsTransactionId three_d_secure[:ds_transaction_id]
411
411
  else
412
412
  xml.xid three_d_secure[:xid]
@@ -73,52 +73,50 @@ module ActiveMerchant
73
73
  headers['connection'] ||= 'close'
74
74
 
75
75
  retry_exceptions(max_retries: max_retries, logger: logger, tag: tag) do
76
- begin
77
- info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag
78
-
79
- result = nil
80
-
81
- realtime = Benchmark.realtime do
82
- http.start unless http.started?
83
- @ssl_connection = http.ssl_connection
84
- info "connection_ssl_version=#{ssl_connection[:version]} connection_ssl_cipher=#{ssl_connection[:cipher]}", tag
85
-
86
- result =
87
- case method
88
- when :get
89
- raise ArgumentError, 'GET requests do not support a request body' if body
90
-
91
- http.get(endpoint.request_uri, headers)
92
- when :post
76
+ info "connection_http_method=#{method.to_s.upcase} connection_uri=#{endpoint}", tag
77
+
78
+ result = nil
79
+
80
+ realtime = Benchmark.realtime do
81
+ http.start unless http.started?
82
+ @ssl_connection = http.ssl_connection
83
+ info "connection_ssl_version=#{ssl_connection[:version]} connection_ssl_cipher=#{ssl_connection[:cipher]}", tag
84
+
85
+ result =
86
+ case method
87
+ when :get
88
+ raise ArgumentError, 'GET requests do not support a request body' if body
89
+
90
+ http.get(endpoint.request_uri, headers)
91
+ when :post
92
+ debug body
93
+ http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
94
+ when :put
95
+ debug body
96
+ http.put(endpoint.request_uri, body, headers)
97
+ when :patch
98
+ debug body
99
+ http.patch(endpoint.request_uri, body, headers)
100
+ when :delete
101
+ # It's kind of ambiguous whether the RFC allows bodies
102
+ # for DELETE requests. But Net::HTTP's delete method
103
+ # very unambiguously does not.
104
+ if body
93
105
  debug body
94
- http.post(endpoint.request_uri, body, RUBY_184_POST_HEADERS.merge(headers))
95
- when :put
96
- debug body
97
- http.put(endpoint.request_uri, body, headers)
98
- when :patch
99
- debug body
100
- http.patch(endpoint.request_uri, body, headers)
101
- when :delete
102
- # It's kind of ambiguous whether the RFC allows bodies
103
- # for DELETE requests. But Net::HTTP's delete method
104
- # very unambiguously does not.
105
- if body
106
- debug body
107
- req = Net::HTTP::Delete.new(endpoint.request_uri, headers)
108
- req.body = body
109
- http.request(req)
110
- else
111
- http.delete(endpoint.request_uri, headers)
112
- end
106
+ req = Net::HTTP::Delete.new(endpoint.request_uri, headers)
107
+ req.body = body
108
+ http.request(req)
113
109
  else
114
- raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
110
+ http.delete(endpoint.request_uri, headers)
115
111
  end
116
- end
117
-
118
- info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
119
- debug result.body
120
- result
112
+ else
113
+ raise ArgumentError, "Unsupported request method #{method.to_s.upcase}"
114
+ end
121
115
  end
116
+
117
+ info '--> %d %s (%d %.4fs)' % [result.code, result.message, result.body ? result.body.length : 0, realtime], tag
118
+ debug result.body
119
+ result
122
120
  end
123
121
  ensure
124
122
  info 'connection_request_total_time=%.4fs' % [Process.clock_gettime(Process::CLOCK_MONOTONIC) - request_start], tag
@@ -21,18 +21,16 @@ module ActiveMerchant
21
21
  connection_errors = DEFAULT_CONNECTION_ERRORS.merge(options[:connection_exceptions] || {})
22
22
 
23
23
  retry_network_exceptions(options) do
24
- begin
25
- yield
26
- rescue Errno::ECONNREFUSED => e
27
- raise ActiveMerchant::RetriableConnectionError.new('The remote server refused the connection', e)
28
- rescue OpenSSL::X509::CertificateError => e
29
- NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag])
30
- raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate'
31
- rescue Zlib::BufError
32
- raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response'
33
- rescue *connection_errors.keys => e
34
- raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e)
35
- end
24
+ yield
25
+ rescue Errno::ECONNREFUSED => e
26
+ raise ActiveMerchant::RetriableConnectionError.new('The remote server refused the connection', e)
27
+ rescue OpenSSL::X509::CertificateError => e
28
+ NetworkConnectionRetries.log(options[:logger], :error, e.message, options[:tag])
29
+ raise ActiveMerchant::ClientCertificateError, 'The remote server did not accept the provided SSL certificate'
30
+ rescue Zlib::BufError
31
+ raise ActiveMerchant::InvalidResponseError, 'The remote server replied with an invalid response'
32
+ rescue *connection_errors.keys => e
33
+ raise ActiveMerchant::ConnectionError.new(derived_error_message(connection_errors, e.class), e)
36
34
  end
37
35
  end
38
36
 
@@ -1,3 +1,3 @@
1
1
  module ActiveMerchant
2
- VERSION = '1.107.4'
2
+ VERSION = '1.108.0'
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: activemerchant
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.107.4
4
+ version: 1.108.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tobias Luetke
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-06-02 00:00:00.000000000 Z
11
+ date: 2020-06-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport
@@ -422,7 +422,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
422
422
  requirements:
423
423
  - - ">="
424
424
  - !ruby/object:Gem::Version
425
- version: '2.3'
425
+ version: '2.5'
426
426
  required_rubygems_version: !ruby/object:Gem::Requirement
427
427
  requirements:
428
428
  - - ">="