Skip to content

Commit 2072754

Browse files
committed
Correct PosSdk live url
1 parent de7b496 commit 2072754

File tree

2 files changed

+55
-6
lines changed

2 files changed

+55
-6
lines changed

src/Adyen/Service.php

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,12 +135,21 @@ public function createBaseUrl(string $url): string
135135
);
136136
}
137137

138-
// We inject the live prefix like "https://{PREFIX}-"
139-
$url = str_replace(
140-
"https://checkout-test.adyen.com/",
141-
"https://" . $config->get('prefix') . '-checkout-live.adyenpayments.com/checkout/',
142-
$url
143-
);
138+
if (strpos($url, "possdk") !== false) {
139+
// PosSdk (PosMobileApi): inject the live prefix like "https://{PREFIX}-" without duplicating `/checkout` in path
140+
$url = str_replace(
141+
"https://checkout-test.adyen.com/",
142+
"https://" . $config->get('prefix') . '-checkout-live.adyenpayments.com/',
143+
$url
144+
);
145+
} else {
146+
// Other services: inject the live prefix like "https://{PREFIX}-"
147+
$url = str_replace(
148+
"https://checkout-test.adyen.com/",
149+
"https://" . $config->get('prefix') . '-checkout-live.adyenpayments.com/checkout/',
150+
$url
151+
);
152+
}
144153
}
145154

146155
// Replace 'test' in string with 'live' for the other endpoints

tests/Unit/ServiceTest.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,44 @@ public function testLiveURLPrefixOther()
5757
$url = $service->createBaseUrl("https://kyc-test.adyen.com/lem/v3/legalEntities");
5858
self::assertEquals("https://kyc-live.adyen.com/lem/v3/legalEntities", $url);
5959
}
60+
61+
// test PosMobileApi LIVE url with prefix
62+
public function testLiveURLPosSdkWithPrefix()
63+
{
64+
$client = new Client();
65+
$client->setEnvironment(Environment::LIVE, "myCompany");
66+
$service = new Service($client);
67+
$url = $service->createBaseUrl("https://checkout-test.adyen.com/checkout/possdk/v68");
68+
self::assertEquals(
69+
"https://myCompany-checkout-live.adyenpayments.com/checkout/possdk/v68",
70+
$url
71+
);
72+
}
73+
74+
// test PosMobileApi TEST url without prefx
75+
public function testTestURLPosSdk()
76+
{
77+
$client = new Client();
78+
$client->setEnvironment(Environment::TEST);
79+
$service = new Service($client);
80+
$url = $service->createBaseUrl("https://checkout-test.adyen.com/checkout/possdk/v68");
81+
self::assertEquals(
82+
"https://checkout-test.adyen.com/checkout/possdk/v68",
83+
$url
84+
);
85+
}
86+
87+
// test PosMobileApi TEST url with prefix
88+
public function testTestURLPosSdkWithPrefix()
89+
{
90+
$client = new Client();
91+
$client->setEnvironment(Environment::TEST, "myCompany");
92+
$service = new Service($client);
93+
$url = $service->createBaseUrl("https://checkout-test.adyen.com/checkout/possdk/v68");
94+
// check prefix is ignored on TEST
95+
self::assertEquals(
96+
"https://checkout-test.adyen.com/checkout/possdk/v68",
97+
$url
98+
);
99+
}
60100
}

0 commit comments

Comments
 (0)