How to set up M-Pesa on your website

A plain overview of what it takes to accept M-Pesa on your website through the Daraja API, and what to get right so payments do not fail.

Ken MurithiKen MurithiFounder, Ken Designers
Published
Reading time
5 min read
Software engineer testing a mobile checkout beside a laptop
AI-generated editorial illustration featuring fictional Kenyan adults.

Accepting M-Pesa on a website is not as simple as pasting a paybill number. Done properly, it is smooth. Done carelessly, customers get charged and orders vanish.

What you need

A Safaricom Daraja account with API credentials, a paybill or till, and a website that can send a payment request and receive the result. For a business, a Lipa na M-Pesa Online (STK push) setup gives the cleanest customer experience.

The part most people get wrong

The order must only be marked paid when Safaricom confirms it through a callback, not when the PIN prompt is sent. Without a reliable callback handler, money leaves the customer's account and the order never updates.

Need a hand with this?Ecommerce website development in KenyaSee how we do it →

Test with real money first

Always run real low-value transactions before launch and confirm every one reconciles correctly. This is the step that separates a payment flow that works from one that quietly loses sales.

Ken Murithi

Written by

Ken Murithi

Founder and lead developer at Ken Designers, the Nairobi studio behind websites, online stores, apps and POS systems for 300+ businesses. Best Software Developer of the Year 2026 (Digitally Fit Awards by KEOnline).

Ask Ken on WhatsApp

Keep reading.

All articles →