@adsesugh/flutterwave-v3-ts
v1.0.3
Published
Flutterwave v3 Node SDK rewritten in TypeScript
Maintainers
Readme
Flutterwave Node v3 (TypeScript SDK)
A fully typed TypeScript SDK for the Flutterwave v3 API.
This library simplifies integrating payments, transfers, card issuing, and more with Flutterwave in your Node.js/TypeScript applications.
📦 Installation
npm install flutterwave-v3-tsor
yarn add flutterwave-v3-ts🚀 Usage
import { Flutterwave } from "flutterwave-v3-ts";
const flw = new Flutterwave({
publicKey: process.env.FLW_PUBLIC_KEY!,
secretKey: process.env.FLW_SECRET_KEY!
});
// Example: Verify a transaction
(async () => {
const response = await flw.transactions.verify({ id: "1234567890" });
console.log(response);
})();🔑 Configuration
Set your Flutterwave API keys in environment variables:
FLW_PUBLIC_KEY=your_public_key
FLW_SECRET_KEY=your_secret_key
BASE_URL=api_base_url
FLW_ENCRYPTION_KEY=your_encryption_keyPass your public and secret keys when initializing:
const flw = new Flutterwave({
publicKey: "FLWPUBK_TEST-xxxxxxxxxxxxxxxxxxxxx",
secretKey: "FLWSECK_TEST-xxxxxxxxxxxxxxxxxxxxx",
baseUrl: "https://api.flutterwave.com/v3", // Optional, defaults to Flutterwave's API URL
encryptionKey: "your encryption_key"
});
📚 Features
- Collections (Card, Bank, Mobile Money, USSD, etc.)
- Tokenization
- Split payments
- Scheduled payments
- Transfers
- Card Issuing
- Virtual Accounts
- Bill Payments
- Transactions & Reporting
- Beneficiaries
- Banks
- Settlements
- OTP
- eBills
- Miscellaneous Endpoints
🔍 Usage Examples
See the examples directory for more usage examples.
Collections
const response = await flw.collections.cardCharge({
card_number: "5531886652142950",
cvv: "564",
expiry_month: "09",
expiry_year: "32",
currency: "NGN",
amount: "100",
fullname: "Flutterwave Developer",
email: "[email protected]",
tx_ref: "MC-3243e"
});
console.log(response);Tokenization
const response = await flw.tokenization.chargeToken({
token: "CARD_TOKEN",
currency: "NGN",
country: "NG",
amount: 5000,
email: "[email protected]",
tx_ref: "ref-1234"
});
console.log(response);Transfers
const response = await flw.transfers.initiate({
account_bank: "044",
account_number: "0690000031",
amount: 5500,
narration: "Test transfer",
currency: "NGN",
reference: "transfer-12345",
debit_currency: "NGN"
});
console.log(response);Card Issuing
const response = await flw.cardIssuing.createCard({
currency: "NGN",
amount: 1000,
billing_name: "John Doe",
billing_address: "123, Test Street",
billing_city: "Lagos",
billing_state: "LA",
billing_postal_code: "100001",
billing_country: "NG"
});
console.log(response);Virtual Accounts
const response = await flw.virtualAccounts.create({
email: "[email protected]",
is_permanent: true,
bvn: "12345678901",
tx_ref: "VA-12345"
});
console.log(response);Bill Payments
const response = await flw.bills.pay({
country: "NG",
customer: "08012345678",
amount: 1000,
recurrence: "ONCE",
type: "AIRTIME",
reference: "bill-1234"
});
console.log(response);Transactions
const response = await flw.transactions.verify({ id: "123456789" });
console.log(response);Banks
const response = await flw.banks.list({ country: "NG" });
console.log(response);Settlements
const response = await flw.settlements.fetch({ from: "2023-01-01", to: "2023-02-01" });
console.log(response);OTP
const response = await flw.otp.create({ length: 6, customer: "[email protected]", send: true });
console.log(response);eBills
const response = await flw.ebills.create({
currency: "NGN",
amount: 5000,
email: "[email protected]",
tx_ref: "EBILL-12345"
});
console.log(response);Miscellaneous
const response = await flw.misc.fetchBalance({ currency: "NGN" });
console.log(response);📜 License
This project is licensed under the MIT License. See the LICENSE file for details.
