A unified payment gateway SDK for Iranian gateways.
Project description
Payman — Unified Payment Gateway Integration for Python
Payman is a Python package for integrating with Iranian payment gateways like Zarinpal and Zibal. It provides a clean and flexible interface for handling payments in both sync and async Python applications.
Key Features
-
Simple and consistent API
You can focus on your business logic — HTTP calls, serialization, and gateway-specific details are handled internally. -
Supports both sync and async
Compatible with synchronous and asynchronous code, including FastAPI, Flask, scripts, and background tasks. -
Pydantic models for inputs and outputs
Type-safe, auto-validating models make integration predictable and IDE-friendly. -
Modular and extensible design
Each gateway integration is separated. You can include only what you need or extend the package with your own gateway. -
Unified error handling
Common exception classes are used across gateways, with optional gateway-specific errors when needed. -
Suitable for real projects
Designed to be usable in real applications, from small services to larger deployments.
Supported Payment Gateways (Currently)
Installation
pip install -U payman
Quick Start: Async Zibal Integration (Create, Redirect, Verify)
import asyncio
from payman import Payman
pay = Payman("zibal", merchant_id="...")
async def main():
create = await pay.payment(
amount=10_000,
callback_url="https://your-site.com/callback",
description="Test"
)
if not create.success:
print(f"Create failed: {create.message}")
return
print("Redirect to:", pay.get_payment_redirect_url(create.track_id))
verify = await pay.verify(track_id=create.track_id)
if verify.success:
print("Paid:", verify.ref_id)
elif verify.already_verified:
print("Already verified.")
else:
print("Verify failed.")
asyncio.run(main())
Sync Zibal Integration (Create, Redirect, Verify)
from payman import Payman
pay = Payman("zibal", merchant_id="...")
create = pay.payment(
amount=10_000,
callback_url="https://your-site.com/callback",
description="Test"
)
if not create.success:
print(f"Create failed: {create.message}")
exit(1)
print("Redirect to:", pay.get_payment_redirect_url(create.track_id))
verify = pay.verify(track_id=create.track_id)
if verify.success:
print("Paid:", verify.ref_id)
elif verify.already_verified:
print("Already verified.")
else:
print("Verify failed.")
Full Documentation
For detailed instructions on using ZarinPal and other gateways with Payman, including all parameters, response codes, and integration tips, please refer to the complete guide:
License
Licensed under the GNU General Public License v3.0 (GPL-3.0). See the LICENSE file for details.
Contributing
Contributions to Payman are welcome and highly appreciated. If you wish to contribute, please follow these guidelines:
- Fork the repository and create a new branch for your feature or bugfix.
- Ensure your code adheres to the project's coding standards and passes all tests.
- Write clear, concise commit messages and provide documentation for new features.
- Submit a pull request with a detailed description of your changes for review.
By contributing, you agree that your work will be licensed under the project's license.
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file payman-2.0.0.tar.gz.
File metadata
- Download URL: payman-2.0.0.tar.gz
- Upload date:
- Size: 37.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6f79b83d509b17424d6dbc93f535bd46eff31b0090a5b9fb670c3fd0ebe24a4e
|
|
| MD5 |
58919a5ce8f66df681ec13091463b469
|
|
| BLAKE2b-256 |
c6b431d1ad4f50221772e9bac9753f42e20e7e18ae68e5e4fbde84bfc079c99d
|
File details
Details for the file payman-2.0.0-py3-none-any.whl.
File metadata
- Download URL: payman-2.0.0-py3-none-any.whl
- Upload date:
- Size: 53.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
801282ba9a7e09f445eeeb898ae87956965dc264571728d56462abfb32566a60
|
|
| MD5 |
762c4a9ffd9c381cf1e5f3e1bed837cf
|
|
| BLAKE2b-256 |
a8768a9e4943a8db16a4fbfa55e905c35f286472d0524aa2dd286109811bc976
|