PesaKit for M-Pesa on Node.js
The practical toolkit for STK Push, Dynamic QR, C2B, B2C, pull-based reconciliation, status checks, reversals, and callback-heavy Daraja integrations.
Why teams use this SDK
Section titled “Why teams use this SDK”- Build against Safaricom Daraja from a Node.js backend without carrying your own auth, request-shaping, and callback-parsing plumbing.
- Keep integrations explicit and maintainable with typed inputs, typed responses, and fast-fail validation at the SDK boundary.
- Move faster across common M-Pesa payment and operational flows with one consistent
Mpesaclient from PesaKit.
What you get out of the box
Section titled “What you get out of the box”Mpesaas a single entry point for the implemented API families.- Automatic OAuth token fetching with in-memory caching and concurrent refresh deduplication.
- Typed SDK errors for auth, request, validation, and callback parsing failures.
- Optional callback parsers and a standalone HTTP callback handler for STK, C2B, and async result routes.
- Pull-based reconciliation support for recent C2B transaction recovery.
- A docs set that covers setup, local testing, sandbox credentials, go-live preparation, and common troubleshooting.
Built for practical Node.js integrations
Section titled “Built for practical Node.js integrations”- Use it in Node services, Express or Fastify apps, workers, queue consumers, or other backend processes that need to talk to Daraja.
- Keep credential sourcing flexible with constructor config and environment-variable fallback.
- Stay close to Daraja behavior while avoiding repetitive payload assembly across flows.
Start here
Section titled “Start here”- Read the quick start.
- Configure your environment and credentials.
- Confirm the Node runtime expectations.
- Follow the end-to-end STK payment flow if you are integrating your first checkout. 5. Pick the guide for your first flow: STK Push, Dynamic QR, C2B, Pull Transactions, or B2C.
Choose your path
Section titled “Choose your path”- Taking customer payments from a phone prompt: start with STK Push and Query and then read the end-to-end STK payment flow.
- Generating a scan-to-pay QR for in-person or assisted checkout: use Dynamic QR.
- Receiving direct customer payments into your business shortcode: use C2B Register URLs and Simulation.
- Reconciling missing or delayed C2B callbacks: use Pull Transactions.
- Sending money out to customers: use B2C Payments.
- Building callback receivers and recovery jobs: use Callbacks and Local Testing and Callback Reliability and Reconciliation.
Why this package stays focused
Section titled “Why this package stays focused”This SDK is aimed at the M-Pesa flows most Node teams need in normal product and operations work. Daraja APIs that mainly serve special onboarding programs, commercial agreements, or narrower enterprise workflows are tracked in the API coverage matrix but intentionally kept out of the core SDK surface.
Operational docs
Section titled “Operational docs”- Need sandbox credentials? Use the sandbox setup guide.
- Designing resilient callback handling? Read callback reliability and reconciliation.
- Preparing for production? Follow the go-live checklist.
- Tracking failures? Start with the error reference, result and status reference, and troubleshooting guide.
Scope note
Section titled “Scope note”This SDK focuses on the commonly used Daraja payment and operational APIs. The current implementation surface and known gaps are tracked in the API coverage matrix.
About Landela Tech
Section titled “About Landela Tech”Landela Tech specializes in payment integrations across local and international providers, building practical infrastructure for teams shipping real-world payment flows.
Learn more at landelatech.com.