Py MoMo SDK
Strictly typed Python SDK for MTN Mobile Money, Airtel Money, Wave, Safaricom M-Pesa, Paystack, Flutterwave, and Orange Money
Py MoMo SDK (py-momo-sdk 1.3.3) is a strictly typed Python client library for MTN Mobile Money (MoMo), Airtel Money, Wave, Safaricom M-Pesa (Daraja), Paystack, Flutterwave, and Orange Money behind a unified PaymentRouter. It provides synchronous and asynchronous clients with matching interfaces, automatic token caching, strict input validation, and verified webhook security.
- PyPI package: py-momo-sdk (
1.3.3, imported aspy_momo_sdk, inspectable viapy_momo_sdk.__version__) - Python support: Python 3.10 to 3.15
- Documentation: https://wkambale.github.io/pymomo/
- Repository: https://github.com/wkambale/pymomo
Features
- Sync and async parity:
PyMomoSDK,AsyncPyMomoSDK,AirtelClient,AsyncAirtelClient,PaymentRouter,AsyncPaymentRouter, and all provider clients backed byhttpx.Clientandhttpx.AsyncClient. - Pydantic v2 models: Fully typed request and response validation and serialization.
- Automated token caching: Thread-safe and async-safe double-checked token management with conditional
expected_tokeninvalidation and retry-once logic. - Comprehensive African payment coverage: MTN MoMo Collection (including CIBA and OAuth2 token exchange/refresh), Disbursement, Remittance, and Sandbox; Airtel Money (
AirtelClient/AsyncAirtelClientwithencrypt_airtel_pin()); Wave; Safaricom M-Pesa (Daraja); Paystack; Flutterwave; and Orange Money behindPaymentRouter. - Resilience and observability: Configurable idempotent retries with
Retry-Afterand jitter, bounded streaming response caps (max_response_bytes), HTTP3xxredirect rejection,wait_for_settlement()/async_wait_for_settlement(),TelemetryHookobservability events, 18-market MSISDN carrier detection, FastAPI/Starlette and Django webhook verifiers, and a localpy-momo-sdk mocksimulator. - CLI utility: Optional
py-momo-sdkTyper CLI for sandbox provisioning, collections, disbursements, remittances, Airtel PIN encryption, webhook verification, carrier lookup, and mock server hosting.
Installation
Install the core library from PyPI:
pip install py-momo-sdk
Install optional extras as needed:
pip install "py-momo-sdk[cli]" # Typer CLI tool
pip install "py-momo-sdk[airtel]" # cryptography for encrypt_airtel_pin()
pip install "py-momo-sdk[fastapi]" # FastAPI / Starlette ASGI webhook verifier
pip install "py-momo-sdk[django]" # Django webhook verifier
pip install "py-momo-sdk[all]" # All optional extras
For local development and testing:
pip install -e ".[all,dev]"
Quickstart
Check installed version and provision sandbox credentials
import py_momo_sdk
from py_momo_sdk import PyMomoSDK, PyMomoSDKConfig
print(py_momo_sdk.__version__)
config = PyMomoSDKConfig(environment="sandbox")
with PyMomoSDK(config) as client:
provisioner = client.create_sandbox_provisioner("your-sandbox-subscription-key")
credentials = provisioner.provision(callback_host="https://example.com")
print(f"API user: {credentials['api_user']}")
print(f"API key: {credentials['api_key']}")
Collection (synchronous example)
Request a payment from a subscriber and wait for settlement:
from py_momo_sdk import (
ProductConfig,
PyMomoSDK,
PyMomoSDKConfig,
wait_for_settlement,
)
config = PyMomoSDKConfig(
environment="sandbox",
collection=ProductConfig(
subscription_key="your-collection-subscription-key",
api_user="550e8400-e29b-41d4-a716-446655440000",
api_key="your-api-key",
callback_url="https://example.com/webhook",
),
)
with PyMomoSDK(config) as client:
balance = client.collection.get_balance()
print(f"Available balance: {balance.available_balance} {balance.currency}")
reference_id = client.collection.request_to_pay(
amount="1000",
currency="UGX",
payer_msisdn="256771234567",
external_id="ext-tx-12345",
payer_message="Payment for invoice 123",
payee_note="Thank you for shopping with us",
)
tx = wait_for_settlement(
lambda: client.collection.get_payment_status(reference_id),
timeout=60.0,
interval=2.0,
)
print(f"Transaction status: {tx.status}")
Disbursement (asynchronous example)
Send funds using the asynchronous client:
import asyncio
from py_momo_sdk import AsyncPyMomoSDK, ProductConfig, PyMomoSDKConfig
config = PyMomoSDKConfig(
environment="sandbox",
disbursement=ProductConfig(
subscription_key="your-disbursement-subscription-key",
api_user="550e8400-e29b-41d4-a716-446655440000",
api_key="your-api-key",
),
)
async def main() -> None:
async with AsyncPyMomoSDK(config) as client:
is_active = await client.disbursement.is_account_holder_active("256771234567")
print(f"Account holder active: {is_active}")
reference_id = await client.disbursement.transfer(
amount="5000",
currency="UGX",
payee_msisdn="256771234567",
external_id="disb-tx-9999",
payer_message="Staff salary payment",
payee_note="Disbursement successful",
)
status = await client.disbursement.get_transfer_status(reference_id)
print(f"Transfer status: {status.status} (ID: {status.financial_transaction_id})")
asyncio.run(main())
CLI usage
Install pip install "py-momo-sdk[cli]" and export credentials via PY_MOMO_SDK_* environment variables or --*-file flags so secrets are never recorded in shell history or process listings:
export PY_MOMO_SDK_ENVIRONMENT="sandbox"
export PY_MOMO_SDK_COLLECTION_SUBSCRIPTION_KEY="your-key"
export PY_MOMO_SDK_COLLECTION_API_USER="550e8400-e29b-41d4-a716-446655440000"
export PY_MOMO_SDK_COLLECTION_API_KEY="your-api-key"
py-momo-sdk --version
py-momo-sdk sandbox provision --callback-host "example.com" --output-file ./creds.json
py-momo-sdk collection balance
py-momo-sdk collection status "550e8400-e29b-41d4-a716-446655440000"
Use py-momo-sdk --help to list all available commands and options.
Testing
Run style checks, type checking, security analysis, and coverage reports:
ruff check .
black --check .
isort --check-only .
mypy py_momo_sdk/ tests/
bandit -r py_momo_sdk/ -ll
pytest --cov=py_momo_sdk --cov-report=term-missing
License
MIT License. Copyright (c) 2026 Wesley Kambale. See LICENSE for more details.
Metadata
Release files for py-momo-sdk 1.3.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| py_momo_sdk-1.3.3.tar.gz | 236.0 kB | With provenance | Details for py_momo_sdk-1.3.3.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| py_momo_sdk-1.3.3-py3-none-any.whl | Python 3 | none | any | Details for py_momo_sdk-1.3.3-py3-none-any.whl |
Total release size: 388.1 kB
Release files / py_momo_sdk-1.3.3.tar.gz
| Download URL | py_momo_sdk-1.3.3.tar.gz |
|---|---|
| Size | 236.0 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
a02ff6eb474474fc2faa7f28f788b46a92900c7b9e287eb52d20c54cfc342a0e
|
|
BLAKE2b-256 checksum How to use checksums |
d78516684570f4b2691963b4a5883c9caa1963762de1747d7e12ea2fbbe564fe
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logRelease files / py_momo_sdk-1.3.3-py3-none-any.whl
| Download URL | py_momo_sdk-1.3.3-py3-none-any.whl |
|---|---|
| Size | 152.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
d63cf929b1913ead20079d283436527dcbfe08fb0c3c5058f14b89f154a588e1
|
|
BLAKE2b-256 checksum How to use checksums |
55f8577e7ae9bdb7802c4e0cfba9c21d96cc78ced3c4a8b1c4557f55a9c62c2f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.16
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logSecurity for py-momo-sdk 1.3.3
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
Full provenance
Both files in this release have been uploaded with provenance metadata.
Attestation for py_momo_sdk-1.3.3.tar.gz
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Nov 28, 2026.
Transparency logA note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.