Skip to main content

integrate django payments with zarrinpal

Project description

django-zarinpal

Integrate django payments with zarinpal

Features

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

Quickstart

Install django-zarinpal::

pip install django-zarinpal

Add it to your INSTALLED_APPS:

.. code-block:: python

INSTALLED_APPS = (
    ...
    'zarinpal',
    ...
)

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 django_zarinpal.services 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.

Tests

Running tests: ::

python manage.py runtests.py

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 details)

Uploaded Source

Built Distribution

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

Uploaded Python 3

File details

Details for the file django-zarinpal-1.0.1.tar.gz.

File metadata

  • Download URL: django-zarinpal-1.0.1.tar.gz
  • Upload date:
  • Size: 6.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.3 Linux/5.4.0-7629-generic

File hashes

Hashes for django-zarinpal-1.0.1.tar.gz
Algorithm Hash digest
SHA256 b6e269c46ab9ed11df4c98d36bf379b37e72ceac432ce8e6df23bd5d5411d4c7
MD5 8181c388b3c91ed00f78ea0c730d9cc5
BLAKE2b-256 b1dea09a3a11491b4d1b0e8027633e9f7078745504f534045e2d9b57733f06ed

See more details on using hashes here.

File details

Details for the file django_zarinpal-1.0.1-py3-none-any.whl.

File metadata

  • Download URL: django_zarinpal-1.0.1-py3-none-any.whl
  • Upload date:
  • Size: 8.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.0.5 CPython/3.8.3 Linux/5.4.0-7629-generic

File hashes

Hashes for django_zarinpal-1.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d48551e7a69841a7ea0084a7912845ff6f0458a18ca33d787f62d8679dfc8eac
MD5 55c12c7f256cf38bfc209714404f8a08
BLAKE2b-256 2f2e467069326baefe977a3b0a8c1bdbad1c67e18090913eca912d19661532fb

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page