MPesa processes over KES 1 billion in transactions every day in Kenya. For any Kenyan business accepting payments online — whether e-commerce, SaaS, school fees, or service bookings — MPesa integration is not optional. It is the payment method your customers trust and use daily.
Safaricom's Daraja API is the official developer portal for MPesa integrations. In this guide, Digital World Kenya walks through how the most popular integration — STK Push (Lipa Na MPesa Online) — works and what you need to implement it.
STK Push triggers a payment prompt directly on the customer's phone. The flow is:
Register at developer.safaricom.co.ke and create a new app. You will receive a Consumer Key and Consumer Secret for sandbox testing.
For production, you need:
Call the OAuth token endpoint using your Consumer Key and Secret (Basic Auth) to get a Bearer token. This token is valid for 1 hour.
POST to https://api.safaricom.co.ke/mpesa/stkpush/v1/processrequest with your business short code, password (Base64 of ShortCode+Passkey+Timestamp), the amount, customer phone number, and your callback URL.
Safaricom POSTs the payment result to your callback URL. Parse the result code — 0 means success. Extract the MpesaReceiptNumber and update your order accordingly.
Digital World Kenya has integrated MPesa into dozens of websites, apps, and enterprise platforms. We handle Daraja API integration as part of all our development projects.
Contact us or WhatsApp +254 790 412 453 to discuss your payment integration requirements.