Skip to content

Commit 46be2eb

Browse files
committed
fix: Correct possdk live endpoint construction
The live endpoint for possdk was being constructed incorrectly, with an extra /checkout segment in the URL path. This was causing 'Resource not found' errors when using the AdyenPosMobileApi in the live environment. This commit fixes the endpoint construction by removing the extra /checkout segment for possdk endpoints. It also adds a unit test to verify the correct behavior.
1 parent 2aa4c17 commit 46be2eb

File tree

2 files changed

+17
-2
lines changed

2 files changed

+17
-2
lines changed

Adyen/client.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,8 +145,13 @@ def _determine_api_url(self, platform, endpoint):
145145
error_string = "Please set your live suffix. You can set it by running " \
146146
"adyen.client.live_endpoint_prefix = 'Your live suffix'"
147147
raise AdyenEndpointInvalidFormat(error_string)
148-
endpoint = endpoint.replace("https://checkout-test.adyen.com/",
149-
"https://" + self.live_endpoint_prefix + "-checkout-live.adyenpayments.com/checkout/")
148+
149+
if "possdk" in endpoint:
150+
endpoint = endpoint.replace("https://checkout-test.adyen.com/",
151+
"https://" + self.live_endpoint_prefix + "-checkout-live.adyenpayments.com/")
152+
else:
153+
endpoint = endpoint.replace("https://checkout-test.adyen.com/",
154+
"https://" + self.live_endpoint_prefix + "-checkout-live.adyenpayments.com/checkout/")
150155

151156
endpoint = endpoint.replace("-test", "-live")
152157

test/DetermineEndpointTest.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import Adyen
22
from Adyen import settings
33
import unittest
4+
from Adyen.services.posMobile import AdyenPosMobileApi
45

56
try:
67
from BaseTest import BaseTest
@@ -28,6 +29,15 @@ def test_checkout_api_url_custom(self):
2829
url = self.adyen.client._determine_api_url("live", self.checkout_url + "/payments")
2930
self.assertEqual("https://1797a841fbb37ca7-AdyenDemo-checkout-"
3031
f"live.adyenpayments.com/checkout/{self.checkout_version}/payments", url)
32+
33+
def test_pos_mobile_api_url_live(self):
34+
self.client.live_endpoint_prefix = "1797a841fbb37ca7-AdyenDemo"
35+
pos_mobile_api = AdyenPosMobileApi(self.client)
36+
pos_mobile_url = pos_mobile_api.baseUrl
37+
pos_mobile_version = pos_mobile_url.split('/')[-1]
38+
url = self.adyen.client._determine_api_url("live", pos_mobile_url + "/sessions")
39+
self.assertEqual("https://1797a841fbb37ca7-AdyenDemo-checkout-"
40+
f"live.adyenpayments.com/checkout/possdk/{pos_mobile_version}/sessions", url)
3141

3242
def test_checkout_api_url(self):
3343
self.client.live_endpoint_prefix = None

0 commit comments

Comments
 (0)