Mobile Money Integration
Mobile Money Integration Guide
Overview
Mobile money integration with PayOS enables you to accept payments through various mobile money providers in Zambia. This guide details the complete integration process using PayOS’s API.
Prerequisites
Before integrating mobile money payments, ensure you have:
- A PayOS account with mobile money enabled
- OAuth2 client credentials (Client ID and Secret)
- Webhook endpoint configured to receive transaction status updates
Integration Steps
1. Authentication (OAuth2 Client Credentials Flow)
First, obtain an access token using your OAuth2 credentials:
The response will include your access token:
2. Session Creation
M-Pesa requires that payment amounts need to be in whole major unit values (i.e. no minor units like cents). Always send whole major unit values for payment amount fields (in practice this means a payment amount of 100 as 11.50 is not).
Create a payment session using the obtained access token:
The response will include:
In case of failure:
Important:
- The
merchantReference
must be unique for each transaction. It’s recommended to stick to only alphanumeric for acceptance across processors, but you can include other characters. However note that they might appear stripped of these on a customer’s statement- You’ll handle the payment flow in your application using the
sessionId
3. Payment Initiation
Initiate the mobile money payment using the session ID:
Transaction Response
A successful initiation will return a response like this:
4. Payment Polling
To check the status of a payment transaction, use the polling endpoint:
Payment Transaction States
After initiation, the payment transaction will move through different states:
-
PENDING: Transaction has been accepted and is being processed
- At this point, you should display a loading page to the user
- The customer will receive a prompt on their mobile phone to approve the payment
-
SUCCESS: Transaction has been successfully completed
- You will receive a webhook notification
- The customer’s payment has been processed
-
FAILED: Transaction has failed
- You will receive a webhook notification with the failure reason
- The customer should be prompted to try again
Payment Transaction Response Examples
Successful Response
Pending Response
Failed Response
Common Failure Scenarios
Here’s an example of a failure response:
The following table lists all possible failure codes and their descriptions:
Supported Providers
PayOS supports the following mobile money providers in Zambia:
PayOS supports the following mobile money providers in Ghana:
PayOS supports the following mobile money providers in Kenya:
Best Practices
Security
- Store OAuth credentials securely
- Use HTTPS for all API calls
- Implement proper error handling
- Validate all input data
Transaction Management
- Implement proper logging
- Monitor webhook notifications
- Set up alerts for failed transactions
- Handle timeout scenarios appropriately
- Poll transaction status regularly until a final state is reached
Testing
- Use test credentials in sandbox environment
- Test with various amount ranges
- Verify error scenarios
- Test webhook integration thoroughly
Sandbox Testing Numbers
When testing in the sandbox environment, use the following phone numbers to simulate different transaction scenarios:
Any other valid phone number format will result in a successful transaction in the sandbox environment.
Note: These test numbers are for sandbox testing only and will not work in the production environment.
Rate Limiting
- Standard rate limit: 100 requests per minute
- Burst rate limit: 200 requests per minute for 5 minutes
- Implement exponential backoff for retries
Support
For integration support:
- Technical documentation: docs.payos.money
- Email support: support@payos.money
- Integration support hours: 24/7