-
Notifications
You must be signed in to change notification settings - Fork 54
/
Copy pathclient.js
44 lines (33 loc) · 1002 Bytes
/
client.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Initialise TerminalCloudAPI client
//
const dotenv = require("dotenv");
const { Client, Config, TerminalCloudAPI } = require("@adyen/api-library");
// enables environment variables by
// parsing the .env file and assigning it to process.env
dotenv.config({
path: "./.env",
});
var terminalCloudAPIClient;
const getClient = () => {
return terminalCloudAPIClient;
}
function client_init() {
if(process.env.ADYEN_API_KEY === undefined) {
throw new Error("ADYEN_API_KEY undefined");
}
if(process.env.ADYEN_HMAC_KEY === undefined) {
throw new Error("ADYEN_HMAC_KEY undefined");
}
if(process.env.ADYEN_POS_POI_ID === undefined) {
throw new Error("ADYEN_POS_POI_ID undefined");
}
const config = new Config({
apiKey: process.env.ADYEN_API_KEY,
environment: "TEST" // change to LIVE for production
});
const client = new Client({ config });
terminalCloudAPIClient = new TerminalCloudAPI(client);
}
client_init();
module.exports = { getClient }