Zarinpal Python SDK Documentation
Introduction
The Zarinpal Python SDK provides an easy and flexible way to interact with Zarinpal’s payment gateway APIs. With features like payment initiation, transaction management, refunds, and reversals, it helps streamline integration with Zarinpal’s platform in both live and sandbox environments.
Installation
Requirements:
- Python >= 3.12
Install:
From PyPI:
pip install zarinpal-py-sdk
From TestPyPI (for testing purposes):
pip install -i https://test.pypi.org/simple/ zarinpal-py-sdk
Features:
-
Manage Payments:
Easily initiate and verify payments using secure APIs.
Example:
payment = zarinpal.payment_gateway.create({ "amount": 10000, "description": "Order #1234", "callback_url": "https://example.com/callback", })
-
Transaction Management:
Fetch transaction details with filters, limits, and pagination using GraphQL.
Example:
transactions = zarinpal.transactions.list({ "terminal_id": "YourTerminalID", "filter": "PAID", "limit": 10, "offset": 0, })
-
Refunds & Reversals:
Easily process refunds or reverse a transaction with a single API call.
Example - Refund:
refund = zarinpal.refunds.create({ "session_id": "Session1234", "amount": 5000, "description": "Refund for Order #1234", "reason": "CUSTOMER_REQUEST", }) Example - Reversal: response = zarinpal.reversals.reverse({ "authority": "AUTHORITY_CODE", })
-
Sandbox Support:
Easily switch between sandbox and live environments for development and production.
How to Use:
- Initialize SDK:
from zarinpal import ZarinPal
from tools.Config import Config
config = Config(
access_token="YourAccessToken",
merchant_id="YourMerchantId"
sandbox=True, # Use sandbox environment
)
zarinpal = ZarinPal(config)
Full Example: Fetching Transactions
from zarinpal import ZarinPal
from tools.Config import Config
def get_transactions():
try:
config = Config(
access_token="YourAccessToken",
)
zarinpal = ZarinPal(config)
transactions = zarinpal.transactions.list({
"terminal_id": "YourTerminalID",
"filter": "PAID",
"limit": 10,
"offset": 0,
})
print("Transactions List:", transactions)
except Exception as e:
print("Error fetching transactions:", e)
if __name__ == "__main__":
get_transactions()
Contribute:
Contributions are welcome! Fork the repository, make your changes, and submit a pull request.
GitHub Repository: Zarinpal Python SDK
By simplifying integration, this SDK ensures smooth payment workflows, enabling developers to focus on building excellent user experiences.
Metadata
Release files for remino-zarinpal-py-sdk 1.0.3
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| remino_zarinpal_py_sdk-1.0.3.tar.gz | 10.9 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| remino_zarinpal_py_sdk-1.0.3-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 23.8 kB
Release files / remino_zarinpal_py_sdk-1.0.3.tar.gz
| Download URL | remino_zarinpal_py_sdk-1.0.3.tar.gz |
|---|---|
| Size | 10.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
c108db437da922ec43d7c526c7fa3aed29a4558f7289be9d7f98ba635e997acb
|
|
BLAKE2b-256 checksum How to use checksums |
26bbbd4c35daffd4c463fd745f89cb2843bbb9c78c6c6cd9cd586027fe91d863
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|
Release files / remino_zarinpal_py_sdk-1.0.3-py3-none-any.whl
| Download URL | remino_zarinpal_py_sdk-1.0.3-py3-none-any.whl |
|---|---|
| Size | 12.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
a09d1deffa68f8fcc0396f1c6cd189c8a82e9536030caab54a532bc5075432cb
|
|
BLAKE2b-256 checksum How to use checksums |
ec8dc3be26367dc95bb6e5e8f0cde0681da057142c7955fdc117ee52c8488557
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.1.0 CPython/3.13.3
|