Docs Open Console

M-Pesa Integration

Accept M-Pesa payments with automatic confirmation: the buyer approves on their phone and the order completes by itself. Kenya, KES checkouts.

What is M-Pesa Integration?#

M-Pesa integration uses Safaricom’s Daraja API to send an STK push (a payment prompt) straight to the buyer’s phone. The buyer enters their M-Pesa PIN, and the payment is detected and confirmed automatically - no manual order confirmation needed.

  • Interactive checkout: buyer enters their Safaricom number, approves on their phone, done
  • Automatic confirmation: the order completes itself via the Daraja callback plus a status poll
  • Non-custodial: funds settle to your own M-Pesa Paybill - the platform never touches them
  • KES only: the rail appears on KES-denominated checkouts

Setup#

  1. Create a free app at developer.safaricom.co.ke and copy the Consumer Key and Consumer Secret.
  2. Get your Lipa na M-Pesa Online Passkey (the sandbox passkey is published on the Daraja portal; production go-live issues yours).
  3. In Settings → M-Pesa, paste the credentials, enter your Business Shortcode (Paybill), and toggle the rail on. Use the Sandbox toggle while testing.

The public sandbox credentials (shortcode 174379) let you test the full push-and-confirm flow before going live.

How it works#

  1. The buyer picks M-Pesa (instant) at checkout and enters their Safaricom number.
  2. Your checkout sends an STK push; the buyer’s phone shows the payment prompt with the exact amount.
  3. The buyer enters their M-Pesa PIN to approve.
  4. The order completes automatically - receipt email, webhook, and any connected store fulfillment run exactly like an on-chain payment.

Daraja signs nothing: completion is only ever decided by a server-side status query, never by the incoming callback. Cancelled, timed-out, and insufficient-balance prompts close the order automatically.

Manual fallback#

The manual M-Pesa bank rail (Paybill or Till number, confirmed with Mark as Paid) stays available separately under Bank Payments for merchants without API credentials.