From 9614001ad0361c2e06508bea2b3a3bb749bf720c Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 07:33:02 +0000 Subject: [PATCH 1/2] Initial plan From 9109f3c48645528b4d171bd1fb6e923afa1a0392 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Fri, 13 Mar 2026 07:36:40 +0000 Subject: [PATCH 2/2] Fix Client#initialize to use setter methods for env and live_url_prefix validation Co-authored-by: gcatanese <1771700+gcatanese@users.noreply.github.com> --- lib/adyen/client.rb | 8 +++++--- spec/client_spec.rb | 16 ++++++++++++++++ 2 files changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/adyen/client.rb b/lib/adyen/client.rb index e3545c6f..493edccd 100644 --- a/lib/adyen/client.rb +++ b/lib/adyen/client.rb @@ -22,7 +22,7 @@ def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, e @ws_password = ws_password @api_key = api_key @oauth_token = oauth_token - @env = env + self.env = env @application_name = application_name @adapter = adapter || Faraday.default_adapter if Gem::Version.new(Faraday::VERSION) >= Gem::Version.new('2.1') @@ -33,7 +33,7 @@ def initialize(ws_user: nil, ws_password: nil, api_key: nil, oauth_token: nil, e @adapter_options = adapter_options || {} end @mock_service_url_base = mock_service_url_base || "http://localhost:#{mock_port}" - @live_url_prefix = live_url_prefix + self.live_url_prefix = live_url_prefix if RUBY_VERSION >= '3.2' # set default timeouts @connection_options = connection_options || Faraday::ConnectionOptions.new( @@ -60,7 +60,9 @@ def env=(value) # remove 'https' from live_url_prefix if necessary def live_url_prefix=(value) - value['https://'] = '' unless value['https://'].nil? + unless value.nil? + value['https://'] = '' unless value['https://'].nil? + end @live_url_prefix = value end diff --git a/spec/client_spec.rb b/spec/client_spec.rb index 433766b3..830e54b8 100644 --- a/spec/client_spec.rb +++ b/spec/client_spec.rb @@ -18,6 +18,22 @@ .to eq(:test) end + it 'raises ArgumentError when initialized with an invalid env string' do + expect { Adyen::Client.new(env: 'live') } + .to raise_error(ArgumentError) + end + + it 'raises ArgumentError when initialized with an invalid env value' do + expect { Adyen::Client.new(env: :invalid) } + .to raise_error(ArgumentError) + end + + it 'strips https:// from live_url_prefix when passed via constructor' do + client = Adyen::Client.new(env: :live, live_url_prefix: 'https://myprefix') + expect(client.service_url_base('Payment')) + .to eq('https://myprefix-pal-live.adyenpayments.com/pal/servlet/Payment') + end + it 'sets the version number' do @shared_values[:client].checkout.version = @shared_values[:version] expect(@shared_values[:client].checkout.version)