Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 6 additions & 8 deletions src/main/java/com/adyen/Service.java
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ protected String createBaseURL(String url) {
}

if (url.contains("/authe/")) {
return url.replaceFirst("https://test.adyen.com/", "https://authe-live.adyen.com/");
return url.replace("https://test.adyen.com/", "https://authe-live.adyen.com/");
}

if (url.contains("pal-")) {
if (config.getLiveEndpointUrlPrefix() == null) {
throw new IllegalArgumentException("please provide a live url prefix in the client");
}
url =
url.replaceFirst(
url.replace(
"https://pal-test.adyen.com/pal/servlet/",
Comment thread
jeandersonbc marked this conversation as resolved.
"https://"
+ config.getLiveEndpointUrlPrefix()
Expand All @@ -113,14 +113,14 @@ protected String createBaseURL(String url) {
if (url.contains("/possdk/")) {
// Custom handling of POS Mobile API url
url =
url.replaceFirst(
url.replace(
"https://checkout-test.adyen.com/",
"https://"
+ config.getLiveEndpointUrlPrefix()
+ "-checkout-live.adyenpayments.com/");
} else {
url =
url.replaceFirst(
url.replace(
"https://checkout-test.adyen.com/",
"https://"
+ config.getLiveEndpointUrlPrefix()
Expand All @@ -131,12 +131,10 @@ protected String createBaseURL(String url) {
if (url.contains("device-api-")) {
if (config.getTerminalApiRegion() == null
|| config.getTerminalApiRegion().equals(Region.EU)) {
url =
url.replaceFirst(
"https://device-api-test.adyen.com", "https://device-api-live.adyen.com");
url = url.replace("https://device-api-test.adyen.com", "https://device-api-live.adyen.com");
} else {
url =
url.replaceFirst(
url.replace(
"https://device-api-test.adyen.com",
String.format(
"https://device-api-live-%s.adyen.com",
Expand Down
15 changes: 15 additions & 0 deletions src/test/java/com/adyen/ServiceTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,21 @@ public void testLivePalUrlWithPrefix() {
assertEquals(expectedUrl, actualUrl);
}

@Test
public void testLivePalUrlOnlyMatchesLiteralDots() {
config.setLiveEndpointUrlPrefix("123456789-company");
// This URL matches pal-test.adyen.com structurally but has non-dot separators.
// The old replaceFirst() would have incorrectly matched it (dots as wildcards).
// String.replace() does exact literal matching so the pal- block leaves it unchanged.
// The final fallback still converts -test to -live as expected.
String urlWithNonDots = "https://pal-testXadyenYcom/pal/servlet/v52/initiate";
String expectedUrl = "https://pal-liveXadyenYcom/pal/servlet/v52/initiate";

String actualUrl = service.createBaseURL(urlWithNonDots);

assertEquals(expectedUrl, actualUrl);
}
Comment thread
jeandersonbc marked this conversation as resolved.

@Test
public void testLivePalUrlWithoutPrefix() {
String testUrl = "https://pal-test.adyen.com/pal/servlet/v52/initiate";
Expand Down