From 3108f479d1517951f3460643e3da4bcc3953d94b Mon Sep 17 00:00:00 2001 From: beppe Date: Tue, 28 Oct 2025 15:21:49 +0100 Subject: [PATCH] Fix SessionAuthentication base url --- src/__tests__/service.spec.ts | 29 ++++++++++++++++++++++++++++- src/service.ts | 4 ++++ 2 files changed, 32 insertions(+), 1 deletion(-) diff --git a/src/__tests__/service.spec.ts b/src/__tests__/service.spec.ts index 670d04ac5..31a828008 100644 --- a/src/__tests__/service.spec.ts +++ b/src/__tests__/service.spec.ts @@ -131,4 +131,31 @@ describe("Service", () => { const url = "https://some-test.adyen.com/api/"; expect(service.testCreateBaseUrl(url)).toBe("https://some-live.adyen.com/api/"); }); -}); \ No newline at end of file + + it("should build TEST url for SessionAuthentication", () => { + const config = new Config({ + apiKey: "test_key", + environment: EnvironmentEnum.TEST, + liveEndpointUrlPrefix: "mycompany" + }); + client = new Client(config); + + const service = new TestService(client); + const url = "https://test.adyen.com/authe/api/v1"; + expect(service.testCreateBaseUrl(url)).toBe("https://test.adyen.com/authe/api/v1"); + }); + + it("should build LIVE url for SessionAuthentication", () => { + const config = new Config({ + apiKey: "test_key", + environment: EnvironmentEnum.LIVE, + liveEndpointUrlPrefix: "mycompany" + }); + client = new Client(config); + + const service = new TestService(client); + const url = "https://test.adyen.com/authe/api/v1"; + expect(service.testCreateBaseUrl(url)).toBe("https://authe-live.adyen.com/authe/api/v1"); + }); + +}); \ No newline at end of file diff --git a/src/service.ts b/src/service.ts index 2aad6c4f6..d78d85623 100644 --- a/src/service.ts +++ b/src/service.ts @@ -58,6 +58,10 @@ class Service { } } + if (url.includes("/authe/")) { + return url.replace("https://test.adyen.com/", "https://authe-live.adyen.com/"); + } + if (url.includes("pal-")) { return url.replace("https://pal-test.adyen.com/pal/servlet/", `https://${this.client.config.liveEndpointUrlPrefix}-pal-live.adyenpayments.com/pal/servlet/`);