Overview
Transaction verification is a critical step in the payment flow. After initiating a charge, you must verify the transaction to confirm its actual status on Flutterwave’s servers. This prevents issues with network failures, timeouts, or fraudulent responses.When to Verify Transactions
You should verify transactions in these scenarios:- After a successful charge response - Confirm the transaction was actually completed
- On payment callback - When users are redirected back to your application
- For failed transactions - Requery failed transactions to check their actual status
- Webhook validation - Verify webhook notifications before processing
Available Methods
TheTransaction class provides two verification methods:
verifyTransactionRequery()
Verifies a transaction using the Flutterwave reference (flwRef) returned in the charge response.
Method Signature:
flwref- The Flutterwave reference from the charge responsetxRef- Your transaction reference (optional)
JSONObject containing transaction details
verifyTransactionXrequery()
Verifies a transaction using your own transaction reference or the Flutterwave reference. This method provides additional filtering options. Method Signature:txRef- Your unique transaction referencelast_attempt- Set to 1 to get only the last attemptonly_successful- Set to 1 to filter only successful transactions
JSONObject containing transaction details
Setup
Complete Example
Handling Verification Response
The verification response contains important transaction details:The
verifyTransactionXrequery() method is useful when you want to filter results by success status or retrieve only the last payment attempt.Best Practices
- Always verify server-side - Never trust client-side responses alone
- Store transaction references - Keep both your
txRefand Flutterwave’sflwRefin your database - Handle timeouts gracefully - If verification fails, retry with exponential backoff
- Verify amounts - Confirm the charged amount matches your expected amount
- Use webhooks - Implement webhook handlers for real-time payment notifications, but always verify webhook data
Next Steps
- Learn about refunding transactions
- Understand fee calculations
- Explore card payment methods