Skip to main content

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 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 Async
    Compatible with asynchronous code, including FastAPI 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)

  • Zibal
  • More gateways will be added soon...

Installation

pip install -U payman[zibal]

Quick Start: Async Zibal Integration (Create, Redirect, Verify)

import asyncio

from payman import Payman

gateway = Payman("zibal", merchant_id="abc")

async def main():
    payment_request = await gateway.initiate_payment(
        amount=10_000,
        callback_url="https://your-site.com/callback",
        description="Test payment"
    )

    if not payment_request.success:
        print(f"Payment creation failed: {payment_request.message}")
        return

    print("Redirect user to:", gateway.get_payment_redirect_url(payment_request.track_id))

    payment_verification = await gateway.verify_payment(track_id=payment_request.track_id)

    if payment_verification.success:
        print("Payment successful. Ref ID:", payment_verification.ref_id)
    elif payment_verification.already_verified:
        print("Payment already verified.")
    else:
        print("Payment verification failed.")

asyncio.run(main())

Full Documentation

For detailed instructions on using Zibal 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

payman-3.0.1.tar.gz (21.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

payman-3.0.1-py3-none-any.whl (22.8 kB view details)

Uploaded Python 3

File details

Details for the file payman-3.0.1.tar.gz.

File metadata

  • Download URL: payman-3.0.1.tar.gz
  • Upload date:
  • Size: 21.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for payman-3.0.1.tar.gz
Algorithm Hash digest
SHA256 76c3771376194d55cc4a02631a880eca9719ae0412e6af4f8d1833689384933e
MD5 4b8efccc0df46c5bffa0333e2485b2c2
BLAKE2b-256 6776189ad728023b826e45708d95f35e0bf01dfb18f67c0d9446f0b9c2243015

See more details on using hashes here.

File details

Details for the file payman-3.0.1-py3-none-any.whl.

File metadata

  • Download URL: payman-3.0.1-py3-none-any.whl
  • Upload date:
  • Size: 22.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for payman-3.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 5ff07dc86188511f972c8e6eebd3c8ea1ffb746d27665027742c3e75361b3dc8
MD5 1a0caab8768a131b1cd8b72c82757939
BLAKE2b-256 17c19f37a10a33cb68e8cbcb04a5f57f6316218a699d25b6d10f35e5bd22721c

See more details on using hashes here.

Supported by

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