The Node library provides easy access to Flutterwave for Business (F4B) v3 APIs for your Node apps. It abstracts the complexity involved in direct integration and allows you to make quick calls to the APIs.
Available features include:
- Collections: Card, Account, Mobile money, Bank Transfers, USSD, Barter, NQR.
- Payouts and Beneficiaries.
- Recurring payments: Tokenization and Subscriptions.
- Split payments
- Card issuing
- Transactions dispute management: Refunds and Chargebacks.
- Transaction reporting: Collections, Payouts, Settlements, Refunds and Chargebacks.
- Bill payments: Airtime, Data bundle, Cable, Power, Toll, E-bills, and Remitta.
- Identity verification: Resolve bank account, resolve BVN information and generate OTP.
- Requirements
- Installation
- Initialization
- Usage
- Testing
- Debugging Errors
- Support
- Contribution guidelines
- License
- Changelog
- Flutterwave for business API Keys
- Node
To install the library, run this comman in your terminal:
npm install flutterwave-node-v3
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY);
For staging, Use TEST API Keys and for production, use LIVE API KEYS. You can get your process.env.FLW_PUBLIC_KEY and process.env.FLW_SECRET_KEY from the Flutterwave dashboard.
Read the requirement section for more information on how to get your API keys.
- Collections
- Tokenization
- Split payments
- Scheduled payments
- Transfers
- Card Issuing
- Virtual Account
- Bill payments
- Transactions and reporting
- Beneficiaries
- Banks
- Settlements
- OTP
- Ebills
- Misc
This describes how to fetch all transactions on your account
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetch_transactions = async () => {
try {
const payload = {
"from": "2020-01-01",
"to": "2020-05-05"
}
const response = await flw.Transaction.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetch_transactions();
This describes how Get transaction fees
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const get_fee = async () => {
try {
const payload = {
"amount": "1000",
"currency": "NGN"
}
const response = await flw.Transaction.fee(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
get_fee();
This describes how resend a failed transaction webhook to your server
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const resendHooks = async () => {
try {
const payload = {
"tx_ref": "rave-123wsvgfwefcwsfc456"
}
const response = await flw.Transaction.resend_hooks(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
resendHooks();
This describes how to initiate a transaction refund
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const refund = async () => {
try {
const payload = {
"id": "5708", //This is the transaction unique identifier. It is returned in the initiate transaction call as data.id
"amount":"10"
}
const response = await flw.Transaction.refund(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
refund();
This describes how Verify transactions using the transaction reference tx_ref
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const verify = async () => {
try {
const payload = {"id": "5708" //This is the transaction unique identifier. It is returned in the initiate transaction call as data.id}
const response = await flw.Transaction.verify(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
verify();
This describes how view Transaction Timeline
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const View_Transaction_Timeline = async () => {
try {
const payload = {
"id": "1296063" //This is the unique transaction ID. It is returned in the verify transaction call as data.id}
const response = await flw.Transaction.event(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
View_Transaction_Timeline();
This describes how to initiate a transfer
For more info about the payload parameteres definition, check here
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const initTrans = async () => {
try {
const payload = {
"account_bank": "044", //This is the recipient bank code. Get list here :https://developer.flutterwave.com/v3.0/reference#get-all-banks
"account_number": "0690000040",
"amount": 200,
"narration": "ionnodo",
"currency": "NGN",
"reference": "transfer-"+Date.now(), //This is a merchant's unique reference for the transfer, it can be used to query for the status of the transfer
"callback_url": "https://webhook.site/b3e505b0-fe02-430e-a538-22bbbce8ce0d",
"debit_currency": "NGN"
}
const response = await flw.Transfer.initiate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
initTrans();
This describes how to initiate a bulk transfer
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const initBulk = async () => {
try {
const payload = {
"title": "Staff salary",
"bulk_data": [
{
"bank_code": "044",
"account_number": "0690000032",
"amount": 45000,
"currency": "NGN",
"narration": "akhlm blktrnsfr",
"reference": "fhsfhsds"
},
{
"bank_code": "044",
"account_number": "0690000034",
"amount": 5000,
"currency": "NGN",
"narration": "akhlm blktrnsfr",
"reference": "akhlmfhsfhsds"
}
]
}
const response = await flw.Transfer.bulk(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
initBulk();
This describes how to get applicable transfer fee
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getFee = async () => {
try {
const payload = {
"amount":"5000",
"currency":"NGN"
}
const response = await flw.Transfer.fee(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getFee();
This describes how to fetch all transfers on your account
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getAllTrans = async () => {
try {
const payload = {
"status":"failed"
}
const response = await flw.Transfer.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getAllTrans();
This describes how to fetch a single transfer on your account
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getATransfer = async () => {
try {
const payload = {
"id":"1570636" // This is the numeric ID of the transfer you want to fetch. It is returned in the call to create a transfer as data.id
}
const response = await flw.Transfer.get_a_transfer(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getATransfer();
This will show you how to initiate a transfer from one Flutterwave wallet to another
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const walletToWallet = async () => {
try {
const payload = {
"account_bank": "flutterwave", // This should always be set to flutterwave
"merchant_id": "2360844", //This is the recipient merchant ID
"amount": 5500, //This is the amount to transfer to the recipient
"narration": "payment for x service provided",
"currency": "NGN", //This can be NGN, GHS, KES, UGX, TZS, USD
"reference": "wallet-transfer"+Date.now(), //This is a merchant's unique reference for the transfer, it can be used to query for the status of the transfer
"debit_currency": "NGN" //You can pass this when you want to debit a currency balance and send money in another currency.
}
const response = await flw.Transfer.wallet_to_wallet(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
walletToWallet();
This describes how to create a new virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createVcard = async () => {
try {
const payload = {
"currency": "NGN",
"amount": 200,
"billing_name": "Jermaine Graham",
"billing_address": "2014 Forest Hills Drive",
"billing_city": "Node",
"billing_state": "Javascript",
"billing_postal_code": "000009",
"billing_country": "NG",
"callback_url": "https://your-callback-url.com/"
}
const response = await flw.
VirtualCard.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createVcard();
This describes how to Get all virtual cards
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchAllVcards = async () => {
try {
const response = await flw.VirtualCard.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchAllVcards();
This describes how to fetch a virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchVCard = async () => {
try {
const payload = {
"id":"c6d7f40b-f772-47b7-8136-81256d2f87a2" //This is the unique id of the particular card you want to fetch its details. You can get this id from the call to create a virtual card or list virtual cards as data.id
}
const response = await flw.
VirtualCard.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchVCard();
This describes how to fund an existing virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fundCard = async () => {
try {
const payload = {
"id":"c6d7f40b-f772-47b7-8136-81256d2f87a2", //This is the unique id of the particular card you want to fund. You can get this id from the call to create a virtual card as data.id
"amount":500,
"debit_currency":"NGN"
}
const response = await flw.VirtualCard.fund(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fundCard();
This describes how to terminate a virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const terminateCard = async () => {
try {
const payload = {
"id":"c6d7f40b-f772-47b7-8136-81256d2f87a2"
}
const response = await flw.VirtualCard.terminate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
terminateCard();
This describes how to fetch transactions by date range on a single card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getTransactions = async () => {
try {
const payload = {
"id":"92b5d258-e85f-4ca6-835d-e0c6fa20d958",
"from":"2019-01-01",
"to":"2020-05-24",
"index":"0", //Pass "0" if you want to start from the beginning
"size":"5" //Specify how many transactions you want to retrieve in a single call
}
const response = await flw.VirtualCard.transactions(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getTransactions();
This describes how to withdraw existing funds from a virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const withdrawal = async () => {
try {
const payload = {
"id":"92b5d258-e85f-4ca6-835d-e0c6fa20d958",
"amount":10
}
const response = await flw.VirtualCard.withdraw_funds(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
withdrawal();
This describes how to block a virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const blockCard = async () => {
try {
const payload = {
"id":"92b5d258-e85f-4ca6-835d-e0c6fa20d958",
"status_action":"block"
}
const response = await flw.VirtualCard.block(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
blockCard();
This describes how to unblock a virtual card
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const unblockCard = async () => {
try {
const payload = {
"id":"92b5d258-e85f-4ca6-835d-e0c6fa20d958",
"status_action":"unblock"
}
const response = await flw.VirtualCard.block(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
unblockCard();
This describes how to create a virtual account number
Note: BVN is required for creating static account numbers in the Live Environment i.e if the value of is_permanent is True. Kindly visit our API section found here for more information.
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createAcct = async () => {
try {
const payload = {
"email": "johnmadakin@allstar.com",
"is_permanent": true,
"bvn":"12345678901"
"tx_ref": "jhn-mdkn-101923123463"
}
const response = await flw.VirtualAcct.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createAcct();
This describes how to create bulk virtual account numbers
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createBulkAcct = async () => {
try {
const payload = {
"accounts": 3, //This is the number of virtual account numbers you want to generate
"email": "sam@son.com",
"is_permanent": true,
"tx_ref": "jhn-mndkn-012439283422"
}
const response = await flw.VirtualAcct.create_bulk(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createBulkAcct();
This describes how to fetch bulk virtual account numbers using batch id
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchBulk = async () => {
try {
const payload = {
"batch_id": "-RND_1311590351499953", // This is the batch ID returned in the bulk virtual account numbers creation
}
const response = await flw.VirtualAcct.fetch_bulk(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchBulk();
This describes how to fetch a virtual account number using order reference
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetch = async () => {
try {
const payload = {
"order_ref": "URF_1590350605901_4406935", // This is the order reference returned in the virtual account number creation
}
const response = await flw.VirtualAcct.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetch();
This describes how to get all wallet balances
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchBal = async () => {
try {
const response = await flw.Misc.bal()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchBal();
This describes how to get balances for specific currencies
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchBal = async () => {
try {
const payload = {
"currency": "NGN",
}
const response = await flw.Misc.bal_currency(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchBal();
This describes how to resolve a bank account to get the account holder's details
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const resolveAcct = async () => {
try {
const payload = {
"account_number": "0690000032",
"account_bank": "044"
}
const response = await flw.Misc.verify_Account(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
resolveAcct();
This describes how to fetch bvn information
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const resolveBvn = async () => {
try {
const payload = {
"bvn": "123456789010"
}
const response = await flw.Misc.bvn(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
resolveBvn();
This describes how to create a transfer beneficiary
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createBeneficiary = async () => {
try {
const payload = {
"account_number": "0690000034",
"account_bank":"044" // This is the beneficiary’s bank code, you can use the List of Banks to retrieve a bank code.
}
const response = await flw.Beneficiary.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createBeneficiary();
This describes how to get all beneficiaries
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchAllBeneficiary = async () => {
try {
const response = await flw.Beneficiary.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchAllBeneficiary();
This describes how to get a single transfer beneficiary details
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchBeneficiary = async () => {
try {
const payload = {
"id":"4150" //This is the unique identifier for the beneficiary you intend to fetch. It is returned in the call to create a beneficiary as data.id
}
const response = await flw.Beneficiary.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchBeneficiary();
This describes how to delete a transfer beneficiary
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const delBeneficiary = async () => {
try {
const payload = {
"id":"4150" //This is the unique identifier for the beneficiary you intend to fetch. It is returned in the call to create a beneficiary as data.id
}
const response = await flw.Beneficiary.delete(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
delBeneficiary();
This describes how to get list of banks you can transfer to
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getBanks = async () => {
try {
const payload = {
"country":"NG" //Pass either NG, GH, KE, UG, ZA or TZ to get list of banks in Nigeria, Ghana, Kenya, Uganda, South Africa or Tanzania respectively
}
const response = await flw.Bank.country(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getBanks();
This describes how to get a list of bank branches
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getBranches = async () => {
try {
const payload = {
"id":280 //Unique bank ID, it is returned in the call to fetch banks GET /banks/:country
}
const response = await flw.Bank.branches(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getBranches();
This describes how to fetch all settlements
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchSettlements = async () => {
try {
const response = await flw.Settlement.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchSettlements();
This describes how to fetch and search all your settlements
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchSettlement = async () => {
try {
const payload = {
"id":"2911" ,//This is a unique identifier for the particular settlement you want to fetch.
"from":"2019-01-01",
"to":"2020-05-22"
}
const response = await flw.Settlement.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchSettlement();
This describes how to get all subscriptions
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchSubscription = async () => {
try {
const response = await flw.Subscription.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchSubscription();
This describes how to cancel a subscription
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const cancelSubscription = async () => {
try {
const payload={
"id":"3477" //This is the unique id of the subscription you want to cancel. It is returned in the Get a subscription call as data.id
}
const response = await flw.Subscription.cancel(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
cancelSubscription();
This describes how to activate a subscription
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const activateSubscription = async () => {
try {
const payload={
"id":"3477" //This is the unique id of the subscription you want to cancel. It is returned in the Get a subscription call as data.id
}
const response = await flw.Subscription.activate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
activateSubscription();
This describes how to create bill payments
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createBill = async () => {
try {
const payload={
"country": "NG",
"customer": "+23490803840303",
"amount": 100,
"recurrence": "ONCE",
"type": "AIRTIME",
"reference": "930rwrwr0049404444"
}
const response = await flw.Bills.create_bill(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createBill();
This describes how to create bulk bills payment
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createBulkBill = async () => {
try {
const payload={
"bulk_reference": "edf-1243de5223d2f32",
"callback_url": "https://webhook.site/5f9a659a-11a2-4925-89cf-8a59ea6a019a",
"bulk_data": [
{
"country": "NG",
"customer": "+23490803840303",
"amount": 500,
"recurrence": "WEEKLY",
"type": "AIRTIME",
"reference": "9300wrwrw49200929"
},
{
"country": "NG",
"customer": "+23490803840304",
"amount": 500,
"recurrence": "WEEKLY",
"type": "AIRTIME",
"reference": "93003535rwr04912332"
}
]
}
const response = await flw.Bills.create_bulk(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createBulkBill();
This describes how to get the status of a bill purchase
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getStatus = async () => {
try {
const payload={
"reference": "9300049404444",
}
const response = await flw.Bills.fetch_status(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getStatus();
This describes how to update bills order
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const updateBills = async () => {
try {
const payload = {
"order_id": "be9c8abf-4611-46e9-85e7-5a2e8c5d7ab3",
"amount": "3814.13",
"reference": "FLWTTOT1000000019"
}
const response = await flw.Bills.update_bills(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
updateBills();
This describes how to validate services like DSTV smartcard no, Meter number etc.
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const validateBill = async () => {
try {
const payload = {
"item_code": "AT099",
"code": "BIL099",
"customer": "08038291822"
}
const response = await flw.Bills.validate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
validateBill();
This describes how to fetch all bill categories on your account
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getBillsCategories = async () => {
try {
const response = await flw.Bills.fetch_bills_Cat()
console.log(response);
} catch (error) {
console.log(error)
}
}
getBillsCategories();
This describes how to get all government agencies you can pay into
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const paymentAgencies = async () => {
try {
const response = await flw.Bills.fetch_bills_agencies()
console.log(response);
} catch (error) {
console.log(error)
}
}
paymentAgencies();
This describes how to get amount to be paid for a product
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const amountToBePaid = async () => {
try {
const payload = {
"id": "BIL136", //This is the biller's code
"product_id": "OT150" //This is the item_code for the particular product
}
const response = await flw.Bills.amt_to_be_paid(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
amountToBePaid();
This describes how to get bill payments
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const getBillsPayment = async () => {
try {
const payload = {
"from": "2019-08-01", //This is the start date it can be in any of this formats: YYYY-MM-DDTHH:MM:SSZ or YYYY-MM-DD
"to": "2020-08-27",
"page":"1", //This is the page you want to start from
"reference":"+233494850059" //
}
const response = await flw.Bills.fetch_bills(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
getBillsPayment();
This describes how to get all products under a government agency.
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const productsUnderAgency = async () => {
try {
const payload = {
"id": "BIL136" //This is the biller's code
}
const response = await flw.Bills.products_under_agency(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
productsUnderAgency();
This describes how to create an order using the biller code and the product Id
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const Createorder = async () => {
try {
const payload = {
"id": "BIL136", //This is the biller's code
"product_id": "OT151",
"amount": "3500.00",
"reference": "FLWTTOT19efe000000029",
"customer": {
"name": "emmanuel",
"email": "emmanuel@x.com",
"phone_number": "08060811638"
},
"fields": [{
"id": "42107711:42107712",
"quantity": "1",
"value": "3500"
},
{
"id": "42107710",
"quantity": "1",
"value": "t@x.com"
}
]
}
const response = await flw.Bills.create_ord_billing(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
Createorder();
This describes how to create a payment plan
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createPaymentPlan = async () => {
try {
const payload = {
"amount": 500,
"name": "the olufemi obafunmiso plan 2", //This is the name of the payment, it will appear on the subscription reminder emails
"interval": "monthly", //This will determine the frequency of the charges for this plan. Could be monthly, weekly, etc.
"duration": 24 //This is the frequency, it is numeric, e.g. if set to 5 and intervals is set to monthly you would be charged 5 months, and then the subscription stops
}
const response = await flw.PaymentPlan.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createPaymentPlan();
This describes how to fetch all payment plans on your account
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchAllPlans = async () => {
try {
const response = await flw.PaymentPlan.get_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchAllPlans();
This describes how to get a single payment plan
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchPlan = async () => {
try {
const payload = {
"id":"5443" //This is the unique ìdof the payment plan you want to fetch. It is returned in the call to create a payment plan asdata.id`
}
const response = await flw.PaymentPlan.get_plan(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchPlan();
This describes how to update an existing payment plan
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const updatePlan = async () => {
try {
const payload = {
"id":"5443", //This is the unique ìdof the payment plan you want to fetch. It is returned in the call to create a payment plan asdata.id`
"name": "January neighbourhood contribution",
"status": "active"
}
const response = await flw.PaymentPlan.update(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
updatePlan();
This describes how to cancel an existing payment plan
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const cancelPlan = async () => {
try {
const payload = {
"id":"5443" //This is the unique ìd` of the payment plan you want to cancel
}
const response = await flw.PaymentPlan.cancel(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
cancelPlan();
This describes how to create a subaccount on Flutterwave
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createSubaccount = async () => {
try {
const payload = {
"account_bank": "044",
"account_number": "0690000037",
"business_name": "Eternal Blue",
"business_email": "petya@stux.net",
"business_contact": "Anonymous",
"business_contact_mobile": "090890382",
"business_mobile": "09087930450",
"country": "NG",
"meta": [
{
"meta_name": "mem_adr",
"meta_value": "0x16241F327213"
}
],
"split_type": "percentage",
"split_value": 0.5
}
const response = await flw.Subaccount.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createSubaccount();
This describes how to get all subaccounts
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchAllSubaccounts = async () => {
try {
const response = await flw.Subaccount.fetch_all()
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchAllSubaccounts();
This describes how to fetch a subaccount using the sub-account's ID
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const fetchSubaccount = async () => {
try {
const payload = {
"id":"5716"
}
const response = await flw.Subaccount.fetch(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
fetchSubaccount();
This describes how to update a subaccount
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const updateSubaccount = async () => {
try {
const payload = {
"id": "3244", //This is the unique id of the subaccount you want to update. It is returned in the call to create a subaccount as data.id
"business_name": "Xyx lol!",
"business_email": "mad@o.enterprises",
"account_bank": "044",
"account_number": "0690000040",
"split_type": "flat",
"split_value": "200"
}
const response = await flw.Subaccount.update(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
updateSubaccount();
This describes how to delete a subaccount
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const updateSubaccount = async () => {
try {
const payload = {
"id": "3244" //This is the unique id of the subaccount you want to update. It is returned in the call to create a subaccount as data.id
}
const response = await flw.Subaccount.delete(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
updateSubaccount();
This describes how to create a new Ebills order
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const placeEbillsOrder = async () => {
try {
const payload = {
"narration": "mndkn blls",
"number_of_units": 2,
"currency": "NGN",
"amount": 200,
"phone_number": "09384747474",
"email": "jake@rad.com",
"tx_ref": "akhlm-pstmn-109470393",
"ip": "127.9.0.7",
"custom_business_name": "John Madakin",
"country": "NG"
}
const response = await flw.Ebills.order(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
placeEbillsOrder();
This describes how to update order for ebills
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const updateEbillsOrder = async () => {
try {
const payload = {
"reference": "RVEBLS-843984E9B66E-23240", //This is the reference returned in the create order endpoint as flw_ref.
"currency": "NGN",
"amount": 100
}
const response = await flw.Ebills.update(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
updateEbillsOrder();
This describes how to create an otp
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const createOTP = async () => {
try {
const payload = {
"length": 7,
"customer": { "name": "Kazan", "email": "kazan@mailinator.com", "phone": "2348131149273" },
"sender": "log t",
"send": true,
"medium": ["email", "whatsapp"],
"expiry": 5
}
const response = await flw.Otp.create(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
createOTP();
This describes how to validate an otp
const Flutterwave = require('flutterwave-node-v3');
const flw = new Flutterwave(process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY );
const validateOTP = async () => {
try {
const payload = {
"reference": "CF-BARTER-20190420022611377491",
"otp": "481208"
}
const response = await flw.Otp.validate(payload)
console.log(response);
} catch (error) {
console.log(error)
}
}
validateOTP();
All of the libraries tests are run on Mocha. Available tests include rave.bank.test
, rave.beneficiaries.test
, rave.bills.test
, rave.charge.test
, rave.ebills.test
, rave.settlements.test
, rave.subscriptions.test
. They can be run by running the test command in your terminal.
npm run test
We understand that you may run into some errors while integrating our library. You can read more about our error messages here.
For authorization
and validation
error responses, double-check your API keys and request. If you get a server
error, kindly engage the team for support.
For additional assistance using this library, contact the developer experience (DX) team via email or on slack.
You can also follow us @FlutterwaveEng and let us know what you think 😊.
Read more about our community contribution guidelines here
By contributing to this library, you agree that your contributions will be licensed under its MIT license.
Copyright (c) Flutterwave Inc.