1
+
2
+ // Test endpoint for Terminal API
3
+ export const TERMINAL_API_ENDPOINT_TEST = "https://terminal-api-test.adyen.com" ;
4
+
5
+ // Live endpoints for Terminal API
6
+ const TERMINAL_API_ENDPOINT_LIVE = "https://terminal-api-live.adyen.com" ;
7
+ const TERMINAL_API_ENDPOINT_AU_LIVE = "https://terminal-api-au.adyen.com" ;
8
+ const TERMINAL_API_ENDPOINT_US_LIVE = "https://terminal-api-us.adyen.com" ;
9
+ const TERMINAL_API_ENDPOINT_APSE_LIVE = "https://terminal-api-apse.adyen.com" ;
10
+
11
+ /**
12
+ * Supported Regions for Terminal API integration.
13
+ */
14
+ export enum RegionEnum {
15
+ EU = "EU" ,
16
+ AU = "AU" ,
17
+ US = "US" ,
18
+ APSE = "APSE"
19
+ }
20
+
21
+ // Terminal API Endpoints Map
22
+ export const TERMINAL_API_ENDPOINTS_MAP : Record < RegionEnum , string > = {
23
+ [ RegionEnum . EU ] : TERMINAL_API_ENDPOINT_LIVE ,
24
+ [ RegionEnum . AU ] : TERMINAL_API_ENDPOINT_AU_LIVE ,
25
+ [ RegionEnum . US ] : TERMINAL_API_ENDPOINT_US_LIVE ,
26
+ [ RegionEnum . APSE ] : TERMINAL_API_ENDPOINT_APSE_LIVE
27
+ }
28
+
29
+
1
30
interface ConfigConstructor {
2
31
username ?: string ;
3
32
password ?: string ;
@@ -9,11 +38,14 @@ interface ConfigConstructor {
9
38
certificatePath ?: string ;
10
39
terminalApiCloudEndpoint ?: string ;
11
40
terminalApiLocalEndpoint ?: string ;
41
+ liveEndpointUrlPrefix ?: string ; // must be provided for LIVE integration
42
+ region ?: RegionEnum ; // must be provided for Terminal API integration
12
43
}
13
44
14
45
const DEFAULT_TIMEOUT = 30000 ; // Default timeout value (30 sec)
15
46
16
47
class Config {
48
+
17
49
public username ?: string ;
18
50
public password ?: string ;
19
51
public environment ?: Environment ;
@@ -24,7 +56,8 @@ class Config {
24
56
public certificatePath ?: string ;
25
57
public terminalApiCloudEndpoint ?: string ;
26
58
public terminalApiLocalEndpoint ?: string ;
27
-
59
+ public liveEndpointUrlPrefix ?: string ;
60
+ public region ?: RegionEnum ;
28
61
29
62
public constructor ( options : ConfigConstructor = { } ) {
30
63
if ( options . username ) this . username = options . username ;
@@ -38,7 +71,29 @@ class Config {
38
71
if ( options . certificatePath ) this . certificatePath = options . certificatePath ;
39
72
if ( options . terminalApiCloudEndpoint ) this . terminalApiCloudEndpoint = options . terminalApiCloudEndpoint ;
40
73
if ( options . terminalApiLocalEndpoint ) this . terminalApiLocalEndpoint = options . terminalApiLocalEndpoint ;
74
+ if ( options . liveEndpointUrlPrefix ) this . liveEndpointUrlPrefix = options . liveEndpointUrlPrefix ;
75
+ if ( options . region ) this . region = options . region ;
76
+ }
77
+
78
+ /**
79
+ * Checks if the provided region is a valid supported.
80
+ * @param region - The region to validate.
81
+ * @returns true if the region exists in RegionEnum, false otherwise.
82
+ */
83
+ public static isRegionValid ( region : RegionEnum ) : boolean {
84
+ return Object . values ( RegionEnum ) . includes ( region ) ;
41
85
}
86
+
87
+ /**
88
+ * Returns the Terminal API endpoint for the given region.
89
+ * If the region is not valid, returns the EU endpoint.
90
+ * @param region - The region to get the endpoint for.
91
+ * @returns The Terminal API endpoint URL.
92
+ */
93
+ public static getTerminalApiEndpoint ( region : RegionEnum ) : string {
94
+ return TERMINAL_API_ENDPOINTS_MAP [ region ] || TERMINAL_API_ENDPOINTS_MAP [ RegionEnum . EU ] ;
95
+ }
96
+
42
97
}
43
98
44
99
export default Config ;
0 commit comments