How to accept M-Pesa on WooCommerce: a step-by-step guide
Quick answer
The best way to accept M-Pesa on WooCommerce is STK push through the Safaricom Daraja API: the customer enters their number at checkout, approves the payment on their phone, and the order is marked paid automatically.
Most Kenyan shoppers would rather pay with M-Pesa than a card. If your store only takes cards, many of them leave at checkout. This guide explains how M-Pesa on WooCommerce works, the options, and the mistakes that cost store owners money.
Three ways to take M-Pesa on WooCommerce
- STK push (recommended): a payment prompt appears on the customer’s phone. Fast, and the order updates itself.
- Till or paybill with manual check: the customer pays and types the code. Cheap to set up, but you confirm every order by hand.
- Payment aggregator: one provider handles M-Pesa and cards together, for a higher fee per sale.
What you need before you start
- A Safaricom till or paybill number registered to the business.
- A Daraja account and API credentials (consumer key, secret and passkey) for your till or paybill.
- An SSL certificate on your site, so payment details are encrypted.
- A hosting plan that can receive Safaricom’s callbacks reliably.
How STK push works at checkout
- The customer chooses M-Pesa and enters their phone number.
- Your store asks Daraja to send a payment prompt to that phone.
- The customer enters their M-Pesa PIN.
- Safaricom sends a confirmation (a callback) to your site.
- Your store checks the amount and order, then marks the order paid and emails the receipt.
Test before you go live
Daraja has a sandbox for testing with fake money. Test a paid order, a cancelled prompt, a wrong PIN and a timeout. Each one should leave the order in the right state. Then apply for live credentials and repeat one real small payment.
Stop fake M-Pesa payment confirmations
Never mark an order paid because a customer sends a screenshot or an SMS. Only trust the callback Safaricom sends to your site, and check that the amount and order number match. This is the most common way small stores lose money.
Fees
Safaricom charges a fee per transaction that depends on your till or paybill tariff. Check the current tariff with Safaricom before setting prices. Aggregators add their own percentage on top.
Want M-Pesa set up on WooCommerce for you?
Our Store package includes M-Pesa, card and PayPal, tested end to end.
Prefer to talk? A real person replies within 1 business day.