-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEwallet.js
75 lines (62 loc) · 1.72 KB
/
Ewallet.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
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//ovo ewallet payment
const Xendit = require('xendit-node')
const readline = require('readline')
const { secretKey } = require('./general/general')
const payment = new Xendit({
secretKey: secretKey
})
const { EWallet } = payment
const ewallet = new EWallet({})
const read = readline.createInterface({
input: process.stdin,
output: process.stdout
})
let phone
let amount
const inputs = []
console.log('Put in amount, phone number9')
read.prompt()
read.on('line', data => {
inputs.push(data)
}).on('close', async () => {
amount = inputs[0]
phone = inputs[1]
// const data = {
// externalID: `sample-external-id-${Date.now().toString()}`,
// amount,
// phone,
// ewalletType: EWallet.Type.OVO,
// callbackUrl: 'https://www.google.com'
// }
console.log('-----Data to be requested-----')
console.log('sample-external-id-1606190341227')
// const response = await createEwalletPayment(data)
const response = await getEwalletPaymentData({
externalID: 'sample-external-id-1606190341227',
ewalletType: EWallet.Type.OVO
})
console.log(response)
process.exit(0)
})
async function createEwalletPayment(ewalletData){
return new Promise((resolve, reject) => {
ewallet.createPayment(ewalletData)
.then(res => {
resolve(res)
}).catch(err => {
console.log(err)
reject(err)
})
})
}
async function getEwalletPaymentData(data){
return new Promise((resolve, reject) => {
ewallet.getPayment(data)
.then(res => {
resolve(res)
})
.catch(err => {
reject(err)
})
})
}