Skip to content

Commit

Permalink
Update required Ruby version
Browse files Browse the repository at this point in the history
Updated required Ruby version to be 2.7 and Rubocop to 0.72.0.

All unit tests and rubocop:
5532 tests, 77501 assertions, 0 failures, 0 errors, 0 pendings, 0 omissions, 0 notifications
100% passed
  • Loading branch information
Alma Malambo committed Jul 19, 2023
1 parent 8dd0d54 commit da2c539
Show file tree
Hide file tree
Showing 185 changed files with 1,958 additions and 1,163 deletions.
2 changes: 0 additions & 2 deletions .github/workflows/ruby-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,6 @@ jobs:
strategy:
matrix:
version:
- 2.5
- 2.6
- 2.7
gemfile:
- gemfiles/Gemfile.rails50
Expand Down
4 changes: 2 additions & 2 deletions .rubocop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ AllCops:
- "lib/active_merchant/billing/gateways/paypal_express.rb"
- "vendor/**/*"
ExtraDetails: false
TargetRubyVersion: 2.5
TargetRubyVersion: 2.7

# Active Merchant gateways are not amenable to length restrictions
Metrics/ClassLength:
Expand All @@ -33,7 +33,7 @@ Layout/DotPosition:
Layout/CaseIndentation:
EnforcedStyle: end

Layout/IndentHash:
Layout/IndentFirstHashElement:
EnforcedStyle: consistent

Naming/PredicateName:
Expand Down
2 changes: 1 addition & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ source 'https://rubygems.org'
gemspec

gem 'jruby-openssl', platforms: :jruby
gem 'rubocop', '~> 0.62.0', require: false
gem 'rubocop', '~> 0.72.0', require: false

group :test, :remote_test do
# gateway-specific dependencies, keeping these gems out of the gemspec
Expand Down
2 changes: 1 addition & 1 deletion activemerchant.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ Gem::Specification.new do |s|
s.email = 'tobi@leetsoft.com'
s.homepage = 'http://activemerchant.org/'

s.required_ruby_version = '>= 2.5'
s.required_ruby_version = '>= 2.7'

s.files = Dir['CHANGELOG', 'README.md', 'MIT-LICENSE', 'CONTRIBUTORS', 'lib/**/*', 'vendor/**/*']
s.require_path = 'lib'
Expand Down
2 changes: 1 addition & 1 deletion circle.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
machine:
ruby:
version: '2.5.0'
version: '2.7.0'

dependencies:
cache_directories:
Expand Down
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/check.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ module Billing #:nodoc:
# You may use Check in place of CreditCard with any gateway that supports it.
class Check < Model
attr_accessor :first_name, :last_name,
:bank_name, :routing_number, :account_number,
:account_holder_type, :account_type, :number
:bank_name, :routing_number, :account_number,
:account_holder_type, :account_type, :number

# Used for Canadian bank accounts
attr_accessor :institution_number, :transit_number
Expand Down
4 changes: 3 additions & 1 deletion lib/active_merchant/billing/gateways/airwallex.rb
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,9 @@ def setup_access_token

def build_request_url(action, id = nil)
base_url = (test? ? test_url : live_url)
base_url + ENDPOINTS[action].to_s % { id: id }
endpoint = ENDPOINTS[action].to_s
endpoint = id.present? ? endpoint % { id: id } : endpoint
base_url + endpoint
end

def add_referrer_data(post)
Expand Down
4 changes: 2 additions & 2 deletions lib/active_merchant/billing/gateways/alelo.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,9 +144,9 @@ def ensure_credentials(try_again = true)
access_token: access_token,
multiresp: multiresp.responses.present? ? multiresp : nil
}
rescue ResponseError => error
rescue ResponseError => e
# retry to generate a new access_token when the provided one is expired
raise error unless try_again && %w(401 404).include?(error.response.code) && @options[:access_token].present?
raise e unless try_again && %w(401 404).include?(e.response.code) && @options[:access_token].present?

@options.delete(:access_token)
@options.delete(:encryption_key)
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/authorize_net_arb.rb
Original file line number Diff line number Diff line change
Expand Up @@ -393,9 +393,13 @@ def recurring_commit(action, request)
test_mode = test? || message =~ /Test Mode/
success = response[:result_code] == 'Ok'

Response.new(success, message, response,
Response.new(
success,
message,
response,
test: test_mode,
authorization: response[:subscription_id])
authorization: response[:subscription_id]
)
end

def recurring_parse(action, xml)
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/axcessms.rb
Original file line number Diff line number Diff line change
Expand Up @@ -71,9 +71,13 @@ def commit(paymentcode, money, payment, options)
message = "#{response[:reason]} - #{response[:return]}"
authorization = response[:unique_id]

