USDPAY Python SDK
Official Python SDK for USDPAY.
Accept USDT directly to your wallet. USDPAY verifies the payment on-chain and notifies your application automatically with signed webhooks.
Requirements
- Python 3.10 or newer
- A USDPAY store secret key for authenticated methods
- A server-side application; never expose the secret key in browser or mobile code
Installation
pip install usdpay
Quick Start
import os
from usdpay import UsdpayClient
client = UsdpayClient(
secret_key=os.environ["USDPAY_SECRET"]
)
result = client.create_invoice(
{
"amount": "49.00",
"orderId": "ORDER-1042",
"network": "TRC20",
"callbackUrl": "https://merchant.example/usdpay/webhook",
"returnUrl": "https://merchant.example/orders/1042",
},
idempotency_key="ORDER-1042-create",
)
print(result["invoice"]["checkoutUrl"])
Create an Invoice
create_invoice() sends POST /api/invoices. JSON field names match the REST API exactly.
result = client.create_invoice(
{
"amount": "49.00",
"orderId": "ORDER-1042",
"network": "TRC20",
"expiresInMinutes": 30,
"callbackUrl": "https://merchant.example/usdpay/webhook",
"returnUrl": "https://merchant.example/orders/1042",
},
idempotency_key="ORDER-1042-create",
)
Omit network to let the customer choose an enabled network in the hosted checkout.
Get an Invoice
result = client.get_invoice("inv_7Fq2xK9")
print(result["invoice"]["status"])
The production API exposes this status endpoint to anyone who has the unguessable invoice ID. The SDK therefore does not send your Bearer key with get_invoice().
List Invoices
result = client.list_invoices()
for invoice in result["invoices"]:
print(invoice["id"], invoice["status"])
list_invoices() is authenticated and returns invoices for the store selected by the secret key. The current API does not define filtering or pagination parameters, so the SDK does not invent any.
Fiat Order Amounts
Keep monetary values as decimal strings. USDPAY performs the currency conversion; the SDK does not use floating-point math or calculate FX rates.
result = client.create_invoice(
{
"amount": "49.00",
"currency": "EUR",
"orderId": "ORDER-1042",
"callbackUrl": "https://merchant.example/usdpay/webhook",
},
idempotency_key="ORDER-1042-create",
)
Idempotency
Pass one stable idempotency_key for a logical create operation. If a timeout, 429, or retryable 5xx occurs, retry with the same key. Do not generate a new key for each attempt.
USDPAY accepts 1–160 letters, digits, dots, underscores, colons, or hyphens. The SDK validates the key but does not automatically retry requests.
Verify Webhooks
Verify the signature against the exact raw request body before parsing JSON.
import os
from usdpay import verify_webhook_signature
raw_body = request_body_bytes
signature = request_headers.get("X-USDPAY-Signature", "")
if not verify_webhook_signature(
raw_body,
signature,
os.environ["USDPAY_WEBHOOK_SECRET"],
):
# Return HTTP 401.
...
The signature format is sha256=<hex HMAC-SHA256>. Store X-USDPAY-Idempotency-Key under a unique database constraint before fulfilling an order, and acknowledge an already processed delivery with a 2xx response.
Error Handling
from usdpay import UsdpayApiError
try:
client.create_invoice(
{"amount": "49.00", "orderId": "ORDER-1042"},
idempotency_key="ORDER-1042-create",
)
except UsdpayApiError as exc:
print(exc.status)
print(exc.code)
print(exc.retry_after)
print(exc.request_id)
UsdpayApiError covers HTTP failures, timeouts, network failures, and malformed JSON. Its public attributes are:
status: HTTP status, or0when no HTTP response was receivedcode: stable API or SDK error codedetails: redacted response object when availableretry_after: parsedRetry-Afterseconds or HTTP-daterequest_id: response request identifier for support
Security
- Keep
USDPAY_SECRETand the webhook signing secret on your server. - The default transport accepts HTTPS only and uses Python's verified system trust store with hostname verification.
- Requests have finite connect and response timeouts; configure them with
connect_timeoutandtimeout. - The client does not follow redirects or make network calls when imported.
- Secrets are not included in
repr(client), public exception messages, or exception details. - Never disable TLS verification.
Documentation
License
MIT © 2026 PIXELTIDE LLC.
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 usdpay-1.0.0.tar.gz.
File metadata
- Download URL: usdpay-1.0.0.tar.gz
- Upload date:
- Size: 12.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c4750fe5206b5353854edc67c0c75fc62507a947dcee83d4469bd8c8307278d0
|
|
| MD5 |
caf6a74bdb5aa587b8d10ee9db8b4247
|
|
| BLAKE2b-256 |
f8a2112f7e3de0fba181661f38f2e9263cf80f6b6c011a9c5426c21f8b466788
|
Provenance
The following attestation bundles were made for usdpay-1.0.0.tar.gz:
Publisher:
release.yml on probizi/usdpay-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usdpay-1.0.0.tar.gz -
Subject digest:
c4750fe5206b5353854edc67c0c75fc62507a947dcee83d4469bd8c8307278d0 - Sigstore transparency entry: 2845881632
- Sigstore integration time:
-
Permalink:
probizi/usdpay-python@ddb11a516f4e666308044f0696a452587c6be177 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/probizi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddb11a516f4e666308044f0696a452587c6be177 -
Trigger Event:
release
-
Statement type:
File details
Details for the file usdpay-1.0.0-py3-none-any.whl.
File metadata
- Download URL: usdpay-1.0.0-py3-none-any.whl
- Upload date:
- Size: 10.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via:
twine/7.0.0 CPython/3.13.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
226f338e1c6af1d63a85c441d7c447615bb18c8f5e79d849e80df0b9ee033792
|
|
| MD5 |
76d9d818fee993314411a2257f69282f
|
|
| BLAKE2b-256 |
fc7003dd097a33a0de0cd2d2b40d9f37e948f10f74db62d93d7efcce5c38b05c
|
Provenance
The following attestation bundles were made for usdpay-1.0.0-py3-none-any.whl:
Publisher:
release.yml on probizi/usdpay-python
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
usdpay-1.0.0-py3-none-any.whl -
Subject digest:
226f338e1c6af1d63a85c441d7c447615bb18c8f5e79d849e80df0b9ee033792 - Sigstore transparency entry: 2845881719
- Sigstore integration time:
-
Permalink:
probizi/usdpay-python@ddb11a516f4e666308044f0696a452587c6be177 -
Branch / Tag:
refs/tags/v1.0.0 - Owner: https://github.com/probizi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@ddb11a516f4e666308044f0696a452587c6be177 -
Trigger Event:
release
-
Statement type: