M-Pesa Daraja API Integration: STK Push, Paybill and Automatic Reconciliation
M-Pesa integration means payments are recorded when they happen, not found later on a statement. Here are the main Daraja building blocks.
From statements to callbacks
Many businesses still reconcile M-Pesa by scrolling through statements. With Safaricom's Daraja APIs, your system is notified of each payment as it happens and can record it, match it and issue a receipt. That is what an M-Pesa integration delivers.
STK push
With STK push (M-Pesa Express), your system sends a payment prompt to the customer's phone. They enter their PIN and your system receives the result by callback. It suits checkout, invoices and portals because the customer does not have to type a Paybill number or account reference.
Paybill and Till payments (C2B)
For customer-initiated payments, you register validation and confirmation URLs so Safaricom notifies your server of each payment. The account reference, such as an invoice or member number, tells you what to credit. Unmatched or mistyped references need a review queue.
Payouts (B2C)
Business-to-customer payments let you send money to phones: refunds, commissions, wages or farmer payments. They need approval controls inside your system and the right permissions on your account.
Questions developers and finance teams ask
Do I need a Paybill or a Till? It depends on your business. Paybill uses account references and suits invoicing, while a Till suits retail. Safaricom can advise on eligibility.
Why did a customer's payment not appear? Common causes are delayed callbacks, wrong references and network issues. Status queries and a review queue handle these.
Can the system refund a customer? Through B2C or reversals, with approval controls.
Mistakes to avoid
Trusting callbacks without verifying them. Not handling duplicate callbacks. Ignoring partial payments and overpayments. Keeping credentials in source code. Testing only the happy path in the sandbox. Each causes real problems once money flows.
Mobile money beyond Kenya
Uganda, Tanzania, Rwanda, Ghana and other countries run mobile money through different operators and APIs, such as MTN MoMo and Airtel Money. The design of the integration, callbacks, matching and receipts, carries over, but the API details differ. If you need mobile money outside Kenya, tell us the operator and country so we can check API access.
Go-live and edge cases
Going live needs your own shortcode and Safaricom's approval. Real payments bring duplicates, delayed callbacks, partial payments and overpayments, so status queries and review queues matter. Callbacks must use HTTPS and be verified. Pair this with bank integration for a complete picture.
To integrate M-Pesa with your website, ERP or app, talk to Zinen Technologies.
The systems and environments discussed in this guide
Systems related to this article
More from the blog
Bank API and Payment Gateway Integration in Kenya: IPN, Jenga, Buni and Pesapal
Bank transfers and card payments are still matched by hand in many finance teams. Here is how bank and gateway integrations work in Kenya.
Biometric Attendance and Fingerprint Integration for Payroll in Kenya
A fingerprint terminal on the wall is only useful when its data reaches payroll. Here is how integration works and what to check first.
How to Set Up a VPS for Your Business: A Practical Security Checklist
A VPS gives you control, and with it responsibility. Here is a practical checklist for setting one up securely for Odoo, ERPNext, a website or n8n.
Ready to put this into practice?
Book a free demo and we'll show you exactly how this fits your business.