How to Integrate MPesa into Your Online Store (Step-by-Step Guide)

Mpesa Integration- You Ultimate Guide

In Kenya, MPesa is the most popular digital payment method — used by millions of customers daily. If you’re running an eCommerce store or planning to start one, MPesa integration is absolutely essential. Whether you’re using WooCommerce, Shopify, or a custom-built website, allowing customers to pay via MPesa makes it easier to convert visits into sales.

This article explains how to integrate MPesa into your online store, the methods available, tools you can use, and key tips to ensure a seamless payment experience. There are several ways to integrate MPesa depending on your tech setup and business size. Its important to note that the platform used to develop an e-commerce website/online shop highly determines the appropriate method. If you have not setup your website yet, you may benefit from learning more on Best E-commerce Platforms in Kenya: Shopify vs WooCommerce vs Magento. Otherwise, the main methods of Mpesa Integration include STK Push API (via Daraja), Payment Gateway (e.g., Pesapal, Flutterwave) and Manual Paybill/Till Checkout. 

MPesa Integration via Safaricom Daraja API (STK Push)

This is the most flexible and powerful method. It allows your store to trigger an STK Push request — prompting the customer to authorize the payment directly on their phone.

What You’ll Need:

Step-by-Step Guide:

🔹 Step 1: Create a Developer Account

🔹 Step 2: Get Your Shortcode and Credentials

  • Apply for MPesa Paybill/Till from Safaricom

  • Get your Shortcode, Passkey, and Initiator Name

🔹 Step 3: Build the STK Push Request

You’ll make an API request to Safaricom’s endpoint:

https://api.safaricom.co.ke/mpesa/stkpush/v1/processrequest

Provide the following:

  • Amount

  • Phone number

  • Business shortcode

  • Callback URL

  • Passkey (Base64 encoded)

Example payload:

{
"BusinessShortCode": "174379",
"Password": "Base64(password+timestamp)",
"Timestamp": "20250430123000",
"TransactionType": "CustomerPayBillOnline",
"Amount": 100,
"PartyA": "2547XXXXXXXX",
"PartyB": "174379",
"PhoneNumber": "2547XXXXXXXX",
"CallBackURL": "https://yourdomain.com/callback",
"AccountReference": "INV001",
"TransactionDesc": "Payment for Order"
}

🔹 Step 4: Handle Callback

Safaricom sends a response to your callback URL. Capture and process this response to confirm the transaction, update the order, and notify the customer.

🔹 Step 5: Automate Order Status Updates

Ensure that once payment is confirmed, the customer sees a “Payment successful” message and their order is marked as complete in your system.

MPesa Integration via Payment Gateways (No Coding)

If you’re not a developer or prefer something plug-and-play, payment gateways like Pesapal, Intasend, Flutterwave, and DPO offer ready MPesa integrations.

🔹 How it works:

  • You create a business account on the platform (e.g., Pesapal.com)

  • Link your MPesa Paybill or use theirs

  • Use their plugin or API to embed MPesa payments into your store

🔹 Pros:

  • No need to build custom APIs

  • Secure and PCI DSS-compliant

  • Offers other payment methods (cards, bank transfers)

🔹 Integration Platforms:

  • WooCommerce: Install the Flutterwave or Pesapal plugin

  • Shopify: Use third-party apps or request custom integration from the gateway

  • Laravel/Custom PHP: Use their APIs to collect and confirm payments

Manual MPesa Checkout

This involves:

  • Sharing your Paybill or Till number on the checkout page

  • Asking the customer to enter the amount manually on their phone

  • Upload a payment confirmation or send an SMS to you

Why It’s Risky:

  • Not user-friendly

  • Payment errors are common

  • Manual confirmation slows order processing

Recommended only for beginners or when testing your store.

Which Method Should You Choose?

Business Type Recommended Integration
WordPress/WooCommerce
Intasend, Pesapal Plugin or Daraja with WooCommerce integration
Shopify
Flutterwave + Shopify or DPO
Laravel / React / Custom Sites
Daraja STK Push API
Small business (no developer)
Intasend or Pesapal dashboard with Pay Now buttons.
Enterprise store
Custom Daraja API integration + backup gateway

Bonus Tips for Successful MPesa Integration

  • Use STK Push over Paybill entry to reduce drop-offs: When customers are required to manually go to their MPesa menu and enter your Paybill, many abandon the process midway. STK Push solves this by prompting them automatically on their phone to authorize the transaction, making it faster and frictionless.
  • Confirm payments instantly to build customer trust: Speed matters. If your system takes too long to confirm payments, customers may think the transaction failed. Use the Daraja API callback feature to instantly update the order status or send a message as soon as payment is successful.
  • Test your integration in the Daraja sandbox before going live: Safaricom provides a testing environment (sandbox) where you can simulate transactions without real money. Always test your integration here to ensure your requests, callbacks, and responses are working perfectly before switching to the live environment.
  • Send SMS/email notifications after payment: After a successful transaction, trigger an automatic confirmation message via email or SMS to the customer. This provides assurance and acts as a digital receipt.
  • Ensure SSL is active on your site (Daraja requires HTTPS): The Safaricom Daraja API mandates that your callback and confirmation URLs must be secured with HTTPS. This also boosts customer trust, as most browsers now flag non-HTTPS sites as “Not Secure.”
  • Log all transactions for audit and support: Maintain a log of all MPesa transactions (both successful and failed). This can help you quickly resolve disputes, match payment issues, or verify customer complaints.
  • Use descriptive account references for tracking: In your STK Push or payment request, use clear AccountReference values like Order#1234 or Invoice2025-08. This makes reconciliation easier.
  • Display clear payment instructions at checkout: If you’re not using STK Push, ensure the payment instructions (Paybill/Till number, amount, account number) are clearly written at checkout.
  • Test payments on multiple mobile networks and devices: Although MPesa is mainly associated with Safaricom, some customers might be using dual SIM phones or have different experiences depending on their phone models.
  • Hire a developer: If you are not tech-savvy, its advisable to seek assistance from professional developers especially those with knowledge on e-commerce/online website shop development. 

Need Help Integrating MPesa?

At Finytab Solutions, we are the top e-commerce website developers in Kenya and therefore the best in Mpesa integration. We help Kenyan businesses:

  • Set up MPesa STK Push with Daraja

  • Install and configure WooCommerce payment plugins

  • Build custom payment systems using Laravel, React, or PHP

  • Test and secure the payment flow

Whether you run an online shop, booking site, or donation platform — we make it easy for you to get paid via MPesa.

Need Professional Online Store Design Services in Kenya?

Order on WhatsApp