统一的低代码支付SDK(微信支付 V2/V3、支付宝、银联、Stripe 等 14 大支付平台),基于 Rust+pyo3
Project description
lesscode_pay
面向 Python 的 Rust+PyO3 支付 SDK,覆盖 14 大支付平台,参数与返回对齐官方文档。
安装
pip install lesscode_pay
或从源码构建:
pip install maturin
maturin build --release
pip install target/wheels/lesscode_pay-*.whl
支持的支付平台
| 支付平台 | 类名 | 签名方式 | 方法数 |
|---|---|---|---|
| 微信支付 V2 | WeChatPayV2 |
MD5 | 47 |
| 微信支付 V3 直连 | WeChatPayV3Common |
WECHATPAY2-SHA256-RSA2048 | 100+ |
| 微信支付 V3 APP | WeChatPayV3App |
WECHATPAY2-SHA256-RSA2048 | 8 |
| 微信支付 V3 服务商 | WeChatPayV3Partner |
WECHATPAY2-SHA256-RSA2048 | 10+ |
| 支付宝 | AlipayClient |
RSA2 | 22(通用 execute 可调任意接口) |
| QQ 钱包支付 | QQPayClient |
MD5 | 24 |
| 抖音支付 | DouyinPayClient |
RSA-SHA256 | 20 |
| 百度支付 | BaiduPayClient |
RSA-SHA256 | 16 |
| 网易支付 | NetEasePayClient |
MD5 | 19 |
| 银联支付 | UnionPayClient |
RSA-SHA256 | 24 |
| 京东支付 | JDPayClient |
RSA-SHA256 | 15 |
| 易宝支付 | YeePayClient |
RSA-SHA256 | 17 |
| Stripe | StripeClient |
Bearer Token | 64 |
| PayPal | PayPalClient |
OAuth2 Bearer Token | 50 |
快速开始
import lesscode_pay as pay
# 微信支付 V3 - JSAPI 下单
c = pay.WeChatPayV3Common(
mchid="1234567890",
cert_serial_no="ABCD1234",
private_key_pem="-----BEGIN PRIVATE KEY-----\n...\n-----END PRIVATE KEY-----\n",
)
resp = c.create_order_jsapi(
out_trade_no="T20240001",
total=100,
description="测试商品",
payer_openid="oUpF8uMuAJO_M2pxb1Q9zNjWeS6o",
notify_url="https://your-domain.com/notify",
)
print(f"prepay_id: {resp['prepay_id']}")
# Stripe - 创建 PaymentIntent
stripe = pay.StripeClient(api_key="sk_test_xxx")
pi = stripe.create_payment_intent('{"amount":2000,"currency":"usd"}')
# 银联 - 消费
union = pay.UnionPayClient(
mer_id="123456",
private_key_pem="-----BEGIN PRIVATE KEY-----\n...",
public_key_pem="-----BEGIN PUBLIC KEY-----\n...",
)
form = union.consume("O20240001", "100", "https://your-domain.com/notify", "https://your-domain.com/return")
文档
详细文档与用法见 doc/ 目录:
示例
各平台使用示例见 example/ 目录。
设计原则
- 原生 API 对接:直接对接各支付平台原始 HTTP API,无第三方支付 SDK 封装
- 零第三方 Rust 依赖:仅使用
pyo3,所有支付逻辑通过 Rust 原生实现 - 统一接口风格:所有平台采用一致的参数命名和调用方式
- 跨平台:支持 Python 3.8+,macOS/Linux/Windows
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 Distributions
Built Distributions
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 lesscode_pay-0.0.2-cp37-abi3-win_amd64.whl.
File metadata
- Download URL: lesscode_pay-0.0.2-cp37-abi3-win_amd64.whl
- Upload date:
- Size: 2.9 MB
- Tags: CPython 3.7+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c3a6cf548ec35db674bf621baa6e81cd3465787c0e7c4090684960ff05c4b5f4
|
|
| MD5 |
c9c5aea53d937b7f3c230550d50d5d26
|
|
| BLAKE2b-256 |
b3ebcbee45497b4acf2bd393dd2f55e5edd98610c15d8957cfe44109fc8bead5
|
File details
Details for the file lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.
File metadata
- Download URL: lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b8bac7426e391a45c0987cc185380f64b6852a1a2255298f6f59d7d6e981cc91
|
|
| MD5 |
397dad07104e60062fd129e5d79763dd
|
|
| BLAKE2b-256 |
dc5a73e76345dc0878cc87958822d234d663b27bda5b62a300c8e766cc754feb
|
File details
Details for the file lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.
File metadata
- Download URL: lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
- Upload date:
- Size: 3.3 MB
- Tags: CPython 3.7+, manylinux: glibc 2.17+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
971a9eb15bad0f04a3903ef4ecfa130c9a9888c8f48ee2cfc6692b92ce647159
|
|
| MD5 |
ca7ed66973e57c97d92ea9f6fe474005
|
|
| BLAKE2b-256 |
4983b17f9bc72fc1625db2ca5981de60245f26a6e2a2bf6e85a211c8fcaf3491
|
File details
Details for the file lesscode_pay-0.0.2-cp37-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: lesscode_pay-0.0.2-cp37-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 3.0 MB
- Tags: CPython 3.7+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b391577c0fc4674b07df1989259a7fa4ec9df6a2b9d18edcd8db66f824da8439
|
|
| MD5 |
5ae419542662036ef92d4e5d2917f008
|
|
| BLAKE2b-256 |
a0661446ac4f07bf38e7351b3c4e40dae7069391592e3af0a2c38262fbe87287
|
File details
Details for the file lesscode_pay-0.0.2-cp37-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: lesscode_pay-0.0.2-cp37-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 3.1 MB
- Tags: CPython 3.7+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.14.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8ccf72c3455cd8dd56c92ce0c524686c4d73ffdd6aed52a13c3add5d300fed0c
|
|
| MD5 |
5269156d0a180369c427f2d876b1946e
|
|
| BLAKE2b-256 |
530ebca9c5385336772f5e87507ac0a6f50cf613b0d1250bd70b764ac68843cc
|