How to Integrate M-pesa Payment to Woocommerce

How to integrate mpesa online payment to woocommerce in Kenya

Integrating your online shop or business to m-pesa payment is one of most important things you should consider implementing. In this post, we will be integrating mpesa payment to woocommerce in Kenya.


  • WooCommerce plugin installed on your WordPress website
  • M-Pesa Developer account on Daraja API
  • SSL certificate for your website


1. Install WooCommerce M-Pesa Gateway Plugin

  • Go to your WordPress dashboard and navigate to “Plugins” > “Add New.”
  • Search for “WooCommerce M-Pesa Gateway” and click “Install Now”.
  • Activate the plugin once installed.

2. Configure M-Pesa API Settings

Go to your M-Pesa developer account and create a new Sandbox or Production App. Create a new account if you do not have one.

How to create a sandbox app on Daraja API

In the Woocommerce plugin settings page, go to “Payment Gateways” > “M-Pesa”. In this case, we are using plugin by Osen.

Enter the following API details:

  • App Client Key
  • App Client Secret
  • Business Shortcode (for Lipa na M-Pesa Online payments)
  • Choose identifier type: either Paybill or Till Number
How to configure mpesa plugin for Woocommerce

3. Configure WooCommerce Settings

  • Go to “Settings” > “Checkout” in your WooCommerce dashboard.
  • Set “M-Pesa” as as one of the checkout gateways.
  • Configure any additional settings as desired, such as title, description, and order status.
Configuring Woocommerce for mpesa online payments

4. Enable SSL Certificate

Ensure that your website has an SSL certificate installed. This is a requirement for secure payment processing.

5. Test the Gateway

  • Add some products to your cart and proceed to checkout.
  • Choose M-Pesa as the payment method and follow the on-screen instructions.
  • Verify that the payment is processed successfully in your M-Pesa account and in your WooCommerce order management system.

Additional Notes

Lipa na M-Pesa Online: This payment option allows customers to pay directly from their M-Pesa account without using a SIM card. It requires a Business Shortcode configured in your API settings.

Checkout Redirect: The payment gateway will redirect customers to the M-Pesa payment page where they can complete the transaction.

IPN Support: The plugin supports Instant Payment Notification (IPN) which automatically updates your orders when a payment is processed.

Security: Ensure that your API keys are securely stored and that your website follows best practices for online payments.

This topic covers deploying mpesa online payment on a test environment. In the next post, we shall explore how to go live.

If you are stuck somewhere, we do offer woocommerce-mpesa integration services. More services here.


More blogs