Your WooCommerce store has products, shipping and a beautiful checkout - but the payment step is still "send KSh X to this paybill and WhatsApp us the screenshot." You're losing orders every day. This is the practical setup guide: the steps to get a proper M-Pesa STK push checkout on WooCommerce, from the Safaricom paperwork to the first real transaction.
Step 0: The prerequisites (start these first)
The Safaricom approval process is the slowest part, so start it before anything else:
- A paybill or till registered to your business. You'll need the business's registration documents to apply.
- A Daraja developer account with Lipa na M-Pesa Online (STK push) enabled and approved. Budget a week or two for this.
- An SSL certificate on your site (HTTPS). Safaricom's callbacks won't work on a plain HTTP site.
- WooCommerce up to date. An outdated store is a security risk you don't want while connecting payments.
Step 1: Pick your integration route
Two ways to add M-Pesa to WooCommerce:
- A Daraja gateway plugin. Fastest for a standard store: install, enter credentials, test, done. Choose one that's actively maintained and has recent reviews from Kenyan stores - old payment plugins quietly break when Safaricom changes its API.
- Custom integration. When you need something non-standard - memberships, bookings, split payments, custom order logic - or when you want the gateway built into your theme. This is real development work and is usually priced as a project.
Whichever route you take, the credentials and callback handling must live server-side. Never put your Daraja consumer key or secret in the browser, and never on a public page.
Step 2: Get your credentials
From Daraja you'll get a consumer key and consumer secret (your app's identity), plus your shortcode, the Lipa na M-Pesa Online passkey, and a callback URL where Safaricom confirms payments. Your developer or the plugin needs all of these to talk to the API.
Step 3: Configure the gateway in WooCommerce
In WooCommerce → Settings → Payments, enable the M-Pesa gateway and fill in:
- Consumer key and secret
- Shortcode (paybill or till number)
- Callback URL - must be HTTPS, reachable from the internet, and typically ends in something like /wp-json/mpesa/callback
- Order statuses for paid and failed orders (set paid orders to "Processing" so they flow into your fulfilment routine)
- Test/Live mode switch - this is the last toggle, not the first
Step 4: Test properly (sandbox, then real money)
Never launch on sandbox screenshots alone.
- Sandbox first. Safaricom's developer portal has test tools - use them to confirm the flow works end to end.
- Then real transactions. Run at least 10 small real payments - a success, a declined PIN, a cancelled prompt, a timeout. For each one, confirm the order status updates correctly and stock is reserved only for paid orders.
- Check the edge cases. What happens if the customer's phone has no airtime? If the callback is delayed? If they pay twice? Your store should handle all of these without you manually editing orders.
Step 5: Go live and watch the first week
Switch from sandbox to live, then monitor the first 20-30 orders closely. Reconcile them against your M-Pesa statement so the numbers match, and check that failed payments leave clean, unpaid orders. After the first week, add "check the M-Pesa log" to your monthly routine - payment gateways need attention, which is exactly what a maintenance plan covers.
Common gotchas that catch Kenyan stores out
- Phone numbers in 254 format. "07XX" works on paper but breaks API calls; the checkout should normalise numbers automatically.
- Callback URL unreachable. If your callback URL is wrong, blocked, or missing HTTPS, payments succeed on the phone but orders stay unpaid forever.
- The 30-60 second window. Customers take time to enter PINs; if the site gives up too early, you'll get "paid but still unpaid" confusion.
- A gateway plugin that stops being maintained. Safaricom's API evolves; an abandoned plugin breaks and there's no one to fix it.
What it should cost
A proper integration on an existing WooCommerce store - done, tested against real transactions, and supported after launch - typically runs KSh 25,000 - 45,000 in Kenya. If it's part of a new store build, it should be in the build price, not an afterthought. The cheap option is the plugin route if you're technical; the expensive mistake is paying for a sandbox demo that dies on launch day.
The bottom line
M-Pesa STK push is the checkout your Kenyan customers expect, and WooCommerce makes it very achievable - as long as you respect the paperwork, test with real money, and keep the gateway maintained. Want us to handle it? Our M-Pesa integration service covers the Daraja setup, real-transaction testing and post-launch support.
Get an M-Pesa integration quote - straight answer, no jargon.
