zpay — ZPay Python SDK
English | 中文
Async Python client for the ZPay payment gateway. Supports Alipay and WeChat Pay via redirect URLs, server-to-server API calls, order queries, refunds, and callback verification.
Installation
pip install zpay
Requirements: Python ≥ 3.10, aiohttp
Quick Start
import asyncio
from zpay import ZPayClient
async def main():
async with ZPayClient(pid="your_pid", key="your_key") as client:
# 1. Redirect URL (no HTTP request)
url = client.create_payment_url(
name="iPhone 17",
money="599.00",
out_trade_no="ORDER_001",
notify_url="https://yoursite.com/notify",
return_url="https://yoursite.com/return",
type="alipay",
)
print("Pay URL:", url)
# 2. API payment — returns payurl / qrcode / img
resp = await client.create_payment(
name="iPhone 17",
money="599.00",
out_trade_no="ORDER_002",
notify_url="https://yoursite.com/notify",
clientip="1.2.3.4",
type="wxpay",
)
print("QR Code:", resp.qrcode)
# 3. Query order
order = await client.query_order(out_trade_no="ORDER_002")
print("Status:", order.status)
# 4. Refund
refund = await client.refund(out_trade_no="ORDER_002", money="599.00")
print(refund.msg)
# 5. Verify callback notification
payload = client.verify_notification(request_params)
if payload.is_paid:
print("Payment confirmed!")
asyncio.run(main())
API Reference
ZPayClient(pid, key, base_url?, session?)
| Parameter | Type | Description |
|---|---|---|
pid |
str |
Merchant ID |
key |
str |
Merchant secret key |
base_url |
str |
API base URL (default: https://zpayz.cn) |
session |
aiohttp.ClientSession |
Optional existing session |
Methods
| Method | Returns | Description |
|---|---|---|
create_payment_url(...) |
str |
Build a signed redirect URL (no HTTP) |
create_payment(...) |
PaymentResponse |
Server-to-server payment API |
query_order(...) |
OrderResponse |
Query order status |
refund(...) |
RefundResponse |
Submit refund request |
verify_notification(params) |
NotificationPayload |
Validate and parse callback |
Payment Types
| Value | Channel |
|---|---|
"alipay" |
Alipay |
"wxpay" |
WeChat Pay |
License
MIT
zpay — ZPay Python SDK 中文
English | 中文
ZPay 支付网关的异步 Python 客户端,支持支付宝、微信支付的跳转收款、服务端 API 下单、订单查询、退款以及回调验签。
安装
pip install zpay
环境要求: Python ≥ 3.10,依赖 aiohttp
快速开始
import asyncio
from zpay import ZPayClient
async def main():
async with ZPayClient(pid="your_pid", key="your_key") as client:
# 1. 生成跳转收款 URL(不发起 HTTP 请求)
url = client.create_payment_url(
name="iPhone 17",
money="599.00",
out_trade_no="ORDER_001",
notify_url="https://yoursite.com/notify",
return_url="https://yoursite.com/return",
type="alipay",
)
print("支付链接:", url)
# 2. 服务端 API 下单(返回 payurl / qrcode / img)
resp = await client.create_payment(
name="iPhone 17",
money="599.00",
out_trade_no="ORDER_002",
notify_url="https://yoursite.com/notify",
clientip="1.2.3.4",
type="wxpay",
)
print("二维码:", resp.qrcode)
# 3. 查询订单
order = await client.query_order(out_trade_no="ORDER_002")
print("订单状态:", order.status)
# 4. 退款
refund = await client.refund(out_trade_no="ORDER_002", money="599.00")
print(refund.msg)
# 5. 验证异步回调通知
payload = client.verify_notification(request_params)
if payload.is_paid:
print("支付成功!")
asyncio.run(main())
API 说明
ZPayClient(pid, key, base_url?, session?)
| 参数 | 类型 | 说明 |
|---|---|---|
pid |
str |
商户 ID |
key |
str |
商户密钥 |
base_url |
str |
API 基础地址(默认:https://zpayz.cn) |
session |
aiohttp.ClientSession |
可选,传入已有的 Session |
方法列表
| 方法 | 返回值 | 说明 |
|---|---|---|
create_payment_url(...) |
str |
生成带签名的跳转收款 URL(不请求网络) |
create_payment(...) |
PaymentResponse |
服务端 API 下单 |
query_order(...) |
OrderResponse |
查询订单状态 |
refund(...) |
RefundResponse |
发起退款 |
verify_notification(params) |
NotificationPayload |
验签并解析回调参数 |
支付方式
| 值 | 渠道 |
|---|---|
"alipay" |
支付宝 |
"wxpay" |
微信支付 |
开源协议
MIT
Metadata
Release files for zpay 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | |
|---|---|---|---|---|
| zpay-0.1.1.tar.gz | 59.9 kB | Without provenance | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| zpay-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 68.6 kB
Release files / zpay-0.1.1.tar.gz
| Download URL | zpay-0.1.1.tar.gz |
|---|---|
| Size | 59.9 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
31c6d6e2343aadd90932a3787093e7628776c476952c34fff1f3c9a339fbac84
|
|
BLAKE2b-256 checksum How to use checksums |
3a65d70d40c5ee4d82f1a23f285f88bdab2e1cb33d0c841e3f2ebcaa9619aa2e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Release files / zpay-0.1.1-py3-none-any.whl
| Download URL | zpay-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.7 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
1a1ac67c0dd0d0cc803a575bce909998ecdbbb5450f0b30c13f1c4fd63c7dddc
|
|
BLAKE2b-256 checksum How to use checksums |
576346a40318c3c98960a8ad3f80e558f3819c2c7617f342bb461387ee099f5e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
uv/0.9.11 {"installer":{"name":"uv","version":"0.9.11"},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
|
Security for zpay 0.1.1
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.