TheDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/theresasogunle/Fintech-flutterwave-Java-Library/llms.txt
Use this file to discover all available pages before exploring further.
AlternativePayment class provides support for various alternative payment methods across Africa, including Nigerian USSD, Ghana Mobile Money, and Kenya M-Pesa.
Supported Payment Methods
Nigerian USSD
GTBank and Zenith Bank USSD payments
Ghana Mobile Money
MTN, Vodafone, AirtelTigo, and Tigo mobile money
Kenya M-Pesa
Safaricom M-Pesa payments
Configuration
First, configure your Rave credentials:Nigerian USSD
USSD payments allow customers to complete transactions by dialing a code on their mobile phone. This method works with GTBank and Zenith Bank.Parameters
Customer’s account number
Bank short code (“058” for GTBank, “057” for Zenith)
Transaction amount
Customer’s email address
Your unique transaction reference
Customer’s first name
Customer’s last name
Customer’s account PIN
Customer’s IP address
Currency code (must be “NGN”)
Country code (must be “NG”)
Example
The customer will receive a USSD code to dial on their phone to complete the payment. The payment type is automatically set to
"ussd".Ghana Mobile Money
Accept payments from major Ghanaian mobile money networks including MTN, Vodafone, AirtelTigo, and Tigo.Parameters
Unique reference for the mobile money transaction (merchant-provided)
Mobile money network provider (e.g., “MTN”, “VODAFONE”, “TIGO”)
Customer’s mobile money phone number
Transaction amount
Customer’s email address
Your unique transaction reference
Customer’s first name
Customer’s last name
Customer’s mobile money PIN
Customer’s IP address
Currency code (must be “GHS”)
Country code (must be “GH”)
Example
Supported Networks
- MTN:
"MTN" - Vodafone:
"VODAFONE" - AirtelTigo:
"AIRTELTIGO" - Tigo:
"TIGO"
Kenya M-Pesa
Accept payments via Safaricom M-Pesa, Kenya’s leading mobile money platform.Parameters
Unique reference for the M-Pesa transaction (merchant-provided)
Customer’s M-Pesa phone number (format: 0XXXXXXXXX)
Transaction amount
Customer’s email address
Your unique transaction reference
Customer’s first name
Customer’s last name
Customer’s M-Pesa PIN
Customer’s IP address
Currency code (must be “KES”)
Country code (must be “KE”)
Example
The customer will receive an M-Pesa prompt on their phone to authorize the payment. They must enter their M-Pesa PIN on their phone to complete the transaction.
Verifying Transactions
For all alternative payment methods, you should verify the transaction status after charging:Initiate Payment
Call the appropriate charge method (
chargeNigerianUssd(), chargeGhanaMobileMoney(), or chargeKenyaMpesa())Method Reference
| Method | Payment Type | Returns | Description |
|---|---|---|---|
chargeNigerianUssd() | Nigerian USSD | JSONObject | Charges via GTB/Zenith USSD |
chargeGhanaMobileMoney() | Ghana Mobile Money | JSONObject | Charges via Ghanaian mobile networks |
chargeKenyaMpesa() | Kenya M-Pesa | JSONObject | Charges via Safaricom M-Pesa |
Payment Type Indicators
Each method automatically sets the appropriate payment type:- Nigerian USSD:
payment_type: "ussd" - Ghana Mobile Money:
payment_type: "mobilemoneygh",is_mobile_money_gh: "1" - Kenya M-Pesa:
payment_type: "mpesa",is_mpesa: "1"
Best Practices
- USSD
- Mobile Money
- M-Pesa
- Clearly display the USSD code to the customer
- Provide instructions on how to dial the code
- Set appropriate timeout periods (USSD sessions can expire)
- Implement webhook handlers for async updates
Troubleshooting
Common Issues
Transaction Pending- Customer hasn’t completed the payment on their device
- Use
verifyTransactionXrequery()to check current status - Wait for webhook notification if configured
- Verify the network name is correct and supported
- Ensure currency and country match the payment method
- Ghana Mobile Money: Include country code if required
- Kenya M-Pesa: Use format 0XXXXXXXXX (not +254XXXXXXXXX)
Next Steps
Card Payments
Accept credit and debit card payments
Account Payments
Charge customer bank accounts directly