Automatic Callback Handling
Moflay automatically handles all callbacks from Safaricom’s Daraja API after successful payments. You don’t need to implement any callback handling logic in your application.This means you can focus on building your payment flow without worrying about the complex callback processing that’s typically required when integrating directly with Safaricom’s Daraja API.
How It Works
1. Payment Initiation
When you initiate a payment through Moflay’s API, we:- Send the STK Push request to Safaricom
- Handle the authentication and token management
- Monitor the transaction status
2. Automatic Callback Processing
After Safaricom processes the payment, they send callbacks to Moflay’s servers:- Success callbacks - When payment is completed
- Timeout callbacks - When payment times out
- Cancellation callbacks - When user cancels the payment
3. Status Updates
Moflay automatically:- Processes all incoming callbacks from Safaricom
- Updates the transaction status in our system
- Provides real-time status updates through our API
- Handles retries and error scenarios
What You Need to Do
Nothing!
Moflay handles everything automatically. Simply:- Initiate payments using our API or SDK
- Wait for the response - the express endpoint waits until the user completes the payment
- Handle the final status in your application
Example Flow
Benefits of Automatic Callback Handling
Simplified Integration
- No callback endpoints to implement
- No webhook configuration required
- No callback validation needed
- No retry logic to manage
Reliability
- Automatic retries for failed callbacks
- Duplicate detection to prevent double processing
- Error handling for all edge cases
- Monitoring and alerting built-in
Security
- Secure callback processing on our infrastructure
- Automatic signature verification from Safaricom
- Encrypted data transmission throughout the flow
Transaction Statuses
Moflay provides clear transaction statuses that you can rely on:| Status | Description |
|---|---|
pending | Payment initiated, waiting for user action |
completed | Payment successfully completed |
failed | Payment failed (insufficient funds, user cancelled, etc.) |
Monitoring and Debugging
Real-time Status Updates
The express endpoint provides immediate status updates when you make a payment request:Dashboard Monitoring
View all transactions and their statuses in the Moflay Dashboard.Webhook Support (Coming Soon)
We’re working on webhook support for real-time notifications when transaction statuses change.Common Questions
Do I need to set up callback URLs?
Do I need to set up callback URLs?
No. Moflay handles all callback URLs automatically. You don’t need to configure anything.
How do I know when a payment is complete?
How do I know when a payment is complete?
The express endpoint tells you immediately. When you call the express payment endpoint, it waits until the user completes the payment and returns the final status in the response.
What if a payment fails or times out?
What if a payment fails or times out?
The express endpoint will return the appropriate status (
failed or timeout) immediately. You can handle these cases in your application logic without needing to poll or check status separately.Can I see detailed transaction information?
Can I see detailed transaction information?
Yes. You can view detailed transaction information including callback data in the Moflay Dashboard or through our API endpoints.
Is there a timeout for payments?
Is there a timeout for payments?
Yes, payments have a timeout period. If a user doesn’t complete the payment within the timeout window, the express endpoint will return a
timeout status. The exact timeout duration is managed by Safaricom’s Daraja API.Next Steps
- Start building your payment integration using our API or SDK
- Test thoroughly in the sandbox environment
- Monitor transactions through our dashboard
- Go live when you’re ready
If you’re migrating from a direct Daraja integration, you can remove all your callback handling code - Moflay takes care of everything!