Skip to main content

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::
    INSTALLED_APPS = [
        ...,
        "django_dpo",
    ]
  1. 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"))

Metadata

Release files for django-dpo 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-dpo 0.0.2
File Size Uploaded Provenance Actions
django_dpo-0.0.2.tar.gz 4.1 kB Without provenance Details for django_dpo-0.0.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-dpo 0.0.2
File Interpreter ABI Platform Actions
django_dpo-0.0.2-py3-none-any.whl Python 3 none any Details for django_dpo-0.0.2-py3-none-any.whl

Total release size: 9.4 kB

Release files / django_dpo-0.0.2.tar.gz

Download URL django_dpo-0.0.2.tar.gz
Size 4.1 kB
Tags Source
SHA-256 checksum
How to use checksums
180b1b6769bcc89af4f13324cddd8e4e66b947d1209192d3ad2698d5f36499eb
BLAKE2b-256 checksum
How to use checksums
8b31960fd0728dc8dbd2261e21b5412ba0ed5fbcc51ee52d5c53c6d0e6e809db
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Release files / django_dpo-0.0.2-py3-none-any.whl

Download URL django_dpo-0.0.2-py3-none-any.whl
Size 5.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a941f0ebc9409dddd19e58228f52e97333a818ebb93990a03b001dfd08cda338
BLAKE2b-256 checksum
How to use checksums
02fb5deba0791436d9174348cdc58a2b24557aed1de248e6d8a42dfdd2385eeb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/5.0.0 CPython/3.10.12

Security for django-dpo 0.0.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.2 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page