Logo Lanfrica
  • Home
  • Atlas
  • Insights
  • Docs
  • Sign in

© 2026 Lanfrica. All rights reserved. All copyrights of the resources shown on the Lanfrica website belong to the original copyright holders, unless explicitly stated otherwise.

lxmwaniky/mpesa-service-go

Domain:

digital infrastructure

Record type:

software
Creator:
lxm
Host:
A lightweight, zero-dependency Go boilerplate for Safaricom Daraja API integration. Features automated STK push triggers, dynamic password generation, and a plug-and-play HTTP callback handler configurable entirely via environment variables. # M-Pesa API Gateway Service in Go A production-ready, highly reusable M-Pesa (Daraja) API gateway service built in Go. Designed around Clean Architecture, SRE best practices, and high-performance, dependency-minimal principles. This service acts as a secure, centralized payment gateway. It shields your Daraja credentials from client-side frontends, maintains transaction state within PostgreSQL, handles asynchronous webhooks, and serves a secure polling endpoint for client UIs. --- ## Core Features * **Clean Architecture**: Complete decoupling of delivery (HTTP), business logic (Use Cases), and infrastructure (Daraja client & Postgres repository). * **Double-Checked Token Caching**: High-performance, thread-safe in-memory OAuth token caching utilizing `sync.RWMutex` to eliminate outbound authentication bottlenecks and protect against concurrent refresh race conditions. * **Multi-Tier Idempotency**: * *Level 1*: Frontends can send an external reference ID. The system validates references before calling Safaricom, preventing duplicate prompt spam. * *Level 2*: Atomic database updates prevent duplicate webhook payloads (e.g., Safaricom retries) from overwriting committed transactions. * **SRE Observability**: Structured JSON logging using standard library `log/slog` which automatically aligns with Google Cloud Logging when deployed on Cloud Run. * **IP-Based Rate Limiting**: Token-bucket-driven IP rate limiter utilizing `golang.org` with background garbage collection of inactive IPs to prevent memory leaks. * **Zero-Dependency Setup**: Hand-rolled, optimized `.env` file loader and self-bootstrapping database migration scripts leveraging Go’s native `go:embed`. * **Safe Lifecycle Controls**: Graceful server shutdowns handling `SIGINT`/`SIGTERM` to safely drain connection pools and active operations. --- ## Project Structure ```text mpesa-service-go/ ├── cmd/ │ └── api/ │ └── main.go # Application entrypoint & gra …

Visit

github.com

Languages

Lusengo

Similar

yannickRafael/go-mpesafreelancer254/mpesa-goedsonmichaque/mpesa-go-sdktanlio/mpesa-api-goFellow3-1/mpesa-api-goSafaricom-Ethiopia-PLC/mpesa-go-sdk

yannickRafael/go-mpesa

# go-mpesa A Go library for the M-Pesa Mozambique API. Ported from mpesa-mz-nodejs-lib. ## Install

freelancer254/mpesa-go

A go Mpesa Daraja API wrapper # M-Pesa Go A high-performance Go module for interacting with Safaric

edsonmichaque/mpesa-go-sdk

# M-Pesa SDK for Go M-Pesa SDK for Go is an unofficial library aiming to help businesses integratin

tanlio/mpesa-api-go

# MPESA Golang API Wrapper The wrapper provides convenient access to the Safaricom MPESA Daraja AP

Fellow3-1/mpesa-api-go

The unofficial Safaricom MPESA API Wrapper for Golang # Unofficial Safaricom MPESA Golang API Wrapp

Safaricom-Ethiopia-PLC/mpesa-go-sdk

# [mpesa-go-sdk]: M-Pesa SDK for Golang ## Overview `mpesa-go-sdk` is a Go SDK for interacting