flutterwave-universal
Version:
Universal TypeScript SDK for Flutterwave payment services, compatible with Node.js, Bun, Deno, Cloudflare Workers and Edge Functions
1,471 lines (1,451 loc) • 42.6 kB
text/typescript
interface FlutterwaveConfig {
secretKey: string;
publicKey?: string;
encryptionKey?: string;
timeout?: number;
}
declare class ApiClient {
private secretKey;
private baseUrl;
private timeout;
constructor(config: FlutterwaveConfig);
private request;
get<T>(endpoint: string, params?: Record<string, unknown>): Promise<T>;
post<T>(endpoint: string, data: Record<string, unknown>): Promise<T>;
put<T>(endpoint: string, data: Record<string, unknown>): Promise<T>;
delete<T>(endpoint: string, data?: Record<string, unknown>): Promise<T>;
}
interface Bank {
id: number;
code: string;
name: string;
}
interface BankBranch {
id: number;
branch_code: string;
branch_name: string;
swift_code: string;
bic: string;
}
declare class BanksService {
private apiClient;
constructor(client: ApiClient);
/** Query all supported Banks in a specified country.
* @param country The country code (e.g., 'NG', 'GH', 'KE')
*/
list(country: string): Promise<Bank[]>;
/** Query the branch code for a specific Bank.
* @param bankId The ID of the bank (can be obtained from the list() method).
*/
branches(bankId: string | number): Promise<BankBranch[]>;
}
interface FlutterwaveResponse<T> {
status: "success" | "error";
message: string;
data: T;
meta?: {
page_info?: {
total: number;
current_page: number;
total_pages: number;
};
authorization?: {
mode: string;
endpoint: string;
};
};
}
interface FlutterwaveErrorResponse {
status: "error";
message: string;
data?: unknown;
code?: string;
}
interface PaginationOptions {
page?: number;
pageSize?: number;
from?: string;
to?: string;
}
type Country = "NG" | "GH" | "KE" | "UG" | "TZ" | "ZA" | "RW" | "MW" | "SL" | "CM" | "CI" | "SN" | "BF" | "ET" | "EG" | "US" | "GB" | "FR" | "DE" | "IT" | "ES" | "BE" | "NL" | "PT" | "IE" | "AT" | "CH" | "SE" | "NO" | "FI" | "DK" | "LU" | "IS" | "MT" | "CY" | "SK" | "SI" | "EE" | "LV" | "LT" | "PL" | "CZ" | "HU" | "RO" | "BG" | "HR" | "GR" | "LI" | "MC" | "SM" | "VA" | "AD" | "AL" | "BA" | "MK" | "ME" | "RS" | "TR" | "UA" | "BY" | "RU" | "MD" | "GE" | "AM" | "AZ" | "KZ" | "UZ" | "TM" | "KG" | "TJ" | "AF" | "PK" | "IN" | "BD" | "LK" | "NP" | "BT" | "MV" | "MM" | "TH" | "LA" | "VN" | "KH" | "MY" | "SG" | "ID" | "PH" | "BN" | "TL" | "CN" | "JP" | "KR" | "KP" | "MN" | "HK" | "MO" | "TW" | "AU" | "NZ" | "FJ" | "PG" | "SB" | "VU" | "NC" | "PF" | "WS" | "TO" | "TV" | "KI" | "NR" | "MH" | "FM" | "PW" | "GU" | "MP" | "AS" | "CK" | "NU" | "TK" | "WF" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI" | "TO" | "WS" | "SB" | "NR" | "TV" | "VU" | "FJ" | "FM" | "MH" | "PW" | "KI";
type Currency = "NGN" | "GBP" | "CAD" | "XAF" | "CLP" | "COP" | "EGP" | "EUR" | "GHS" | "GNF" | "KES" | "MWK" | "MAD" | "RWF" | "SLL" | "STD" | "ZAR" | "TZS" | "UGX" | "USD" | "XOF" | "ZMW";
interface Authorization {
mode: string;
pin: number;
city: string;
address: string;
state: string;
country: string;
zipcode: number;
}
interface Meta {
flightID: string;
sideNote: string;
}
type Charge = {
amount: number;
currency: Currency;
tx_ref: string;
fullname?: string;
client_ip?: string;
redirect_url: string;
device_fingerprint?: string;
phone_number?: string;
};
interface ChargeCardPaylood extends Omit<Charge, "phone_number"> {
card_number: string;
cvv: number;
expiry_month: number;
expire_year: number;
email: string;
authorization?: Authorization;
preauthorize?: boolean;
card_holder_name?: string;
payment_plan?: string;
meta: Meta;
eci?: string;
a_authenticationtoken: string;
a_amount?: string;
a_version?: string;
a_transactionid?: string;
a_transactionstatus?: string;
a_statusreasoncode: string;
is_custom_3ds_enabled: boolean;
a_time?: Date;
}
interface ChargeCardResponse {
data: {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: null;
name: string;
email: string;
created_at: string;
};
card: {
last_4digits: string;
issuer: string;
country: string;
type: string;
expiry: string;
};
};
meta: {
authorization: {
mode: string;
endpoint: string;
};
};
}
interface ChargeBankTransferPaylod extends Omit<Charge, "redirect_url"> {
is_permanent?: boolean;
narration?: string;
subaccounts?: Record<"id", string>[];
meta: Meta;
email: string;
}
interface ChargeBankTransferResponse {
meta: {
authorization: {
transfer_reference: string;
transfer_account: string;
transfer_bank: string;
account_expiration: string;
transfer_note: string;
transfer_amount: number;
mode: string;
};
};
}
interface ChargeACHPayload extends Charge {
email: string;
phone_number?: string;
meta: Meta;
country?: Country;
}
interface ChargeACHResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
auth_url: string;
currency: string;
ip: string;
narration: string;
status: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
redirect_url: string;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
}
interface ChargeBankPayload extends Omit<Charge, "amount" | ""> {
account_bank: string;
account_number: string;
email: string;
meta: Meta;
}
interface ChargeBankResponse {
amount: string;
type: string;
redirect: boolean;
created_at: string;
order_ref: string;
flw_ref: string;
redirect_url: null;
payment_code: string;
type_data: string;
meta: {
authorization: {
account_number: string;
sort_code: string;
};
};
}
interface ChargeBankNGResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
meta: {
authorization: {
mode: string;
redirect: string;
validate_instructions: string;
};
};
}
interface ChargeMpesaPayload extends Charge {
email: string;
phone_number: string;
meta: Meta;
}
interface ChargeMpesaResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
}
interface ChargeGhanaMobilePayload extends Charge {
email: string;
phone_number: string;
network: "MTN" | "VODAFONE" | "TIGO";
meta: Meta;
}
interface ChargeGhanaMobileResponse {
authorization: {
redirect: string;
mode: string;
};
}
interface ChargeRwandaMobilePayload extends Charge {
order_id: string;
email: string;
phone_number: string;
meta: Meta;
}
interface ChargeRwandaMobileResponse {
authorization: {
redirect: string;
mode: string;
};
}
interface ChargeUgandaMobileMobilePayload extends Charge {
order_id?: string;
email: string;
phone_number: string;
meta: Meta;
voucher?: number;
network?: "MTN" | string;
}
interface ChargeUgandaMobileResponse {
authorization: {
redirect: string;
mode: string;
};
}
interface ChargeFrancoPhoneMobilePaylaod extends ChargeACHPayload {
}
interface ChargeFranncophoneMobileResponse {
data: {
id: number;
tx_ref: string;
flw_ref: string;
order_id: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
processor_response: string;
};
meta: {
authorization: {
mode: string;
redirect_url: string;
};
};
}
interface ChargeTanzaniaMobilePayload extends ChargeGhanaMobilePayload {
}
interface ChargeTanzaniaMobileResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
}
interface Charge1VoucherPayload extends Charge {
country?: Country;
pin: number;
}
interface Charge1VoucherResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
}
interface ChargeApplePay extends Omit<Charge, "phone_number"> {
email: string;
billing_address?: string;
billing_city?: string;
billing_state?: string;
billing_country?: Country;
billing_zip?: string;
meta: Meta;
}
interface ChargeApplePayResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
meta: {
authorization: {
mode: string;
redirect: string;
};
};
}
interface ChargeGooglePay extends ChargeApplePay {
}
interface ChargeGooglePayResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: null;
name: string;
email: string;
created_at: string;
};
meta: {
authorization: {
mode: string;
redirect: string;
};
};
}
interface ChargeENairaPayload extends Charge {
email: string;
meta: Meta;
}
interface ChargeENairaResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: null;
name: string;
email: string;
created_at: string;
};
meta: {
authorization: {
mode: string;
redirect: string;
};
};
}
interface ChargeUSSDPayload extends Charge {
email: string;
meta: Meta;
}
interface ChargeUSSDResponse {
data: {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
payment_code: string;
};
meta: {
authorization: {
mode: string;
note: string;
};
};
}
interface ChargeNQRPayload extends Charge {
email: string;
is_nqr: number;
meta: Meta;
}
interface ChargeNQRResponse {
data: {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
};
meta: {
authorization: {
qr_image: string;
mode: string;
validate_instructions: string;
};
};
}
interface ChargeOpayPayload extends Charge {
email: string;
meta: Meta;
fullame: string;
}
interface ChargeOpayResponse {
data: {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
};
meta: {
authorization: {
qr_image: string;
mode: string;
validate_instructions: string;
};
};
}
interface ChargeCaptecPaylod extends Charge {
}
interface ChargeCaptecResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
}
interface ChargeFawryPayPayload extends Charge {
meta: Meta;
fullname: string;
}
interface ChargeFawryResponse {
data: {
id: number;
tx_ref: string;
order_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
currency: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: string;
name: string;
email: string;
created_at: string;
};
};
meta: {
authorization: {
mode: string;
instruction: string;
};
};
}
interface ValidateChargePayload {
otp: string;
flw_ref: string;
type: "card" | "account";
}
interface ValidateChargeResponse {
id: number;
tx_ref: string;
flw_ref: string;
device_fingerprint: string;
amount: number;
charged_amount: number;
app_fee: number;
merchant_fee: number;
processor_response: string;
auth_model: string;
currency: string;
ip: string;
narration: string;
status: string;
auth_url: string;
payment_type: string;
fraud_status: string;
charge_type: string;
created_at: string;
account_id: number;
customer: {
id: number;
phone_number: null;
name: string;
email: string;
created_at: string;
};
card: {
first_6digits: string;
last_4digits: string;
issuer: string;
country: string;
type: string;
expiry: string;
};
}
declare class ChargeService {
private client;
constructor(apiClient: ApiClient);
/**
* Collect card payments with Flutterwave.
* We recommend you read the {@link https://developer.flutterwave.com/docs/direct-card-charge} method overview before you proceed.
*/
card(payload: ChargeCardPaylood): Promise<ChargeCardResponse>;
/**
* Generate dynamic virtual accounts for instant payments via bank transfers.
* We recommend you read the {@link https://developer.flutterwave.com/docs/bank-transfer-1} method overview before you proceed.
*/
bankTransfer(payload: ChargeBankTransferPaylod): Promise<ChargeBankTransferResponse>;
/**
* Collect ACH payments for USD and ZAR transactions. We recommend you read the method overview before you proceed.
* {@linnk https://developer.flutterwave.com/docs/ach-payment}
*/
ach(payload: ChargeACHPayload): Promise<ChargeACHResponse>;
/**
* Charge Customers UK and EU bank accounts. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/uk-and-eu}
*/
bank_uk_eu(paylaod: ChargeBankPayload): Promise<ChargeBankResponse>;
/**
* Charge Nigerian bank accounts using Flutterwave. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/nigeria}
*/
bank_ng(payload: ChargeBankPayload): Promise<ChargeBankNGResponse>;
/**
* Collect Mpesa payments from customers in Kenya. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/m-pesa}
*/
mpesa(payload: ChargeMpesaPayload): Promise<ChargeMpesaResponse>;
/**
* Collect mobile money payments from customers in Ghana. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/ghana}
*/
ghanaMobile(payload: ChargeGhanaMobilePayload): Promise<ChargeGhanaMobileResponse>;
/**
* Collect mobile money payments from customers in Rwanda. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/rwanda}
*/
rwandaMobile(payload: ChargeRwandaMobilePayload): Promise<ChargeRwandaMobileResponse>;
/**
* Receive mobile money payments from customers in Uganda. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/uganda}
*/
ugandaMobile(payload: ChargeUgandaMobileMobilePayload): Promise<ChargeUgandaMobileResponse>;
/**
* Collect mobile money payments from customers in Francophone countries. This method supports payment from Cameroon,
* Cote d'Ivoire, Mali and Senegal. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/francophone}
*/
francophoneMobile(payload: ChargeFrancoPhoneMobilePaylaod): Promise<ChargeFranncophoneMobileResponse>;
/**
* This document describes how to collect payments via Tanzania mobile money.
*/
tanzaniaMobile(payload: ChargeTanzaniaMobilePayload): Promise<ChargeTanzaniaMobileResponse>;
/**
* This document describes how to collect payments via Zambia mobile money.
*/
zambiaMobile(paylaod: unknown): Promise<unknown>;
/**
* Charge South African customers via 1Voucher. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/1voucher}
*/
voucher(payload: Charge1VoucherPayload): Promise<Charge1VoucherResponse>;
/**
* Accept payments from your customers with Apple Pay. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/apple-paytm%EF%B8%8F}
*/
applePay(payload: ChargeApplePay): Promise<ChargeApplePayResponse>;
/**
* Accept payments from your customers with Google Pay. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/google-paytm%EF%B8%8F}
*/
googlePay(payload: ChargeGooglePay): Promise<ChargeGooglePayResponse>;
/**
* Accept payment from eNaira wallets. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/enaira-payment}
*/
enaira(paylaod: ChargeENairaPayload): Promise<ChargeENairaResponse>;
/**
* Collect USSD payments from customers in Nigeria. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/ussd}
*/
ussd(payload: ChargeUSSDPayload): Promise<ChargeUSSDResponse>;
/**
* Generate QR images for NQR payments. We recommend you read the method overview before you proceed.
* {@link https://developer.flutterwave.com/docs/nibss-qr}
*/
nqr(payload: ChargeNQRPayload): Promise<ChargeNQRResponse>;
/**
* Collect payments from OPay wallets. We cover this payment method in more details in the method overview.
* {@link https://developer.flutterwave.com/docs/opay}
*/
opay(payload: ChargeOpayPayload): Promise<ChargeOpayResponse>;
/**
* Collect capitec payments with Flutterwave. we recommend you read the overview before you proceed.
*/
capitec(payload: ChargeCaptecPaylod): Promise<ChargeCaptecResponse>;
/**
* Receive Fawry payments from customers in Egypt. Read the overview for this payment method before proceeding.
* {@link https://developer.flutterwave.com/docs/fawry-pay}
*/
fawryPay(payload: ChargeFawryPayPayload): Promise<ChargeFawryResponse>;
/**
* Validate a pending transaction using an OTP (Card or account charges)
*/
validate(payload: ValidateChargePayload): Promise<ValidateChargeResponse>;
}
interface GenerateOtpPayload {
length?: number;
customer: {
name: string;
email: string;
phone: string;
};
sender: string;
send: boolean;
medium?: ("sms" | "email" | "whatsapp")[];
expiry?: number;
}
type GenerateOtpResult = {
medium: string;
reference: string;
otp: string;
expiry: string;
}[];
declare class OTPServices {
private client;
constructor(apiClient: ApiClient);
/**
* Create OTP strings of varying lengths.
*/
generate(payload: GenerateOtpPayload): Promise<GenerateOtpResult>;
/**
* Validate an OTP
* @param otp The one time password sent to the customer.
*/
validate(payload: {
otp: string;
}): Promise<unknown>;
}
interface PaymentInitPayload {
tx_ref: string;
amount: string | number;
currency: Currency;
redirect_url: string;
payment_options?: string;
customer: {
email: string;
phonenumber?: string;
name?: string;
};
customizations?: {
title?: string;
description?: string;
logo?: string;
};
meta?: Record<string, unknown>;
subaccounts?: Array<{
id: string;
transaction_split_ratio?: number;
transaction_charge_type?: string;
transaction_charge?: number;
}>;
}
interface PaymentInitResponse {
link: string;
}
declare class PaymentService {
private apiClient;
constructor(client: ApiClient);
/**
* Generate Flutterwave checkout to receive payments from customers (Standard payment)
* @param payload Payment details
*/
initiate(payload: PaymentInitPayload): Promise<PaymentInitResponse>;
}
type TransferMeta = {
sender: string;
sender_address?: string;
sender_city?: string;
sender_country: Country;
sender_id_number?: string;
sender_id_type?: "PASSPORT" | "DRIVING LICENSE" | "ID CARD" | "VOTER CARD";
sender_id_expiry?: string;
sender_mobile_number?: string;
sender_email_address?: string;
sender_occupation?: string;
sender_beneficiary_relationship?: string;
first_name: string;
last_name: string;
email: string;
mobile_number: string;
beneficiary_mobile_number: string;
recipient_address: string;
beneficiary_state: string;
beneficiary_country: Country;
beneficiary_occupation: string;
transfer_purpose?: string;
routing_number?: string;
merchant_name?: string;
account_number?: string;
};
interface CreateTransferPayload {
account_bank: string;
account_number: string;
amount: number;
currency: Currency;
debit_subaccount?: string;
beneficiary: number;
beneficiary_name: string;
reference?: string;
debit_currency?: Currency;
destination_branch_code?: string;
callback_url?: string;
narration?: string;
meta: TransferMeta;
}
interface CreateTransferResponse {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
currency: string;
debit_currency: string;
amount: number;
fee: number;
status: string;
reference: string;
meta: null;
narration: string;
complete_message: string;
requires_approval: number;
is_approved: number;
bank_name: string;
}
interface RetryTransferResponse {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
currency: string;
debit_currency: string;
amount: number;
fee: number;
status: string;
reference: string;
meta: null;
complete_message: string;
requires_approval: number;
is_approved: number;
bank_name: string;
}
type BulkTransfer = {
email: string;
mobile_number: string;
recipient_address: string;
first_name?: string;
last_name?: string;
};
interface BulkTransferPayload {
currency: Currency;
title?: string;
error_reporting?: boolean;
entity?: string;
bulk_data: BulkTransfer[];
}
interface BulkTransferResponse {
id: number;
created_at: string;
approver: string;
}
type Fee = {
fee_type: string;
currency: string;
fee: number;
};
interface QueryFeeResponse {
data: Fee[];
}
interface ListTransferPayload {
reference?: string;
page?: number;
status?: "failed" | "successful";
from?: Date | string;
to?: Date | string;
include_proof?: boolean;
include_provider_ref?: boolean;
include_approver_info?: boolean;
include_vat?: string;
include_date_completed?: string;
include_rate?: string;
include_debit_currency_amount?: string;
page_size?: number;
}
interface ListTransferMeta {
page_info?: {
total: number;
current_page: number;
total_pages: number;
};
AccountId?: number;
merchant_id?: string;
}
interface ListTransferResponse {
meta: ListTransferMeta;
data: {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
currency: string;
debit_currency: string | null;
amount: number;
fee: number;
status: string;
reference: string;
meta: ListTransferMeta | {
sender: string;
mobile_number: string;
}[];
narration: null | string;
approver: null;
complete_message: string;
requires_approval: number;
is_approved: number;
bank_name: string;
debit_currency_amount: null;
rate: null;
}[];
}
interface Transfer {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
currency: string;
debit_currency: string;
amount: number;
fee: number;
status: string;
reference: string;
meta: null;
narration: string;
approver: null;
complete_message: string;
requires_approval: number;
is_approved: number;
bank_name: string;
}
interface Retry {
id: number;
account_number: string;
bank_code: string;
bank_name: string;
full_name: string;
currency: string;
debit_currency: string;
amount: number;
fee: number;
status: string;
reference: string;
narration: null;
complete_message: string;
meta: null;
requires_approval: number;
is_approved: number;
created_at: string;
}
interface GetBulkTransferPayload {
batch_id: string;
page?: number;
from?: Date | string;
to?: Date | string;
include_proof?: string;
include_provider_ref?: string;
include_approver_info?: string;
include_vat?: string;
include_rate?: string;
include_debit_currency?: string;
include_retry_tag?: string;
}
interface GetBulkTransferResponse {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
currency: string;
debit_currency: string;
amount: number;
fee: number;
status: string;
reference: string;
meta: null;
narration: string;
approver: null;
complete_message: string;
requires_approval: number;
is_approved: number;
bank_name: string;
}
interface QueryRateResponse {
rate: number;
source: {
currency: string;
amount: number;
};
destination: {
currency: string;
amount: number;
};
}
interface BulkRates {
batch_reference: string;
data: {
from: Currency;
to: Currency;
amount: number;
}[];
}
interface From {
currency: string;
amount: number;
}
interface To {
currency: string;
amount: number | null;
}
interface VerifyBulkRateResponse {
rate: number | null;
from: From;
to: To;
status: string;
error: null | string;
}
declare class TransferService {
private apiClient;
constructor(client: ApiClient);
/** This will show you how to initiate a transfer */
create(payload: CreateTransferPayload): Promise<CreateTransferResponse>;
/** This helps you retry a previously failed transfer. */
retry(payload: {
id: string;
}): Promise<RetryTransferResponse>;
/** This document shows you how to initiate a bulk transfer */
bulkTransfer(payload: BulkTransferPayload): Promise<BulkTransferResponse>;
/** Get applicable transfer fee */
queryFee(payload: {
amount: number;
currency: Currency;
type: "mobilemoney" | "account";
}): Promise<QueryFeeResponse>;
/** Fetch all transfers on your account */
list(payload: ListTransferPayload): Promise<ListTransferResponse>;
/** Fetch a single transfer on your account */
get(payload: {
id: string;
}): Promise<Transfer>;
/** Fetch transfer retry attempts for a single transfer on your account.*/
getRetry(payload: {
id: string;
}): Promise<Retry[]>;
/** Get the status of a bulk transfer on your account*/
getBulkTransfer(payload: GetBulkTransferPayload): Promise<GetBulkTransferResponse>;
/** This endpoint helps you understand transfer rates when making international transfers */
queryTransferRates(payload: {
amount: number;
destination_currency: Currency;
source_currency: Currency;
}): Promise<QueryRateResponse>;
queryBulkRates(payload: BulkRates): Promise<unknown>;
verifyBulkRates(payload: {
id: string;
}): Promise<VerifyBulkRateResponse[]>;
}
interface CreateBeneficiaryPayload {
account_bank: string;
account_number: string;
beneficiary_name: string;
currency: Currency;
bank_name: string;
}
interface CreateBeneficiaryRespose {
id: number;
account_number: string;
bank_code: string;
full_name: string;
created_at: string;
bank_name: string;
}
interface Beneficiary {
id: number;
account_number: string;
bank_code: string;
full_name: string;
meta: null;
created_at: string;
bank_name: string;
}
interface ListBeneficiariesResponse {
data: Beneficiary[];
meta: {
page_info: {
total: number;
current_page: number;
total_pages: number;
};
};
}
declare class TransferBeneficiaryService {
private apiClient;
constructor(client: ApiClient);
/** Create a transfer beneficiary */
create(payload: CreateBeneficiaryPayload): Promise<CreateBeneficiaryRespose>;
/** Get all beneficiaries */
list(payload: {
page: number;
}): Promise<ListBeneficiariesResponse>;
/** Get a single transfer beneficiary details */
get(paylaod: {
id: string;
}): Promise<Beneficiary>;
/** Delete a transfer beneficiary */
delete(payload: {
id: string;
}): Promise<unknown>;
}
interface CreateVirtualAccountPayload {
email: string;
currency: Currency;
amount: number;
tx_ref: string;
is_permanent?: boolean;
narration?: string;
bvn?: string;
phonenumber?: string;
}
interface CreateVirtualAccountResponse {
response_code: string;
response_message: string;
flw_ref: string;
order_ref: string;
account_number: string;
frequency: string;
bank_name: string;
created_at: string;
expiry_date: string;
note: string;
amount: number;
}
interface BulkVirtualAccountPayload {
batch_ref: string;
bulk_data: {
lastname: string;
firstname: string;
email: string;
bvn: string;
nin?: string;
is_permanent?: boolean;
}[];
narration?: string;
currency: Currency;
}
interface BulkVirtualAccountResponse {
batch_id: string;
response_code: string;
response_message: string;
}
interface VirtualAccount {
response_code: string;
response_message: string;
flw_ref: string;
order_ref: string;
account_number: string;
frequency: string;
bank_name: string;
created_at: string;
expiry_date: string;
note: string;
amount: number;
}
declare class VirtualAccountService {
private apiClient;
constructor(client: ApiClient);
/**
* Create a Virtual Account for Your Customer.
*/
create(payload: CreateVirtualAccountPayload): Promise<CreateVirtualAccountResponse>;
/**
* Create Virtual Account Numbers in Bulk.
*/
createBulk(payload: BulkVirtualAccountPayload): Promise<BulkVirtualAccountResponse>;
/** Retrieve virtual account information using its account number */
get(payload: {
account_number: string;
}): Promise<VirtualAccount>;
/** Query virtual account information using the batch ID from the batch creation response. */
getBulk(payload: {
batch_id: string;
}): Promise<VirtualAccount[]>;
/** Update the BVN of existing virtual accounts. */
updateBVN(payload: {
order_ref: string;
bvn: string;
}): Promise<unknown>;
/** Delete a virtual account */
delete(payload: {
order_ref: string;
status: "active" | "inactive" | string;
}): Promise<{
status: string;
status_desc: string;
}>;
}
declare class FlutterwaveError extends Error {
readonly status?: string;
readonly code?: string;
readonly data?: unknown;
constructor(message: string, status?: string, code?: string, data?: unknown);
}
declare class Flutterwave {
private apiClient;
banks: BanksService;
payments: PaymentService;
otp: OTPServices;
charges: ChargeService;
transfer: TransferService;
beneficiary: TransferBeneficiaryService;
virtualAccount: VirtualAccountService;
constructor(config: FlutterwaveConfig);
ping(): Promise<{
status: string;
message: string;
}>;
}
export { type Bank, type BankBranch, type Beneficiary, type BulkRates, type BulkTransferPayload, type BulkTransferResponse, type BulkVirtualAccountPayload, type BulkVirtualAccountResponse, type Charge1VoucherPayload, type Charge1VoucherResponse, type ChargeACHPayload, type ChargeACHResponse, type ChargeApplePay, type ChargeApplePayResponse, type ChargeBankNGResponse, type ChargeBankPayload, type ChargeBankResponse, type ChargeBankTransferPaylod, type ChargeBankTransferResponse, type ChargeCaptecPaylod, type ChargeCaptecResponse, type ChargeCardPaylood, type ChargeCardResponse, type ChargeENairaPayload, type ChargeENairaResponse, type ChargeFawryPayPayload, type ChargeFawryResponse, type ChargeFrancoPhoneMobilePaylaod, type ChargeFranncophoneMobileResponse, type ChargeGhanaMobilePayload, type ChargeGhanaMobileResponse, type ChargeGooglePay, type ChargeGooglePayResponse, type ChargeMpesaPayload, type ChargeMpesaResponse, type ChargeNQRPayload, type ChargeNQRResponse, type ChargeOpayPayload, type ChargeOpayResponse, type ChargeRwandaMobilePayload, type ChargeRwandaMobileResponse, type ChargeTanzaniaMobilePayload, type ChargeTanzaniaMobileResponse, type ChargeUSSDPayload, type ChargeUSSDResponse, type ChargeUgandaMobileMobilePayload, type ChargeUgandaMobileResponse, type Country, type CreateBeneficiaryPayload, type CreateBeneficiaryRespose, type CreateTransferPayload, type CreateTransferResponse, type CreateVirtualAccountPayload, type CreateVirtualAccountResponse, type Currency, type Fee, Flutterwave, type FlutterwaveConfig, FlutterwaveError, type FlutterwaveErrorResponse, type FlutterwaveResponse, type GenerateOtpPayload, type GenerateOtpResult, type GetBulkTransferPayload, type GetBulkTransferResponse, type ListBeneficiariesResponse, type ListTransferPayload, type ListTransferResponse, type PaginationOptions, type PaymentInitPayload, type PaymentInitResponse, type QueryFeeResponse, type QueryRateResponse, type Retry, type RetryTransferResponse, type Transfer, type ValidateChargePayload, type ValidateChargeResponse, type VerifyBulkRateResponse, type VirtualAccount, Flutterwave as default };