Skip to content

M-Pesa Website Integration: Daraja API or a Payment Gateway?

How to accept M-Pesa on your website in Kenya: connecting directly to Safaricom's Daraja API versus using a gateway such as Paystack or Pesapal, with fees, setup steps and what to choose for Tanzania, Uganda and Rwanda.

best e-commerce agency
best e-commerce agency

If you sell online in Kenya, customers will expect to pay by M-Pesa. There are two main ways to add it to a website: connect directly to Safaricom’s Daraja API, or use a payment gateway that includes M-Pesa alongside cards. Both work. The right choice depends on your volume, your developer, and whether you also need card payments.

How M-Pesa checkout works on a website

The standard experience is M-Pesa Express, also called STK push. The customer enters their phone number at checkout, a payment prompt appears on their phone, they enter their M-Pesa PIN, and the website receives confirmation a few seconds later. No copying of Paybill numbers or account references.

The older method, where customers pay manually to a Paybill or Till and type a transaction code into the website, still works but loses more sales and creates more reconciliation work.

Option 1: Direct integration with Safaricom Daraja

Daraja is Safaricom’s developer platform for M-Pesa APIs. A developer uses it to connect your website to your own Paybill or Till number.

What you need:

  • A registered business with a Lipa na M-Pesa Paybill or Till number.
  • A developer to build and test the integration in Daraja’s sandbox.
  • Approval from Safaricom to take the integration live.
  • Secure hosting with HTTPS, because M-Pesa sends payment confirmations to your server.

Advantages: money goes straight to your Paybill or Till with no gateway percentage on top of Safaricom’s own merchant charges, full control of the checkout, and access to other APIs such as B2C payouts for refunds or disbursements.

Disadvantages: it covers M-Pesa only, so you need a separate solution for cards; more development and maintenance; and you are responsible for handling failed and timed-out payments correctly.

Option 2: A payment gateway

Gateways such as Paystack, Pesapal and Flutterwave give you M-Pesa and cards in one integration, often with ready-made plugins for WooCommerce, Shopify and other platforms.

Paystack, for example, publishes these standard Kenyan rates: 1.5% for M-Pesa, 2.9% for local cards and 3.8% for international cards, with no setup or monthly fees. Settlement is to a bank account or M-Pesa wallet. Rates for other gateways differ, so compare current published pricing before signing up.

Advantages: fast setup, cards and M-Pesa together, one dashboard, plugins maintained by the gateway, and support when things go wrong.

Disadvantages: a percentage on every transaction, and settlement takes a day or more instead of arriving instantly in your Paybill.

Which costs less?

At low volume, the gateway is usually cheaper overall because you avoid development and maintenance costs. At high volume, direct Daraja integration usually wins because the gateway percentage adds up. Example: a shop taking KES 2 million a month by M-Pesa would pay about KES 30,000 a month at a 1.5% gateway rate. If a direct integration costs a one-off development fee plus Safaricom’s own charges, it can pay for itself within months at that volume. At KES 100,000 a month, it probably would not.

Our usual recommendation

  • New or small shops: a gateway with M-Pesa and cards. Launch fast and learn what sells.
  • Service businesses taking deposits: a gateway, or a simple payment link, is usually enough.
  • High-volume M-Pesa sellers: direct Daraja for M-Pesa, plus a gateway for cards.
  • Businesses selling to tourists: card payments matter more than M-Pesa. Choose a gateway that handles international cards and USD well.

Technical checks before launch

  1. Orders are only marked paid after M-Pesa confirms payment, not when the prompt is sent.
  2. Customers who cancel or time out see a clear message and can retry.
  3. Phone numbers are accepted in 07xx, 01xx and 254 formats.
  4. Every payment is logged with the M-Pesa receipt number for reconciliation.
  5. Refunds have a defined process.
  6. Conversion tracking fires only on confirmed payments. See our conversion tracking guide.

Tanzania, Uganda and Rwanda

Daraja and Kenyan gateway M-Pesa channels cover Safaricom in Kenya. In Tanzania, M-Pesa is run by Vodacom, alongside Tigo Pesa (Mixx by Yas) and Airtel Money. Uganda and Rwanda rely mainly on MTN Mobile Money and Airtel Money. To accept these, use a gateway with regional mobile money coverage, such as Pesapal or Flutterwave, or the operators’ own merchant APIs. Show prices in the customer’s currency and test each method end to end.

Related reading

Planning an online shop? See ecommerce website prices in Kenya and website design costs. Our web design team builds WooCommerce and booking sites with M-Pesa and card checkout.

Frequently asked questions

Can I add M-Pesa to a WordPress website?

Yes. WooCommerce plugins exist for Daraja and for gateways such as Paystack and Pesapal. Choose one that is actively maintained.

Do I need a Paybill or a Till number?

For a direct Daraja integration, yes. Gateways can settle to your bank account or M-Pesa wallet without your own Paybill.

How long does Daraja go-live approval take?

It varies. Allow time for testing and Safaricom’s review before your launch date.

Is it safe to accept M-Pesa on a website?

Yes, if the site uses HTTPS, confirms payments from Safaricom or the gateway on the server, and never asks customers for their M-Pesa PIN.

Put the ideas to work

Let’s talk about your business.

Discuss search, campaigns, content or your next website project.

Talk to us on WhatsAppSend an enquiry