Skip to content

A complete open-source platform for building, testing, and monitoring M-Pesa webhooks and payment integrations. Built for developers who want fast setup, flexible APIs, real-time dashboards, and CLI tools --- all in one.

Notifications You must be signed in to change notification settings

DarajaDevToolkit/darajadevToolkit

Repository files navigation

Daraja Developer Toolkit πŸ‡°πŸ‡ͺ

Never lose another M-Pesa webhook again

A reliable webhook proxy service that sits between M-Pesa and your application, solving the most common pain points in Kenyan fintech development.

🎯 The Problem We're Solving

Every Kenyan developer integrating M-Pesa has experienced:

  • Lost webhooks when dev servers go down
  • Zero visibility into webhook delivery status
  • Manual testing in production environments
  • No retry mechanism when webhooks fail

Summary

This is a developer toolkit for M-Pesa (Daraja) that ensures webhooks are reliably delivered, retried if they fail, and logged for visibility;solving common issues like missed callbacks, sandbox failures, and silent delivery errors.

πŸš€ Our Solution

One permanent URL + Intelligent routing + Reliability

M-Pesa β†’ [Your Permanent URL] β†’ [Smart Validation] β†’ [Queue] β†’ [Environment Router] β†’ [Your App]

Key Features

  • βœ… Permanent webhook URLs - Set once with M-Pesa, never change
  • βœ… Environment routing - Dev/staging/prod from one URL
  • βœ… Reliable delivery - Retries, queuing, circuit breakers
  • βœ… Full observability - Real-time dashboard and detailed logs
  • βœ… M-Pesa compliance - Proper validation and response handling

πŸ—οΈ Architecture

Services

β”œβ”€β”€ webhook-service/     # Receives M-Pesa webhooks (Bun + Hono)
β”œβ”€β”€ delivery-worker/     # Handles webhook delivery with retries (Node.js)
β”œβ”€β”€ dashboard/          # User interface (Next.js + React)
β”œβ”€β”€ cli/               # Command-line interface (Python)
└── shared/            # Common types and utilities

Flow

  1. M-Pesa sends webhook β†’ webhook-service (permanent URL)
  2. Validate & queue β†’ Ensure it's real M-Pesa, store safely
  3. Environment routing β†’ Determine dev/staging/prod destination
  4. Reliable delivery β†’ delivery-worker handles retries & failures
  5. Monitor & observe β†’ dashboard shows real-time status

πŸ› οΈ Quick Start

Prerequisites

  • Node.js 18+
  • Bun (for webhook service)

Installation

# Clone the repository
git clone https://github.com/DarajaDevToolkit/darajadevToolkit.git
cd darajadevToolkit

# Install dependencies
npm install

# Start development services
npm run dev

Services will be running on:

CLI Installation (for developers):

cd cli
pip install -e .
daraja --help

πŸ“š Usage

Option A: CLI (Recommended for developers)

# Initialize and login
daraja init

# Configure environments
daraja config set-endpoint dev http://localhost:3000/webhook
daraja config set-endpoint prod https://yourapp.com/webhook

# Get your permanent URL for M-Pesa
daraja config get-url

# Test your setup
daraja test webhook --environment dev

# Monitor in real-time
daraja logs --tail

Option B: Dashboard (Web interface)

1. Get Your Permanent URL

https://api.daraja-toolkit.com/webhook/your-user-id

2. Configure M-Pesa

Use your permanent URL in M-Pesa developer portal - never change it again!

3. Set Environment Routes

Configure where webhooks should be delivered:

{
  "dev": "http://localhost:3000/mpesa/webhook",
  "staging": "https://staging.yourapp.com/mpesa/webhook",
  "production": "https://yourapp.com/mpesa/webhook"
}

4. Monitor & Debug

Real-time dashboard shows:

  • Webhook delivery status
  • Response times and success rates
  • Detailed error logs
  • Environment switching controls

πŸ§ͺ Development

Project Structure

daraja-developer-toolkit/
β”œβ”€β”€ webhook-service/        # M-Pesa webhook receiver
β”‚   β”œβ”€β”€ src/server.ts      # Main webhook server
β”‚   └── package.json
β”œβ”€β”€ delivery-worker/        # Async webhook delivery
β”‚   β”œβ”€β”€ src/worker.ts      # Delivery logic with retries
β”‚   └── package.json
β”œβ”€β”€ dashboard/             # Next.js dashboard
β”‚   β”œβ”€β”€ src/app/          # App router pages
β”‚   └── package.json
β”œβ”€β”€ shared/               # Common types & utilities
β”‚   β”œβ”€β”€ src/types/        # TypeScript interfaces
β”‚   β”œβ”€β”€ src/utils/        # Validation utilities
β”‚   └── package.json
└── package.json          # Workspace root

Available Scripts

npm run dev         # Start all services in development
npm run build       # Build all services
npm run build:shared # Build shared package only
npm run lint        # Lint all services
npm run clean       # Clean all build artifacts

Testing Webhooks

# Test webhook endpoint
curl -X POST http://localhost:3001/test/your-user-id

# Health check
curl http://localhost:3001/health

🀝 Team & Contributing

We're a focused team of ~10 Kenyan developers building this in the open.

Current Team Leads Needed

  • Backend (Webhook proxy service) - Available
  • Frontend (Dashboard) - Available
  • DevOps (Infrastructure) - Available
  • CLI tooling - Available

Development Timeline

  • Week 1-2: Architecture & team setup βœ…
  • Week 3-4: Core webhook service MVP
  • Week 5-6: Dashboard & delivery worker
  • Week 7-8: Integration testing & polish
  • Week 8+: Public beta launch πŸš€

Contributing

  1. Join our Discord server (link coming soon)
  2. Check open issues for tasks
  3. Fork, develop, test, PR
  4. We review & merge quickly

πŸ™ Acknowledgments

Built by developers who have felt the M-Pesa integration pain. Special thanks to the Kenyan fintech community for inspiration and feedback.


Made with ❀️ in Kenya πŸ‡°πŸ‡ͺ

About

A complete open-source platform for building, testing, and monitoring M-Pesa webhooks and payment integrations. Built for developers who want fast setup, flexible APIs, real-time dashboards, and CLI tools --- all in one.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •