forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
disbursement.js
47 lines (40 loc) · 1.5 KB
/
disbursement.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
45
46
47
const x = require('../xendit');
const { Disbursement } = x;
const d = new Disbursement({});
(async function() {
try {
const banks = await d.getBanks();
console.log('available banks:', banks); // eslint-disable-line no-console
const disbursements = banks.slice(0, 5).map(b => ({
externalID: `${b.name} - ${b.code}`,
bankCode: b.code,
accountHolderName: 'Stan',
accountNumber: '1234567890',
description: `purchase paid from ${b.name}`,
amount: 10000,
}));
const batch = await d.createBatch({ reference: '111', disbursements });
console.log('batch created:', batch); // eslint-disable-line no-console
let disb = await d.create({
externalID: `${banks[0].name} - ${banks[0].code} single disbursement`,
bankCode: banks[0].code,
accountHolderName: 'Stan',
accountNumber: '1234567890',
description: `purchase paid from ${banks[0].name}`,
amount: 10000,
forUserID: 'for-user-id-test',
});
// eslint-disable-next-line no-console
console.log('disbursement created:', disb);
disb = await d.getByID({ disbursementID: disb.id });
// eslint-disable-next-line no-console
console.log('disbursement retrieved from ID:', disb);
disb = await d.getByExtID({ externalID: disb.external_id });
// eslint-disable-next-line no-console
console.log('disbursement retrieved from extID:', disb);
process.exit(0);
} catch (e) {
console.error(e); // eslint-disable-line no-console
process.exit(1);
}
})();