Skip to main content

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/ 目录。

设计原则

  1. 原生 API 对接:直接对接各支付平台原始 HTTP API,无第三方支付 SDK 封装
  2. 零第三方 Rust 依赖:仅使用 pyo3,所有支付逻辑通过 Rust 原生实现
  3. 统一接口风格:所有平台采用一致的参数命名和调用方式
  4. 跨平台:支持 Python 3.8+,macOS/Linux/Windows

Metadata

Release files for lesscode-pay 0.0.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Built distributions (wheels)

Table of built distributions (wheels) for lesscode-pay 0.0.2
File
lesscode_pay-0.0.2-cp37-abi3-win_amd64.whl CPython 3.7 abi3 Windows x86-64 Details
lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.7 abi3 Linux glibc 2.17+ x86-64 Details
lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.7 abi3 Linux glibc 2.17+ ARM64 Details
lesscode_pay-0.0.2-cp37-abi3-macosx_11_0_arm64.whl CPython 3.7 abi3 macOS 11.0+ ARM64 Details
lesscode_pay-0.0.2-cp37-abi3-macosx_10_12_x86_64.whl CPython 3.7 abi3 macOS 10.12+ x86-64 Details

Total release size: 15.6 MB

Release files / lesscode_pay-0.0.2-cp37-abi3-win_amd64.whl

Download URL lesscode_pay-0.0.2-cp37-abi3-win_amd64.whl
Size 2.9 MB
Tags CPython 3.7 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
c3a6cf548ec35db674bf621baa6e81cd3465787c0e7c4090684960ff05c4b5f4
BLAKE2b-256 checksum
How to use checksums
b3ebcbee45497b4acf2bd393dd2f55e5edd98610c15d8957cfe44109fc8bead5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 3.3 MB
Tags CPython 3.7 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
b8bac7426e391a45c0987cc185380f64b6852a1a2255298f6f59d7d6e981cc91
BLAKE2b-256 checksum
How to use checksums
dc5a73e76345dc0878cc87958822d234d663b27bda5b62a300c8e766cc754feb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL lesscode_pay-0.0.2-cp37-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 3.3 MB
Tags CPython 3.7 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
971a9eb15bad0f04a3903ef4ecfa130c9a9888c8f48ee2cfc6692b92ce647159
BLAKE2b-256 checksum
How to use checksums
4983b17f9bc72fc1625db2ca5981de60245f26a6e2a2bf6e85a211c8fcaf3491
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / lesscode_pay-0.0.2-cp37-abi3-macosx_11_0_arm64.whl

Download URL lesscode_pay-0.0.2-cp37-abi3-macosx_11_0_arm64.whl
Size 3.0 MB
Tags CPython 3.7 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
b391577c0fc4674b07df1989259a7fa4ec9df6a2b9d18edcd8db66f824da8439
BLAKE2b-256 checksum
How to use checksums
a0661446ac4f07bf38e7351b3c4e40dae7069391592e3af0a2c38262fbe87287
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release files / lesscode_pay-0.0.2-cp37-abi3-macosx_10_12_x86_64.whl

Download URL lesscode_pay-0.0.2-cp37-abi3-macosx_10_12_x86_64.whl
Size 3.1 MB
Tags CPython 3.7 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
8ccf72c3455cd8dd56c92ce0c524686c4d73ffdd6aed52a13c3add5d300fed0c
BLAKE2b-256 checksum
How to use checksums
530ebca9c5385336772f5e87507ac0a6f50cf613b0d1250bd70b764ac68843cc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.14.1

Release history Release notifications | RSS feed

This release

0.0.2 This release

5 release files

0.0.1

2 release files

0.0.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page