We recommend reading the main readme first, to understand the requirements for using the library and how to initiate this in your apps. This guide assumes you've read that.
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();