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 momo-sdk
Or install from source:
git clone https://github.com/yourusername/momo-sdk.git
cd momo-sdk
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
- 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: @yourusername
Email: your@email.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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mtn_momo_sdk-0.1.1.tar.gz.
File metadata
- Download URL: mtn_momo_sdk-0.1.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e7ffb885af66c2412f9c1cd6d6cb5167c6d5f23a456175d9046670f7e49ad717
|
|
| MD5 |
2c90f5451c0d17acc54dc18f860cc6c2
|
|
| BLAKE2b-256 |
8a10bf5aa53576d88bf0bfd624c234ae27d011c7d8a09d82860856002bbdf92f
|
File details
Details for the file mtn_momo_sdk-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mtn_momo_sdk-0.1.1-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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dce22ff4032603840786108a6563c74b58c0f87b7d4c33be4687cbbe4b3d57fb
|
|
| MD5 |
b4e534d4275aafbfc110bf3f59b8167a
|
|
| BLAKE2b-256 |
22af8ec13af035734a9d64844ee0d5325d218edbb6111cd5cb8bfc24e2f62201
|