Skip to main content

Py MoMo SDK (py-momo-sdk)

PyPI version Build status License

Py MoMo SDK (py-momo-sdk 1.0.6) 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.

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, and Airtel Money APIs.
  • Robust security: Strict HTTPS and input validation, constant-time webhook HMAC and source IP verification, and secret-redacting exceptions and representations.
  • 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.0.6) 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.0.6

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.0.6
File Size Uploaded Provenance Actions
py_momo_sdk-1.0.6.tar.gz 52.5 kB With provenance Details for py_momo_sdk-1.0.6.tar.gz

Built distribution (wheel)

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

Total release size: 101.2 kB

Release files / py_momo_sdk-1.0.6.tar.gz

Download URL py_momo_sdk-1.0.6.tar.gz
Size 52.5 kB
Tags Source
SHA-256 checksum
How to use checksums
aeec3faf695bb8fcf9673c8d39ea9b3a163cbc1aa60d8384c805fa9442286f59
BLAKE2b-256 checksum
How to use checksums
e39b741d481dca40f4d0ae6ecb0e36dc305a2093e5a0303790fde4d9e54815af
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 20, 2026.

Transparency log

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

Download URL py_momo_sdk-1.0.6-py3-none-any.whl
Size 48.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58022b2ca257f6c661a762038e6795453783c0098cdfafeeed07cf4f273b3291
BLAKE2b-256 checksum
How to use checksums
ef6de00b4ce579d012fec44d6a423d33ef8eb0bdf67985842b601d824c5ec93a
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 20, 2026.

Transparency log

Security for py-momo-sdk 1.0.6

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.0.6.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 20, 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