Skip to main content

Python SDK for MTN Uganda MoMo API integration

Project description

momo-sdk

A lightweight Python SDK to interact with the MTN MoMo (Mobile Money) API. Supports sandbox and live environments for mobile money collections.


🔧 Features

  • Get access tokens (sandbox or live)
  • Check account holder status
  • Request mobile money payments
  • Track transaction status

📦 Installation

Install from PyPI:

pip install mtn-momo-sdk

Or install from source:

git clone https://github.com/yourusername/mtn-momo.git
cd mtn-momo
pip install .

🛠️ Setup

To start using the SDK, instantiate the Momo class with your credentials:

from momo_sdk import Momo
import uuid

momo = Momo(
    api_user="your_api_user",
    api_key="your_api_key",
    subscription_key="your_subscription_key",
    mode="development", # or "production"
    callback_url='your_callbackurl' # e.g https://example.com
)

🚀 Usage

✅ 1. Get API Context

print(momo.get_env())         # sandbox or mtnuganda
print(momo.get_url())         # Base API URL
print(momo.get_callback())    # Callback URL

📞 2. Check Account Status

status = momo.get_accountholder("256771234567")
print(status)

💰 3. Request Mobile Money Payment

transaction_id = str(uuid.uuid4())

response = momo.deposit_money(
    msisdn="256771234567",  # Customer MSISDN
    amount="10000",         # Amount in UGX or EUR
    reference=transaction_id
)

print(response)

📦 4. Check Transaction Status

result = momo.get_transaction(transaction_id)
print(result)

📁 Project Structure

momo_sdk/
├── momo.py           # SDK module
├── __init__.py
├── setup.py
├── pyproject.toml
├── README.md
└── LICENSE

🧪 Testing the API

Sandbox credentials are required from:
https://sandbox.momodeveloper.mtn.com/

Make sure:

  • Your callback URL is set in the MTN portal
  • Your user is created and provisioned
  • Subscription key is valid for collection

📫 Contributing

Pull requests are welcome. For major changes, open an issue first to discuss your ideas.


📝 License

This project is licensed under the MIT License. See the LICENSE file for details.


👤 Author

Your Name
GitHub: @brucekyl
Email: bbagarukayo5@gmail.com


🚨 Disclaimer

Use this SDK at your own risk. Ensure you follow MTN MoMo's terms, guidelines, and security protocols before deploying to production.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mtn_momo_sdk-0.1.5.tar.gz (4.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mtn_momo_sdk-0.1.5-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

Details for the file mtn_momo_sdk-0.1.5.tar.gz.

File metadata

  • Download URL: mtn_momo_sdk-0.1.5.tar.gz
  • Upload date:
  • Size: 4.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for mtn_momo_sdk-0.1.5.tar.gz
Algorithm Hash digest
SHA256 b74cfd9c36d3eec17582936a2db3575e9d05401fc8e5cc439a255fce1e69311c
MD5 63b9a25583a2e3feaf7c69fef3f49260
BLAKE2b-256 86b7dccdd6ef1cc68d400863b8bbb0a07b85be1cc0410be709290deb07a5616b

See more details on using hashes here.

File details

Details for the file mtn_momo_sdk-0.1.5-py3-none-any.whl.

File metadata

  • Download URL: mtn_momo_sdk-0.1.5-py3-none-any.whl
  • Upload date:
  • Size: 4.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.10.0

File hashes

Hashes for mtn_momo_sdk-0.1.5-py3-none-any.whl
Algorithm Hash digest
SHA256 7b96ff6d4efa0c21b90472ffcfb8138bba7fd8326269580173f8c03f19e8efd7
MD5 bce5f5ee470de9aa73ff9cb40c4e326f
BLAKE2b-256 852ae7c0a894a031104d9695b2333f165390b2a69fa1d202ca52b22e0a537797

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page