BEpusdt 支付网关 Python SDK - 支持 USDT/TRX/USDC 多链支付
Project description
❗️声明:本 SDK 为 BEpusdt 支付网关的非官方 Python 客户端库,仅供学习研究使用。使用本项目请遵守当地法律法规,任何违法违规使用产生的后果由使用者自行承担。
BEpusdt Python SDK
🪧 介绍
BEpusdt 支付网关的 Python SDK,让 Python 开发者能够快速集成 USDT/TRX/USDC 加密货币支付功能。
✨ 特性
- 🎯 简单易用 - 几行代码即可集成
- 🔐 自动签名 - 内置签名生成和验证
- 🌐 多链支持 - 支持 10+ 区块链网络
- 💰 多币种 - USDT、USDC、TRX、ETH、BNB
- 🔄 自动重试 - 网络错误自动重试,提升成功率
- 📱 二维码生成 - 一键生成收款地址二维码
- 📝 类型提示 - 完整的 IDE 智能提示
- ✅ 生产就绪 - 经过真实环境测试
- 🔄 完全兼容 - 完整支持 BEpusdt API
🌟 支持的网络
USDT
🔥 主流网络:Tron (TRC20) · Ethereum (ERC20) · BSC (BEP20) · Polygon
⚡ 其他网络:Arbitrum · Solana · Aptos · X-Layer · Plasma
USDC
🔥 主流网络:Tron (TRC20) · Ethereum (ERC20) · BSC (BEP20) · Polygon
⚡ 其他网络:Arbitrum · Solana · Aptos · X-Layer · Base
其他
💎 TRX (Tron) · ETH (Ethereum) · BNB (BSC)
📦 安装
pip install bepusdt
# 如需二维码功能
pip install bepusdt[qrcode]
🚀 快速开始
from bepusdt import BEpusdtClient, TradeType
# 初始化客户端(支持自动重试)
client = BEpusdtClient(
api_url="https://your-bepusdt-server.com",
api_token="your-api-token",
max_retries=3 # 可选:网络错误自动重试3次
)
# 创建订单
order = client.create_order(
order_id="ORDER_001",
amount=10.0,
notify_url="https://your-domain.com/notify",
trade_type=TradeType.USDT_TRC20
)
print(f"💰 支付金额: {order.actual_amount} USDT")
print(f"📍 收款地址: {order.token}")
print(f"🔗 支付链接: {order.payment_url}")
📖 文档
🔧 核心功能
错误处理
SDK 会自动处理网络错误和服务器临时故障:
from bepusdt.exceptions import ServerError, NetworkError, TimeoutError
try:
order = client.create_order(...)
except ServerError as e:
# 服务器错误 5xx(已自动重试)
print(f"服务器错误: {e}")
except NetworkError as e:
# 网络连接失败(已自动重试)
print(f"网络错误: {e}")
except TimeoutError as e:
# 请求超时(已自动重试)
print(f"超时: {e}")
自动重试配置:
client = BEpusdtClient(
api_url="https://your-server.com",
api_token="your-api-token",
max_retries=3, # 最多重试 3 次
retry_delay=1.0 # 初始延迟 1 秒(指数退避)
)
创建订单
order = client.create_order(
order_id="ORDER_001",
amount=10.0,
notify_url="https://your-domain.com/notify",
redirect_url="https://your-domain.com/success",
trade_type=TradeType.USDT_TRC20
)
查询订单
order = client.query_order(trade_id="xxx")
if order.status == OrderStatus.SUCCESS:
print("✅ 支付成功")
验证回调
@app.route('/notify', methods=['POST'])
def notify():
data = request.get_json()
if client.verify_callback(data):
# 处理支付成功
return "ok", 200
return "fail", 400
生成二维码
# 创建订单后生成收款地址二维码
order = client.create_order(...)
# 方式1:保存为图片文件
qr = order.generate_qrcode()
qr.save("payment_qr.png")
# 方式2:获取 Base64(用于 API 返回)
qr_base64 = order.get_qrcode_base64()
# 方式3:获取 Data URI(直接用于 HTML img src)
data_uri = order.get_qrcode_data_uri()
# <img src="{data_uri}">
🏝️ 交流反馈
- 💬 Telegram: @luoyanglang
- 📝 提交 Issue
- 🔗 BEpusdt 官方群组
🙏 感谢
🔗 相关链接
- 🏠 BEpusdt 官方
- 📦 PyPI 页面
- 💻 GitHub 仓库
- 📋 更新日志
📄 许可证
📢 声明
本项目仅供学习研究使用,使用过程中请遵守当地法律法规,任何违法违规使用产生的后果由使用者自行承担。
Made with ❤️ for BEpusdt community
Project details
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 bepusdt-0.3.1.tar.gz.
File metadata
- Download URL: bepusdt-0.3.1.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01d0080b17b70860454a4ecec9e28269fadf376a20980ad2edd12b2c58faf95f
|
|
| MD5 |
3b2f750f7eb5e359df285894fd3527e5
|
|
| BLAKE2b-256 |
5676c8793904bdbb83016db59676b1cea78eac89c27375c9552610da279a5192
|
File details
Details for the file bepusdt-0.3.1-py3-none-any.whl.
File metadata
- Download URL: bepusdt-0.3.1-py3-none-any.whl
- Upload date:
- Size: 14.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
01b063c2de8ab64b0f6ade6407d50cc9ba716f7e8fdbba5b58b57cbdb55ef1e1
|
|
| MD5 |
512828242ca0391c07063f2947a7e44e
|
|
| BLAKE2b-256 |
8cd8ec6d381e1a825801e2f890d17ba02635862d186e5a1ba0d2857456b13d6e
|