Skip to content

Commit c40a083

Browse files
committed
Refactor Service to use Config object
1 parent 5d0ad15 commit c40a083

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/service.ts

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,28 +36,34 @@ class Service {
3636
return url.replace("-live", "-test");
3737
}
3838

39+
if(config.environment === "LIVE") {
40+
if(config.liveEndpointUrlPrefix === undefined || config.liveEndpointUrlPrefix === "") {
41+
throw new Error("Live endpoint URL prefix must be provided for LIVE environment.");
42+
}
43+
}
44+
3945
if (url.includes("pal-")) {
40-
if (this.client.liveEndpointUrlPrefix === "")
46+
if (this.client.config.liveEndpointUrlPrefix === "")
4147
{
4248
throw new Error("Please provide your unique live url prefix on the setEnvironment() call on the Client.");
4349
}
4450
return url.replace("https://pal-test.adyen.com/pal/servlet/",
45-
`https://${this.client.liveEndpointUrlPrefix}-pal-live.adyenpayments.com/pal/servlet/`);
51+
`https://${this.client.config.liveEndpointUrlPrefix}-pal-live.adyenpayments.com/pal/servlet/`);
4652
}
4753

4854
if (url.includes("checkout-")) {
49-
if (this.client.liveEndpointUrlPrefix === "")
55+
if (this.client.config.liveEndpointUrlPrefix === "")
5056
{
5157
throw new Error("Please provide your unique live url prefix on the setEnvironment() call on the Client.");
5258
}
5359

5460
if (url.includes("/possdk/v68")) {
5561
return url.replace("https://checkout-test.adyen.com/",
56-
`https://${this.client.liveEndpointUrlPrefix}-checkout-live.adyenpayments.com/`);
62+
`https://${this.client.config.liveEndpointUrlPrefix}-checkout-live.adyenpayments.com/`);
5763
}
5864

5965
return url.replace("https://checkout-test.adyen.com/",
60-
`https://${this.client.liveEndpointUrlPrefix}-checkout-live.adyenpayments.com/checkout/`);
66+
`https://${this.client.config.liveEndpointUrlPrefix}-checkout-live.adyenpayments.com/checkout/`);
6167
}
6268

6369
return url.replace("-test", "-live");

0 commit comments

Comments
 (0)