forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinvoice.js
42 lines (36 loc) · 1.18 KB
/
invoice.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
const x = require('../xendit');
const { Invoice } = x;
const i = new Invoice({});
(async function() {
try {
let invoice = await i.createInvoice({
externalID: Date.now().toString(),
payerEmail: '[email protected]',
description: 'Invoice for Shoes Purchase',
amount: 100000,
customer: {
given_names: 'xen customer',
email: '[email protected]',
},
customerNotificationPreference: {
invoice_created: ['email'],
},
});
console.log('created invoice', invoice); // eslint-disable-line no-console
const retrievedInvoice = await i.getInvoice({ invoiceID: invoice.id });
// eslint-disable-next-line no-console
console.log('retrieved invoice', retrievedInvoice);
const expiredInvoice = await i.expireInvoice({
invoiceID: retrievedInvoice.id,
});
// eslint-disable-next-line no-console
console.log('expired invoice', expiredInvoice);
const invoices = await i.getAllInvoices();
// eslint-disable-next-line no-console
console.log('first 10 invoices', invoices);
process.exit(0);
} catch (e) {
console.error(e); // eslint-disable-line no-console
process.exit(1);
}
})();