To accept M-Pesa on WooCommerce in Kenya, install a compatible payment gateway plugin such as Pesapal, IntaSend, or DPO Pay. These gateways add M-Pesa STK Push as a checkout option. For in-store M-Pesa at your physical counter, use WebpinnPOS, which sends STK Push requests and automatically confirms payment: separately from your WooCommerce online checkout.
M-Pesa payment options for WooCommerce
WooCommerce does not include M-Pesa support out of the box. To accept M-Pesa, you install a payment gateway plugin from a provider that has integrated with Safaricom's Daraja API. There are two distinct contexts in which you might want to accept M-Pesa through WooCommerce:
- Online payments: A customer visits your WooCommerce store, adds items to their cart, and pays with M-Pesa at checkout from their computer or phone. The gateway handles this via STK Push.
- In-person checkout: A customer is at your physical shop counter, and you want to use WooCommerce as your POS. In this case you need an STK Push trigger from the counter. This is better handled by a dedicated POS system like WebpinnPOS that also keeps stock in sync with your WooCommerce store.
This guide covers both scenarios. Most merchants with a physical shop will use a gateway plugin for online orders and WebpinnPOS for in-store M-Pesa.
Available WooCommerce M-Pesa plugins and gateways in Kenya
| Gateway | M-Pesa STK Push | Card support | Settlement |
|---|---|---|---|
| Pesapal | Yes | Visa, Mastercard | Daily, KES |
| IntaSend | Yes | Visa, Mastercard | Next business day, KES |
| DPO Pay | Yes | Yes, multi-currency | Varies by agreement |
All three providers require you to create a merchant account and complete identity and business verification before you can process live payments. This process typically takes one to three business days and requires your national ID or passport, business registration certificate (if applicable), and bank account details for settlement.
How to install and configure (step by step)
- Create a merchant account with your chosen gateway and complete verification. You will receive API credentials (API key, IPN URL, etc.) from their dashboard.
- Install the gateway's WooCommerce plugin. Most are available directly from the WordPress plugin directory: search by provider name. Some providers supply a downloadable zip you install via Plugins then Add New then Upload Plugin.
- Activate the plugin. Then go to WooCommerce then Settings then Payments. Your new gateway should appear in the list. Click Manage next to it.
- Enter your API credentials from your gateway merchant dashboard. Enable the gateway and set it to sandbox/test mode.
- Place a test order on your WooCommerce store. Select M-Pesa at checkout. If the gateway is in sandbox mode, use their test phone number and PIN. Confirm the order appears as paid in WooCommerce and in your gateway dashboard.
- Once testing is successful, switch the gateway from sandbox to live mode. Your store is now ready to accept real M-Pesa payments.
IPN (Instant Payment Notification) URL: Most gateways require you to configure a webhook URL (often called the IPN URL) in their dashboard. This is how they notify WooCommerce when a payment is confirmed. The plugin documentation will specify the exact URL format to use, typically something like yourdomain.co.ke/?wc-api=gateway_name.
Direct Daraja plugin or payment gateway?
There are two ways to add M-Pesa to WooCommerce, and they work differently.
| Direct Daraja plugin | Payment gateway (Pesapal, IntaSend, DPO Pay) | |
|---|---|---|
| How it connects | Talks to Safaricom's Daraja API using your own Paybill or Till number | The gateway collects the payment and pays you out |
| Setup | You create a Daraja app and handle go-live with Safaricom yourself | You complete the gateway's merchant verification |
| Fees | No gateway fee, but you carry the setup and support work | The gateway charges a fee per payment |
| Cards | Usually M-Pesa only | Usually cards as well |
| Best for | Merchants with a developer and an existing Paybill or Till | Merchants who want one provider and a faster start |
Free and open-source M-Pesa plugins exist on the WordPress plugin directory and on GitHub. Before you install one, check when it was last updated, whether it supports your WooCommerce version, and what other store owners say. Keep your API keys out of public code and rotate them if they are ever exposed.
M-Pesa payment not confirming? Troubleshooting
| Symptom | Likely cause | Fix |
|---|---|---|
| The order stays on pending after the customer paid | The callback (IPN) URL cannot be reached, or a security plugin or firewall is blocking it | Check the URL in the gateway dashboard, allow it in your security plugin, and make sure the site uses HTTPS |
| The customer never gets the prompt | The phone number is in the wrong format, or the number is not registered for M-Pesa | Use the 2547 or 2541 format with no spaces, and confirm the customer's M-Pesa number |
| Payments work in testing but fail live | Sandbox credentials are still in use | Enter the live credentials and switch the gateway to live mode |
| The customer says they paid but the order failed | The prompt timed out before the PIN was entered, or the payment was reversed | Check the payment in the gateway dashboard before you refund or resend |
| The checkout page behaves oddly | A caching plugin is caching the checkout | Exclude the cart and checkout pages from caching |
Reconciling M-Pesa payments with WooCommerce orders
Match each order to its M-Pesa reference at the end of every day for the first few weeks. Your gateway dashboard lists each payment with its reference, and the order note in WooCommerce should carry the same one. If you also sell from a shop, keep stock in step with the till by reading how to sync online and in-store inventory, and see how to sync WooCommerce with a physical shop. For the full picture of online checkout options, read accepting M-Pesa on your online store.
STK Push for in-person checkout via WebpinnPOS
If you use WooCommerce and also have a physical shop, you face a practical challenge: WooCommerce's gateway plugins are designed for online checkout flows, not for a cashier initiating a payment from a counter tablet. The flow where a cashier sees the customer, enters their phone number, and the customer receives an STK Push. That is a point-of-sale flow, not a web checkout flow.
WebpinnPOS handles this natively. The cashier enters the customer's phone number (or the customer's Safaricom number is retrieved from their loyalty profile), WebpinnPOS sends an STK Push, and the system automatically confirms when payment is received from Safaricom's callback. No one needs to check SMS messages or manually verify the transaction. The completed sale then syncs to your WooCommerce store, reducing stock levels automatically.
This combination, a WooCommerce M-Pesa gateway for online orders and WebpinnPOS for in-store M-Pesa, gives customers a consistent payment experience on both channels without requiring two separate manual reconciliation processes at the end of the day.
Testing your M-Pesa integration
Before going live, run through the following test checklist:
- Place a test order on your WooCommerce store using the gateway's sandbox mode. Confirm the order appears as pending payment, then as paid after the simulated STK Push confirmation.
- Check that your WooCommerce stock count reduces correctly after the test order is paid.
- Test an order where the customer "times out" on the STK Push (does not confirm). Confirm the order stays in a pending state and is not marked as paid.
- If you are using WebpinnPOS for in-store payments, initiate a test in-store sale and confirm the payment completes and the sale appears in your WooCommerce order list or inventory is updated correctly.
Running these tests in sandbox mode before switching to live credentials prevents real-money issues on your first day of trading.
Frequently asked questions
More guides
- Sync Online and In-Store Inventory in Kenya: Complete Guide
- Ecommerce POS for Shopify and WooCommerce in Kenya
Handle in-store M-Pesa through WebpinnPOS
STK Push with automatic confirmation, stock sync to WooCommerce, and full sales reporting: built for Kenyan shops.
Start Free Trial