Skip to main content

BEpusdt 支付网关 Python SDK - 支持 USDT/TRX/USDC 多链支付

Project description

❗️声明:本 SDK 为 BEpusdt 支付网关的非官方 Python 客户端库,仅供学习研究使用。使用本项目请遵守当地法律法规,任何违法违规使用产生的后果由使用者自行承担。


BEpusdt Python SDK

PyPI version Python Support License: MIT BEpusdt

🪧 介绍

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}">

🏝️ 交流反馈

🙏 感谢

  • BEpusdt - 优秀的 USDT 支付网关
  • Epusdt - BEpusdt 的前身

🔗 相关链接

📄 许可证

MIT License

📢 声明

本项目仅供学习研究使用,使用过程中请遵守当地法律法规,任何违法违规使用产生的后果由使用者自行承担。


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

bepusdt-0.3.8.tar.gz (30.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

bepusdt-0.3.8-py3-none-any.whl (15.2 kB view details)

Uploaded Python 3

File details

Details for the file bepusdt-0.3.8.tar.gz.

File metadata

  • Download URL: bepusdt-0.3.8.tar.gz
  • Upload date:
  • Size: 30.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bepusdt-0.3.8.tar.gz
Algorithm Hash digest
SHA256 1c5dc961dc713cacd579214dcd8a80d8d181ffce0bd52f9a54c2e4c482a5c974
MD5 ca47fd26edcebee6ef07daeb84629ad1
BLAKE2b-256 8f24aabdc78f71c9f408d76720a2eceb18f346ae81ecc61640d6149a172e50bf

See more details on using hashes here.

File details

Details for the file bepusdt-0.3.8-py3-none-any.whl.

File metadata

  • Download URL: bepusdt-0.3.8-py3-none-any.whl
  • Upload date:
  • Size: 15.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.12

File hashes

Hashes for bepusdt-0.3.8-py3-none-any.whl
Algorithm Hash digest
SHA256 f95982c573079a6fb67f60b7dd0010137368bb91ccfd6fe6681b52ad6a4f96c3
MD5 0c2ff3687437ddd6fd628a1778e82976
BLAKE2b-256 0edc28cfe3584660321ba48598c96ed07394fe5bf702e539978365ac8749c6fd

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page