Skip to main content

pybkash

A Pythonic client for the bKash payment gateway. Supports both synchronous and asynchronous usage and covers the entire API surface.

Features

  1. Normal Payment
  2. Agreement Creation
  3. Agreement Payment
  4. Refund
  5. Search Transaction
  6. Token caching (in-memory or Redis)

Installation

pip install pybkash

Usage

Synchronous Client

from pybkash import Client, Token

# First, initialize the token. This will be passed to the Client.
token = Token(
    username="your_username",
    password="your_password", 
    app_key="your_app_key",
    app_secret="your_app_secret",
    sandbox=True  # Use False for production
)

Then, create a client object by passing the token:

client = Client(token)

You can now use this client to perform various operations.

Step 1: Create Payment

payment = client.create_payment(
    callback_url="https://yoursite.com/callback",
    payer_reference="CUSTOMER001",  # Passing a phone or bKash number pre-populates the wallet number field on the bKash checkout page.
    amount=1000  # Amount in BDT
)

This returns a PaymentCreation object:

  • payment.payment_id is the ID bKash uses to identify individual payments.
  • payment.bkash_url is the payment URL — send the user to this page.

After the user has completed the payment:

Step 2: Execute Payment

execution = client.execute_payment(payment.payment_id)

This returns a PaymentExecution object.

# Verify completion
if execution.is_complete():
    print(f"Payment successful! TrxID: {execution.trx_id}")
else:
    print(f"Payment status: {execution.status}")

Documentation

For detailed synchronous and asynchronous usage information, including return types and attributes, see docs.

Release files for pybkash 0.4.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 pybkash 0.4.0
File Size Uploaded
pybkash-0.4.0.tar.gz 9.3 kB Details

Built distribution (wheel)

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

Total release size: 20.7 kB

Release files / pybkash-0.4.0.tar.gz

Download URL pybkash-0.4.0.tar.gz
Size 9.3 kB
Tags Source
SHA-256 checksum
How to use checksums
e13460c43b564c7b59832ebb01d478889c72b51fa54417692c9a84e40c6eab0b
BLAKE2b-256 checksum
How to use checksums
01c87ae9acd16e0345f799317e7ba1b9acaa1ca1c175d13f26f8d533b133306f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release files / pybkash-0.4.0-py3-none-any.whl

Download URL pybkash-0.4.0-py3-none-any.whl
Size 11.4 kB
Tags Python 3
SHA-256 checksum
How to use checksums
d23812846b066a5b3553ac4d7843e8aba1da2002dbeac6d1e2b61ffd94ca8b4c
BLAKE2b-256 checksum
How to use checksums
77fb867c5bb0e7d10c64b13f42a3490d9f5d8da3681635f186c79f84d268dab4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.14.6

Release history Release notifications | RSS feed

This release

0.4.0 This release

2 release files

0.3.0

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

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