Flutterwave Setup & Integration Guide
The flutterwave provider integrates Flutterwave API v3 Standard Checkout, Subscriptions, Saved Cards, and Chargeback Tracking across African and international markets (NGN, GHS, KES, UGX, TZS, RWF, XOF, XAF, ZAR, USD, EUR, GBP).
1. Prerequisites & Installation
Section titled “1. Prerequisites & Installation”Kirak connects to Flutterwave directly via async REST API calls with httpx. No external Flutterwave SDK or additional pip package is required.
pip install "kirak"2. Credentials & Configuration
Section titled “2. Credentials & Configuration”Step 1: Obtain Secret Key
Section titled “Step 1: Obtain Secret Key”In the Flutterwave Dashboard:
- Navigate to Settings $\rightarrow$ API keys.
- Copy your Secret key (
FLWSECK_TEST-...in test mode,FLWSECK-...in live mode).
Step 2: Configure Webhook & Secret Hash
Section titled “Step 2: Configure Webhook & Secret Hash”In Settings $\rightarrow$ Webhooks:
- Set the URL to:
https://your-domain.com/payments/webhook/flutterwave. - Enter a Secret hash (a long random secret string of your choosing).
- Enable webhook retries (Flutterwave turns this off by default).
- Select the v3 webhook format.
- (Optional) Contact Flutterwave support (
hi@flutterwavego.com) to enable refund and chargeback webhooks for your merchant account.
Step 3: Configure kirak.json
Section titled “Step 3: Configure kirak.json”{ "payments": { "default_provider": "flutterwave", "providers": { "flutterwave": { "type": "flutterwave", "environment": "test", "country": "NG", "success_url": "https://your-domain.com/payment/success" } } }}| Setting | Type | Required | Description |
|---|---|---|---|
country |
string | Yes (for off-session) | Two-letter ISO country code of your merchant account (e.g. "NG", "KE") |
environment |
string | No | "test" (default) or "live" |
success_url |
string | No | Buyer return URL after checkout |
Step 4: Set Environment Variables
Section titled “Step 4: Set Environment Variables”KIRAK_PAYMENT_FLUTTERWAVE_SECRET_KEY=FLWSECK_TEST-...KIRAK_PAYMENT_FLUTTERWAVE_SECRET_HASH=your_secret_hash_from_step23. Usage Examples
Section titled “3. Usage Examples”3.1 One-Time Payment
Section titled “3.1 One-Time Payment”Amounts are passed in minor units (e.g. kobo for NGN; 250,000 kobo = NGN 2,500.00):
result = await kirak.payments.initiate_payment({ "provider": "flutterwave", "user_id": "usr_700", "amount": 250000, # ₦2,500.00 "currency": "NGN", "name": "Standard Access", "type": "one_time", "payment_email": "buyer@example.com",})
checkout_url = result["data"]["url"]3.2 Subscriptions
Section titled “3.2 Subscriptions”Subscriptions link to a Flutterwave Payment Plan ID:
result = await kirak.payments.initiate_payment({ "provider": "flutterwave", "user_id": "usr_700", "amount": 0, # Set by Flutterwave Plan "currency": "NGN", "name": "Pro Monthly Plan", "type": "subscription", "subscription_plan_id": "12345", # Flutterwave Plan ID "payment_email": "buyer@example.com",})[!WARNING] Cancellation Behavior: Flutterwave only supports immediate cancellation. Calling
cancel_subscriptionwithat_period_end: Truereturns501 NOT_SUPPORTED.
3.3 Saved Cards & Off-Session Charges
Section titled “3.3 Saved Cards & Off-Session Charges”- Save card during one-time payment: pass
save_payment_method: Truewithconsent. - Headless off-session charge:
Note: Because 3-D Secure is mandatory across most African issuing banks, off-session charges typically returnresult = await kirak.payments.charge_off_session({"provider": "flutterwave","user_id": "usr_700","amount": 100000, # ₦1,000.00"currency": "NGN","name": "Metered Storage","idempotency_key": "flw-overage-usr700-oct",})
status="REQUIRES_ACTION"withaction_urlfor the user to complete 2FA authentication.
4. Webhook Event Mapping
Section titled “4. Webhook Event Mapping”Normalized event |
Gateway Events | Description |
|---|---|---|
payment_completed |
charge.completed |
Payment completed and verified |
payment_failed |
charge.completed (status="failed") |
Payment failed |
subscription_cancelled |
subscription.cancelled |
Subscription cancelled |
refund_completed |
refund.completed |
Refund settled |
dispute_created |
chargeback.initiated |
Chargeback opened |
dispute_updated |
chargeback.accepted, chargeback.declined, chargeback.lost |
Chargeback updated |
payment_method_saved |
charge.completed (with card token) |
Reusable token stored |