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. At least 1, up to 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.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 pybkash 0.4.1
File Size Uploaded
pybkash-0.4.1.tar.gz 9.4 kB Details

Built distribution (wheel)

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

Total release size: 21.0 kB

Release files / pybkash-0.4.1.tar.gz

Download URL pybkash-0.4.1.tar.gz
Size 9.4 kB
Tags Source
SHA-256 checksum
How to use checksums
5834f2b09cd14ec2250f21bbafcf0d8312a234d456f784685bcb187ebea285e8
BLAKE2b-256 checksum
How to use checksums
3f7bc28121aa361ca1a74c1bbfb71e1f7417478197e33711885f51ff202b6f8b
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.1-py3-none-any.whl

Download URL pybkash-0.4.1-py3-none-any.whl
Size 11.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a946c75d530b3c98b2363a78f03e6ff81fabc1a16fa2f0da06b0073bacb25a22
BLAKE2b-256 checksum
How to use checksums
3fb1ee992696ca8dd607e217692c9b1f6af1c9246ee2a20ad7e6a817ce2b5c1a
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

0.4.2

2 release files

This release

0.4.1 This release

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