Skip to main content

integrate django payments with zarrinpal

Project description


Integrate django payments with zarinpal


  • sending signal on verifying transaction to let other apps know about it


Install django-zarinpal::

pip install django-zarinpal

Add it to your INSTALLED_APPS:

.. code-block:: python


Add django-zarinpal's URL patterns:

.. code-block:: python

import zarrinpal

urlpatterns = [
    path('zarinpal/', include(zarinpal_urls)),

How to Use

set these variables in your settings file:

ZARINPAL_CALLBACK_URL: bool # the url user redirects to after transaction

ZARINPAL_SIMULATION: bool # is transactions for test?

ZARINPAL_MERCHANT_ID: str # merchant id from zarinpal (you may leave it blank if you set the simulation to True)

you can use function start_transaction with a dictionary containing your transaction data like this:

from django.shortcuts import redirect
from import start_transaction

def start_payment(request):
    result = start_transaction(
            "user": request.user,
            "amount": 10000,
            "description": "transaction description",
            "mobile": "09123456789",
            "email": "string",
    return redirect(result) # result is the url for starting transaction

If you specify a callback_url in transaction data after completing transaction zarinpal will redirect user to the page you specified with two get arguments:

1.order_number: str

2.success: boolean

Custom verification

If you want to handle verifying transaction your self you can define your view and address it in settings with ZARINPAL_VERIFY_TRANSACTION_VIEW. you can use function verify_transaction to verify a transaction.

If you don't specify this view, package will use default view for verifying transactions.


Running tests: ::


Project details

Download files

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

Source Distribution

django-zarinpal-1.0.1.tar.gz (6.6 kB view hashes)

Uploaded source

Built Distribution

django_zarinpal-1.0.1-py3-none-any.whl (8.4 kB view hashes)

Uploaded py3

Supported by

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