Fortpesa
Blog / Guides / How to accept M-Pesa payments on your website

How to accept M-Pesa payments on your website

How to accept M-Pesa payments on your website
On this page How M-Pesa collections actually work Option 1: STK Push from your own checkout Option 2: payment links (no checkout code required) Which one should you choose? What it costs Get started

Customers are ready to pay you the moment they decide to buy — the last thing you want is a clunky checkout that loses them at the payment step. If you sell in Kenya, M-Pesa is where the money is. This guide walks through the two ways Fortpesa lets you collect it from your own website: STK Push (the customer gets a prompt on their phone) and payment links (share one URL, get paid).

How M-Pesa collections actually work

M-Pesa has no "card number" to type. The equivalent is the STK Push (STK = SIM Toolkit): your system asks the customer for their phone number, M-Pesa sends a prompt to that phone, the customer enters their PIN, and the payment is confirmed back to your system within seconds.

Behind the scenes there are three moving parts:

  1. A collection channel — the paybill, till number or bank paybill your money lands on.
  2. The prompt — an STK Push sent to your customer's phone with the exact amount.
  3. Confirmation — a callback that tells your system the payment succeeded, so you can fulfil the order.

Fortpesa wires all three together. You add a channel once, then every collection after that is a single call.

Option 1: STK Push from your own checkout

STK Push is what you want inside your own website, app or system: the customer enters their phone number on your checkout, presses Pay, and gets an M-Pesa prompt on that same phone.

A real request looks like this:

curl -X POST https://fortpesa.co.ke/api/v1/payments/stk \
  -H "Authorization: Bearer YOUR_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{
    "phone": "254712345678",
    "amount": 150,
    "channel_id": 42,
    "reference": "ORDER-1042"
  }'

Three things worth noting:

  • amount is whole shillings — 150 means KES 150. No minor units, no surprises.
  • channel_id is required — you pick which channel the prompt comes from, so a payment can never land in the wrong place.
  • reference shows up as the account reference on the customer's M-Pesa confirmation SMS.

The response gives you a transaction UUID. You then poll GET /api/v1/transactions/{uuid} (or wait for the webhook) until the payment is success or failed.

A two-minute run-through of a live collection on Fortpesa.

Not everything needs a full checkout integration. A payment link is a public URL you can share anywhere — WhatsApp, an invoice, a social bio, a printed flyer. The customer opens it, sees your business name and the amount, enters their M-Pesa number and pays.

Payment links are ideal when:

  • You sell on social media and chat with customers directly.
  • You send invoices manually.
  • You want to get paid today, and will integrate the API next week.

You can make a link fixed-amount ("KES 1,500 for order #1042") or open-amount (the customer types what they owe). Both are created from the dashboard in a few clicks.

Which one should you choose?

STK Push API Payment link
Best for Websites, apps, POS systems WhatsApp, invoices, social selling
Setup Developer minutes, one API call Zero code
Amount Fixed by your system Fixed or customer-entered
Experience Stays inside your checkout Opens the Fortpesa pay page

Most merchants start with a link, then move their best-selling product to an API checkout once volume grows. Nothing is lost in the move — the transactions, receipts and webhooks look exactly the same.

What it costs

The platform publishes its full fee schedule up front — flat tiers by amount, starting with a free band and KES 3 from KES 10 up. You see the exact fee on every transaction before you send a prompt, so pricing never becomes a guessing game.

Get started

  1. Create an account — your dashboard is ready in under a minute.
  2. Add your first channel (paybill, till or bank deposit) and it is provisioned for you.
  3. Either share a payment link or grab your API key and take the API quickstart for a spin.

Want to understand where the prompt comes from first? Read Paybill, till or bank channel — or compare the two collection styles in STK Push vs payment links.

Start collecting with Fortpesa

Create an account, add a channel and take your first M-Pesa payment — the platform fee schedule is public.