Django DPO Gateway Integration
Project description
Django DPO Gateway
Django DPO Gateway is a Django app for integrating DPO payment gateway. Detailed documentation is in the "docs" directory.
Quick start
- Add
django_dpo
to your INSTALLED_APPS setting like this::
INSTALLED_APPS = [
...,
"django_dpo",
]
- Include DPO Settings in your project
settings.py
like this::
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
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
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
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"))
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
django_dpo-0.0.2.tar.gz
(4.1 kB
view details)
Built Distribution
File details
Details for the file django_dpo-0.0.2.tar.gz
.
File metadata
- Download URL: django_dpo-0.0.2.tar.gz
- Upload date:
- Size: 4.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 180b1b6769bcc89af4f13324cddd8e4e66b947d1209192d3ad2698d5f36499eb |
|
MD5 | a1f53aa69481037832a6d31cf1584792 |
|
BLAKE2b-256 | 8b31960fd0728dc8dbd2261e21b5412ba0ed5fbcc51ee52d5c53c6d0e6e809db |
File details
Details for the file django_dpo-0.0.2-py3-none-any.whl
.
File metadata
- Download URL: django_dpo-0.0.2-py3-none-any.whl
- Upload date:
- Size: 5.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/5.0.0 CPython/3.10.12
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a941f0ebc9409dddd19e58228f52e97333a818ebb93990a03b001dfd08cda338 |
|
MD5 | 6d539e8663a2484ab17995809f156cba |
|
BLAKE2b-256 | 02fb5deba0791436d9174348cdc58a2b24557aed1de248e6d8a42dfdd2385eeb |