Skip to main content

UG MOBILE MONEY

UG Mobile Money is a python library for making mobile money transactions in Uganda. It currently supports MTN MOMO and Yo Payments

UG Mobile Money provides a simple interface for making mobile money transactions in a way that is similar to what the official MTN Mobile Money API provides but in a more pythonic and simple way. This makes it easy for beginners to get started and also for experienced developers who have been using the official API shift.

The library also handles other underlying functions like encryption, Authorization and regenerating access tokens. This makes it easy for developers to focus on the business logic of their applications and not worry about the underlying details.

The library utitlizes the Official MTN Mobile Money API. The API is documented here.

Installation

Use the package manager pip to install UG Mobile Money.

pip install ugmobilemoney

After installing it you can now import the package in your project.

from mobile_money.momo import Collection, Disbursment

Usage

This library is currently in development and only supports MTN MOMO. It supports the following operations:

  • Collection
    • Request to pay
  • Disbursment
    • Transfer

Note: You need to have an account with MTN MOMO and have your API user ID and API key. You can get these from the MTN MOMO Developer Portal. If your in sandbox environment, we provide utils for creation of API user ID and API key.

Collection

The UG Mobile Money library provides a Collection class that can be used to carry out operations or call the MOMO APIs provided under the collection Products.

You access it from the mobile_money.momo module.

from mobile_money.momo import Collection


collection = Collection(
    subscription_key=SUBSCRIPTION_KEY,
    api_user=API_USER,
    api_key=API_KEY,
    callback_url="http://mydomain.com/webhooks/mtn/",
    production=False,
)

Request to Pay

Request to pay is a service that allows a merchant to receive payments on from a customer. This is typically used when a customer is paying for goods or services. The collect() method is used to initiate a request to pay transaction.

from mobile_money.momo import Collection
from mobile_money import generate_uuid

collection = Collection(
    subscription_key=SUBSCRIPTION_KEY,
    api_user=API_USER,
    api_key=API_KEY,
    callback_url="http://mydomain.com/webhooks/mtn/",
    production=False,
)

transaction_reference = generate_uuid()
# Request to pay
response = COLLECTION.collect(
    amount="100",
    phone_number="256772123456",
    currency="UGX",
    external_id="external id",
    reference_id=transaction_reference,
    payee_note="test",
    payer_message="test",
)

print(response)

# >>> <Response [202 Accepted]>

Disbursment

The UG Mobile Money library provides a Disbursment class that can be used to carry out operations or call the MOMO APIs provided under the Disbursment Products.

You access it from the mobile_money.momo module.

from mobile_money.momo import Disbursment

DISBURSEMENT = Disbursment(
    subscription_key=SUBSCRIPTION_KEY,
    api_user=API_USER,
    api_key=API_KEY,
    callback_url="http://mydomain.com/webhooks/mtn/",
    production=False,
)

Transfer

Transfer is a service that allows a merchant to transfer money from their account to a customer's account. This is typically used when a customer is receiving money for goods or services. The transfer() method is used to initiate a transfer transaction.

from mobile_money.momo import Disbursment
from mobile_money import generate_uuid

DISBURSEMENT = Disbursment(
    subscription_key=SUBSCRIPTION_KEY,
    api_user=API_USER,
    api_key=API_KEY,
    callback_url="http://mydomain.com/webhooks/mtn/",
    production=False,
)

transaction_reference = generate_uuid()

# Transfer
response = DISBURSEMENT.transfer(
    amount="100",
    phone_number="256772123456",
    currency="UGX",
    external_id="external id",
    reference_id=transaction_reference,
    payee_note="test",
    payer_message="test",
)

print(response)

# >>> <Response [202 Accepted]>

Contributing

Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

License

MIT License (MIT). Please see License File for more information.

Metadata

Release files for ugmobilemoney 0.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 ugmobilemoney 0.1.0
File Size Uploaded Provenance Actions
ugmobilemoney-0.1.0.tar.gz 11.3 kB Without provenance Details for ugmobilemoney-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for ugmobilemoney 0.1.0
File Interpreter ABI Platform Actions
ugmobilemoney-0.1.0-py3-none-any.whl Python 3 none any Details for ugmobilemoney-0.1.0-py3-none-any.whl

Total release size: 26.5 kB

Release files / ugmobilemoney-0.1.0.tar.gz

Download URL ugmobilemoney-0.1.0.tar.gz
Size 11.3 kB
Tags Source
SHA-256 checksum
How to use checksums
1754fe25b1bcecbfc1bc45b4c59d547bace2912ca609443efe957d3899e5b4f0
BLAKE2b-256 checksum
How to use checksums
701e07df1941283425828fcb371fd5a6282dae244b1b72b35a5f9018e950a8c3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Release files / ugmobilemoney-0.1.0-py3-none-any.whl

Download URL ugmobilemoney-0.1.0-py3-none-any.whl
Size 15.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a8a648eca3ae7dca2de7f855a28b2081318515418963b668f62625606d8c15e
BLAKE2b-256 checksum
How to use checksums
22f3ecade1bbeb0a61a81dfefff85a8aadb4edec3b9159b3040a87a788852119
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.9.18

Security for ugmobilemoney 0.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.

No provenance found

None of the files in this release were uploaded with provenance metadata.

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