django-dpo


Namedjango-dpo JSON
Version 0.0.2 PyPI version JSON
download
home_pageNone
SummaryDjango DPO Gateway Integration
upload_time2024-05-08 06:26:12
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseNone
keywords django dpo django payment dpo payment payment gateway
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            
# Django DPO Gateway

Django DPO Gateway is a Django app for integrating DPO payment gateway.
Detailed documentation is in the "docs" directory.

## Quick start

1. Add `django_dpo` to your INSTALLED_APPS setting like this::

```python 

    INSTALLED_APPS = [
        ...,
        "django_dpo",
    ]

```

2. Include DPO Settings in your project `settings.py` like this::

```python
	
	DPO_END_POINT = "https://secure.3gdirectpay.com/API/v6/"
	DPO_PAYMENT_URL = "https://secure.3gdirectpay.com/payv2.php"
	DPO_COMPANY_TOKEN = "<your-company-token-from-dpo>"
	DPO_PAYMENT_CURRENCY = "<preferred currency>"
	DPO_PAYMENT_TIME_LIMIT = 5
	DPO_SERVICE_TYPE = 5525 

```


## DPO Gateway Usage


### Create Token

```python

from django.shortcuts import resolve_url
from django_dpo import DPOGateway


def create_token(request):

    invoice_number = request.POST.get('invoice_number')
    amount = request.POST.get('amount')
    description = request.POST.get('description')

    redirect_url= request.build_absolute_uri(resolve_url('payment_url'))
    back_url = request.build_absolute_uri(resolve_url('back_url'))

    gateway = DPOGateway()

    gateway.set_redirect_url(redirect_url)
    gateway.set_back_url(back_url)

    response = gateway.create_token(
        company_ref=invoice_number,
        amount=float(amount),
        description=description
    )
    transaction_token = response.TransToken

    return gateway.make_payment(transaction_token)

```


### Verify Token

```python

from django.http import HttpResponseBadRequest
from django.contrib import messages
from django.shortcuts import redirect,reverse
from django_dpo import DPOGateway

def verify_payment(request):

    if not request.GET.get('TransID') and not request.GET.get('companyRef'):
        return HttpResponseBadRequest()
        
    transaction_token = request.GET.get('TransID')
    invoice_number = request.GET.get('PnrID')

    gateway = DPOGateway()

    response = gateway.verify_payment(transaction_token)

    amount = response.TransactionAmount
    currency = response.TransactionCurrency
    
    message = f"The payment of {currency} {amount} was successful"

    messages.success(request, message) 

    return redirect(reverse("index"))

```


### Cancel Token

