Welcome to Nemtel Systems
GET A QUOTE
Call: +254 722 682 017
~PAYMENTS

How to Add M-Pesa STK Push to Your Business System

Home/Blog & News/How to Add M-Pesa STK Push to Your Business System
Nov 20 2026
By Emmanuel Nyakoe
6 min read
0 Comments
How to Add M-Pesa STK Push to Your Business System

In Kenya's digital economy, manual payment reconciliation is one of the biggest silent drains on business productivity. When a customer pays via Paybill or Till, asking them to manually forward an SMS confirmation or type an M-Pesa code into a web form leads to fraud, typos, delayed orders, and frustrated customers. The solution adopted by modern forward-thinking businesses is Lipa Na M-Pesa Online (STK Push).

STK Push—technically known as the Daraja C2B / Lipa Na M-Pesa Online API—initiates a payment directly on the customer's mobile handset. When the customer clicks 'Pay with M-Pesa' on your website or mobile app, Safaricom's servers immediately display a secure pop-up dialog on their screen: 'Do you want to pay KES X to Business Y? Enter PIN'. The customer enters their PIN, Safaricom deducts the amount, and sends an automated instant cryptographic webhook notification directly to your server.

To implement STK Push effectively, your business needs a few verified prerequisites. First is an active Safaricom Paybill or Buy Goods Till number registered to your legal business entity. Second is a Safaricom Daraja developer portal account where your developer registers an application to receive an API Key and Consumer Secret. Third, and most importantly, is a secure, publicly accessible HTTPS callback listener endpoint capable of handling real-time JSON webhooks with zero latency.

The architectural workflow is straightforward: Your backend issues a POST request to Safaricom's authentication endpoint to generate a short-lived OAuth bearer token. Using this token, your server computes a Base64-encoded password consisting of your Business Shortcode, a unique Passkey issued by Safaricom, and a current timestamp (YYYYMMDDHHmmss). Your server then invokes the LNMO Express endpoint passing the customer's phone number, amount, account reference, and your CallbackURL.

Handling callbacks requires rigorous engineering. Safaricom's servers fire an asynchronous callback within seconds containing the result code (0 for success, 1032 for user cancelled, 1 for insufficient funds). Your endpoint must respond immediately with an HTTP 200 JSON acknowledgment to prevent Safaricom from queueing retries. Furthermore, you must implement idempotency: storing the unique MpesaReceiptNumber in your database with a unique index constraint so duplicate notifications never result in double-credited balances.

When properly architected by an experienced engineering team like Nemtel Systems, STK Push completely eliminates manual human intervention. Invoices are marked paid within 3 seconds, digital receipts are dispatched, stock is updated, and your financial records remain in 100% real-time balance.

Share this article

Comments (0)

No comments published yet. Be the first to share your thoughts below!

Leave a Reply

Your email address will not be published. Required fields are marked *

About the Author

Written by Emmanuel Nyakoe from the Nemtel Systems technical team. Our team delivers direct, battle-tested insights from active field telecom cabling and software deployments across Kenya.

View Full Team →

Have a Technical Project in Mind?

From Daraja STK Push to PBX hotel extension repairs, our engineering team is ready to assist.

GET A QUOTE
Nemtel Support and Field Engineering
NEMTEL SYSTEMS

Our business is to maintain yours.