A momo payment package
Project description
Django Payplus
Django app for Nalo Solutions Limited mobile money payment platform integration.
Requirements
- python 3.5+
- django 2.2+
- requests 2.24+
Please use python virtual environment for project isolation
Installation
-
Run
pip install djangopayplusto install package. -
Add
'payplus'tosettings.pyat INSTALLED_APPS section like this:INSTALLED_APPS = [ ... 'payplus', ]
-
Also include the below at the bottom of
settings.pylike this:... # complusory Payment Settings PAYMENT_CALLBACK = /url/to/callback/ PAYMENT_GATEWAY = /url/to/gateway/ # optional payment settings PAYMENT_MERCHANT = NSP_XXXXXX PAYMENT_PASSWORD = password PAYMENT_USERNAME = username -
Run
python manage.py migrateto create the associated models. -
Start the server and verify all is runing well
Sending payment request
Prerequiste mostly your validated data should have the below parameters:
| Parameter | Description | Format |
|---|---|---|
| order_id | The unique identification for the payment order. This is also generated at the client side and will be returned in the charging response. | STRING |
| customerName | The name of the payment authorizer or the buyer. Eg. Jane Doe | STRING |
| amount | This is the invoice amount stated in units of Ghanaian cedis. Note: the amount should be used without the currency. Eg. 2.00 | DECIMAL |
| item_desc | The description of the purchased item or service. Eg. bulksms | STRING |
- Sending payment with optional settings
from payplus.momopay import MomoPayProcessor
from django.views import View
class MomoPaymentView(View):
def post(self, request, *args, **kwargs):
...
response = MomoPayProcessor(data=validated_data).pay()
- Sending payment without optional settings
from payplus.momopay import MomoPayProcessor
from django.views import View
class MomoPaymentView(View):
def post(self, request, *args, **kwargs):
...
response = MomoPayProcessor(
data=validated_data,
merchant=merchant{
"id": "your-merchant-id",
"username": "merchant-username",
"password": "merchant-password",
}
).pay()
Request response
When you initiate the momo payment call, a sample requset response below is received.
On Success
{
status: True,
message: Passed
}
On Failure
{
status: False,
message: reason of failure
}
Receiving callback
from payplus.momopay import MomoPayProcessor
from django.views import View
import json
class MomoPaymentCallbackView(View):
def post(self, request, *args, **kwargs):
post_data = json.loads(request.body)
...
response = MomoPayProcessor(callback=validated_data).onCallback()
Callback response
When you initiate the momo payment call, a sample callback response below is received.
On Success
{
"status": True,
"transactionID": 22,
"amount": 1.00
}
On Failure
{
"status": False,
"message": reason of failure
}
Upgrade
pip install djangopayplus --upgrade
Need help, have any questions, suggestions?
Submit an issue/PR or email us at noc@nalosolutions.com
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 djangopayplus-1.2.5.tar.gz.
File metadata
- Download URL: djangopayplus-1.2.5.tar.gz
- Upload date:
- Size: 7.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
71d7cc2a992944103a0a2ad7b6cf30ba620585fc0ac8d88aed54a0b45965730f
|
|
| MD5 |
a7e3debc27890079046f0a1ed399e576
|
|
| BLAKE2b-256 |
40a561ee6529142afd97a6954af99f79c31bef00ab34ecd1026e81827d52cf37
|
File details
Details for the file djangopayplus-1.2.5-py3-none-any.whl.
File metadata
- Download URL: djangopayplus-1.2.5-py3-none-any.whl
- Upload date:
- Size: 9.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.0 CPython/3.9.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e8691c7de175a68f706936c7689d8c918a9fcef9cbc5b67a8a52ce905a9a7f88
|
|
| MD5 |
b953df639034e51702f9ae9f8eb8c1f4
|
|
| BLAKE2b-256 |
2456357a242166a25143a605957a175e8da6d25ea3388d48cfe40b16de59323b
|