-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathtest.js
35 lines (31 loc) · 1011 Bytes
/
test.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
const Chapa = require('./lib/chapa')
let myChapa = new Chapa('secret-key')
const customerInfo = {
amount: '100',
currency: 'ETB',
email: '[email protected]',
first_name: 'Abebe',
last_name: 'Bikila',
// tx_ref: 'tx-x12345',
callback_url: 'https://chapa.co', // your callback URL
customization: {
title: 'I love e-commerce',
description: 'It is time to pay'
}
}
myChapa.initialize(customerInfo, { autoRef: true }).then(response => {
/*
response:
{
message: 'Hosted Link',
status: 'success' || 'failed',
data: {
checkout_url: 'https://checkout.chapa.co/checkout/payment/:token'
},
tx_ref: 'generated-token' // this will be the auto generated reference
}
*/
console.log(response)
// saveReference(response.tx_ref)
}).catch(e => console.log(e)) // catch errors
// myChapa.verify('5b1472b1-4b28-475c-8fa9-8bf2242fea9f').then(d => console.log(d)).catch(e => console.log(e))