open-withdrawal-demo/README.md
echo 82c7f3406d init: multi-language OpenAPI demos (java/php/nodejs/python)
Co-authored-by: Cursor <cursoragent@cursor.com>
2026-07-20 13:40:29 +08:00

46 lines
1.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 代付 OpenAPI Demo
多语言对接示例:签名算法 + 下单 / 查单 / 查余额。
- 仓库https://git.weilai-pay.com/echo/open-withdrawal-demo
- 文档https://sh.weilai-pay.com/doc/znhtbr/
- 网关占位:`https://example.com`(请换成实际域名)
## 目录
| 语言 | 目录 |
| --- | --- |
| Java | `java/` |
| PHP | `php/` |
| Node.js | `nodejs/` |
| Python | `python/` |
## 配置(环境变量)
| 变量 | 说明 | 示例 |
| --- | --- | --- |
| `BASE_URL` | 网关根地址 | `https://example.com` |
| `ACCESS_KEY` | 商户号 | `your_access_key` |
| `SECRET_KEY` | 商户密钥 | `your_secret_key` |
| `PAY_CHANNEL_ID` | 通道编码 | `821` |
## 快速跑(以 Python 为例)
```bash
cd python
export BASE_URL=https://example.com
export ACCESS_KEY=your_access_key
export SECRET_KEY=your_secret_key
export PAY_CHANNEL_ID=821
python3 demo.py balance
python3 demo.py submit
python3 demo.py query <商户订单号>
```
## 签名规则(各语言一致)
1. 去掉 `Sign` 字段;值为 `null` 或空字符串 `""` 的字段不参与
2. 按字段名字典序ASCII拼接`k=v&k2=v2`
3. 末尾追加 `&SecretKey=<密钥>`
4. 对整串做 MD532 位小写)得到 `Sign`