Websites11 min read

Integrate M-Pesa Daraja with Django in Nairobi in 2026

Mohamed Bah·Fondateur, Kolonell
August 25, 2026
Share:
Integrate M-Pesa Daraja with Django in Nairobi in 2026

Integrate M-Pesa Daraja with Django in Nairobi in 2026

Websites

The verdict in three sentences

M-Pesa STK Push via the Daraja API sends a payment prompt straight to the customer's phone, with confirmation in 5 to 15 seconds. On the merchant side, paybill/till fees range from 0 to 0.5%, making it one of the cheapest flows on the continent. The Django integration rests on ShortCode validation, C2B/B2C callbacks and respecting the applicable daily cap.

The STK Push flow step by step

In Django, you get an OAuth token, send the STK Push request with amount and phone number, then receive the result on your callback URL. The CheckoutRequestID acts as the idempotency key.

ParameterRoleExample
BusinessShortCodeMerchant identifierPaybill / Till
PasswordBase64(ShortCode+Passkey+Timestamp)Request security
AmountAmount to debit1500
PhoneNumberCustomer MSISDN2547XXXXXXXX
CallBackURLResult deliveryHTTPS required
CheckoutRequestIDIdempotency keyReturned by Daraja

Fees, delays and caps

M-Pesa stands out for very low merchant cost and near-instant confirmation, but with caps to watch.

CriterionM-Pesa DarajaMobile money benchmark
Merchant fee0 to 0.5%1.5 to 2%
Confirmation5 to 15 s30 to 120 s
Daily cap300,000 KESVariable
CallbackC2B / B2CWebhook
SandboxFreeFree
IdempotencyCheckoutRequestIDUnique reference

These values are a 2026 order of magnitude; caps evolve with local regulation.

Need a professional website?

Kolonell builds websites that attract clients, optimized for the Sénégalese market. Free quote in 2 minutes.

Mini case study

Wanjiku runs an online course platform in Nairobi, collecting the equivalent of 6,000,000 FCFA/month via M-Pesa. At 0.4% merchant fee she pays ~24,000 FCFA/month, versus ~102,000 FCFA on a 1.7% flow. Confirmation in under 15 seconds also cuts her checkout abandonment by 8 points.

FAQ

Must the CallBackURL be HTTPS? Yes, Daraja requires a publicly reachable HTTPS URL. In development, expose your local Django server through a secure tunnel.

How do you handle idempotency? Store the CheckoutRequestID returned by Daraja with a unique constraint. Since the callback can arrive more than once, you ignore duplicates.

What happens if the customer never enters their PIN? The STK Push expires and Daraja returns a failure code. Never fulfil the order until the callback confirms payment.

Which cap should I watch? The standard daily cap is around 300,000 KES per customer. For higher amounts, plan a split or an alternative payment method.

Let's talk about your project. We integrate M-Pesa Daraja into your Django backend with reliable callbacks and idempotency. WhatsApp +221 77 596 93 33.

Tags:#mpesa#daraja api#django#nairobi#stk push#kenya#integration#2026
Share:

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.