Python SDK for PayGate x402 payment flows
Project description
deltablab-paygate
Python SDK for PayGate Cloud management, Gateway Facade request orchestration, and x402-compatible payment retries.
Install
Paid client:
pip install "deltablab-paygate[client]"
Cloud management / webhook helpers:
pip install "deltablab-paygate[cloud]"
Publisher integrations:
pip install "deltablab-paygate[publisher]"
Gateway publisher
Current public publisher path is the Cloud Gateway Facade. Use the gateway helpers for protected merchant routes.
import os
import uvicorn
from fastapi import FastAPI
from paygate.publisher import create_fastapi_gateway
app = FastAPI()
paygate = create_fastapi_gateway(
api_key=os.environ["PAYGATE_API_KEY"],
publisher_id=os.environ["PAYGATE_PUBLISHER_ID"],
env="dev",
)
@app.get("/v1/weather")
@paygate.protect(endpoint_id=os.environ["PAYGATE_WEATHER_ENDPOINT_ID"])
async def weather():
return {"city": "Shanghai", "temp": 22}
if __name__ == "__main__":
uvicorn.run(app, host="127.0.0.1", port=8000)
For dynamic prepaid-balance flows, use create_fastapi_metered(...) and return
{"quantity": "...", "body": ...} from the protected handler.
Gateway client
Current public client path is the gateway-aware paid client. It handles:
401 payer_auth_required402 payment_requiredpayer_sessionpersistence202 settlingpolling
import json
import os
from eth_account import Account
from paygate.client import create_gateway_client
from paygate.cloud import paygate_chain_id_for_environment
env = os.getenv("PAYGATE_ENV", "dev")
client = create_gateway_client(
account=Account.from_key(os.environ["CLIENT_WALLET_PRIVATE_KEY"]),
base_url="http://127.0.0.1:8000",
payer_auth_chain_id=paygate_chain_id_for_environment(env),
)
response = client.get(
"/v1/weather",
)
print(response.status_code)
print(json.dumps(response.json(), indent=2))
Cloud management helpers
paygate.cloud.PublisherCloudClient and AsyncPublisherCloudClient now cover:
GET /supportedPOST /verifyPOST /settle/v1/gateway/*/v1/access-grants*/v1/usage-events- publishers/endpoints/webhooks/transactions/metrics
Compatibility surfaces
Legacy helpers remain available for compatibility and migration:
- publisher compat:
from paygate.publisher.compat import create_fastapi_paygate, create_starlette_paygate - client compat:
from paygate.client.compat import create_relay_client, create_async_relay_client - client compat:
from paygate.client.compat import create_eip3009_client, create_async_eip3009_client
PayGate Cloud URLs and chain IDs are built into the SDK. Examples typically use env="dev" for Base Sepolia development and env="prod" for Base mainnet production.
Examples
Runnable examples live in examples/README.md:
examples/publisher/register.pyexamples/publisher/fastapi_app.pyexamples/publisher/starlette_app.pyexamples/client/weather.pyexamples/client/llm_chat.pyexamples/client/company_search.pyexamples/client/premium_feed.pyexamples/cloud_ops/endpoints.pyexamples/cloud_ops/transactions.pyexamples/cloud_ops/metrics.pyexamples/cloud_ops/settlement_events.pyexamples/cloud_ops/webhook_register.pyexamples/cloud_ops/webhook_receiver.py
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file deltablab_paygate-0.1.1.tar.gz.
File metadata
- Download URL: deltablab_paygate-0.1.1.tar.gz
- Upload date:
- Size: 34.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5e16d14fd54b24a086ec5b140f70b2d7cc73e1293cba8991071227f9958e3cdb
|
|
| MD5 |
983c74ee68197176ffe9c04f7e2a32d5
|
|
| BLAKE2b-256 |
8ca5e0ef762119cea2901a54dfc04454876e7979566a7f973dfb17230e14475a
|
File details
Details for the file deltablab_paygate-0.1.1-py3-none-any.whl.
File metadata
- Download URL: deltablab_paygate-0.1.1-py3-none-any.whl
- Upload date:
- Size: 45.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.14.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8826cc54aa4da9259512d795c01f586f0ae44adc143b2cac53ef743947878ce
|
|
| MD5 |
ed030bfe817ec67335101603590e5ffc
|
|
| BLAKE2b-256 |
69689bbe04bc8e02a6e4a8ba43a3b7fa7978ec5f667834c57e44811421d4d684
|