Skip to main content

3

Py MoMo SDK

PyPI version Python versions Build status License

Py MoMo SDK (py-momo-sdk 1.1.0) is a strictly typed, production-grade Python client library for the MTN Mobile Money (MoMo) Open API and Airtel Money API. It provides synchronous and asynchronous clients with matching interfaces, automatic token caching, strict validation, and complete product coverage. Py MoMo SDK (py-momo-sdk 1.1.0) is a strictly typed Python client library for the MTN Mobile Money (MoMo) Open API and Airtel Money API. It provides synchronous and asynchronous clients with matching interfaces, automatic token caching, strict validation, and complete product coverage.

Developed for high reliability and clean developer experience, Py MoMo SDK adheres to the strict security standards of modern payment systems.

Features

  • Sync and async parity: PyMomoSDK and AsyncPyMomoSDK backed by httpx.Client and httpx.AsyncClient with matching interfaces.
  • Pydantic v2 models: Fully typed request and response validation and serialization.
  • Automated token caching: Thread-safe and async-safe in-memory token management with automatic cache invalidation and retry-once logic.
  • Comprehensive API coverage: Full MTN MoMo Collection (including CIBA and OAuth2 token exchange), Disbursement, Remittance, Sandbox, synchronous and asynchronous Airtel Money (AirtelClient and AsyncAirtelClient), Wave, M-Pesa (Daraja), Paystack, Flutterwave, and Orange Money adapters behind PaymentRouter.
  • Resilience and observability: Configurable idempotent retries with Retry-After and jitter, settlement polling helpers, TelemetryHook observability events, MSISDN carrier auto-routing, FastAPI and Django webhook verifiers, and a local py-momo-sdk mock simulator.
  • CLI utility: Ships with the py-momo-sdk Typer-powered CLI to bootstrap sandbox credentials, initiate payments, and query balances or transaction status.

Installation

Install py-momo-sdk (1.1.0) from PyPI using pip:

pip install py-momo-sdk

For development dependencies, install with:

pip install -e ".[dev]"

Quickstart

Sandbox provisioning

Bootstrap a new sandbox API user and API key:

from py_momo_sdk import PyMomoSDK, PyMomoSDKConfig

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 using the synchronous client:

from py_momo_sdk import ProductConfig, PyMomoSDK, PyMomoSDKConfig

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:
    # Query account balance
    balance = client.collection.get_balance()
    print(f"Available balance: {balance.available_balance} {balance.currency}")

    # Initiate a request to pay
    reference_id = client.collection.request_to_pay(
        amount="1000.00",
        currency="UGX",
        payer_msisdn="256771234567",
        external_id="ext-tx-12345",
        payer_message="Payment for invoice 123",
        payee_note="Thank you for shopping with us",
    )
    print(f"Transaction reference: {reference_id}")

    # Check status
    tx = client.collection.get_payment_status(reference_id)
    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:
        # Check active status of a mobile money user
        is_active = await client.disbursement.is_account_holder_active("256771234567")
        print(f"Account holder active: {is_active}")

        # Initiate a transfer
        reference_id = await client.disbursement.transfer(
            amount="5000.00",
            currency="UGX",
            payee_msisdn="256771234567",
            external_id="disb-tx-9999",
            payer_message="Staff salary payment",
            payee_note="Disbursement successful",
        )

        # Query transaction details
        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

Py MoMo SDK bundles the py-momo-sdk CLI tool for sandbox management, balance checks, and payment queries:

# Show installed version
py-momo-sdk --version

# Provision a sandbox environment
py-momo-sdk sandbox provision --subscription-key "your-key"

# Query the collection balance
py-momo-sdk collection balance --subscription-key "your-key" --api-user "550e8400-e29b-41d4-a716-446655440000" --api-key "key"

# Check the status of a request to pay transaction
py-momo-sdk collection status "550e8400-e29b-41d4-a716-446655440000" --subscription-key "your-key" --api-user "550e8400-e29b-41d4-a716-446655440000" --api-key "key"

Use py-momo-sdk --help to list all available commands and flags.

Testing

Run checks, security analysis, and coverage reports:

# Style and format checks
ruff check .
black --check .
isort --check .

# Static type check
mypy py_momo_sdk/

# Security analysis
bandit -r py_momo_sdk/

# Test execution with coverage
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.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for py-momo-sdk 1.1.0
File Size Uploaded Provenance Actions
py_momo_sdk-1.1.0.tar.gz 82.2 kB With provenance Details for py_momo_sdk-1.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for py-momo-sdk 1.1.0
File Interpreter ABI Platform Actions
py_momo_sdk-1.1.0-py3-none-any.whl Python 3 none any Details for py_momo_sdk-1.1.0-py3-none-any.whl

Total release size: 166.4 kB

Release files / py_momo_sdk-1.1.0.tar.gz

Download URL py_momo_sdk-1.1.0.tar.gz
Size 82.2 kB
Tags Source
SHA-256 checksum
How to use checksums
0bec9799fd13fdcac20b60675ac0f85d8e2a3f5e05cdc2ff06dcdee0185fa643
BLAKE2b-256 checksum
How to use checksums
b995234192a154cb6570ba19ee1b53a4a3624ecfdc20c41aee3bd177a2926f37
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 21, 2026.

Transparency log

Release files / py_momo_sdk-1.1.0-py3-none-any.whl

Download URL py_momo_sdk-1.1.0-py3-none-any.whl
Size 84.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
1ffaa1e86a32f9318cbe5c03469b93fe2876ec4b09440b264688fe64dbad2e66
BLAKE2b-256 checksum
How to use checksums
cc032de8a971d64efeb03e2ba25de5a203f450fc9582bd4846d4b2ecf1a6d957
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 21, 2026.

Transparency log

Security for py-momo-sdk 1.1.0

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.

Select from 2 files

Attestation for py_momo_sdk-1.1.0.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 21, 2026.

Transparency log

A 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.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page