Production-ready Vodacom M-Pesa Tanzania integration for Python & Django
Skip weeks of undocumented API pain. C2B USSD push payments via openapi.m-pesa.com — extracted from a live SaaS product and verified against the real sandbox and production callbacks.
For Vodacom M-Pesa Tanzania — not Safaricom Daraja (Kenya), not Node.js. Django app included; the core client also works with Flask, FastAPI, or plain scripts.
Why this API costs teams weeks
Vodacom Tanzania's OpenAPI is a different, poorly documented API — almost every tutorial online covers the wrong one. These are the walls you hit alone.
RSA-encrypted session tokens
Vodacom's OpenAPI doesn't use plain OAuth like Daraja. Session tokens must be RSA-encrypted with the portal's public key — the kit ships the encryption and auto-refresh logic you'd otherwise spend days reverse-engineering.
Error codes barely documented
The official docs leave most response codes unexplained. The kit includes a response-code table live-verified against the real Vodacom sandbox and a production deployment.
Callbacks arrive more than once
M-Pesa retries callbacks, so a naive handler double-credits customers. The kit's callback handler is idempotent out of the box — a retried callback can never record a payment twice.
Sandbox ≠ production
Same host, different path prefix, and separate public keys per environment — undocumented gotchas that silently break your first deployment. The kit's configuration handles both environments.
What's inside
Extracted from a live SaaS product processing real M-Pesa callbacks — not a demo.
Framework-agnostic MpesaClient + Django app
Model, callback view, signals, and migrations included — no foreign-key coupling to your models. The core client also works with Flask, FastAPI, or plain scripts.
Idempotent async callback handler
Safe against M-Pesa's callback retries, with a success signal/hook so your own logic runs exactly once per payment.
62 passing tests, zero third-party SDK code
Everything is readable, auditable Python you own — no black-box dependencies.
8 runnable examples
One-time payment, recurring billing, status polling, a Flask webhook server, and Celery tasks with retry.
Docs that fill the gaps
Portal credentials walkthrough, full configuration reference, live-verified error-code table, top-10 troubleshooting guide, and a deployment guide (Ubuntu VPS + Railway).
Full Kiswahili quickstart
QUICKSTART_SW.md — the complete getting-started guide in Kiswahili.
One USSD push — from prompt to paid
Exact usage from the kit's quickstart — this is the whole integration surface.
from mpesa.django.client import get_mpesa_client
from mpesa.django.models import MpesaTransaction
txn = MpesaTransaction.objects.create(
external_ref=order.id, msisdn="255712345678", amount="5000"
)
client = get_mpesa_client()
client.c2b_payment(
amount="5000", msisdn="255712345678", third_party_ref=txn.external_ref.hex
)
# Customer enters PIN → callback fires your success handler. Order paid ✔One-time payment
$39
Per developer · instant download
- ✓ Full source code — MpesaClient + Django app (v1.2.0)
- ✓ 62 passing tests + 8 runnable examples
- ✓ Docs, error-code table & Kiswahili quickstart
- ✓ 6 months of email support
- ✓ 14-day money-back guarantee
Secure checkout · instant delivery
Frequently asked questions
What license do I get?
Licensed per developer. Use in unlimited client/commercial projects allowed. Redistribution or resale of the kit itself is not permitted.
What support is included?
6 months of email support for setup and integration questions. Responses within 24–48 hours (Mon–Fri).
What if it doesn't work for me?
14-day money-back guarantee. If the kit doesn't work as described, you get a full refund — no questions asked.
Does this work for Safaricom M-Pesa Kenya?
No. This kit is for Vodacom M-Pesa Tanzania's OpenAPI (openapi.m-pesa.com) only. Safaricom Daraja is a different API with different authentication and endpoints.
Stop reverse-engineering undocumented APIs.
Get the integration that already survived production — and ship M-Pesa payments this week.