The verdict in three sentences
Integrating M-Pesa via Safaricom's Daraja API relies on an STK Push request that pops a PIN prompt on the customer's phone, followed by a callback that confirms the payment server-side. Plan for 2 to 5 days of development for a clean integration with sandbox, user-return handling and server verification. The golden rule: never mark an order paid on the browser return alone — always wait for the signed callback.
The technical steps of an M-Pesa integration
The Daraja flow rests on token auth, an STK Push and an asynchronous callback. Your server requests a token, triggers the push, then Safaricom notifies your callback URL.
| Step | Action | Side | Est. dev time |
|---|---|---|---|
| 1. API keys | Get Consumer Key + Secret in the Daraja portal | Config | 0.5 day |
| 2. OAuth token | Request short-lived access token | Server | 0.5 day |
| 3. STK Push | POST amount, phone, CallBackURL, account ref | Server | 1 day |
| 4. Callback | Receive result, verify ResultCode = 0 | Server | 1 day |
| 5. Reconciliation | Mark order paid, send the receipt | Server | 0.5 day |
| 6. Sandbox tests | Success, failure, timeout, double click | QA | 1 day |
The required STK Push fields are few: Amount (integer KES), PhoneNumber (2547XXXXXXXX), CallBackURL, AccountReference (your order ID) and TransactionDesc. Daraja returns a CheckoutRequestID you store to match the later callback.
Custom API or no-code plugin: what to pick
Not every store needs code. Here is the 2026 trade-off for East African merchants.
| Criterion | Custom API integration | Plugin / no-code |
|---|---|---|
| Upfront cost | KES 20,000 – 60,000 | KES 0 – 12,000 |
| Lead time | 2 – 5 days | 2 – 6 hours |
| Checkout flexibility | Full (one-page, split) | Theme-limited |
| Custom callback | Yes | Often no |
| Maintenance | On you | Plugin vendor |
| Best for | Custom store, high volume | Small WooCommerce shop |
A merchant handling fewer than 30 orders a month is better off with a plugin. Beyond that, or as soon as a one-page checkout and accounting reconciliation matter, the custom API quickly repays the 2 to 5 days invested.
Mini case study
Brenda, who runs a cosmetics shop in Nairobi, sells 45 orders a month at an average basket of KES 2,600, i.e. KES 117,000 monthly. Her old checkout sent buyers to a manual paybill: she lost about 8% of payments for lack of automatic confirmation, roughly KES 9,360/month. After a KES 40,000 API integration with a callback, lost payments fall below 1%. Annual amount recovered: about KES 100,000, paying back the build in under 5 months.
Need a professional website?
Kolonell builds websites that attract clients, optimized for the Sénégalese market. Free quote in 2 minutes.
FAQ
How long to add M-Pesa to an existing site?
Between 2 and 5 dev days for a clean integration with sandbox and callback. A bare STK Push button without reconciliation can ship in a day, but it exposes you to unconfirmed payments.
Is a callback URL mandatory?
Yes. The browser return can be lost (closed tab, dropped 3G). Only the signed callback guarantees your server knows a KES 2,600 payment landed. This is the top cause of ghost orders.
Is there an M-Pesa test environment?
Yes, the Daraja portal gives sandbox credentials separate from live keys. You simulate success, failure and timeout with no real money before switching to production.
What are the common launch mistakes?
Forgetting to verify the callback, confirming the order on the browser return alone, and not handling the double click that fires two STK pushes. These three account for most first-week incidents.
What budget should I plan for the integration?
Expect KES 20,000 to 60,000 depending on whether the checkout is standard or custom (one-page, multi-provider, split). A no-code plugin stays under KES 12,000 but limits your options.
Let's talk about your project. We integrate M-Pesa into your checkout in 2 to 5 days, sandbox and callback included. 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.

