Skip to main content

A Django app for server side payment verification of Khalti Payment Gateway.

Project description

django-khalti is a Django app based on djangorestframework to conduct server based payment verification of khalti payment gateway. For each payment,it can verify and return status of payment through transaction token and paid amount.

Detailed documentation is in the “docs” directory.

Quick start

  1. Intall the django-khalti and django rest framework like this:

    pip install djangorestframework
    pip install django-khalti
  2. Add “django-khalti” and “djangorestframework “to your INSTALLED_APPS setting like this:

  3. Include the django-khalti URLconf in your project like this:

    path('khalti/', include('khalti.urls')),
  4. Add Khalti Merchant API key and Verify URL in your

    KHALTI_SECRET_KEY = "<your api key>"

5.Test your endpoints like this:

POST: /khalti/verifypayment/
    'token':<transaction token>,
    'amount':<transaction amount>

6.You will get responses like this:

On Success:
                      "idx": "8xmeJnNXfoVjCvGcZiiGe7",
                      "type": {
                        "idx": "e476BL6jt9kgagEmsakyTL",
                        "name": "Wallet payment"
                      "state": {
                        "idx": "DhvMj9hdRufLqkP8ZY4d8g",
                        "name": "Completed",
                        "template": "is complete"
                      "amount": 1000,
                      "fee_amount": 30,
                      "refunded": false,
                      "created_on": "2018-06-20T14:48:08.867125+05:45",
                      "ebanker": null,
                      "user": {
                        "idx": "cCaPkRPQGn5D8StkiqqMJg",
                        "name": "Test User",
                        "mobile": "98XXXXXXX9"
                      "merchant": {
                        "idx": "UM75Gm2gWmZvA4TPwkwZye",
                        "name": "Test Merchant",
                        "mobile": ""

On Error:
        'details':{'token': ['Invalid token.']}

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for django-khalti, version 1.0
Filename, size File type Python version Upload date Hashes
Filename, size django-khalti-1.0.tar.gz (3.9 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page