The most common MoMo and Airtel Money API errors fall into five categories: (1) authentication failures (wrong API keys, expired tokens, incorrect Base64 encoding), (2) callback delivery failures (localhost URLs, HTTPS issues, server downtime), (3) transaction errors (insufficient balance, wrong phone format, duplicate references), (4) timeout errors (customer never confirmed), and (5) environment mismatches (sandbox credentials in production or vice versa). Most can be diagnosed by logging every request and response, and fixed by checking credentials, callback URL accessibility, and request formatting.
These are the errors you will hit first and the ones that cause the most frustration. If you cannot authenticate, nothing else works.
General advice: test authentication in isolation before building anything else. Use Postman, curl, or a simple script to get a token. If that works, your credentials are correct. If it fails, do not move on until it works.
The callback is where MoMo or Airtel Money tells your server whether the payment succeeded. If your server never receives the callback, your application never knows the payment result. This is the most common integration headache.
Debugging tactic: add logging to your callback endpoint that records every incoming request, including headers and body. If nothing appears in your logs, the callback is not reaching your server (a network/URL issue). If the callback appears but your app is not processing it, the issue is in your handler code.
Always implement status polling as a backup. After sending a payment request, poll the provider's status endpoint every few seconds. Even if the callback fails, polling gives you the result.
Get weekly developer tips
Join 25,000+ developers. Practical guides, job tips, and new content — straight to your inbox.
No spam. Unsubscribe anytime.
These errors occur during the payment flow itself, after authentication succeeds.
For each error, the provider's response body usually contains an error code and a reason field. Log these. The error messages can be cryptic, but they narrow down the problem significantly.
Timeouts are not bugs in your code. They are a normal part of mobile money payment flows. The customer might not have their phone nearby, might be in an area with poor network, or might simply decide not to confirm.
Design principle: never block the user indefinitely. Set a client-side timeout (show a "Still waiting..." message after 30 seconds, a "Payment timed out" message after 2-3 minutes) and a server-side timeout (stop polling after a defined period). Give the customer a clear path to retry or cancel.
These errors are easy to introduce and hard to diagnose because the error messages often look like authentication failures:
Prevention: use a .env file (never committed to git) with clearly named variables like MOMO_API_USER_ID, MOMO_API_KEY, MOMO_SUBSCRIPTION_KEY, MOMO_TARGET_ENV, and MOMO_BASE_URL. Load these in your application code. Have separate .env files for development (sandbox) and production.
For a complete guide on managing this transition, see our sandbox testing guide.
When something is not working and you are not sure why, follow this sequence:
If you are still stuck, the developer communities around MoMo and the aggregators can help. Post your error code (never post your API keys), the request you are making (with credentials redacted), and the response you are getting. Experienced developers can usually spot the issue from the error code and request format.
McTaba's M-Pesa Integration course (KES 9,999, approximately UGX 280,000) includes modules on debugging mobile money integrations, covering the systematic approach to isolating and fixing callback, authentication, and transaction errors. The debugging patterns transfer to MoMo and Airtel Money.
Create a free McTaba Academy account. Access starter lessons, join the community, and explore at your own pace.
Create Free Account