Safaricom daraja 3.0 java (SpringBoot) api integrations (sdk) - STK Push, C2B, B2C, B2B, Transaction Status, Account Balance, Reversals, Dynamic QR, and Bill Manager
# M-Pesa Daraja API
A production-ready Spring Boot backend for Safaricom's M-Pesa Daraja APIs. Covers the full integration surface — STK Push, C2B, B2C, B2B, Transaction Status, Account Balance, Reversals, Dynamic QR, and Bill Manager — with a clean SDK layer, PostgreSQL persistence for C2B callbacks, and Docker support.
## Architecture
## System Flow & Schema
## API Endpoints
### Outbound — you call these
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/mpesa/stk-push` | Trigger payment prompt on customer phone |
| `POST` | `/api/v1/mpesa/stk-push/query` | Check STK push status |
| `POST` | `/api/v1/mpesa/b2c/payment` | Send money to a customer |
| `POST` | `/api/v1/mpesa/b2b/payment` | Pay another business |
| `POST` | `/api/v1/mpesa/transactions/status` | Query a transaction |
| `POST` | `/api/v1/mpesa/account-balance` | Check business account balance |
| `POST` | `/api/v1/mpesa/reversal` | Reverse a transaction |
| `POST` | `/api/v1/mpesa/dynamic-qr` | Generate a payment QR code |
| `POST` | `/api/v1/mpesa/bill-manager/invoices/single` | Create a single invoice |
| `POST` | `/api/v1/mpesa/bill-manager/invoices/bulk` | Create bulk invoices |
| `POST` | `/api/v1/mpesa/bill-manager/invoices/cancel` | Cancel an invoice |
| `POST` | `/api/v1/mpesa/bill-manager/reconciliation` | Reconcile billing |
### Admin
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/mpesa/admin/register-urls` | Register your callback URLs with Daraja |
| `POST` | `/api/v1/mpesa/admin/simulate` | Simulate a C2B payment (sandbox only) |
### Inbound — Safaricom calls these
| Method | Endpoint | Description |
|--------|----------|-------------|
| `POST` | `/api/v1/mpesa/c2b/confirmation` | C2B payment confirmation (persisted) |
| `POST` | `/api/v1/mpesa/c2b/validation` | C2B payment validation |
| `POST` | `/api/v1/mpesa/results/stk` | STK Push async result |
| `POST` | `/api/v1/mpesa/result …