How to accept M-Pesa payments on your website
M-Pesa is how Kenya pays. Here's how to accept it from your own website, from the simplest no-code option to a full Daraja API integration.
Quick answer
First get a Paybill number or Buy Goods Till from Safaricom — apply at a Safaricom shop, by calling 100, or online, with your business registration, ID and KRA PIN. The simplest website route is to display your Paybill or Till and instructions on a payments page. For an automated checkout, register at developer.safaricom.co.ke for Daraja API credentials and implement STK Push, which sends a payment prompt straight to the customer's phone. Your site must be on HTTPS.
Three ways to take M-Pesa from a website
| Method | Effort | Customer experience |
|---|---|---|
| Display Paybill / Till + instructions | None | Customer enters details manually in M-Pesa menu |
| Third-party payment gateway | Low, no code | Hosted checkout, automatic confirmation |
| Daraja STK Push | Developer needed | Prompt appears on their phone; enter PIN and done |
Step-by-step
- 1
Get a Paybill or a Till number
Apply at any Safaricom shop, by calling 100, or online through Safaricom's business pages. You'll need your business registration documents, your ID and your KRA PIN. Buy Goods Till suits shops and simple sales; Paybill suits businesses that need an account reference against each payment, such as invoices or subscriptions.
- 2
Start with the no-code version
You don't need an API to take M-Pesa from a website. A clear payments page showing your Paybill or Till number, the exact steps, and what to put as the account reference works today and costs nothing. Most small Kenyan businesses run entirely this way. Add a WhatsApp button so customers can send the confirmation SMS straight to you.
- 3
Understand what Daraja adds
The Daraja API automates confirmation. With STK Push, your site sends a prompt directly to the customer's phone — they enter their M-Pesa PIN and the payment completes without typing your Paybill or the amount. That removes the most common failure points: wrong number, wrong amount, missing reference.
- 4
Know the technical requirements before committing
Register at developer.safaricom.co.ke for your Consumer Key, Consumer Secret and Pass Key. Your site must be served over HTTPS, and Daraja sends payment confirmations to a callback URL on your server — which means you need a server, not just a static site. Keep the keys server-side, never in frontend code.
- 5
Or use a gateway and skip the integration
Several Kenyan payment providers wrap M-Pesa in a hosted checkout you can link to from any website, including a static one. You trade a transaction fee for not maintaining a Daraja integration. For most small businesses that's the right trade — build the integration when volume justifies the engineering.
Tips & best practices
- ▸Paybill for anything needing a reference (invoices, accounts); Till for straightforward sales.
- ▸Never put your Consumer Key or Pass Key in frontend code — they belong server-side only.
- ▸STK Push removes the wrong-amount and missing-reference errors that cost you reconciliation time.
- ▸A payments page plus a WhatsApp button handles most small-business volume with no code at all.
Common questions
How do I accept M-Pesa payments on my website?
+−
The simplest way is to display your Paybill or Till number with clear instructions on a payments page. For an automated checkout, register for Daraja API credentials at developer.safaricom.co.ke and implement STK Push, which prompts the customer's phone directly. A third-party gateway sits between the two — hosted checkout, no code.
What's the difference between Paybill and Till?
+−
A Buy Goods Till is for straightforward sales where you just need the money. A Paybill lets the customer enter an account reference, which is what you want for invoices, subscriptions, or anything you need to reconcile against a specific customer.
What do I need to apply for a Paybill number?
+−
Your business registration documents, your ID and your KRA PIN. Apply at any Safaricom shop, by calling 100, or online through Safaricom's business pages.
What is STK Push?
+−
STK Push, also called the Lipa Na M-Pesa Online API, is initiated by your server: it sends a payment prompt directly to the customer's phone showing the amount. They enter their M-Pesa PIN and it's done — no typing your Paybill number or the amount, which is where manual payments usually go wrong.
Do I need a developer to accept M-Pesa online?
+−
Not to get started. Displaying your Paybill or Till with instructions needs no code, and a hosted payment gateway needs only a link. You need a developer for a Daraja integration, because it requires a server to receive callbacks and secure handling of your API keys.