djangopayplus
pypi i djangopayplus

djangopayplus

A sample project that exists for PyPUG's "Tutorial on Packaging and Distributing Projects"

by pypa

1.2.5 (see all)
pypi i djangopayplus
Readme

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

  1. Run pip install djangopayplus to install package.

  2. Add 'payplus' to settings.py at INSTALLED_APPS section like this:

    INSTALLED_APPS = [
        ...
    
        'payplus',
    ]
    
  3. Also include the below at the bottom of settings.py like 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
    
    
  4. Run python manage.py migrate to create the associated models.

  5. Start the server and verify all is runing well

Sending payment request

Prerequiste mostly your validated data should have the below parameters:

ParameterDescriptionFormat
order_idThe unique identification for the payment order. This is also generated at the client side and will be returned in the charging response.STRING
customerNameThe name of the payment authorizer or the buyer. Eg. Jane DoeSTRING
amountThis is the invoice amount stated in units of Ghanaian cedis. Note: the amount should be used without the currency. Eg. 2.00DECIMAL
item_descThe description of the purchased item or service. Eg. bulksmsSTRING
  1. 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()
  1. 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

GitHub Stars

4.3K

LAST COMMIT

5mos ago

MAINTAINERS

1

CONTRIBUTORS

52

OPEN ISSUES

8

OPEN PRs

4
VersionTagPublished
1.2.5
3mos ago
1.2.4
1yr ago
1.2.3
1yr ago
1.2.2
2yrs ago
No alternatives found
No tutorials found
Add a tutorial