Go Daraja (M‑Pesa) Client¶
A lightweight, idiomatic Go client for Safaricom's Daraja (M‑Pesa) APIs. Clean configuration, safe defaults, and a consistent API for core payment flows.

Highlights¶
- Simple, composable client construction with functional options
- Context-aware APIs for cancellation and timeouts
- Embedded X.509 certs and typed error model
- Covers STK Push, B2C, C2B, B2B and Business Express
- 12‑factor configuration from environment (optional
.env)
Quick links¶
- Getting started: Installation · Quickstart
- Usage guides: STK Push, B2C, C2B, B2B, Business Express
- Reference: API, Environment variables
- Support: Troubleshooting · FAQ
Project structure¶
pkg/
handler/ # Public client and operations
internal/
auth/ # Basic auth token creation
builder/ # Helpers (base URLs, phone formatting, timestamp)
config/ # Viper-based configuration loader
x509/ # go:embed certs + security credential generation
example/ # Example .env and sample usage