Skip to main content
https://travis-ci.org/meyt/payit.svg?branch=master https://coveralls.io/repos/github/meyt/payit/badge.svg?branch=master https://img.shields.io/pypi/pyversions/payit.svg

Online payment gateways wrapper library. 💳

Supported Gateways

(Iran)

  • Aqayepardakht

  • AsanPardakht

  • Bahamta

  • IranKish

  • Mellat

  • Parsian (PECCO)

  • Pay.ir

  • Zarinpal

Install

pip install payit

Usage

from payit import (
    GatewayManager,
    gateways,
    Transaction,
    TransactionAlreadyPaidError
)

# Configure:
config = {
    'mellat': {
        'terminal_id': '1234',
        'username': 'demo',
        'password': 'demo',
        'callback_url': 'http://localhost/callback/mellat'
    },
    'zarinpal1': {
        'merchant': '534534534532225234234',
        'description': '',
        'callback_url': 'http://localhost/callback/zarinpal1'
    },
    'zarinpal2': {
        'merchant': '33333333532225234234',
        'description': '',
        'callback_url': 'http://localhost/callback/zarinpal2'
    }
}
manager = GatewayManager()
manager.register('mellat', gateways.MellatGateway)
manager.register('zarinpal1', gateways.ZarinpalGateway)
manager.register('zarinpal2', gateways.ZarinpalGateway)
manager.configure(config)


# Make Transaction:
my_database = {}
selected_gateway = 'zarinpal1'
try:
    transaction = Transaction(amount=1500, order_id=11002)
    transaction = manager.request(selected_gateway, transaction)
    # Store `transaction.id` on your database
    my_database['transaction_id'] = transaction.id

    # Get redirection details
    redirection = manager.get_redirection(selected_gateway, transaction)

    # Now redirect your client to gateway by redirection details

except PayitException:
    print('Something wrong on payment')
    raise


# Callback
# Now user backs from gateway to complete payment procedure
selected_gateway = 'zarinpal1'
try:
    callback_data = {
        'Authority': 101
    }
    transaction = manager.validate(selected_gateway, callback_data)
    if not transaction.validate_status:
        raise RuntimeError('Transaction is not valid')

    # Check `transaction.id` exist on your database
    if transaction.id not in my_database:
        raise RuntimeError('Transaction is not exists')

    # Now verify transaction
    manager.verify(selected_gateway, callback_data)

except TransactionAlreadyPaidError:
    print('Transaction Already Paid')
    raise

except PayitException:
    print('Something wrong on payment')
    raise

# Payment succeed! 🎉

Metadata

Release files for payit 1.2.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for payit 1.2.0
File Size Uploaded
payit-1.2.0.tar.gz 18.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for payit 1.2.0
File Interpreter ABI Platform
payit-1.2.0-py3-none-any.whl Python 3 none any Details

Total release size: 51.7 kB

Release files / payit-1.2.0.tar.gz

Download URL payit-1.2.0.tar.gz
Size 18.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bd0c20c0a48a0fcaef22d38ca4e68395f176596620524deac3d730ef7023cf6e
BLAKE2b-256 checksum
How to use checksums
6f75d3b332e24da8f6dcfb3c117a12d26fc443aa6f45367a20eb69232a63aba7
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release files / payit-1.2.0-py3-none-any.whl

Download URL payit-1.2.0-py3-none-any.whl
Size 33.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
212385637e45c3aae6b0320a8ef6d81d334d7e523913405db59ba416bd0bcc86
BLAKE2b-256 checksum
How to use checksums
ff16b60c68a7527603be608f0933de72f24a6bf1338a68bb19a755902891d852
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.4.2 requests/2.22.0 setuptools/45.2.0 requests-toolbelt/0.8.0 tqdm/4.30.0 CPython/3.8.10

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 release files

1.1.1

2 release files

1.1.0

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.8.3

2 release files

0.8.1

1 release file

0.7.0

1 release file

0.6.1

1 release file

0.6.0

1 release file

0.5.5

1 release file

0.5.4

1 release file

0.5.3

1 release file

0.5.1

1 release file

0.5.0

1 release file

0.4.0

1 release file

0.3.11

1 release file

0.3.9

1 release file

0.3.8

1 release file

0.3.0

1 release file

0.2.4

1 release file

0.2.3

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page