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. Must be greater than or equal to 1 with at most 2 decimal places.
)

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.2

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.2
File Size Uploaded
pybkash-0.4.2.tar.gz 9.4 kB Details

Built distribution (wheel)

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

Total release size: 21.0 kB

Release files / pybkash-0.4.2.tar.gz

Download URL pybkash-0.4.2.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
8d8b0fb80047b1437fc821460a6ec098370867254c9046586d9f128bd41422ad
BLAKE2b-256 checksum
How to use checksums
bc55858a4a73dd71e6ce11ae0c442efeba26be52fecc5ad1b22ef6a6763d609a
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.2-py3-none-any.whl

Download URL pybkash-0.4.2-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6d5cda285544d174cd475b2eac669f0d59fa91c2320b15bd78557c69c8be9668
BLAKE2b-256 checksum
How to use checksums
0970e6dba74d1b5e51d92d4c402210dbe92c3bea03f7a5efa42dc58f26e6ba1d
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.2 This release

2 release files

0.4.1

2 release files

0.4.0

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