daraja-sdk
A memory-safe Rust SDK for Safaricom Daraja (M-Pesa API 3.0), focused on correctness and type safety.
Experimental: This project is an early experiment. The API is unstable, coverage is limited, and it is not ready for production use.
use Mpesa;
async
Planned features
- OAuth authentication — generate access tokens for Daraja API requests
- M-Pesa Express (STK Push) — initiate Lipa na M-Pesa Online payments and query transaction status
- B2C — send money from a business shortcode to a customer
- C2B — register validation and confirmation URLs for paybill/till payments
- Transaction status — query the result of a payment request
- Account balance — check balances for a shortcode
- Reversals — reverse a completed transaction
- Production environment — configurable sandbox vs production base URLs
Developing locally
Requires a Rust toolchain that supports edition 2024, plus sandbox credentials from the Daraja Developer Portal.
# add your sandbox consumer_key and consumer_secret to config.toml
Integration tests call the live Daraja sandbox. config.toml is gitignored so credentials are not committed.