Skip to main content

⚡ ClusterPay Python SDK

Official Python library for ClusterPay — the open-source, non-custodial cryptocurrency checkout and merchant settlement engine.

PyPI version Python 3.8+ License: MIT


📦 Installation

pip install clusterpay

🚀 Quick Start

1. Initialize Client

from clusterpay import ClusterPay

client = ClusterPay(
    api_key="CS_key_live_9f8a2b3c4d5e6f7a8b9c0d1e2f3a4b5c",
    base_url="https://pay.yourstore.com"  # Or your self-hosted instance
)

2. Create a Checkout Invoice (Async / FastAPI / aiogram)

import asyncio
from clusterpay import ClusterPay

async def main():
    client = ClusterPay(api_key="CS_key_live_...", base_url="https://pay.yourstore.com")
    
    invoice = await client.create_checkout_async(
        amount=25.00,
        currency="USD",
        callback_url="https://yourstore.com/api/webhooks/clusterpay",
        custom_id="ORDER-98214",
        description="1 Year Pro Subscription",
        redirect_url="https://yourstore.com/orders/success",
        wallets={
            "bep20": "0x71C8418013511110293C7C432929424838192834",
            "trc20": "TYDzsYUE2989Xwz4T2L7e2V9J38hXj4kLm8921",
            "poly":  "0x892a764f3e91b2c45d8f99a012e8749bc38e9124"
        }
    )
    
    print("Payment URL:", invoice["payment_url"])
    print("Exact Amount (USDT):", invoice["amount"])  # e.g. 25.004829
    print("Session ID:", invoice["session_id"])

asyncio.run(main())

3. Verify Incoming Webhook Signatures (FastAPI)

from fastapi import FastAPI, Request, Header, HTTPException
from clusterpay import verify_webhook_signature

app = FastAPI()
CLUSTERPAY_API_KEY = "CS_key_live_..."

@app.post("/api/webhooks/clusterpay")
async def handle_clusterpay_webhook(
    request: Request,
    x_clusterpay_signature: str = Header(...),
    x_clusterpay_timestamp: str = Header(""),
    x_clusterpay_nonce: str = Header("")
):
    raw_body = await request.body()
    
    # Timing-safe HMAC-SHA256 verification with 5-minute replay defense
    is_valid = verify_webhook_signature(
        raw_payload=raw_body,
        signature=x_clusterpay_signature,
        timestamp=x_clusterpay_timestamp,
        nonce=x_clusterpay_nonce,
        api_key=CLUSTERPAY_API_KEY
    )
    
    if not is_valid:
        raise HTTPException(status_code=403, detail="Invalid cryptographic webhook signature")
    
    data = await request.json()
    if data.get("event") == "payment.settled":
        order_id = data.get("custom_id")
        amount = data.get("amount")
        txid = data.get("tx_hash")
        print(f"✅ Order {order_id} paid with {amount} on-chain! TxID: {txid}")
        # Fulfill order / deliver product
    
    return {"status": "ok"}

4. Query Settlement Status

status = client.get_status("cpay_982f1b63e91a4b82")
print("Status:", status["status"])       # 'paid', 'pending', or 'expired'
print("TxID:", status.get("tx_hash"))

🛡️ Supported Networks & Chains

  • USDT: BNB Smart Chain (BEP-20), TRON (TRC-20), Polygon PoS, Arbitrum One, TON
  • Native: Bitcoin (BTC SegWit), Litecoin (LTC), TON, Polygon (POL), BNB

📜 License

MIT License. Copyright (c) 2026 ClusterPay Technologies.

Metadata

Release files for clusterpay 2.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for clusterpay 2.1.0
File Size Uploaded
clusterpay-2.1.0.tar.gz 6.7 kB Details

Built distribution (wheel)

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

Total release size: 13.9 kB

Release files / clusterpay-2.1.0.tar.gz

Download URL clusterpay-2.1.0.tar.gz
Size 6.7 kB
Tags Source
SHA-256 checksum
How to use checksums
cb60b2e42bbd2834fd41469d9eac98aa5ebe905e3acb1f83dd10f13e4da3a817
BLAKE2b-256 checksum
How to use checksums
d5574110137720e068edef81f3cd234b872219a7af970fb63e5da32e1fba12f8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release files / clusterpay-2.1.0-py3-none-any.whl

Download URL clusterpay-2.1.0-py3-none-any.whl
Size 7.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8e6a8e8afe68fe773e6d91750f1245b3dfa7d7732b3556e4b07c9010fcff87e6
BLAKE2b-256 checksum
How to use checksums
de4de9b6ca0f9af77fea23860f5279d038531c6e7277f41ee29ff43cbbacb965
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.15

Release history Release notifications | RSS feed

This release

2.1.0 This release

2 release files

1.0.1

2 release files

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