If you run a business in Kenya and want to sell online, accepting MPESA payments is no longer optional – it’s essential. Over 80% of online transactions in Kenya are done via MPESA. In this guide, we’ll walk you through the different ways to integrate MPESA into your website, from the simplest to the most advanced.
Option 1: Manual Paybill / Till Number
The easiest way to start accepting MPESA is by displaying your Paybill or Till number on your website. Customers initiate the payment themselves and then send you the confirmation code. You then manually verify and process the order.
Pros: No technical integration, works immediately.
Cons: Manual work, prone to errors, not seamless for customers.
This is only recommended for very low‑volume sites or as a temporary measure.
Option 2: Lipa Na MPESA Online (Daraja API)
Safaricom’s Daraja API is the official way to integrate MPESA directly into your website. It enables automatic payment confirmation, so customers can pay and get instant feedback without leaving your site.
How it works (simplified):
- Customer enters their phone number and confirms the amount on your checkout page.
- Your server sends a request to Safaricom’s API.
- Customer receives an STK push prompt on their phone – they enter their PIN.
- Safaricom sends a confirmation to your server (callback URL).
- You update the order status and show a success message.
What you need:
- A registered business with Safaricom (Paybill/Till).
- A developer who can work with REST APIs.
- A server with SSL (HTTPS) – required for callbacks.
- API credentials (consumer key, consumer secret, passkey).
We’ve implemented this for many of our clients, including ecommerce stores and service platforms. It’s reliable and gives customers a smooth experience.
Sample API request (STK Push)
{
"BusinessShortCode": "174379",
"Password": "MTc0Mzc5YmZiMjc5Zjl...",
"Timestamp": "20260220120000",
"TransactionType": "CustomerPayBillOnline",
"Amount": "1000",
"PartyA": "2547XXXXXXXX",
"PartyB": "174379",
"PhoneNumber": "2547XXXXXXXX",
"CallBackURL": "https://yourwebsite.com/mpesa-callback",
"AccountReference": "Order123",
"TransactionDesc": "Payment for Order #123"
}
After a successful payment, the callback will send a JSON response with details. Your server must verify the transaction and update the order.
Option 3: Ecommerce Plugins (WooCommerce, etc.)
If you’re using WordPress + WooCommerce, there are several plugins that integrate MPESA via Daraja or third‑party gateways:
- WooCommerce MPESA Gateway – uses Daraja STK Push.
- iPay Africa – aggregates MPESA, cards, and other methods.
- Jenga API – Equity Bank’s payment gateway.
These plugins simplify the integration – you usually just enter your API keys and configure the callbacks. They handle the rest.
Which option is best for you?
- Just starting and low volume: Start with a manual Paybill, then upgrade.
- Ecommerce store (WordPress): Use a WooCommerce plugin – quick and reliable.
- Custom website or high‑volume: Direct Daraja API integration gives you full control and a seamless user experience.
💡 Pro tip: Whichever method you choose, always test in Safaricom’s sandbox environment first. This avoids costly mistakes and ensures your integration works perfectly before going live.
Common pitfalls to avoid
- Not validating callbacks: Always verify that the callback actually came from Safaricom (check origin IP, use security tokens).
- Hardcoding credentials: Store API keys in environment variables, not in your code.
- Ignoring failed transactions: Implement retry logic and alert your team if something goes wrong.
- Poor user experience: Show clear instructions during checkout, and handle errors gracefully.
Need help integrating MPESA?
We’ve integrated MPESA for dozens of Kenyan businesses – from small shops to large ecommerce platforms. If you’d like us to handle the technical side, just reach out.
In our ecommerce website packages, we include MPESA integration as standard. We’ll set up the API, test everything, and ensure your customers can pay seamlessly.
Have questions about MPESA integration? Contact us or chat with us on WhatsApp – we’re happy to advise.