```python

from django.http import HttpResponseBadRequest
from django.contrib import messages
from django.shortcuts import redirect, reverse
from django_dpo import DPOGateway

def cancel_token(request):

    if not request.GET.get('TransID') and not request.GET.get('companyRef'):
        return HttpResponseBadRequest()

    transaction_token = request.GET.get('TransID')
    gateway = DPOGateway()
    gateway.cancel_token(transaction_token)
    messages.success(request, "Transaction cancelled") 
    return redirect(reverse("index"))

```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "django-dpo",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "django dpo, django payment, dpo, payment, payment gateway",
    "author": null,
    "author_email": "Brian Simpokolwe <briansimpokolwe@gmail.com>",
    "download_url": "https://files.pythonhosted.org/packages/8b/31/960fd0728dc8dbd2261e21b5412ba0ed5fbcc51ee52d5c53c6d0e6e809db/django_dpo-0.0.2.tar.gz",
    "platform": null,
    "description": "\n# Django DPO Gateway\n\nDjango DPO Gateway is a Django app for integrating DPO payment gateway.\nDetailed documentation is in the \"docs\" directory.\n\n## Quick start\n\n1. Add `django_dpo` to your INSTALLED_APPS setting like this::\n\n```python \n\n    INSTALLED_APPS = [\n        ...,\n        \"django_dpo\",\n    ]\n\n```\n\n2. Include DPO Settings in your project `settings.py` like this::\n\n```python\n\t\n\tDPO_END_POINT = \"https://secure.3gdirectpay.com/API/v6/\"\n\tDPO_PAYMENT_URL = \"https://secure.3gdirectpay.com/payv2.php\"\n\tDPO_COMPANY_TOKEN = \"<your-company-token-from-dpo>\"\n\tDPO_PAYMENT_CURRENCY = \"<preferred currency>\"\n\tDPO_PAYMENT_TIME_LIMIT = 5\n\tDPO_SERVICE_TYPE = 5525 \n\n```\n\n\n## DPO Gateway Usage\n\n\n### Create Token\n\n```python\n\nfrom django.shortcuts import resolve_url\nfrom django_dpo import DPOGateway\n\n\ndef create_token(request):\n\n    invoice_number = request.POST.get('invoice_number')\n    amount = request.POST.get('amount')\n    description = request.POST.get('description')\n\n    redirect_url= request.build_absolute_uri(resolve_url('payment_url'))\n    back_url = request.build_absolute_uri(resolve_url('back_url'))\n\n    gateway = DPOGateway()\n\n    gateway.set_redirect_url(redirect_url)\n    gateway.set_back_url(back_url)\n\n    response = gateway.create_token(\n        company_ref=invoice_number,\n        amount=float(amount),\n        description=description\n    )\n    transaction_token = response.TransToken\n\n    return gateway.make_payment(transaction_token)\n\n```\n\n\n### Verify Token\n\n```python\n\nfrom django.http import HttpResponseBadRequest\nfrom django.contrib import messages\nfrom django.shortcuts import redirect,reverse\nfrom django_dpo import DPOGateway\n\ndef verify_payment(request):\n\n    if not request.GET.get('TransID') and not request.GET.get('companyRef'):\n        return HttpResponseBadRequest()\n        \n    transaction_token = request.GET.get('TransID')\n    invoice_number = request.GET.get('PnrID')\n\n    gateway = DPOGateway()\n\n    response = gateway.verify_payment(transaction_token)\n\n    amount = response.TransactionAmount\n    currency = response.TransactionCurrency\n    \n    message = f\"The payment of {currency} {amount} was successful\"\n\n    messages.success(request, message) \n\n    return redirect(reverse(\"index\"))\n\n```\n\n\n### Cancel Token\n\n```python\n\nfrom django.http import HttpResponseBadRequest\nfrom django.contrib import messages\nfrom django.shortcuts import redirect, reverse\nfrom django_dpo import DPOGateway\n\ndef cancel_token(request):\n\n    if not request.GET.get('TransID') and not request.GET.get('companyRef'):\n        return HttpResponseBadRequest()\n\n    transaction_token = request.GET.get('TransID')\n    gateway = DPOGateway()\n    gateway.cancel_token(transaction_token)\n    messages.success(request, \"Transaction cancelled\") \n    return redirect(reverse(\"index\"))\n\n```\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Django DPO Gateway Integration",
    "version": "0.0.2",
    "project_urls": {
        "Homepage": "https://github.com/briansimpo/django-dpo",
        "Issues": "https://github.com/briansimpo/django-dpo/issues"
    },
    "split_keywords": [
        "django dpo",
        " django payment",
        " dpo",
        " payment",
        " payment gateway"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "02fb5deba0791436d9174348cdc58a2b24557aed1de248e6d8a42dfdd2385eeb",
                "md5": "6d539e8663a2484ab17995809f156cba",
                "sha256": "a941f0ebc9409dddd19e58228f52e97333a818ebb93990a03b001dfd08cda338"
            },
            "downloads": -1,
            "filename": "django_dpo-0.0.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "6d539e8663a2484ab17995809f156cba",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 5339,
            "upload_time": "2024-05-08T06:26:10",
            "upload_time_iso_8601": "2024-05-08T06:26:10.661302Z",
            "url": "https://files.pythonhosted.org/packages/02/fb/5deba0791436d9174348cdc58a2b24557aed1de248e6d8a42dfdd2385eeb/django_dpo-0.0.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "8b31960fd0728dc8dbd2261e21b5412ba0ed5fbcc51ee52d5c53c6d0e6e809db",
                "md5": "a1f53aa69481037832a6d31cf1584792",
                "sha256": "180b1b6769bcc89af4f13324cddd8e4e66b947d1209192d3ad2698d5f36499eb"
            },
            "downloads": -1,
            "filename": "django_dpo-0.0.2.tar.gz",
            "has_sig": false,
            "md5_digest": "a1f53aa69481037832a6d31cf1584792",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 4084,
            "upload_time": "2024-05-08T06:26:12",
            "upload_time_iso_8601": "2024-05-08T06:26:12.653318Z",
            "url": "https://files.pythonhosted.org/packages/8b/31/960fd0728dc8dbd2261e21b5412ba0ed5fbcc51ee52d5c53c6d0e6e809db/django_dpo-0.0.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-08 06:26:12",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "briansimpo",
    "github_project": "django-dpo",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": false,
    "lcname": "django-dpo"
}
        
Elapsed time: 2.65542s