diff --git a/lib/adyen/services/payment.rb b/lib/adyen/services/payment.rb index 9dd096c..28b55f6 100644 --- a/lib/adyen/services/payment.rb +++ b/lib/adyen/services/payment.rb @@ -18,11 +18,11 @@ def initialize(client, version = DEFAULT_VERSION) end def modifications_api - @modifications_api ||= Adyen::ModificationsApi.new(@client, @version) + @modifications_api ||= Adyen::ClassicModificationsApi.new(@client, @version) end def payments_api - @payments_api ||= Adyen::PaymentsApi.new(@client, @version) + @payments_api ||= Adyen::ClassicPaymentsApi.new(@client, @version) end end diff --git a/lib/adyen/services/payment/modifications_api.rb b/lib/adyen/services/payment/modifications_api.rb index 7283937..88e95c3 100644 --- a/lib/adyen/services/payment/modifications_api.rb +++ b/lib/adyen/services/payment/modifications_api.rb @@ -5,7 +5,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class ModificationsApi < Service + class ClassicModificationsApi < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) diff --git a/lib/adyen/services/payment/payments_api.rb b/lib/adyen/services/payment/payments_api.rb index 94f762a..e50d032 100644 --- a/lib/adyen/services/payment/payments_api.rb +++ b/lib/adyen/services/payment/payments_api.rb @@ -5,7 +5,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class PaymentsApi < Service + class ClassicPaymentsApi < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION) diff --git a/spec/checkout_spec.rb b/spec/checkout_spec.rb index 2c0e673..a9a688a 100644 --- a/spec/checkout_spec.rb +++ b/spec/checkout_spec.rb @@ -8,6 +8,19 @@ service: 'Checkout' } end + + it 'uses the correct PaymentsApi for the Checkout service' do + # Load both API files to ensure there's no conflict after the fix. + load File.expand_path('../lib/adyen/services/payment/payments_api.rb', __dir__) + load File.expand_path('../lib/adyen/services/checkout/payments_api.rb', __dir__) + + checkout = Adyen::Checkout.new(@shared_values[:client]) + payments_api = checkout.payments_api + + # Verify that the Checkout facade uses the correct PaymentsApi class. + expect(payments_api.class.name).to eq('Adyen::PaymentsApi') + expect(payments_api.service).to eq('Checkout') + end # must be created manually because every field in the response is an array it 'makes a payment_methods call' do diff --git a/templates/api-single.mustache b/templates/api-single.mustache index 8d53518..9fc9447 100644 --- a/templates/api-single.mustache +++ b/templates/api-single.mustache @@ -23,7 +23,7 @@ module Adyen {{#apiInfo}} {{#apis}} def {{classFilename}} - @{{classFilename}} ||= Adyen::{{classname}}.new(@client, @version) + @{{classFilename}} ||= Adyen::{{classicPrefix}}{{classname}}.new(@client, @version) end {{/apis}} diff --git a/templates/api.mustache b/templates/api.mustache index 25a091c..4bde74d 100644 --- a/templates/api.mustache +++ b/templates/api.mustache @@ -6,7 +6,7 @@ module Adyen # Ref: https://openapi-generator.tech # # Do not edit the class manually. - class {{classname}} < Service + class {{classicPrefix}}{{classname}} < Service attr_accessor :service, :version def initialize(client, version = DEFAULT_VERSION)