Skip to content

Commit f23dcdf

Browse files
jillingkColin RoodrkewlaniAlexandrosMorcyattilakiss
authored
Live URL fix for checkout/terminal (#140) (#141)
* add fix for bad live url checkout * removed the terminal part as the base url already contains everything * Update spec/checkout_spec.rb --------- Co-authored-by: Colin Rood <[email protected]> Co-authored-by: Rajni Kewlani <[email protected]> Co-authored-by: Alexandros Moraitis <[email protected]> Co-authored-by: Attila Kiss <[email protected]> Co-authored-by: Ángel Campos <[email protected]> Co-authored-by: Wouter Boereboom <[email protected]>
1 parent 5f5233c commit f23dcdf

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

lib/adyen/client.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,11 @@ def service_url_base(service)
8383

8484
# construct full URL from service and endpoint
8585
def service_url(service, action, version)
86-
"#{service_url_base(service)}/v#{version}/#{action}"
86+
if service == "Checkout" && @env == :live
87+
return "#{service_url_base(service)}/checkout/v#{version}/#{action}"
88+
else
89+
return "#{service_url_base(service)}/v#{version}/#{action}"
90+
end
8791
end
8892

8993
# send request to adyen API

spec/checkout_spec.rb

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,6 +632,23 @@
632632
).to have_been_made.once
633633
end
634634

635+
# must be created manually because every field in the response is an array
636+
it "makes a LIVE paymentMethods call" do
637+
request_body = JSON.parse(json_from_file("mocks/requests/Checkout/payment_methods.json"))
638+
639+
response_body = json_from_file("mocks/responses/Checkout/payment_methods.json")
640+
641+
adyen = Adyen::Client.new
642+
adyen.api_key = 'AF5XXXXXXXXXXXXXXXXXXXX'
643+
adyen.env = :live
644+
adyen.live_url_prefix = "prefix"
645+
url = adyen.service_url("Checkout", "paymentMethods", @shared_values[:client].checkout.version)
646+
647+
expect(url).
648+
to eq("https://prefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods")
649+
650+
end
651+
635652
end
636653

637654
# rubocop:enable Metrics/BlockLength

spec/client_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@
133133
it "checks the creation of checkout url" do
134134
client = Adyen::Client.new(api_key: "api_key", env: :live, live_url_prefix: "YourLiveUrlPrefix")
135135
expect(client.service_url("Checkout", "paymentMethods", "70")).
136-
to eq("https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/v70/paymentMethods")
136+
to eq("https://YourLiveUrlPrefix-checkout-live.adyenpayments.com/checkout/v70/paymentMethods")
137137
end
138138
it "checks the creation of lem url" do
139139
client = Adyen::Client.new(api_key: "api_key", env: :live)

0 commit comments

Comments
 (0)