fonepay-js
v1.0.4
Published
A fonepay payement gateway manager.
Readme
fonepay-js
A fonepay payment gateway manager without merchant keys.
This package allows you to manage Fonepay payments without needing a merchant key or secret. Instead, it uses your merchant dashboard credentials to automate dynamic QR code generation with callbacks, mimicking the merchant API. This approach also helps in removing the cost or fee paid per transaction using the merchant API. This package doesn't store or send credentials anywhere; it stays locally where used.
Installation
npm install fonepay-jsUsage
const Fonepay = require('fonepay-js');
// Store username & password in .env
const fonepay = new Fonepay({
username: 'your-username',
password: 'your-password',
});
// Login once at first
await fonepay.login()
// Generate QR Code and listen for payment confirmation
fonepay.createTransaction({
amount: '100',
billId: 'bill-123',
// callback fn that runs after payment is successfull
onSuccess: (paymentSuccess)=>{
console.log(paymentSuccess)
}
}).then(transaction => {
console.log('Transaction:', transaction);
}).catch(error => {
console.error('Error:', error);
});
// Generate QR Code
fonepay.generateQr({
amount: '100',
billId: 'bill-123',
}).then(qrData => {
console.log('QR Data:', qrData);
}).catch(error => {
console.error('Error:', error);
});
Testing
npm test