bpay
Unified Python SDK for Bangladeshi payment gateways.
bpay provides a clean, typed, async-first developer experience for integrating Bangladeshi payment providers like bKash, Nagad, and SSLCommerz.
Features
- Async-first architecture
- Typed request & response models
- Sandbox & production environment support
- Hosted checkout workflows
- Agreement/tokenized checkout support
- Payment callback parsing
- Payment verification support
- Provider abstraction layer
- Modern Python packaging with
uv
Supported Providers
| Provider | Status |
|---|---|
| bKash | In Progress |
| Nagad | Planned |
| SSLCommerz | Planned |
Installation
pip install bpay
Quick Start
Create a One-Time Payment
import asyncio
from bpay import BPay
from bpay.config.environments import (
Environment,
)
from bpay.schemas.payment import (
CreatePaymentRequest,
)
async def main() -> None:
client = BPay(
provider="bkash",
environment=Environment.SANDBOX,
username="YOUR_USERNAME",
password="YOUR_PASSWORD",
app_key="YOUR_APP_KEY",
app_secret="YOUR_APP_SECRET",
)
payment = await client.create_payment(
CreatePaymentRequest(
amount=100,
merchant_invoice_number="INV-1001",
callback_url=(
"https://yourdomain.com/callback"
),
)
)
print(payment.checkout_url)
if __name__ == "__main__":
asyncio.run(main())
Agreement / Tokenized Checkout
Agreements allow merchants to create reusable customer payment authorizations for recurring or saved payments.
Create Agreement
import asyncio
from bpay import BPay
from bpay.config.environments import (
Environment,
)
from bpay.schemas.agreement import (
CreateAgreementRequest,
)
async def main() -> None:
client = BPay(
provider="bkash",
environment=Environment.SANDBOX,
username="YOUR_USERNAME",
password="YOUR_PASSWORD",
app_key="YOUR_APP_KEY",
app_secret="YOUR_APP_SECRET",
)
agreement = await (
client.create_agreement(
CreateAgreementRequest(
customer_phone="017XXXXXXXX",
callback_url=(
"https://yourdomain.com/callback"
),
)
)
)
print(agreement.checkout_url)
if __name__ == "__main__":
asyncio.run(main())
Callback Parsing
Payment Callback
from bpay import BPay
client = BPay(...)
callback = client.parse_payment_callback(
{
"paymentID": "PAY123",
"status": "success",
"signature": "abc123",
}
)
print(callback.status)
Agreement Callback
from bpay import BPay
client = BPay(...)
callback = (
client.parse_agreement_callback(
{
"paymentID": "PAY123",
"agreementID": "AGR123",
"status": "success",
"signature": "abc123",
}
)
)
print(callback.status)
Payment Verification
verification = await client.verify_payment(
payment_id="PAY123"
)
print(verification.status)
Environments
bpay supports both sandbox and production environments.
Sandbox
from bpay.config.environments import (
Environment,
)
Environment.SANDBOX
Production
from bpay.config.environments import (
Environment,
)
Environment.PRODUCTION
Development
Setup
uv sync
Run Checks
make check
Run Tests
uv run pytest
Project Structure
src/bpay/
├── client.py
├── exceptions.py
├── config/
├── providers/
├── schemas/
├── transports/
└── types.py
Roadmap
- Full bKash recurring payment workflow
- Nagad integration
- SSLCommerz integration
- Refund support
- Webhook signature verification
- Automatic retry handling
- Sync client support
- Logging middleware
License
MIT License
Metadata
Release files for bpay 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| bpay-0.1.0.tar.gz | 54.1 kB | Without provenance | Details for bpay-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| bpay-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for bpay-0.1.0-py3-none-any.whl |
Total release size: 69.5 kB
Release files / bpay-0.1.0.tar.gz
| Download URL | bpay-0.1.0.tar.gz |
|---|---|
| Size | 54.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
66e01e52b9fe35b1afb97657deaa299bb34f337add65e55ed6de236b4b83c935
|
|
BLAKE2b-256 checksum How to use checksums |
8feefb8d3812481466dc6c84030b8b8c8a387d837c3511919e754fea59a573c3
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Release files / bpay-0.1.0-py3-none-any.whl
| Download URL | bpay-0.1.0-py3-none-any.whl |
|---|---|
| Size | 15.4 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
9994dd3e9fca802faf351d9549c94381ec479467ed8ca5ca6a8218e3153a4998
|
|
BLAKE2b-256 checksum How to use checksums |
42c0af7e7e3b9a45c262ef211556cd4993ed4276aed7e71808121e6c80819d6e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.13
|
Security for bpay 0.1.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.