Now Hiring: Are you a driven and motivated Web Developer or Digital Marketer?

How To Accept M-Pesa Payments On Your Website

Sep 24, 2026

Your Customers Already Pay By M-Pesa

In Kenya, M-Pesa is how most people pay for things. Ask a customer to pay by card and many will hesitate. Ask them to pay by M-Pesa and the sale is done in seconds. Yet plenty of business websites still tell customers to “send money and then WhatsApp us the message”. That works, but it is slow, someone has to check every payment by hand, and mistakes happen.

When M-Pesa is built into your website, the customer pays from their phone without leaving your page, and your website knows straight away that the money has arrived. This guide explains how it works and what you need to set it up.

The easiest payment is the one your customer already knows. When a payment prompt appears on their phone and all they do is enter their PIN, fewer people abandon the sale.

— Serina Systems

What Is An STK Push?

STK push, also called M-Pesa Express, is the pop-up that appears on a customer’s phone asking them to approve a payment. It saves them from typing a paybill number, an account number and an amount. You will know it from paying for many online services. Safaricom provides it to businesses through a service called Daraja, its set of tools that let a website or app connect to M-Pesa.

How It Works, Step By Step

From the customer’s side, it takes a few seconds. Behind the scenes, this is what happens:

  • The customer chooses what they want and enters their M-Pesa phone number at checkout.
  • Your website sends the amount and phone number to Safaricom.
  • A payment prompt appears on the customer’s phone, showing your business name and the amount.
  • The customer enters their M-Pesa PIN on their own phone. You never see or handle the PIN.
  • Safaricom sends the result back to your website, saying whether the payment succeeded or failed.
  • Your website confirms the order, records the M-Pesa receipt number and shows the customer a thank-you message.

What You Need To Set It Up

Before a developer can connect your website, you need a few things in place:

  • A registered business account for receiving payments: this is a Paybill number or a Till number (Buy Goods). Which one suits you depends on how you sell, and Safaricom can advise you on this.
  • A Daraja developer account: your developer uses this to create an app and receive the keys that let your website talk to M-Pesa.
  • A website with a secure address (HTTPS): Safaricom sends payment results back to your website, and this needs a secure, publicly reachable address.
  • Your business documents: Safaricom usually asks for business registration documents and ID when you apply to go live. Requirements can change, so check with Safaricom directly.
  • A developer who can build and test the connection, because this involves server-side code and not just a plugin you paste in.

Test First, Then Go Live

Daraja includes a free testing area called the sandbox, where your developer can send practice payments without moving real money. Everything should be tested here first: successful payments, cancelled payments, wrong PINs and customers who simply ignore the prompt. Only when it all works smoothly do you apply to move to the live system with your real Paybill or Till number. Then do one small real payment yourself before announcing it to customers.

Keep Payments Safe

Because real money is involved, a few rules are not optional:

  • Keep your Daraja keys on the server only, never inside the page code that visitors can see.
  • Confirm an order only when Safaricom reports success, not just because the customer clicked a button.
  • Check that the amount paid matches the order before marking it as paid.
  • Store the M-Pesa receipt number with every order so you can reconcile your records.
  • Never ask customers for their M-Pesa PIN. Only Safaricom ever needs it.

Plan For Things Going Wrong

Not every payment goes smoothly, and a good checkout expects that. A customer may have too little balance, enter the wrong PIN, cancel the prompt or have a weak network. Your website should show a clear message for each case and let the customer try again without starting over. It also helps to give a backup option, such as a Till number and a WhatsApp contact, so nobody is stuck at the last step.

Can I Use A Payment Provider Instead?

Yes. Several payment providers in Kenya offer M-Pesa together with cards and other options, and they handle much of the technical side for you. This can be quicker to start with, but they usually charge fees on each transaction, so compare the costs before you choose. Connecting directly to Daraja gives you more control, while a provider can save time. The right choice depends on your volume, budget and how much customisation you need.

Where To Start

First make sure your business has a Paybill or Till number and a secure website that works well on phones. Our guide on why every Kenyan business needs a professional website is a good place to begin if you are still planning, and our tips on showing up on Google Maps will help customers find you. When you are ready to take payments online, Serina Systems can connect M-Pesa to your website, test it properly and set it up for your business. Contact us for a free consultation.

Chat with us