Unofficial Promise based Chapa API library for node js
$ npm install chapa
Usage
constChapa=require('chapa')letmyChapa=newChapa('secret-key')constcustomerInfo={amount: '100',currency: 'ETB',email: 'abebe@bikila.com',first_name: 'Abebe',last_name: 'Bikila',// tx_ref: 'tx-x12345', // if autoRef is set in the options we dont't need to provide reference, instead it will generate it for uscallback_url: 'https://chapa.co',// your callback URLcustomization: {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// async/awaitletresponse=awaitmyChapa.initialize(customerInfo,{autoRef: true})myChapa.verify('txn-reference').then(response=>{console.log(response)// if success}).catch(e=>console.log(e))// catch errors// async/awaitletresponse=awaitmyChapa.verify('txn-reference')