M-Pesa integration for your app, website or system
We add Safaricom M-Pesa payments through the Daraja API. STK Push, Paybill and Till, B2C payouts and the callbacks that make them reliable. Built in Kenya by a team that runs its own Paybill every day.
KEPAS adds Safaricom M-Pesa payments to apps, websites and business systems anywhere in Kenya. We work on the Daraja API every day because our own products run on it. KodiSap collects rent through our Paybill 4052037. Wabi holds a client's M-Pesa until the job is done and pays the worker after. daraja-js, our open source SDK, came out of the bugs we met running that Paybill with real money.
What we integrate
- STK Push (Lipa na M-Pesa Online)
- The customer taps pay, the M-Pesa PIN prompt appears on their phone, and your system learns the result the moment Safaricom posts it back.
- Paybill and Till payments (C2B)
- Customers pay your Paybill or Till the way they already know. Validation and confirmation URLs match every payment to the right account, invoice, student or tenant.
- B2C payouts
- Pay workers, suppliers, refunds or loan disbursements straight to a phone from your shortcode, with every result parsed and stored.
- B2B, reversals and status checks
- Business to business payments, float transfers, transaction status, account balance and reversals on the same Daraja app.
- Callbacks and reconciliation
- Every callback is verified, stored before it is processed and never counted twice. Payments Safaricom never called back about are pulled in with the Pull Transaction API, so your records and your M-Pesa statement agree.
- Paybill application and Go-Live
- No shortcode yet? We guide you through the Safaricom Paybill or Till application and the Daraja Go-Live, the same forms and emails we went through for our own Paybill.
Where it goes to work
- School fees with the admission number as the account
- Hospital and clinic bills
- NGO donations and member contributions
- Rent collection and tenant receipts
- Online shop checkout
- Worker, agent and supplier payouts
Why ask KEPAS
- We run a Paybill of our own
- Paybill 4052037 collects rent for landlords on KodiSap, our Android app on Google Play. Callbacks, reconciliation and Safaricom's quirks are things we handle every day, not things we read about.
- We wrote the SDK other developers use
- daraja-js is our open source Node.js and TypeScript SDK for Daraja, published on npm as @kepas/daraja-js under the Apache 2.0 licence. Each check in it is a bug we hit in production and now stop before it reaches you.
- We built a console for shortcodes
- Daraja Studio is our simpler alternative to the Safaricom organisation portal, built on daraja-js.
- We have written it all down
- Read Adding M-Pesa to your app, what they don't tell you and How to integrate M-Pesa payments into your organisation website before you call us.
How an M-Pesa integration goes
- A short call. We look at your app or system, your shortcode if you have one, and what a payment should trigger. You get a written quote and dates.
- Accounts. Paybill or Till, Daraja app, callback URLs and credentials. We help with the Safaricom forms when you are starting from nothing.
- Build and test. We build against the Daraja sandbox, then test live with small real amounts on your shortcode.
- Go live. We watch the first days of real payments, then hand over the code, the credentials and a short guide. The code is yours.
What you need to have
- A registered business or organisation
- A Paybill or Till number, or our help applying for one
- A Safaricom Daraja developer account
- The app, website or system that will take the payments, or a plan for one
What it costs
Safaricom does not charge for the Daraja API. M-Pesa charges its normal transaction fees on your Paybill or Till, and those stay the same whoever builds the integration.
A new app with M-Pesa, offline sync and push notifications costs between KSh 150,000 and KSh 500,000, as listed on our services page. Adding M-Pesa to a website, app or system you already have costs between KSh 20,000 and KSh 60,000. STK Push alone sits at the low end. Paybill payments, stored callbacks, a daily match and the Go-Live paperwork sit at the high end. We quote it in writing after the first call, before any work starts, and the quote is the price.
M-Pesa integration questions
Do I need my own Paybill or Till?
How long does it take?
What happens when a payment fails or the customer cancels?
Can you integrate into a system I already have?
Do you also take card payments?
Will I own the code?
Do you work outside Nairobi?
Tell us what should happen when a customer pays
Send a line about your app or system and whether you have a Paybill or Till. We reply with questions, then a written quote.