forked from xendit/xendit-node
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayment_method_v2.js
More file actions
48 lines (42 loc) · 1.46 KB
/
Copy pathpayment_method_v2.js
File metadata and controls
48 lines (42 loc) · 1.46 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
44
45
46
47
48
const x = require('../xendit');
const { PaymentMethodV2 } = x;
const pm = new PaymentMethodV2({});
(async function() {
try {
let createdPaymentMethod = await pm.createPaymentMethodV2({
type: 'DIRECT_DEBIT',
reusability: 'ONE_TIME_USE',
customer_id: '16f72571-9b3a-43dc-b241-5b71f470202f',
country: 'ID',
direct_debit: {
channel_code: 'BRI',
channel_properties: {
mobile_number: '+6281299640904',
card_last_four: '8888',
card_expiry: '10/29',
email: 'dharma@xendit.co',
},
},
});
// eslint-disable-next-line no-console
console.log('created payment method', createdPaymentMethod);
const paymentMethodDetailsById = await pm.getPaymentMethodByIdV2({
id: createdPaymentMethod.id,
});
// eslint-disable-next-line no-console
console.log('retrieved payment method', paymentMethodDetailsById);
const listOfPaymentMethod = await pm.listPaymentMethodV2({});
// eslint-disable-next-line no-console
console.log('retrieved payment method list', listOfPaymentMethod);
const authorizedPaymentMethod = await pm.authorizePaymentMethodV2({
id: createdPaymentMethod.id,
auth_code: '333000',
});
// eslint-disable-next-line no-console
console.log('authorized payment method', authorizedPaymentMethod);
process.exit(0);
} catch (e) {
console.error(e); // eslint-disable-line no-console
process.exit(1);
}
})();