Skip to content

Commit

Permalink
Revert "Normalize API versions"
Browse files Browse the repository at this point in the history
This reverts commit a8311f2.
  • Loading branch information
Buitragox committed Dec 12, 2024
1 parent a8311f2 commit e09bf17
Show file tree
Hide file tree
Showing 19 changed files with 15 additions and 152 deletions.
1 change: 0 additions & 1 deletion CHANGELOG
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,6 @@
* Worldpay: Fix stored credentials unscheduled reason type [Buitragox] #5352
* Worldpay: Worldpay: Idempotency key fix [jherreraa] #5359
* Hi Pay: Don't add 3ds when :three_ds_2 is missing [Buitragox] #5355
* Normalize API versions [Buitragox] #5319

== Version 1.137.0 (August 2, 2024)
* Unlock dependency on `rexml` to allow fixing a CVE (#5181).
Expand Down
1 change: 0 additions & 1 deletion lib/active_merchant/billing.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require 'active_merchant/errors'
require 'active_merchant/versionable'

require 'active_merchant/billing/avs_result'
require 'active_merchant/billing/cvv_result'
Expand Down
3 changes: 0 additions & 3 deletions lib/active_merchant/billing/gateway.rb
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ module Billing # :nodoc:
class Gateway
include PostsData
include CreditCardFormatting
include Versionable

CREDIT_DEPRECATION_MESSAGE = 'Support for using credit to refund existing transactions is deprecated and will be removed from a future release of ActiveMerchant. Please use the refund method instead.'
RECURRING_DEPRECATION_MESSAGE = 'Recurring functionality in ActiveMerchant is deprecated and will be removed in a future version. Please contact the ActiveMerchant maintainers if you have an interest in taking ownership of a separate gem that continues support for it.'
Expand Down Expand Up @@ -144,8 +143,6 @@ def generate_unique_id
class_attribute :application_id, instance_writer: false
self.application_id = nil

self.versions = {}

attr_reader :options

# Use this method to check if your gateway of interest supports a credit card of some type
Expand Down
11 changes: 5 additions & 6 deletions lib/active_merchant/billing/gateways/adyen.rb
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,8 @@ class AdyenGateway < Gateway
self.homepage_url = 'https://www.adyen.com/'
self.display_name = 'Adyen'

version 'v68', :payment_api
version 'v68', :payout_api
version 'v68', :recurring_api
PAYMENT_API_VERSION = 'v68'
RECURRING_API_VERSION = 'v68'

STANDARD_ERROR_CODE_MAPPING = {
'0' => STANDARD_ERROR_CODE[:processing_error],
Expand Down Expand Up @@ -871,11 +870,11 @@ def cvv_result_from(response)
def endpoint(action)
case action
when 'disable', 'storeToken'
"Recurring/#{fetch_version(:recurring_api)}/#{action}"
"Recurring/#{RECURRING_API_VERSION}/#{action}"
when 'payout'
"Payout/#{fetch_version(:payout_api)}/#{action}"
"Payout/#{PAYMENT_API_VERSION}/#{action}"
else
"Payment/#{fetch_version(:payment_api)}/#{action}"
"Payment/#{PAYMENT_API_VERSION}/#{action}"
end
end

Expand Down
10 changes: 5 additions & 5 deletions lib/active_merchant/billing/gateways/barclaycard_smartpay.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ class BarclaycardSmartpayGateway < Gateway
self.homepage_url = 'https://www.barclaycardsmartpay.com/'
self.display_name = 'Barclaycard Smartpay'

version 'v40'
API_VERSION = 'v40'

def initialize(options = {})
requires!(options, :company, :merchant, :password)
Expand Down Expand Up @@ -257,13 +257,13 @@ def success_from(response)
def build_url(action)
case action
when 'store'
"#{test? ? self.test_url : self.live_url}/Recurring/#{fetch_version}/storeToken"
"#{test? ? self.test_url : self.live_url}/Recurring/#{API_VERSION}/storeToken"
when 'finalize3ds'
"#{test? ? self.test_url : self.live_url}/Payment/#{fetch_version}/authorise3d"
"#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/authorise3d"
when 'storeDetailAndSubmitThirdParty', 'confirmThirdParty'
"#{test? ? self.test_url : self.live_url}/Payout/#{fetch_version}/#{action}"
"#{test? ? self.test_url : self.live_url}/Payout/#{API_VERSION}/#{action}"
else
"#{test? ? self.test_url : self.live_url}/Payment/#{fetch_version}/#{action}"
"#{test? ? self.test_url : self.live_url}/Payment/#{API_VERSION}/#{action}"
end
end

Expand Down
3 changes: 0 additions & 3 deletions lib/active_merchant/billing/gateways/braintree_blue.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,6 @@ class BraintreeBlueGateway < Gateway

self.display_name = 'Braintree (Blue Platform)'

version Braintree::Configuration::API_VERSION
version Braintree::Version::String, :gem

ERROR_CODES = {
cannot_refund_if_unsettled: 91506
}
Expand Down
6 changes: 2 additions & 4 deletions lib/active_merchant/billing/gateways/fat_zebra.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,8 @@
module ActiveMerchant # :nodoc:
module Billing # :nodoc:
class FatZebraGateway < Gateway
version 'v1.0'

self.live_url = "https://gateway.fatzebra.com.au/#{fetch_version}"
self.test_url = "https://gateway.sandbox.fatzebra.com.au/#{fetch_version}"
self.live_url = 'https://gateway.fatzebra.com.au/v1.0'
self.test_url = 'https://gateway.sandbox.fatzebra.com.au/v1.0'

self.supported_countries = ['AU']
self.default_currency = 'AUD'
Expand Down
6 changes: 2 additions & 4 deletions lib/active_merchant/billing/gateways/forte.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,8 @@ module Billing # :nodoc:
class ForteGateway < Gateway
include Empty

version 'v2'

self.test_url = "https://sandbox.forte.net/api/#{fetch_version}"
self.live_url = "https://api.forte.net/#{fetch_version}"
self.test_url = 'https://sandbox.forte.net/api/v2'
self.live_url = 'https://api.forte.net/v2'

self.supported_countries = ['US']
self.default_currency = 'USD'
Expand Down
5 changes: 1 addition & 4 deletions lib/active_merchant/billing/gateways/global_collect.rb
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ class GlobalCollectGateway < Gateway
self.money_format = :cents
self.supported_cardtypes = %i[visa master american_express discover naranja cabal tuya patagonia_365]

version 'v1'
version 'v2', :ogone_direct

def initialize(options = {})
requires!(options, :merchant_id, :api_key_id, :secret_api_key)
super
Expand Down Expand Up @@ -446,7 +443,7 @@ def ogone_direct?
end

def uri(action, authorization)
version = ogone_direct? ? fetch_version(:ogone_direct) : fetch_version
version = ogone_direct? ? 'v2' : 'v1'
uri = "/#{version}/#{@options[:merchant_id]}/"
case action
when :authorize, :verify
Expand Down
2 changes: 0 additions & 2 deletions lib/active_merchant/billing/gateways/hps.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ class HpsGateway < Gateway
google_pay: 'GooglePayApp'
}

version 'v3'

def initialize(options = {})
requires!(options, :secret_api_key)
super
Expand Down
24 changes: 0 additions & 24 deletions lib/active_merchant/versionable.rb

This file was deleted.

6 changes: 0 additions & 6 deletions test/unit/gateways/adyen_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -144,12 +144,6 @@ def setup
# assert response
# assert_success response
# end
def test_endpoint
assert_equal 'Recurring/v68/disable', @gateway.send(:endpoint, 'disable')
assert_equal 'Recurring/v68/storeToken', @gateway.send(:endpoint, 'storeToken')
assert_equal 'Payout/v68/payout', @gateway.send(:endpoint, 'payout')
assert_equal 'Payment/v68/authorise', @gateway.send(:endpoint, 'authorise')
end

def test_supported_card_types
assert_equal AdyenGateway.supported_cardtypes, %i[visa master american_express diners_club jcb dankort maestro discover elo naranja cabal unionpay patagonia_365]
Expand Down
8 changes: 0 additions & 8 deletions test/unit/gateways/barclaycard_smartpay_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -127,14 +127,6 @@ def setup
}
end

