Powered by Safaricom Daraja · Built for Kenyan Devs

M-Pesa PaymentsThat Just Work.

Stop wrestling with Daraja API. Use your own credentials - we handle OAuth, callbacks, retries, and webhook delivery.

payment.ts
import { MpesaGateway } from 'mpesa-gateway-sdk';

const mpesa = new MpesaGateway({
  apiKey: process.env.MPESA_API_KEY,
});

// Send STK Push to customer's phone
const payment = await mpesa.stkPush({
  phone: '254712345678',
  amount: 2500,
  reference: 'ORDER-001',
});

// That's it - callback handled for you
What you get

Everything Daraja should have been

Production-hardened features that handle the edge cases Safaricom's documentation won't tell you about.

STK Push in one line

Trigger a payment prompt to any M-Pesa number instantly. Callbacks handled, tokens cached, retries automatic.

B2C Payouts & Bulk

Send salaries, commissions, or refunds to hundreds of numbers at once. Upload CSV - we do the rest.

C2B Payments

Accept payments via your Till or Paybill number. Register callback URLs and receive real-time payment notifications.

QR Code Payments

Generate Counter QRs for physical tills or per-Invoice QRs with optional expiry - all from the dashboard.

Account Balance Query

Check your M-Pesa Working and Utility account balances on demand - results delivered via callback, tracked in your dashboard.

Reliable Webhooks

HMAC-signed delivery with exponential backoff retry. You won't miss a payment event - ever.

AES-256 Credentials

Your Daraja credentials are encrypted at rest. You own the relationship with Safaricom - we just wrap it.

Live Dashboard

Real-time transaction status with adaptive polling, toast notifications, and zero manual refreshes.

TypeScript SDK

Full type safety, autocomplete everywhere, and a clean API surface. Built for modern toolchains.

Multi-Config Support

Manage sandbox and production configs side by side. Switch with a single param: config: "production".

Test Mode Built-in

Toggle test mode per config - instant mock responses, simulated callbacks after 3 s. No Safaricom calls.

How it works

From zero to live in three steps

No PSP license. No intermediaries. Your credentials, our infrastructure.

01

Connect your Daraja credentials

Add your Safaricom Daraja consumer key, secret, and passkey. We encrypt them with AES-256-GCM and cache OAuth tokens automatically.

  • Sandbox & production configs
  • Test mode - zero real API calls
  • B2C initiator credentials
02

Integrate in minutes

Install the SDK or use the REST API directly. Both are fully typed with TypeScript. Pick the pattern that fits your stack.

  • npm install mpesa-gateway-sdk
  • REST API for any language
  • Idempotency keys included
03

Receive payments & monitor

Webhooks fire on every status change. The live dashboard shows real-time transaction state. No polling, no guessing.

  • HMAC-signed webhook delivery
  • Exponential backoff retries
  • Live dashboard + toasts
Developer experience

Clean API. Great defaults.

stk-push.ts
import { MpesaGateway } from 'mpesa-gateway-sdk';

const mpesa = new MpesaGateway({
  apiKey: process.env.MPESA_API_KEY,
});

// Initiate payment
const result = await mpesa.stkPush({
  phone: '254712345678',
  amount: 2500,
  reference: 'ORDER-001',
  description: 'Coffee and laptop stand',

  // Optional: use specific config by name
  config: 'production',

  // Optional: prevent duplicate charges
  idempotencyKey: 'order-001-v1',
});

// result.checkoutRequestId - track this
// Safaricom calls your callback when done ✓
Pricing

Simple, honest pricing

No per-transaction cuts. No hidden fees. Cancel anytime.

Ready to ship?

Daraja done right.Start in minutes.

Join developers who stopped reading Daraja docs and started shipping. Free tier included, no credit card needed.