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! 🎉

Download files

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

Source Distribution

payit-1.2.0.tar.gz (18.7 kB view details)

Uploaded Source

Built Distribution

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

payit-1.2.0-py3-none-any.whl (33.0 kB view details)

Uploaded Python 3

File details

Details for the file payit-1.2.0.tar.gz.

File metadata

  • Download URL: payit-1.2.0.tar.gz
  • Upload date:
  • Size: 18.7 kB
  • Tags: Source
  • Uploaded using 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

File hashes

Hashes for payit-1.2.0.tar.gz
Algorithm Hash digest
SHA256 bd0c20c0a48a0fcaef22d38ca4e68395f176596620524deac3d730ef7023cf6e
MD5 49db27fe05e3c36423ec4e0e9d87f03d
BLAKE2b-256 6f75d3b332e24da8f6dcfb3c117a12d26fc443aa6f45367a20eb69232a63aba7

See more details on using hashes here.

File details

Details for the file payit-1.2.0-py3-none-any.whl.

File metadata

  • Download URL: payit-1.2.0-py3-none-any.whl
  • Upload date:
  • Size: 33.0 kB
  • Tags: Python 3
  • Uploaded using 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

File hashes

Hashes for payit-1.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 212385637e45c3aae6b0320a8ef6d81d334d7e523913405db59ba416bd0bcc86
MD5 0ba43aa012dcd5b8c8128d9459a31b1a
BLAKE2b-256 ff16b60c68a7527603be608f0933de72f24a6bf1338a68bb19a755902891d852

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

1.2.0 This release

2 files

1.1.1

2 files

1.1.0

2 files

1.0.1

2 files

1.0.0

2 files

0.8.3

2 files

0.8.1

1 file

0.7.0

1 file

0.6.1

1 file

0.6.0

1 file

0.5.5

1 file

0.5.4

1 file

0.5.3

1 file

0.5.1

1 file

0.5.0

1 file

0.4.0

1 file

0.3.11

1 file

0.3.9

1 file

0.3.8

1 file

0.3.0

1 file

0.2.4

1 file

0.2.3

1 file

Supported by

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