A Pythonic client for the bKash payment gateway. Supports both synchronous and asynchronous usage and covers the entire API surface.
- Normal Payment
- Agreement Creation
- Agreement Payment
- Refund
- Search Transaction
pip install pybkashfrom 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.
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_idis the ID bKash uses to identify individual payments.payment.bkash_urlis the payment URL — send the user to this page.
After the user has completed the 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}")For detailed synchronous and asynchronous usage information, including return types and attributes, see docs.