Skip to main content

Python package for Webpay gateway API

Installation

Install from PyPI:

pip install webpay-bahamta

For async support:

pip install webpay-bahamta[async]

Usage

Simple example:

from webpay import WebpayAPI

API_KEY = "webpay:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"
webpay = WebpayAPI(API_KEY)

# Make a payment
payment_url = webpay.payment(
    reference='payment#1',
    amount_irr=100000,
    callback_url='https://example.com',
    payer_mobile='+989111111111',  # Optional
    trusted_pan=None  # Optional
)

# Verify payment
try:
    payment_data = webpay.verify(
        reference='payment#1',
        amount_irr=100000
    )
    if payment_data.get("status") == "paid":
        print("Payment confirmed")
    else:
        print("Payment not confirmed")
except Exception as exc:
    if exc.error_key == 'NOT_CONFIRMED':
        print("Payment not confirmed")
    else:
        raise exc

Async example:

import asyncio
from webpay import AsyncWebpayAPI

API_KEY = "webpay:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx:zzzzzzzz-zzzz-zzzz-zzzz-zzzzzzzzzzzz"
webpay = AsyncWebpayAPI(API_KEY)


async def main():
    # Make a payment
    payment_url = await webpay.payment(
        reference='payment#1',
        amount_irr=100000,
        callback_url='https://example.com',
        payer_mobile='+989111111111',  # Optional
        trusted_pan=None  # Optional
    )

    # Verify payment
    try:
        payment_data = await webpay.verify(
            reference='payment#1',
            amount_irr=100000
        )
        if payment_data.get("status") == "paid":
            print("Payment confirmed")
        else:
            print("Payment not confirmed")
    except Exception as exc:
        if exc.error_key == 'NOT_CONFIRMED':
            print("Payment not confirmed")
        else:
            raise exc

loop = asyncio.get_event_loop()
loop.run_until_complete(main())

payment_url will be like:

https://webpay.bahamta.com/api/…

payment_data will be like:

{
    "state": "paid",
    "total": 1000000,
    "wage": 5000,
    "gateway": "sep",
    "terminal": "11223344",
    "pay_ref": "GmshtyjwKSu5lKOLquYrzO9BqjUMb/TPUK0qak/iVs",
    "pay_trace": "935041",
    "pay_pan": "123456******1234",
    "pay_cid": "77CB1B455FB5F60415A7A02E4502134CFD72DBF6D1EC8FA2B48467DFB124AA75A",
    "pay_time": "2019-11-12T16:39:57.686436+03:30"
}

API Documentation

https://webpay.bahamta.com/doc/api

Metadata

Release files for webpay-bahamta 0.1.1

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

Source distribution (sdist)

Source distribution for webpay-bahamta 0.1.1
File Size Uploaded
webpay-bahamta-0.1.1.tar.gz 4.4 kB Details

Release files / webpay-bahamta-0.1.1.tar.gz

Download URL webpay-bahamta-0.1.1.tar.gz
Size 4.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8e1d7d63e38d4bf957d82aeb9cc9bd7221c8e2d7210f9164f094b9b11eb3ebc2
BLAKE2b-256 checksum
How to use checksums
177f7e5c066c566be7c02f7ed02d7ba295a989384135eb9c802c1318e6c0ffa2
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.2.0 pkginfo/1.6.1 requests/2.24.0 setuptools/50.3.2 requests-toolbelt/0.9.1 tqdm/4.51.0 CPython/3.8.6

Release history Release notifications | RSS feed

This release

0.1.1 This release

1 release file

0.1

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