Response.new(success, message, response,
Response.new(
success,
message,
response,
authorization: authorization,
test: (response[:mode] != 'LIVE'))
test: (response[:mode] != 'LIVE')
)
end

def parse(body)
Expand Down
6 changes: 4 additions & 2 deletions lib/active_merchant/billing/gateways/banwire.rb
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,13 @@ def commit(money, parameters)
response = json_error(raw_response)
end

Response.new(success?(response),
Response.new(
success?(response),
response['message'],
response,
test: test?,
authorization: response['code_auth'])
authorization: response['code_auth']
)
end

def success?(response)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -413,11 +413,15 @@ def recurring_commit(params)
def post(data, use_profile_api = nil)
response = parse(ssl_post((use_profile_api ? SECURE_PROFILE_URL : self.live_url), data))
response[:customer_vault_id] = response[:customerCode] if response[:customerCode]
build_response(success?(response), message_from(response), response,
build_response(
success?(response),
message_from(response),
response,
test: test? || response[:authCode] == 'TEST',
authorization: authorization_from(response),
cvv_result: CVD_CODES[response[:cvdId]],
avs_result: { code: AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] })
avs_result: { code: AVS_CODES.include?(response[:avsId]) ? AVS_CODES[response[:avsId]] : response[:avsId] }
)
end

def recurring_post(data)
Expand Down
16 changes: 12 additions & 4 deletions lib/active_merchant/billing/gateways/blue_pay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -344,9 +344,13 @@ def parse_recurring(response_fields, opts = {}) # expected status?
success = parsed[:status] != 'error'
message = parsed[:status]

Response.new(success, message, parsed,
Response.new(
success,
message,
parsed,
test: test?,
authorization: parsed[:rebill_id])
authorization: parsed[:rebill_id]
)
end

def parse(body)
Expand All @@ -364,11 +368,15 @@ def parse(body)
# normalize message
message = message_from(parsed)
success = parsed[:response_code] == '1'
Response.new(success, message, parsed,
Response.new(
success,
message,
parsed,
test: test?,
authorization: (parsed[:rebid] && parsed[:rebid] != '' ? parsed[:rebid] : parsed[:transaction_id]),
avs_result: { code: parsed[:avs_result_code] },
cvv_result: parsed[:card_code])
cvv_result: parsed[:card_code]
)
end

def message_from(parsed)
Expand Down
31 changes: 21 additions & 10 deletions lib/active_merchant/billing/gateways/braintree_blue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -193,15 +193,20 @@ def update(vault_id, creditcard, options = {})
}
}, options)[:credit_card]

result = @braintree_gateway.customer.update(vault_id,
result = @braintree_gateway.customer.update(
vault_id,
first_name: creditcard.first_name,
last_name: creditcard.last_name,
email: scrub_email(options[:email]),
phone: phone_from(options),
credit_card: credit_card_params)
Response.new(result.success?, message_from_result(result),
credit_card: credit_card_params
)
Response.new(
result.success?,
message_from_result(result),
braintree_customer: (customer_hash(@braintree_gateway.customer.find(vault_id), :include_credit_cards) if result.success?),
customer_vault_id: (result.customer.id if result.success?))
customer_vault_id: (result.customer.id if result.success?)
)
end
end

Expand Down Expand Up @@ -271,13 +276,16 @@ def add_customer_with_credit_card(creditcard, options)
device_data: options[:device_data]
}.merge credit_card_params
result = @braintree_gateway.customer.create(merge_credit_card_options(parameters, options))
Response.new(result.success?, message_from_result(result),
Response.new(
result.success?,
message_from_result(result),
{
braintree_customer: (customer_hash(result.customer, :include_credit_cards) if result.success?),
customer_vault_id: (result.customer.id if result.success?),
credit_card_token: (result.customer.credit_cards[0].token if result.success?)
},
authorization: (result.customer.id if result.success?))
authorization: (result.customer.id if result.success?)
)
end
end

Expand Down Expand Up @@ -371,8 +379,8 @@ def map_address(address)

def commit(&block)
yield
rescue Braintree::BraintreeError => ex
Response.new(false, ex.class.to_s)
rescue Braintree::BraintreeError => e
Response.new(false, e.class.to_s)
end

def message_from_result(result)
Expand Down Expand Up @@ -901,13 +909,16 @@ def add_bank_account_to_customer(payment_method, options)
message = message_from_result(result)
message = not_verified_reason(result.payment_method) unless verified

