Home › M-Pesa integration

M-Pesa integration for Kenyan businesses

Accept and send money inside your own system. We build secure, reliable M-Pesa integrations using the Safaricom Daraja API, with proper handling of callbacks, failures and reconciliation.

What we integrate

Safaricom's Daraja API lets your own system collect and send money through M-Pesa without staff matching payments by hand. We build the integration end to end, from the first request to production.

Collect

STK Push (M-Pesa Express)

Your system prompts the customer's phone to pay. They enter their PIN and your system is notified automatically.

Collect

C2B Paybill and Till

Customers pay your Paybill or Till number directly. We handle the validation and confirmation callbacks and match each payment to an order or account.

Pay out

B2C payouts

Send money from your business to customers: refunds, withdrawals, commissions, salaries or loan disbursements.

Verify

Transaction status

Query Safaricom to confirm what really happened when a callback is delayed or never arrives.

Control

Reversals

Reverse eligible transactions from your own admin screen with a full audit trail.

Monitor

Account balance

Check your M-Pesa account balance programmatically and alert your team before funds run low.

How an integration project runs

Scope the flowsWe agree which payments you need (collect, pay out, or both), whether you use a Paybill or a Till, and how payments map to your orders, invoices or customer accounts.
Build in the sandboxWe develop and test every path against Safaricom's sandbox first, including failures, cancellations and timeouts.
Go liveWe guide you through Safaricom's go-live process and switch to production credentials. Requirements can vary, so we confirm them with you early.
Monitor and supportAfter launch we watch for failed callbacks, reconcile payments and fix issues quickly.

Where M-Pesa integrations usually go wrong

The happy path is easy. Problems appear in production, so these are the things we design for from day one:

  • Callbacks that never arrive. Networks fail. We query transaction status and reconcile so a paid order is never left unpaid.
  • Duplicate callbacks. The same notification can be delivered more than once. Processing is idempotent, so a customer is never credited twice.
  • Public callback URLs. Safaricom must be able to reach your HTTPS callback endpoint. We set this up and secure it properly.
  • Phone number formats. Numbers are normalised to the 2547XXXXXXXX format before any request.
  • Secrets in code. Consumer keys and passkeys live in server configuration, never in source code or the browser.
  • No audit trail. Every request and callback is stored, so finance can trace any payment.

New to the topic? Read our step-by-step guide to M-Pesa STK Push integration.

Frequently asked questions

What do I need before we start?

A Paybill or Till number for production (the sandbox lets us build before you have one), a Safaricom Daraja developer account, and details of how you want payments to work in your business. We guide you through the rest.

Can you integrate M-Pesa into my existing website or system?

Yes. We usually build the payment logic as a small secure service with a clean REST API, so your existing website, app or ERP only needs to call it.

Which technology do you use?

Mostly Java and Spring Boot, which suits payment systems well. See our Spring Boot development page.

How long does it take?

It depends on scope. A basic STK Push integration into an existing system can be quick once credentials are ready. Payouts, reconciliation and reporting take longer. We give you a clear estimate after the first conversation.

Do you provide support after launch?

Yes. We offer maintenance and monitoring so payment issues are caught and fixed quickly.

Ready to get started?

Tell us what you need and we will reply with a clear plan. Call, text or WhatsApp 0707 083 949, or email support@mabiznahub.co.ke.