BchainPayBchainPay

Python SDK


title: "Python SDK" description: "Official bchainpay Python SDK — synchronous and async clients, type-hinted end-to-end." section: "SDKs" order: 2 updated: "2026-04-18" sourcePath: "content/docs/sdks/python.mdx"

The bchainpay package ships sync and async clients with full type hints, automatic retries on 429 and 5xx, and a webhook verifier.

Install

pip install bchainpay

Requires Python 3.10+.

Initialize

import os
import bchainpay
 
client = bchainpay.Client(api_key=os.environ["BCHAINPAY_API_KEY"], timeout=10.0)

Create a payment intent

intent = client.payment_intents.create(
    amount_cents=4999,
    currency="USD",
    settlement_currency="USDC",
    network="polygon",
    reference="INV-2026-001",
)
 
print(intent.address)  # 0x9f3a...b41C

Async client

async with bchainpay.AsyncClient(api_key=...) as client:
    intent = await client.payment_intents.create(
        amount_cents=4999, currency="USD",
        settlement_currency="USDC", network="polygon",
    )

Verify a webhook (Flask)

from flask import Flask, request, abort
from bchainpay.webhooks import verify
 
app = Flask(__name__)
 
@app.post("/webhooks")
def webhook():
    if not verify(request.get_data(), request.headers["BchainPay-Signature"],
                  os.environ["BCHAINPAY_WEBHOOK_SECRET"]):
        abort(400)
    # ... handle event
    return "", 200
Last updated Edit on GitHub