Skip to main content

Online payment gateways wrapper library.

Project description

Online payment gateways wrapper library. 💳

Supported Gateways


  • AsanPardakht
  • IranKish
  • Mellat
  • Zarinpal
  • Parsian (PECCO)
  • Bahamta


pip install payit


from payit import (

# 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)

# Make Transaction:
my_database = {}
selected_gateway = 'zarinpal1'
    transaction = Transaction(amount=1500, order_id=11002)
    transaction = manager.request(selected_gateway, transaction)
    # Store `` on your database
    my_database['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')

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

    # Check `` exist on your database
    if 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')

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

# Payment succeed! 🎉

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for payit, version 0.8.3
Filename, size File type Python version Upload date Hashes
Filename, size payit-0.8.3-py3-none-any.whl (31.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size payit-0.8.3.tar.gz (17.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page