def test_build_url
assert_equal "#{@gateway.test_url}/Recurring/v40/storeToken", @gateway.send(:build_url, 'store')
assert_equal "#{@gateway.test_url}/Payment/v40/authorise3d", @gateway.send(:build_url, 'finalize3ds')
assert_equal "#{@gateway.test_url}/Payout/v40/storeDetailAndSubmitThirdParty", @gateway.send(:build_url, 'storeDetailAndSubmitThirdParty')
assert_equal "#{@gateway.test_url}/Payout/v40/confirmThirdParty", @gateway.send(:build_url, 'confirmThirdParty')
assert_equal "#{@gateway.test_url}/Payment/v40/authorise", @gateway.send(:build_url, 'authorise')
end

def test_successful_purchase
response = stub_comms do
@gateway.purchase(@amount, @credit_card, @options)
Expand Down
4 changes: 0 additions & 4 deletions test/unit/gateways/braintree_blue_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ def teardown
$VERBOSE = @old_verbose
end

def test_api_version
assert_equal '6', @gateway.fetch_version
end

def test_refund_legacy_method_signature
Braintree::TransactionGateway.any_instance.expects(:refund).
with('transaction_id', nil).
Expand Down
5 changes: 0 additions & 5 deletions test/unit/gateways/fat_zebra_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,6 @@ def setup
}
end

