Pay with M-PESA

send_payment()

Enter your number. Get the prompt.

This is a real till — the charge is genuine, not a sandbox. Secured by Safaricom Daraja · your PIN never leaves your phone.

Buy Goods Till Number 9237817 Drinah Online Traders
  1. Open the M-PESA menu or app on your phone
  2. Select Lipa na M-PESA → Buy Goods and Services
  3. Enter till 9237817 → amount → confirm with your PIN

You'll get an M-PESA confirmation SMS addressed to Drinah Online Traders — that's your receipt. Done.

david@mpesa: ~/transaction
  1. 1STK pushserver → Safaricom Daraja API
  2. 2PIN entryprompt lands on your phone — enter M-PESA PIN
  3. 3CallbackSafaricom confirms → receipt issued
  4. 4Donereceipt shown here + WhatsApp confirmation

under the hood

What just happened, in 4 hops.

01

STK Push

Your number and amount hit Safaricom's Daraja API over a signed request — the phone buzzes with a payment prompt.

02

PIN on-device

You enter your M-PESA PIN on your own phone. It never touches this server — that's the whole security model.

03

Callback

Safaricom posts the result to a webhook here — idempotent, deduplicated, matched to your transaction id.

04

Receipt + WhatsApp

The receipt number lands on screen and a formatted WhatsApp confirmation lands on your phone via my WotSap API.

edge_cases

Every M-PESA outcome, handled.

The same result-code map I ship to clients — no mystery failures, no silent drops. If the callback stalls, the system queries Daraja directly.

CodeWhat it meansWhat you see
0SuccessReceipt + WhatsApp confirmation
1Insufficient fundsClear message, retry prompt
1032Cancelled on the phone“Declined” state, retry allowed
1037Phone unreachable / no responseTimeout state with guidance
1019Prompt expired — no PIN in timeExpired state, fresh retry
2001Wrong M-PESA PINPIN error, safe to retry
1004 / 13Another push already in progressDuplicate guard blocks spam
others40+ mapped result codesHuman-readable, logged for admin

// want this on your own platform? see the integration service →

Payments are infrastructure.
Build them properly.

STK Push, C2B, B2C, reconciliation and every failure mode — shipped the same way you just used it.