A package to manage mobile payments using the MTN MoMo and Orange Money APIs
Project description
ZIGNPAY
[![build-status-image]][build-status] [![coverage-status-image]][codecov] [![pypi-version]][pypi]
Make mobile payment easy
Overview
A package to manage mobile payments using the MTN MoMo and Orange Money APIs
Some reasons you might want to use REST framework:
- Add a payment method to your website or application
- Create a mobile payment app
- Customization and extensibility
- Support for multiple operators
Steps summary
- Sign up for an account
- Get a product subscription key
- Installation
- Create an API user and API key
- Initialize the collection class
- Make a payment request
Getting Started
Sign up for an account
Head over to https://momodeveloper.mtn.com/ and create your account. Once created, verify your account and sign in to the developer dashboard.
Get a product subscription key
The momo developer API is segmented into different products. Like; Collections, Remittances, Disbursement, and a collections widget. Find and Subscribe to the product that your application will be using. For the case of this tutorial, we shall subscribe to the collections product. It enables us to make a remote collection of fees and bills. Once subscribed, you shall be able to get a primary subscription key and a secondary subscription key in your developer dashboard.
Installation
Requirements
- Python 3.10+
pip install zignpay
Create an API user
import os
from zignpay.momo import MomoApiProvisioning, MomoCollection
"""
Here we will subscribe to the product collection.
"""
subscription_key = os.environ('subscription_key') # Put the subscription key that you copied
"""
Keep in mind that your subscription key in development is different in production,
To go into production you must click on Go Live in your Dashboard
"""
The MOMO API relies heavily on unique identifying identifiers called UUIDs. Each API user you create will have a unique UUID, zignpay will generate this automatically for you.
...
momo = MomoApiProvisioning({
"subscription_key" : subscription_key,
"environment" : "DEV" # Define DEV if you are in development and PROD if you are in production
})
api_user = momo.create_api_user() # This returns the unique reference (UUID) of the created API user
if api_user: #Check if the query returns an object
api_key = momo.create_api_key() # Then generate the API key
"""
You can save these two values in a secure database, they will be necessary later.
"""
Initialize the collection class
...
collection = MomoCollection({
"api_user_id" : api_user, # The user reference created above
"api_key" : api_key, # The api key created above
"subscription_key" : subscription_key, # The subscription key for the collection product
"environment" : "DEV",
"country_code" : "CM", # our Country Codes Alpha-2
})
You will find your Country codes here.
Make a payment request
...
requestToPay = collection.request_to_pay({
"amount": 15, # Payment request amount
"from": "2376xxxxxxxx", # Example of Cameroonian number
"reference_id": "123456789",
"description": "Requested to pay" # Put your own description
})
Example query result
{
'financialTransactionId': '490639485',
'externalId': '123456789',
'amount': '15',
'currency': 'EUR',
'payer': {
'partyIdType': 'MSISDN',
'partyId': '2376xxxxxxxx'
},
'payerMessage': 'Requested to pay',
'payeeNote': 'Thank you for your payment',
'status': 'SUCCESSFUL'
}
We are currently working on improving this documentation
Project details
Release history Release notifications | RSS feed
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 zignpay-0.2.1.tar.gz.
File metadata
- Download URL: zignpay-0.2.1.tar.gz
- Upload date:
- Size: 5.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eecc020e44f736390cb9c329ba1d943408d9530392639cc33b923f5eac144ab7
|
|
| MD5 |
1a5306910fe57015bbd6d67de2c580c8
|
|
| BLAKE2b-256 |
993d26b2c5df1e517dfef7774eb34200556a07b65ac5c76716568f97c867f926
|
File details
Details for the file zignpay-0.2.1-py3-none-any.whl.
File metadata
- Download URL: zignpay-0.2.1-py3-none-any.whl
- Upload date:
- Size: 5.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0fa411adf7ea53f59c53dc21d7457d897e78534f5678054bc3d2f94f1a506e66
|
|
| MD5 |
1ce9c60cf4006aec0f1b55dfcaafcc2e
|
|
| BLAKE2b-256 |
e80eea99b44e4c4e02d95118d51d0805b26640f0579aac7771f4974668fd0822
|