Response.new(verified, message,
Response.new(
verified,
message,
{
customer_vault_id: options[:customer],
bank_account_token: result.payment_method&.token,
verified: verified
},
authorization: result.payment_method&.token)
authorization: result.payment_method&.token
)
end

def not_verified_reason(bank_account)
Expand Down
7 changes: 5 additions & 2 deletions lib/active_merchant/billing/gateways/card_connect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -146,9 +146,12 @@ def store(payment, options = {})

def unstore(authorization, options = {})
account_id, profile_id = authorization.split('|')
commit('profile', {},
commit(
'profile',
{},
verb: :delete,
path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}")
path: "/#{profile_id}/#{account_id}/#{@options[:merchant_id]}"
)
end

def supports_scrubbing?
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/cyber_source.rb
Original file line number Diff line number Diff line change
Expand Up @@ -1055,12 +1055,16 @@ def commit(request, action, amount, options)

message = auto_void?(authorization_from(response, action, amount, options), response, message, options)

Response.new(success, message, response,
Response.new(
success,
message,
response,
test: test?,
authorization: authorization,
fraud_review: in_fraud_review?(response),
avs_result: { code: response[:avsCode] },
cvv_result: response[:cvCode])
cvv_result: response[:cvCode]
)
end

def auto_void?(authorization, response, message, options = {})
Expand Down
38 changes: 21 additions & 17 deletions lib/active_merchant/billing/gateways/data_cash.rb
Original file line number Diff line number Diff line change
Expand Up @@ -235,23 +235,23 @@ def add_credit_card(xml, credit_card, address)
# a predefined one
xml.tag! :ExtendedPolicy do
xml.tag! :cv2_policy,
notprovided: POLICY_REJECT,
notchecked: POLICY_REJECT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_REJECT
notprovided: POLICY_REJECT,
notchecked: POLICY_REJECT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_REJECT
xml.tag! :postcode_policy,
notprovided: POLICY_ACCEPT,
notchecked: POLICY_ACCEPT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_ACCEPT
notprovided: POLICY_ACCEPT,
notchecked: POLICY_ACCEPT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_ACCEPT
xml.tag! :address_policy,
notprovided: POLICY_ACCEPT,
notchecked: POLICY_ACCEPT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_ACCEPT
notprovided: POLICY_ACCEPT,
notchecked: POLICY_ACCEPT,
matched: POLICY_ACCEPT,
notmatched: POLICY_REJECT,
partialmatch: POLICY_ACCEPT
end
end
end
Expand All @@ -260,9 +260,13 @@ def add_credit_card(xml, credit_card, address)
def commit(request)
response = parse(ssl_post(test? ? self.test_url : self.live_url, request))

Response.new(response[:status] == '1', response[:reason], response,
Response.new(
response[:status] == '1',
response[:reason],
response,
test: test?,
authorization: "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}")
authorization: "#{response[:datacash_reference]};#{response[:authcode]};#{response[:ca_reference]}"
)
end

def format_date(month, year)
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/efsnet.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,15 @@ def add_creditcard(post, creditcard)
def commit(action, parameters)
response = parse(ssl_post(test? ? self.test_url : self.live_url, post_data(action, parameters), 'Content-Type' => 'text/xml'))

Response.new(success?(response), message_from(response[:result_message]), response,
Response.new(
success?(response),
message_from(response[:result_message]),
response,
test: test?,
authorization: authorization_from(response, parameters),
avs_result: { code: response[:avs_response_code] },
cvv_result: response[:cvv_response_code])
cvv_result: response[:cvv_response_code]
)
end

def success?(response)
Expand Down
1 change: 0 additions & 1 deletion lib/active_merchant/billing/gateways/element.rb
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,6 @@ def build_soap_request
xml['soap'].Envelope('xmlns:xsi' => 'http://www.w3.org/2001/XMLSchema-instance',
'xmlns:xsd' => 'http://www.w3.org/2001/XMLSchema',
'xmlns:soap' => 'http://schemas.xmlsoap.org/soap/envelope/') do

xml['soap'].Body do
yield(xml)
end
Expand Down
8 changes: 6 additions & 2 deletions lib/active_merchant/billing/gateways/epay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -174,17 +174,21 @@ def commit(action, params)
response = send("do_#{action}", params)

if action == :authorize
Response.new response['accept'].to_i == 1,
Response.new(
response['accept'].to_i == 1,
response['errortext'],
response,
test: test?,
authorization: response['tid']
)
else
Response.new response['result'] == 'true',
Response.new(
response['result'] == 'true',
messages(response['epay'], response['pbs']),
response,
test: test?,
authorization: params[:transaction]
)
end
end

Expand Down
Loading

0 comments on commit da2c539

Please sign in to comment.