def test_url
assert_equal 'https://gateway.fatzebra.com.au/v1.0', @gateway.live_url
assert_equal 'https://gateway.sandbox.fatzebra.com.au/v1.0', @gateway.test_url
end

def test_successful_purchase
@gateway.expects(:ssl_request).returns(successful_purchase_response)

Expand Down
5 changes: 0 additions & 5 deletions test/unit/gateways/forte_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,6 @@ def setup
}
end

def test_url
assert_equal 'https://api.forte.net/v2', @gateway.live_url
assert_equal 'https://sandbox.forte.net/api/v2', @gateway.test_url
end

def test_successful_purchase
response = stub_comms(@gateway, :raw_ssl_request) do
@gateway.purchase(@amount, @credit_card, @options)
Expand Down
22 changes: 0 additions & 22 deletions test/unit/gateways/global_collect_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,6 @@ def setup
)
end

def test_url
url = @gateway.test? ? @gateway.test_url : @gateway.live_url
merchant_id = @gateway.options[:merchant_id]
assert_equal "#{url}/v1/#{merchant_id}/payments", @gateway.send(:url, :authorize, nil)
assert_equal "#{url}/v1/#{merchant_id}/payments", @gateway.send(:url, :verify, nil)
assert_equal "#{url}/v1/#{merchant_id}/payments/0000/approve", @gateway.send(:url, :capture, '0000')
assert_equal "#{url}/v1/#{merchant_id}/payments/0000/refund", @gateway.send(:url, :refund, '0000')
assert_equal "#{url}/v1/#{merchant_id}/payments/0000/cancel", @gateway.send(:url, :void, '0000')
assert_equal "#{url}/v1/#{merchant_id}/payments/0000", @gateway.send(:url, :inquire, '0000')
end

def test_ogone_url
url = @gateway_direct.test? ? @gateway_direct.ogone_direct_test : @gateway_direct.ogone_direct_live
merchant_id = @gateway_direct.options[:merchant_id]
assert_equal "#{url}/v2/#{merchant_id}/payments", @gateway_direct.send(:url, :authorize, nil)
assert_equal "#{url}/v2/#{merchant_id}/payments", @gateway_direct.send(:url, :verify, nil)
assert_equal "#{url}/v2/#{merchant_id}/payments/0000/capture", @gateway_direct.send(:url, :capture, '0000')
assert_equal "#{url}/v2/#{merchant_id}/payments/0000/refund", @gateway_direct.send(:url, :refund, '0000')
assert_equal "#{url}/v2/#{merchant_id}/payments/0000/cancel", @gateway_direct.send(:url, :void, '0000')
assert_equal "#{url}/v2/#{merchant_id}/payments/0000", @gateway_direct.send(:url, :inquire, '0000')
end

def test_supported_card_types
assert_equal GlobalCollectGateway.supported_cardtypes, %i[visa master american_express discover naranja cabal tuya patagonia_365]
end
Expand Down
4 changes: 0 additions & 4 deletions test/unit/gateways/hps_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ def setup
}
end

def test_api_version
assert_equal 'v3', @gateway.fetch_version
end

def test_successful_purchase
@gateway.expects(:ssl_post).returns(successful_charge_response)

Expand Down
41 changes: 0 additions & 41 deletions test/unit/versionable_test.rb

This file was deleted.

0 comments on commit e09bf17

Please sign in to comment.