How to accept M-Pesa payments on your website
Updated · Berican Designs
The short answer
There are three ways. You can show your till or paybill number and confirm payments by hand. You can use a payment gateway that sends the M-Pesa prompt to the customer’s phone and confirms it for you. Or you can connect to Safaricom directly, which needs a till or paybill registered to a business. With us, adding M-Pesa to an existing site starts at KSh 30,000.
1. Show your till or paybill number
The simplest way. The customer pays your till or paybill from their phone and types their name or order number as the reference. You check your M-Pesa messages and mark the order paid.
It costs nothing to set up and works on any website. The catch is that someone has to match every payment by hand, and a customer who mistypes the reference is hard to trace. It is fine for a few orders a week, not for a busy shop.
2. A payment gateway (the M-Pesa prompt)
The customer types their phone number on your site, an M-Pesa prompt appears on their phone, they enter their PIN, and your site is told the payment went through. Paystack, Pesapal and similar gateways do this, and most take cards too.
The gateway charges a small fee on each payment and pays the money out to your account. Your site has to check every payment with the gateway rather than trust the customer’s browser, and it has to handle the cases where the prompt times out or the balance is too low.
3. Straight to Safaricom (Daraja)
Safaricom’s own API, Daraja, sends the same prompt with no middleman. It needs a till or paybill registered to a business, not a personal till, and Safaricom has to approve it before it goes live.
It suits businesses with a lot of M-Pesa traffic, or ones that want payments to match their paybill accounts automatically.
What to watch for, whichever way you choose
- Payments must be confirmed by the server, never by a “thank you” page alone.
- Every payment needs a reference you can trace back to an order.
- Customers need a way out when a payment fails: try again, pay later, or cancel.
- Someone should be told when payments stop coming through.
Questions people ask
Can I use my personal till number?
For showing a number on your site and confirming by hand, yes. To connect straight to Safaricom for automatic prompts, the till or paybill must be registered to a business. A payment gateway works with your business account and handles that side.
How much does M-Pesa integration cost?
With us, from KSh 30,000 to add M-Pesa prompts to your existing site or system, then KSh 2,000 a month while we watch it for you. Paybill and till reconciliation starts at KSh 80,000.
Can customers also pay by card?
Yes, with a payment gateway. The same checkout can offer M-Pesa and card.
What happens if the customer has too little money on M-Pesa?
M-Pesa declines it and the site should say so plainly, then let them try again, pay later or cancel. Ours do.