The verdict in three sentences
Integrating M-Pesa Daraja in Nairobi requires a till number/shortcode, a consumer key/secret and a public callback URL to receive STK Push results. Buy Goods merchant fees run 0 to 0.55 %, average latency is 2 to 6 seconds, and the failure rate sits between 6 and 11 %. A 60-second timeout and a single retry turn most of those transient failures into completed sales.
The M-Pesa Daraja STK Push flow step by step
| Step | Technical action | 2026 detail |
|---|---|---|
| 1 | Get consumer key + secret | Via the Safaricom Daraja portal |
| 2 | Generate an OAuth token | Lifetime ~3600 s |
| 3 | Call STK Push | Amount, KES, unique AccountReference |
| 4 | Customer enters PIN | Prompt pushed to their phone |
| 5 | Receive callback POST | Safaricom hits your callback URL |
| 6 | Read ResultCode 0/other | Confirm the order server-side |
Key point: use an idempotent AccountReference per order to avoid double charges on retry. Never confirm an order on the front-end response alone — wait for the ResultCode 0 callback confirmed server-side.
M-Pesa Daraja (Nairobi) vs MTN MoMo (Abidjan)
| Criterion | M-Pesa Daraja (KE) | MTN MoMo (CI) |
|---|---|---|
| Merchant fee | 0 to 0.55 % (Buy Goods) | ~1.5 % |
| Mechanism | STK Push + callback | requesttopay + polling |
| Merchant ID | till number / shortcode | apiuser/apikey |
| Confirmation | Callback URL POST | Polling GET status |
| Average latency | 2-6 s | 3-8 s |
| Failure rate | 6-11 % | 4-9 % |
| Recommended timeout | 60 s | 90 s |
Structural difference: M-Pesa calls you back via a callback URL, while MTN makes you poll the status. The callback model saves requests but demands an always-available public endpoint — plan a queue and rely on Safaricom's own retries.
Mini case study
Wanjiru runs an accessories shop in Nairobi: 300 M-Pesa payments/month, average basket KES 1,500. At 0.55 % her monthly fees are just KES 2,475. But with a 9 % STK Push failure rate she loses 27 sales — about KES 40,500 in revenue. Adding a single retry after a 60 s timeout recovers roughly 60 % of those transient failures, i.e. 16 sales and KES 24,000/month saved. Reliability engineering beats fee optimization here.
FAQ
Need a professional website?
Kolonell builds websites that attract clients, optimized for the Sénégalese market. Free quote in 2 minutes.
Do I need the Daraja sandbox before production?
Yes, absolutely. The sandbox simulates STK Push, PIN entry and failure result codes. Test ResultCode 0, cancellation, timeout and insufficient-funds cases before switching to production keys.
How do I avoid double charges?
Use an idempotent AccountReference per order and check status before any new call. On retry, reuse the same reference so Safaricom recognises the transaction and does not charge twice.
What timeout should I set?
60 seconds for M-Pesa, since the customer must approve the STK prompt and enter their PIN. Below 30 s you cut off in-progress payments and inflate your failure rate.
What if my callback URL is unreachable?
Safaricom retries the callback, but you should still query the transaction status as a fallback. Always expose a health-checked, always-on endpoint behind a queue.
Is MTN MoMo relevant from Nairobi?
Not for selling in Kenya, but essential if you target West Africa. MTN uses requesttopay + polling, a different model you integrate separately.
Let's talk about your project. We integrate M-Pesa Daraja and MTN MoMo with sandbox testing, idempotency and smart retries so you stop losing sales. WhatsApp +221 77 596 93 33.
Mohamed Bah
Fondateur, Kolonell
Passionate about digital and entrepreneurship in Africa, Mohamed has been helping Sénégalese businesses with their digital transformation since 2020. Founder of Kolonell, he believes every SME deserves a professional and accessible online présence.

