-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
42 lines (37 loc) · 1.13 KB
/
index.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
/**
* PayEx: Payment gateway
* ##CreditCard checkout flow
*
*/
const PayExOrder = require('./src/order');
const SETTINGS= {
TEST_URL: 'https://external.externaltest.payex.com/',
LIVE_URL: 'https://external.payex.com',
};
const PayEx = {
initialize_payex: (config) => {
let validated = {};
if(config.account_number){
validated.account_number = config.account_number;
}else{
throw 'account_number missing in config!';
}
if(config.encryption_key){
validated.encryption_key = config.encryption_key;
}else{
throw 'encryption_key missing in config!';
}
validated.default_currency = config.default_currency ? config.default_currency : 'SEK';
validated.base_url = config.environment === 'production' ? SETTINGS.LIVE_URL : SETTINGS.TEST_URL;
return validated;
},
initialize_transaction: (config, params) => {
config = PayEx.initialize_payex(config);
return PayExOrder.Initialize(config, params);
},
complete_transactions: (config, params) => {
config = PayEx.initialize_payex(config);
return PayExOrder.Complete(config, params);
}
};
module.exports = PayEx;