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://momodeveloper.mtn.com/

Make sure:

  • Your callback URL is set in the MTN portal
  • Your user is created and provisioned
  • The subscription key is the primary or secondary key for collections product subscribed on the portal
  • 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.6.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.6-py3-none-any.whl (4.3 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: mtn_momo_sdk-0.1.6.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.6.tar.gz
Algorithm Hash digest
SHA256 a779153430eee49519da9fba1b0c562493bd13906d3be17676f93f588860755a
MD5 7898e1a5361358c12679d117f5045f0f
BLAKE2b-256 7f6a8e3988af3adb1eaaf08e713ed63ef677a2018848712e494d0f8ea588d026

See more details on using hashes here.

File details

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

File metadata

  • Download URL: mtn_momo_sdk-0.1.6-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.6-py3-none-any.whl
Algorithm Hash digest
SHA256 4977c6c9fee3bb7f7045771166f31ac7333db9b1780fcc8104b5739516c9f147
MD5 836a98600a5b95a682b8550d4f1e4d4a
BLAKE2b-256 b176afb33c6361eb64930026fc44d44851ac13551d2883f3dfd1a53734bf585f

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