### Install Flutterwave NodeJS Library Source: https://github.com/flutterwave/node-v3/blob/master/README.md Install the Flutterwave v3 Node.js package using npm. Ensure you have Node.js 18 or higher installed. ```sh npm install flutterwave-node-v3 ``` -------------------------------- ### Sample Response for Get Transfer Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md This is an example of the JSON response you can expect when successfully fetching transfer fee details. ```json { "status": "success", "message": "Transfer fee fetched", "data": [ { "currency": "NGN", "fee_type": "value", "fee": 26.875 } ] } ``` -------------------------------- ### Sample Response for Update Payment Plan Source: https://github.com/flutterwave/node-v3/blob/master/documentation/payment-plan.md Example of a successful response when updating a payment plan. ```javascript { "status": "success", "message": "Payment plan updated", "data": { "id": 34185, "name": "A sample KES monthly plan", "plan_token": "rpp_2f711270c4de5c2393d3", "status": "active", "currency": "NGN", "amount": 0, "duration": 12, "interval": "monthly", "created_at": "2023-03-15T00:34:50.000Z" } } ``` -------------------------------- ### Sample Response for Cancel Payment Plan Source: https://github.com/flutterwave/node-v3/blob/master/documentation/payment-plan.md Example of a successful response when canceling a payment plan. ```javascript { "status": "success", "message": "Payment plan cancelled", "data": { "id": 34185, "name": "A sample KES monthly plan", "plan_token": "rpp_2f711270c4de5c2393d3", "status": "cancelled", "currency": "NGN", "amount": 0, "duration": 12, "interval": "monthly", "created_at": "2023-03-15T00:34:50.000Z" } } ``` -------------------------------- ### Sample Bank Response - JSON Source: https://github.com/flutterwave/node-v3/blob/master/documentation/banks.md This is an example of the JSON response structure when successfully fetching a list of banks. ```json { "status": "success", "message": "Banks fetched successfully", "data": [ { "id": 132, "code": "560", "name": "Page MFBank" }, { "id": 133, "code": "304", "name": "Stanbic Mobile Money" }, { "id": 134, "code": "308", "name": "FortisMobile" }, { "id": 135, "code": "328", "name": "TagPay" }, { "id": 136, "code": "309", "name": "FBNMobile" }, { "id": 137, "code": "011", "name": "First Bank of Nigeria" }, { "id": 138, "code": "326", "name": "Sterling Mobile" }, { "id": 139, "code": "990", "name": "Omoluabi Mortgage Bank" }, { "id": 140, "code": "311", "name": "ReadyCash (Parkway)" }, { "id": 141, "code": "057", "name": "Zenith Bank" }, { "id": 142, "code": "068", "name": "Standard Chartered Bank" }, { "id": 143, "code": "306", "name": "eTranzact" }, { "id": 144, "code": "070", "name": "Fidelity Bank" }, { "id": 145, "code": "023", "name": "CitiBank" }, { "id": 146, "code": "215", "name": "Unity Bank" }, { "id": 147, "code": "323", "name": "Access Money" }, { "id": 148, "code": "302", "name": "Eartholeum" }, { "id": 149, "code": "324", "name": "Hedonmark" }, { "id": 150, "code": "325", "name": "MoneyBox" }, { "id": 151, "code": "301", "name": "JAIZ Bank" }, { "id": 152, "code": "050", "name": "Ecobank Plc" }, { "id": 153, "code": "307", "name": "EcoMobile" }, { "id": 154, "code": "318", "name": "Fidelity Mobile" }, { "id": 155, "code": "319", "name": "TeasyMobile" }, { "id": 156, "code": "999", "name": "NIP Virtual Bank" }, { "id": 157, "code": "320", "name": "VTNetworks" }, { "id": 158, "code": "221", "name": "Stanbic IBTC Bank" }, { "id": 159, "code": "501", "name": "Fortis Microfinance Bank" }, { "id": 160, "code": "329", "name": "PayAttitude Online" }, { "id": 161, "code": "322", "name": "ZenithMobile" }, { "id": 162, "code": "303", "name": "ChamsMobile" }, { "id": 163, "code": "403", "name": "SafeTrust Mortgage Bank" }, { "id": 164, "code": "551", "name": "Covenant Microfinance Bank" }, { "id": 165, "code": "415", "name": "Imperial Homes Mortgage Bank" }, { "id": 166, "code": "552", "name": "NPF MicroFinance Bank" }, { "id": 167, "code": "526", "name": "Parralex" }, { "id": 168, "code": "035", "name": "Wema Bank" }, { "id": 169, "code": "084", "name": "Enterprise Bank" }, { "id": 170, "code": "063", "name": "Diamond Bank" }, { "id": 171, "code": "305", "name": "Paycom" }, { "id": 172, "code": "100", "name": "SunTrust Bank" }, { "id": 173, "code": "317", "name": "Cellulant" }, { "id": 174, "code": "401", "name": "ASO Savings and & Loans" }, { "id": 175, "code": "030", "name": "Heritage" }, { "id": 176, "code": "402", "name": "Jubilee Life Mortgage Bank" }, { "id": 177, "code": "058", "name": "GTBank Plc" }, { "id": 178, "code": "032", "name": "Union Bank" }, { "id": 179, "code": "232", "name": "Sterling Bank" }, { "id": 180, "code": "076", "name": "Skye Bank" }, { "id": 181, "code": "082", "name": "Keystone Bank" }, { "id": 182, "code": "327", "name": "Pagatech" }, { "id": 183, "code": "559", "name": "" } ] } ``` -------------------------------- ### Fetch Products Under Agency Source: https://github.com/flutterwave/node-v3/blob/master/documentation/billPayments.md Get all available products for a specific government agency using its biller code. Ensure the Flutterwave SDK is initialized. ```javascript 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" } const response = await flw.Bills.products_under_agency(payload) console.log(response); } catch (error) { console.log(error) } } productsUnderAgency(); ``` -------------------------------- ### Commit Message Example Source: https://github.com/flutterwave/node-v3/blob/master/CONTRIBUTING.md Use a clear and descriptive commit message. For larger changes, provide a detailed explanation of what changed and its impact. ```markdown $ git commit -m "A brief summary of the commit > > A paragraph describing what changed and its impact." ``` -------------------------------- ### Get All Payment Plans Source: https://github.com/flutterwave/node-v3/blob/master/documentation/payment-plan.md Fetches all payment plans associated with your Flutterwave account. ```APIDOC ## Get All Payment Plans ### Description This endpoint allows you to retrieve a list of all payment plans configured on your Flutterwave account. ### Method GET ### Endpoint `/payment-plans` (This is a conceptual endpoint, the actual call is made via the SDK method `flw.PaymentPlan.get_all()`) ### Parameters None ### Request Example ```javascript 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(); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request (e.g., "success"). - **message** (string) - A message describing the result of the request. - **meta** (object) - Contains metadata about the pagination of the results. - **page_info** (object) - **total** (integer) - The total number of payment plans available. - **current_page** (integer) - The current page number of the results. - **total_pages** (integer) - The total number of pages available. - **data** (array) - An array of payment plan objects. - **id** (integer) - The unique identifier for the payment plan. - **name** (string) - The name of the payment plan. - **amount** (integer) - The amount for the payment plan. - **interval** (string) - The interval for the payment plan (e.g., "weekly", "monthly"). - **duration** (integer) - The duration of the payment plan. - **status** (string) - The current status of the payment plan (e.g., "active", "cancelled"). - **currency** (string) - The currency of the payment plan (e.g., "NGN"). - **plan_token** (string) - A unique token for the payment plan. - **created_at** (string) - The timestamp when the payment plan was created. #### Response Example ```json { "status": "success", "message": "Payment plans fetched", "meta": { "page_info": { "total": 106, "current_page": 1, "total_pages": 11 } }, "data": [ { "id": 37829, "name": "testing", "amount": 100, "interval": "weekly", "duration": 4, "status": "cancelled", "currency": "NGN", "plan_token": "rpp_0aac3d0aa3f0c18565c0", "created_at": "2023-06-14T11:57:26.000Z" } ] } ``` ``` -------------------------------- ### Get All Wallet Balances Source: https://github.com/flutterwave/node-v3/blob/master/documentation/misc.md Fetch all available wallet balances across different currencies. Requires Flutterwave API keys to be set in environment variables. ```javascript 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(); 1 ``` ```json { "status": "success", "message": "Wallet balances fetched", "data": [ { "currency": "NGN", "available_balance": 2367840, "ledger_balance": 253125.82 }, { "currency": "KES", "available_balance": 0, "ledger_balance": 1226.72 }, { "currency": "GHS", "available_balance": 0, "ledger_balance": 0 }, { "currency": "USD", "available_balance": 0, "ledger_balance": 472.08 }, { "currency": "EUR", "available_balance": 0, "ledger_balance": 0 }, { "currency": "ZAR", "available_balance": 0, "ledger_balance": 0 }, { "currency": "GBP", "available_balance": 0, "ledger_balance": 0 }, { "currency": "TZS", "available_balance": 0, "ledger_balance": 0 }, { "currency": "UGX", "available_balance": 0, "ledger_balance": 0 }, { "currency": "RWF", "available_balance": 0, "ledger_balance": 5000 }, { "currency": "ZMW", "available_balance": 0, "ledger_balance": 0 }, { "currency": "INR", "available_balance": 0, "ledger_balance": 0 }, { "currency": "XOF", "available_balance": 0, "ledger_balance": 0 }, { "currency": "MUR", "available_balance": 0, "ledger_balance": 0 }, { "currency": "ETB", "available_balance": 0, "ledger_balance": 0 } ] } ``` -------------------------------- ### Sample Response for Fetched Transfers Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md This is an example of the JSON response structure when fetching transfers. It includes metadata about pagination and a list of transfer objects, each detailing its ID, account number, amount, status, and other relevant information. ```json { "status": "success", "message": "Transfers fetched", "meta": { "page_info": { "total": 47, "current_page": 1, "total_pages": 5 } }, "data": [ { "id": 403318, "account_number": "256782033409", "bank_code": "MPS", "full_name": "N/A", "created_at": "2023-05-22T16:34:49.000Z", "currency": "UGX", "debit_currency": null, "amount": 20, "fee": 500, "status": "FAILED", "reference": "6b76aa8f93bd765c", "meta": [ { "mobile_number": "08109328188" } ], "narration": "Mobile money payout", "approver": null, "complete_message": "beneficiary_name is required", "requires_approval": 0, "is_approved": 1, "bank_name": "N/A" }, { "id": 403317, "account_number": "256782033409", "bank_code": "MPS", "full_name": "N/A", "created_at": "2023-05-22T16:33:13.000Z", "currency": "UGX", "debit_currency": null, "amount": 20, "fee": 500, "status": "FAILED", "reference": "6b3269daa45fa640", "meta": [ { "mobile_number": "08109328188" } ], "narration": "Mobile money payout", "approver": null, "complete_message": "beneficiary_name is required", "requires_approval": 0, "is_approved": 1, "bank_name": "N/A" }, { "id": 403047, "account_number": "1295124", "bank_code": "wallet", "full_name": "Michael Onyeforo Jnr", "created_at": "2023-05-19T12:56:13.000Z", "currency": "EUR", "debit_currency": "EUR", "amount": 1000, "fee": 0, "status": "FAILED", "reference": "TRF-555600071008", "meta": { "AccountId": 37782, "merchant_id": "5758113" }, "narration": null, "approver": null, "complete_message": "DISBURSE FAILED: You can only spend EUR 100.00 at once", "requires_approval": 0, "is_approved": 1, "bank_name": "wallet" }, { "id": 401090, "account_number": "28581375", "bank_code": "wallet", "full_name": "Trulipay technologies ", "created_at": "2023-04-26T22:30:12.000Z", "currency": "UGX", "debit_currency": "UGX", "amount": 1000, "fee": 0, "status": "FAILED", "reference": "TRF-282263183180", "meta": { "AccountId": 1758777, "merchant_id": "100756902" }, "narration": null, "approver": null, "complete_message": "DISBURSE FAILED: You can only spend UGX 100.00 at once", "requires_approval": 0, "is_approved": 1, "bank_name": "wallet" }, { "id": 401083, "account_number": "28581369", "bank_code": "wallet", "full_name": "Trulipay technologies ", "created_at": "2023-04-26T22:10:27.000Z", "currency": "GHS", "debit_currency": "GHS", "amount": 20000, "fee": 0, "status": "FAILED", "reference": "TRF-546614104664", "meta": { "AccountId": 1758777, "merchant_id": "100756902" }, "narration": null, "approver": null, "complete_message": "DISBURSE FAILED: You can only spend GHS 1000.00 at once", "requires_approval": 0, "is_approved": 1, "bank_name": "wallet" }, { "id": 398682, "account_number": "32000713", "bank_code": "wallet", "full_name": "Olivier Staff", "created_at": "2023-03-31T11:52:06.000Z", "currency": "XAF", "debit_currency": "XAF", "amount": 1000000, "fee": 0, "status": "FAILED", "reference": "TRF-180822210828", "meta": { "AccountId": 1895433, "merchant_id": "100872524" }, "narration": null, "approver": null, "complete_message": "DISBURSE FAILED: A fatal error occured while proccesing your request.", "requires_approval": 0, "is_approved": 1 } ] } ``` -------------------------------- ### Sample Response for Subaccount Creation Source: https://github.com/flutterwave/node-v3/blob/master/documentation/subaccount.md This is a sample JSON response received after successfully creating a subaccount. ```json { "status": "success", "message": "Subaccount created", "data": { "id": 2181, "account_number": "0690000037", "account_bank": "044", "full_name": "Eternal Blue", "created_at": "2020-05-31T00:40:15.000Z", "split_type": "percentage", "split_value": 0.5, "subaccount_id": "RS_235E8F4E92A4048B57EA29B0E1B8F78B", "bank_name": "ACCESS BANK NIGERIA" } } ``` -------------------------------- ### Get Virtual Card Transactions Source: https://github.com/flutterwave/node-v3/blob/master/documentation/virtualCard.md Fetch transactions for a specific virtual card within a given date range. You can control the number of transactions retrieved per call and specify the starting point. ```javascript 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":"b1405144-3427-4baf-80ea-5c6075a01a74", "from":"2019-01-01", "to":"2022-09-24", "index":"0", //Pass "0" if you want to start from the beginning "size":"1" //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(); ``` -------------------------------- ### Sample Payment Plan Creation Response Source: https://github.com/flutterwave/node-v3/blob/master/documentation/payment-plan.md This is a sample JSON response received after successfully creating a payment plan. ```json { "status": "success", "message": "Payment plan created", "data": { "id": 52045, "name": "SDK test Plan", "amount": "100", "interval": "monthly", "duration": 0, "status": "active", "currency": "NGN", "plan_token": "rpp_cd93e2fa88e065b960bf", "created_at": "2023-07-04T09:16:42.000Z" } } ``` -------------------------------- ### Sample Response for Bulk Virtual Account Creation Source: https://github.com/flutterwave/node-v3/blob/master/documentation/virtualAccount.md This is a sample response indicating that the request to create bulk virtual account numbers has been queued. It includes a batch ID for tracking. ```javascript { "status": "success", "message": "Bulk virtual accounts creation queued", "data": { "batch_id": "-RND_2611692003353987", "response_code": "02", "response_message": "Request added to Queue" } } ``` -------------------------------- ### Get Transaction Fee Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transactions.md Use this method to get the transaction fee for a specified amount and currency. Ensure your Flutterwave keys are set in your environment variables. ```javascript 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(); ``` -------------------------------- ### Get Bank Branches using Node.js SDK Source: https://github.com/flutterwave/node-v3/blob/master/documentation/banks.md Use this method to retrieve bank branches. Ensure you have your Flutterwave public and secret keys configured. The 'id' parameter is the unique identifier for the bank, which can be obtained from the GET /banks/:country endpoint. ```javascript 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(); ``` -------------------------------- ### Initialize Flutterwave Client Source: https://github.com/flutterwave/node-v3/blob/master/README.md Initialize the Flutterwave client with your API keys. Use test keys for the staging environment and live keys for production. Ensure your API keys are set as environment variables. ```javascript const Flutterwave = require('flutterwave-node-v3'); const flw = new Flutterwave( process.env.FLW_PUBLIC_KEY, process.env.FLW_SECRET_KEY, ); ``` -------------------------------- ### Get all Subscriptions Source: https://github.com/flutterwave/node-v3/blob/master/documentation/subscription.md Retrieves a list of all user subscriptions. ```APIDOC ## GET /subscriptions ### Description Retrieves a list of all user subscriptions. ### Method GET ### Endpoint /subscriptions ### Parameters None ### Request Example ```javascript 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(); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request. - **message** (string) - A message describing the result of the request. - **meta** (object) - Contains metadata about the response, including pagination information. - **data** (array) - An array of subscription objects. #### Response Example ```json { "status": "success", "message": "Plan subscriptions fetched", "meta": { "page_info": { "total": 2, "current_page": 1, "total_pages": 1 } }, "data": [ { "id": 4147, "amount": 2000, "customer": { "id": 247546, "customer_email": "developers@flutterwavego.com" }, "plan": 3657, "status": "cancelled", "created_at": "2019-12-31T17:00:55.000Z" } ] } ``` ``` -------------------------------- ### GET /transfers Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md Fetches a list of all transfers on your account. You can filter transfers by status. ```APIDOC ## GET /transfers ### Description Fetches a list of all transfers on your account. You can filter transfers by status. ### Method GET ### Endpoint /transfers ### Query Parameters - **status** (string) - Optional - Filter transfers by their status (e.g., "failed", "successful", "pending"). ### Request Example ```javascript 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(); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the API request (e.g., "success"). - **message** (string) - A message describing the result of the request (e.g., "Transfers fetched"). - **meta** (object) - Contains metadata about the transfer list, including pagination information. - **page_info** (object) - **total** (integer) - Total number of transfers. - **current_page** (integer) - The current page number. - **total_pages** (integer) - The total number of pages available. - **data** (array) - An array of transfer objects. - **id** (integer) - The unique identifier for the transfer. - **account_number** (string) - The account number of the recipient. - **bank_code** (string) - The code of the recipient's bank. - **full_name** (string) - The full name of the recipient. - **created_at** (string) - The timestamp when the transfer was created. - **currency** (string) - The currency of the transfer amount. - **debit_currency** (string) - The currency used for debiting the account. - **amount** (integer) - The amount of the transfer. - **fee** (integer) - The fee charged for the transfer. - **status** (string) - The current status of the transfer (e.g., "FAILED", "SUCCESSFUL"). - **reference** (string) - A unique reference ID for the transfer. - **meta** (object or array) - Additional metadata associated with the transfer. - **narration** (string) - A description or narration for the transfer. - **approver** (string or null) - Information about the approver, if applicable. - **complete_message** (string) - A detailed message about the transfer's completion status. - **requires_approval** (integer) - Indicates if the transfer requires approval (0 or 1). - **is_approved** (integer) - Indicates if the transfer has been approved (0 or 1). - **bank_name** (string) - The name of the recipient's bank. #### Response Example ```json { "status": "success", "message": "Transfers fetched", "meta": { "page_info": { "total": 47, "current_page": 1, "total_pages": 5 } }, "data": [ { "id": 403318, "account_number": "256782033409", "bank_code": "MPS", "full_name": "N/A", "created_at": "2023-05-22T16:34:49.000Z", "currency": "UGX", "debit_currency": null, "amount": 20, "fee": 500, "status": "FAILED", "reference": "6b76aa8f93bd765c", "meta": [ { "mobile_number": "08109328188" } ], "narration": "Mobile money payout", "approver": null, "complete_message": "beneficiary_name is required", "requires_approval": 0, "is_approved": 1, "bank_name": "N/A" } ] } ``` ``` -------------------------------- ### Run Library Tests Source: https://github.com/flutterwave/node-v3/blob/master/README.md Execute the library's test suite using npm commands. Tests cover various functionalities like banks, beneficiaries, bills, and more. ```sh npm run test or npm test ``` -------------------------------- ### Get Balances Per Currency Source: https://github.com/flutterwave/node-v3/blob/master/documentation/misc.md Fetches the available and ledger balances for a specific currency. ```APIDOC ## POST /misc/balances/currency ### Description Retrieves wallet balances for a specified currency. ### Method POST ### Endpoint /misc/balances/currency ### Parameters #### Request Body - **currency** (string) - Required - The currency code for which to fetch the balance (e.g., "NGN", "USD"). ### Request Example ```javascript 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(); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the request (e.g., "success"). - **message** (string) - A message describing the result of the request. - **data** (object) - An object containing the balance details for the specified currency: - **currency** (string) - The currency code. - **available_balance** (number) - The available balance for the currency. - **ledger_balance** (number) - The ledger balance for the currency. #### Response Example ```json { "status": "success", "message": "Wallet balance fetched", "data": { "currency": "NGN", "available_balance": 2168880, "ledger_balance": 253125.82 } } ``` ``` -------------------------------- ### Create Payment Plan with Node.js SDK Source: https://github.com/flutterwave/node-v3/blob/master/documentation/payment-plan.md Use this function to create a new payment plan. Ensure your environment variables for FLW_PUBLIC_KEY and FLW_SECRET_KEY are set. The plan name appears on subscription reminder emails. ```javascript 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: 1000, name: 'SDK test Plan', //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. }; const response = await flw.PaymentPlan.create(payload); console.log(response); } catch (error) { console.log(error); } }; createPaymentPlan(); ``` -------------------------------- ### Get all Subscriptions Source: https://github.com/flutterwave/node-v3/wiki/Subscriptions This endpoint allows developers to query all subscribers, including those who have cancelled their subscriptions. ```APIDOC ## GET /subscriptions ### Description Fetches all user subscriptions, including cancelled ones. ### Method GET ### Endpoint /subscriptions ### Parameters None ### Request Example ```javascript 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(); ``` ### Response #### Success Response (200) - **data** (array) - An array of subscription objects. - **meta** (object) - Metadata about the response. #### Response Example ```json { "status": "success", "data": [ { "id": 123, "customer_id": 456, "plan_id": 789, "status": "active", "created_at": "2023-10-27T10:00:00Z" } ], "meta": { "total": 1, "page": 1, "limit": 10 } } ``` ``` -------------------------------- ### Get a Transfer Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md This endpoint allows you to fetch the details of a specific transfer using its unique ID. ```APIDOC ## GET /transfers/:id ### Description Fetches the details of a specific transfer. ### Method GET ### Endpoint /transfers/:id ### Parameters #### Path Parameters - **id** (string) - Required - The unique identifier of the transfer to fetch. ### Request Example ```javascript 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":"396456" } const response = await flw.Transfer.get_a_transfer(payload); console.log(response); } catch (error) { console.log(error); } } getATransfer(); ``` ### Response #### Success Response (200) - **status** (string) - Indicates the status of the operation. - **message** (string) - A message describing the result of the operation. - **data** (array) - An array containing transfer fee details. - **currency** (string) - The currency of the transfer fee. - **fee_type** (string) - The type of fee (e.g., 'value'). - **fee** (number) - The amount of the transfer fee. #### Response Example ```json { "status": "success", "message": "Transfer fee fetched", "data": [ { "currency": "NGN", "fee_type": "value", "fee": 26.875 } ] } ``` ``` -------------------------------- ### Wallet to Wallet Transfer Sample Response Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md This is a sample response object for a successful wallet-to-wallet transfer initiation. It includes details about the transaction status, amount, and reference. ```javascript { "status": "success", "message": "Transfer Queued Successfully", "data": { "id": 128286, "account_number": 99992069, "bank_code": "flutterwave", "full_name": "FLUTTERWAVE V3 DOCS", "created_at": "2020-06-29T21:35:15.000Z", "currency": "NGN", "debit_currency": "NGN", "amount": 500, "fee": 0, "status": "NEW", "reference": "wallet-transfer", "meta": { "wallet_email": "hip@cool.com", "AccountId": 118468, "merchant_id": "00118468" }, "narration": "payment for x service provided", "complete_message": "", "requires_approval": 0, "is_approved": 1, "bank_name": "wallet" } } ``` -------------------------------- ### Get Transfer Fee Source: https://github.com/flutterwave/node-v3/blob/master/documentation/transfers.md This endpoint retrieves the applicable fee for a transfer based on the amount and currency. ```APIDOC ## GET /transfer/fee ### Description Retrieves the applicable fee for a transfer based on the specified amount and currency. ### Method GET ### Endpoint /transfer/fee ### Parameters #### Query Parameters - **amount** (string) - Required - The amount for which to calculate the fee. - **currency** (string) - Required - The currency of the transfer (e.g., 'NGN'). ### Request Example ```json { "amount": "12500", "currency": "NGN" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the request. - **message** (string) - A message indicating the result of the request. - **data** (array) - An array of fee objects. - **currency** (string) - The currency for which the fee is applicable. - **fee_type** (string) - The type of fee (e.g., 'value'). - **fee** (float) - The calculated transfer fee. #### Response Example ```json { "status": "success", "message": "Transfer fee fetched", "data": [ { "currency": "NGN", "fee_type": "value", "fee": 26.875 } ] } ``` ``` -------------------------------- ### Sample Response for Virtual Account Creation Source: https://github.com/flutterwave/node-v3/blob/master/documentation/virtualAccount.md This is a sample success response when a virtual account number is created. It includes transaction details and account information. ```javascript { "status": "success", "message": "Virtual account created", "data": { "response_code": "02", "response_message": "Transaction in progress", "flw_ref": "FLW-da93010f630240a7978e893af92fed62", "order_ref": "URF_1613406439309_370935", "account_number": "7824822527", "frequency": "N/A", "bank_name": "WEMA BANK", "created_at": "2021-02-15 16:27:22", "expiry_date": "N/A", "note": "Please make a bank transfer to CollinX Akpevwe Omokri", "amount": null } } ``` -------------------------------- ### Create Order for Billing Source: https://github.com/flutterwave/node-v3/blob/master/documentation/billPayments.md Create a new order for a bill payment by providing the biller code, product ID, amount, customer details, and specific fields. The SDK must be initialized. ```javascript 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": "3644", "product_id": "OT151", "amount": "3500.00", "reference": "FLWTTOT1000000029", "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(); ``` -------------------------------- ### Get Bill Payment Status Source: https://github.com/flutterwave/node-v3/blob/master/documentation/billPayments.md This endpoint allows you to retrieve the status of a specific bill payment. ```APIDOC ## GET /api/bills/status ### Description Fetches the status of a previously initiated bill payment. ### Method GET ### Endpoint /api/bills/status ### Query Parameters - **reference** (string) - Required - The reference of the bill payment to check. ### Request Example ```json { "reference": "9300049404444" } ``` ### Response #### Success Response (200) - **status** (string) - The status of the operation. - **message** (string) - A message indicating the result. - **data** (object) - Contains details of the bill payment status. - **currency** (string) - The currency of the transaction. - **customer_id** (string) - The customer's identifier. - **frequency** (string) - The recurrence frequency. - **amount** (string) - The transaction amount. - **product** (string) - The product type. - **product_name** (string) - The name of the product. - **commission** (number) - The commission charged. - **transaction_date** (string) - The date and time of the transaction. - **country** (string) - The country code. - **tx_ref** (string) - Flutterwave's transaction reference. - **extra** (any) - Additional information. - **product_details** (string) - Details about the product. #### Response Example ```json { "status": "success", "message": "Bill status fetch successful", "data": { "currency": "NGN", "customer_id": "2348109328188", "frequency": "One Time", "amount": "500.0000", "product": "AIRTIME", "product_name": "MTN", "commission": 0, "transaction_date": "2023-02-24T16:46:19.107Z", "country": "NG", "tx_ref": "CF-FLYAPI-20230224044619923826", "extra": null, "product_details": "FLY-API-NG-AIRTIME-MTN" } } ``` ```