forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathrecurring_payment.js
More file actions
43 lines (36 loc) · 1.44 KB
/
Copy pathrecurring_payment.js
File metadata and controls
43 lines (36 loc) · 1.44 KB
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
const x = require('../xendit');
const RecurringPayment = x.RecurringPayment;
const rp = new RecurringPayment({});
(async function() {
try {
const payment = await rp.createPayment({
externalID: '123',
payerEmail: 'stanley@xendit.co',
description: 'Payment for something',
amount: 10000,
interval: RecurringPayment.Interval.Month,
intervalCount: 1,
});
// eslint-disable-next-line no-console
console.log('recurring payment created:', payment);
const { id } = payment;
const retrievedPayment = await rp.getPayment({ id });
// eslint-disable-next-line no-console
console.log('recurring payment details:', retrievedPayment);
const editedPayment = await rp.editPayment({ id, amount: 20000 });
// eslint-disable-next-line no-console
console.log('recurring payment updated:', editedPayment.id);
const pausedPayment = await rp.pausePayment({ id });
// eslint-disable-next-line no-console
console.log('recurring payment paused:', pausedPayment.id);
const resumedPayment = await rp.resumePayment({ id });
// eslint-disable-next-line no-console
console.log('recurring payment resumed:', resumedPayment.id);
const stoppedPayment = await rp.stopPayment({ id });
// eslint-disable-next-line no-console
console.log('recurring payment stopped:', stoppedPayment.id);
} catch (e) {
console.error(e); // eslint-disable-line no-console
process.exit(1);
}
})();