How to Integrate M-Pesa Into Your Website in Kenya (Step-by-Step Guide)
If you’re building an e-commerce store, selling services, or collecting payments online in Kenya, M-Pesa is a must-have.
Over 30 million Kenyans use M-Pesa daily — and your website needs to meet them where they are.
This guide will show you how to integrate M-Pesa into your WordPress or custom website, even if you’re not a developer. Whether you’re a startup, freelancer, or SME, this step-by-step process is beginner-friendly and locally relevant.
Step 1: Choose the Right Integration Method
There are 3 main ways to integrate M-Pesa:
- Safaricom Daraja API (for custom integration)
- WordPress/WooCommerce plugins (easy, no-code option)
- Third-party gateways like iPay, Pesapal, or Flutterwave
Each has its pros:
- Daraja = Full control, ideal for developers
- Plugins = Quick, works well with WordPress stores
- Gateways = Add multiple payment options, easier onboarding
Need help choosing the best method?
Talk to our Web Design Experts
Step 2: If You’re Using WordPress, Install a Plugin
If you’re on WooCommerce, go with:
- M-Pesa Paybill Plugin by PesaPal
- M-Pesa Payment Gateway for WooCommerce (by Kenyan devs)
How to do it:
- Go to your WordPress dashboard
- Navigate to Plugins > Add New
- Search for “M-Pesa WooCommerce”
- Install and activate your chosen plugin
- Enter your Paybill/Till Number, API credentials, and callback URL
Test with the plugin’s sandbox before going live.
Looking for affordable Website Design Services in Kenya? We help clients set this up daily.
Step 3: If You’re Building Custom, Use Daraja API
For developers or custom sites (Laravel, Django, React, etc.), use Safaricom’s Daraja API.
- Register at Safaricom Daraja Portal
- Get your Consumer Key and Consumer Secret
- Use your business Paybill or Till Number
- Implement API endpoints for:
- STK Push (to initiate payment directly on user’s phone)
- C2B (Customer to Business payments)
- B2C (Business to Customer payouts)
Safaricom offers great documentation and sample code in PHP and Python.
Make sure you implement security checks and confirm payment responses via callback URLs.
Step 4: Set Up Confirmation and Validation URLs
These are required for Safaricom’s APIs to:
- Send payment status updates
- Confirm payment success/failure
- Trigger actions (like order confirmation or account top-up)
Your developer will need to:
- Create a secure URL endpoint
- Accept JSON responses from Safaricom
- Log transactions in your database
You can view logs or test responses using Postman or tools like Ngrok.
Step 5: Go Live and Test Everything
Before you go live:
- Test on Safaricom’s Sandbox environment
- Check for response delays, failed transactions, and errors
- Ensure your SSL certificate is valid for production API calls
Once stable:
- Switch your API keys to live mode
- Monitor transactions using your plugin dashboard or payment gateway portal
Want your site fully optimized for local payments, SEO, and speed?
See our Website Management Services
Bonus: Third-Party Integrations (No Code Required)
If you don’t want the headache of setup, use tools like:
- Pesapal – Popular in Kenya, supports M-Pesa, Airtel Money, Visa, etc.
- iPay – Offers local M-Pesa checkout + other methods
- Flutterwave – Offers global cards, mobile money, and local wallets
These tools offer one dashboard, built-in reports, and zero coding.
Final Thoughts
Integrating M-Pesa into your website isn’t just about convenience — it’s about conversion. If your visitors can’t pay how they want, they’ll bounce.
At Tera Creations, we help Kenyan businesses build payment-ready websites — fast, mobile-first, and secure.
Need help setting up your M-Pesa integration from scratch?
Contact Us — and let’s make your website ready to do business, 24/7.