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
Built Distribution
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | b6e269c46ab9ed11df4c98d36bf379b37e72ceac432ce8e6df23bd5d5411d4c7 |
|
MD5 | 8181c388b3c91ed00f78ea0c730d9cc5 |
|
BLAKE2b-256 | b1dea09a3a11491b4d1b0e8027633e9f7078745504f534045e2d9b57733f06ed |
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
Algorithm | Hash digest | |
---|---|---|
SHA256 | d48551e7a69841a7ea0084a7912845ff6f0458a18ca33d787f62d8679dfc8eac |
|
MD5 | 55c12c7f256cf38bfc209714404f8a08 |
|
BLAKE2b-256 | 2f2e467069326baefe977a3b0a8c1bdbad1c67e18090913eca912d19661532fb |