How to set up M-Pesa STK push for your business

Connect your own paybill or till, and collect payment from inside an order — the customer taps their PIN, and you see it settle.

Updated 21 August 20267 min read

Most small businesses in Kenya collect M-Pesa the manual way: send the customer a paybill number and account reference, wait, then ask them to read back the confirmation code so you can check it off. It works, but it is slow, it invites typos, and reconciling it at the end of the day is its own job.

STK push replaces that. You enter the amount and the customer's number, and a payment prompt appears on their phone. They enter their M-Pesa PIN and the payment is confirmed back to you automatically. No reference code to read out, nothing to reconcile by hand.

This guide covers connecting Safaricom's Daraja API to ClusterBox. If you use Kopokopo instead, the setup is different but the result is the same — see the comparison at the end.

What you need before you start

  • An M-Pesa paybill or till number registered to your business.
  • A Safaricom Daraja developer account, with your paybill or till linked to it.
  • Your Daraja app credentials: consumer key, consumer secret, and passkey.
  • Admin access to your ClusterBox workspace. Payment provider settings are restricted to workspace admins, because those rows hold your provider credentials.

Step 1 — Get your Daraja credentials

  1. 1Sign in to the Safaricom Daraja developer portal and open your app.
  2. 2Copy the Consumer Key and Consumer Secret from the app's credentials page.
  3. 3Find your Lipa Na M-Pesa Online passkey. This is separate from the consumer secret, and it is the one people most often miss.
  4. 4Note your shortcode — your paybill number, or your till number if you are on Buy Goods.

Step 2 — Add the provider in ClusterBox

Payment providers are configured on the web dashboard, not in the mobile app. Open your ClusterBox dashboard and go to Payment providers, then add a provider and choose M-Pesa (Daraja).

What each field wants

Display name
Whatever helps you recognise it later — "Main paybill" is fine. Only you see this.
Shortcode / Paybill
Your paybill or till number.
Environment
Sandbox while testing, Production when you go live.
Transaction type
Paybill for a paybill number, or Till (Buy Goods) for a till.
Consumer key
From your Daraja app.
Consumer secret
From your Daraja app.
Passkey
Your Lipa Na M-Pesa Online passkey.

Step 3 — Whitelist your callback URL

Once you save the provider, ClusterBox shows you a callback URL. This is the address Safaricom sends the payment result to — without it, the customer can pay and your order will never update.

  1. 1Copy the callback URL from the provider page in ClusterBox.
  2. 2In the Daraja portal, add it to your app as the confirmation and validation URL.
  3. 3Back in ClusterBox, use Register C2B. This registers those URLs with Safaricom for your shortcode so incoming payments are confirmed back to your workspace.

Step 4 — Collect a payment

Collection happens in the ClusterBox mobile app, where you are already working through orders. Open an order and choose to collect payment.

  1. 1Pick the provider you just connected.
  2. 2Enter the amount and the customer's phone number.
  3. 3Send the request. The customer gets the M-Pesa prompt on their phone.
  4. 4Watch it move to paid — or fail, if they cancel or the PIN times out.

Recording a payment by hand still works exactly as before. STK push is for when you would rather the customer just paid on the spot, while you have their attention.

When it does not work

What you seeUsual cause
The prompt never reaches the customer's phoneWrong environment — the provider is still on Sandbox, or the number is not a Safaricom line.
Payment succeeds but the order stays unpaidCallback URL not whitelisted in Daraja, or Register C2B was never run.
The request is rejected immediatelyTransaction type does not match your shortcode — Paybill selected for a till, or the reverse.
Authentication errorsConsumer key or secret copied with trailing whitespace, or from the sandbox app while set to Production.
Prompt appears but always failsPasskey belongs to a different shortcode.

If you have worked through those and it still will not connect, message us on WhatsApp at +254 724 433585 and we will set it up with you. It usually takes about ten minutes.

Frequently asked questions

Do I need my own paybill or till to use STK push?

Yes. STK push initiates a payment into your own M-Pesa shortcode, so the money goes directly to your business. ClusterBox never holds your funds — you connect your own Daraja credentials and Safaricom settles to you exactly as it does now.

What does Safaricom charge for this?

Transaction charges are set by Safaricom against your paybill or till, not by ClusterBox, and they depend on your tariff. Check with Safaricom for the rates on your shortcode.

Can I test it before going live?

Yes. Choose the Sandbox environment when adding the provider and use your Daraja sandbox credentials. Switch to Production once the flow works end to end.

Can I still record cash and manual M-Pesa payments?

Yes. Recording a payment by hand works exactly as it always has. STK push is an additional way to collect, not a replacement.

Why is the setup on the website and not in the app?

Provider credentials are configured on the web dashboard, where they are restricted to workspace admins. Collecting payment happens in the mobile app, where you are already working through orders.

Want a hand with any of this?

We set this up with businesses most weeks and can usually do it with you in about ten minutes. Message us on WhatsApp, or email hello@clusterbox.co.

Chat with us on WhatsApp

More guides