epusdt 0.2.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- epusdt-0.2.0/LICENSE +22 -0
- epusdt-0.2.0/PKG-INFO +259 -0
- epusdt-0.2.0/README.md +227 -0
- epusdt-0.2.0/epusdt/__init__.py +78 -0
- epusdt-0.2.0/epusdt/client.py +463 -0
- epusdt-0.2.0/epusdt/exceptions.py +68 -0
- epusdt-0.2.0/epusdt/models.py +334 -0
- epusdt-0.2.0/epusdt/py.typed +1 -0
- epusdt-0.2.0/epusdt/retry.py +42 -0
- epusdt-0.2.0/epusdt/signature.py +123 -0
- epusdt-0.2.0/epusdt.egg-info/PKG-INFO +259 -0
- epusdt-0.2.0/epusdt.egg-info/SOURCES.txt +18 -0
- epusdt-0.2.0/epusdt.egg-info/dependency_links.txt +1 -0
- epusdt-0.2.0/epusdt.egg-info/requires.txt +8 -0
- epusdt-0.2.0/epusdt.egg-info/top_level.txt +1 -0
- epusdt-0.2.0/pyproject.toml +54 -0
- epusdt-0.2.0/setup.cfg +4 -0
- epusdt-0.2.0/tests/test_client.py +350 -0
- epusdt-0.2.0/tests/test_models.py +39 -0
- epusdt-0.2.0/tests/test_signature.py +60 -0
epusdt-0.2.0/LICENSE
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Yufeifeio
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
22
|
+
|
epusdt-0.2.0/PKG-INFO
ADDED
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: epusdt
|
|
3
|
+
Version: 0.2.0
|
|
4
|
+
Summary: Python SDK for GMWalletApp/epusdt GMPay and EPay integrations
|
|
5
|
+
Author: Yufeifeio
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/Yufeifeio/epusdt-python-sdk
|
|
8
|
+
Project-URL: Source, https://github.com/Yufeifeio/epusdt-python-sdk
|
|
9
|
+
Project-URL: Issues, https://github.com/Yufeifeio/epusdt-python-sdk/issues
|
|
10
|
+
Keywords: epusdt,gmpay,epay,payment,crypto,sdk
|
|
11
|
+
Classifier: Development Status :: 4 - Beta
|
|
12
|
+
Classifier: Intended Audience :: Developers
|
|
13
|
+
Classifier: Programming Language :: Python :: 3
|
|
14
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
15
|
+
Classifier: Programming Language :: Python :: 3.8
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
20
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
21
|
+
Classifier: Topic :: Office/Business :: Financial
|
|
22
|
+
Requires-Python: >=3.8
|
|
23
|
+
Description-Content-Type: text/markdown
|
|
24
|
+
License-File: LICENSE
|
|
25
|
+
Requires-Dist: requests<3,>=2.31
|
|
26
|
+
Provides-Extra: dev
|
|
27
|
+
Requires-Dist: build>=1.0; extra == "dev"
|
|
28
|
+
Requires-Dist: pytest>=8.0; extra == "dev"
|
|
29
|
+
Provides-Extra: qrcode
|
|
30
|
+
Requires-Dist: qrcode[pil]>=7.4; extra == "qrcode"
|
|
31
|
+
Dynamic: license-file
|
|
32
|
+
|
|
33
|
+
# Epusdt Python SDK
|
|
34
|
+
|
|
35
|
+
`epusdt` 的 Python SDK,按 `GMWalletApp/epusdt` 当前公开支付接口实现。
|
|
36
|
+
|
|
37
|
+
当前已覆盖的商户接入能力:
|
|
38
|
+
|
|
39
|
+
- `POST /payments/gmpay/v1/order/create-transaction`
|
|
40
|
+
- `GET /payments/gmpay/v1/config`
|
|
41
|
+
- `GET /pay/checkout-counter-resp/{trade_id}`
|
|
42
|
+
- `GET /pay/check-status/{trade_id}`
|
|
43
|
+
- `POST /pay/switch-network`
|
|
44
|
+
- `POST /pay/submit-tx-hash/{trade_id}`
|
|
45
|
+
- `GET/POST /payments/epay/v1/order/create-transaction/submit.php`
|
|
46
|
+
- GMPay / EPay 两套回调验签
|
|
47
|
+
|
|
48
|
+
## 安装
|
|
49
|
+
|
|
50
|
+
当前版本已经把包名配置为 `epusdt`,但还没有发布到 PyPI。
|
|
51
|
+
|
|
52
|
+
所以现在可用的安装方式是:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
pip install git+https://github.com/Yufeifeio/epusdt-python-sdk.git
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
如果要启用二维码功能:
|
|
59
|
+
|
|
60
|
+
```bash
|
|
61
|
+
pip install "epusdt[qrcode] @ git+https://github.com/Yufeifeio/epusdt-python-sdk.git"
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
如果以后发布到 PyPI,就可以直接使用:
|
|
65
|
+
|
|
66
|
+
```bash
|
|
67
|
+
pip install epusdt
|
|
68
|
+
pip install epusdt[qrcode]
|
|
69
|
+
pip install --upgrade epusdt
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
本地开发安装:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
pip install -e .
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
## 功能说明
|
|
79
|
+
|
|
80
|
+
- 使用 `pid + secret_key`
|
|
81
|
+
- 主下单入口是 `GMPay v1`
|
|
82
|
+
- 支持创建 `status=4` 占位订单
|
|
83
|
+
- 支持后续 `switch-network`
|
|
84
|
+
- 支持 `submit-tx-hash` 手动补单
|
|
85
|
+
- 支持 `EPay submit.php` 重定向模式
|
|
86
|
+
- 支持 GMPay JSON 回调验签
|
|
87
|
+
- 支持 EPay GET 回调验签
|
|
88
|
+
- 支持二维码生成功能(可选依赖)
|
|
89
|
+
|
|
90
|
+
## 快速开始
|
|
91
|
+
|
|
92
|
+
```python
|
|
93
|
+
from epusdt import EpusdtClient
|
|
94
|
+
|
|
95
|
+
client = EpusdtClient(
|
|
96
|
+
base_url="https://pay.example.com",
|
|
97
|
+
pid="1000",
|
|
98
|
+
secret_key="epusdt_secret_key",
|
|
99
|
+
)
|
|
100
|
+
|
|
101
|
+
order = client.create_order(
|
|
102
|
+
order_id="ORD202606240001",
|
|
103
|
+
amount=100,
|
|
104
|
+
currency="cny",
|
|
105
|
+
token="usdt",
|
|
106
|
+
network="tron",
|
|
107
|
+
notify_url="https://merchant.example.com/notify",
|
|
108
|
+
redirect_url="https://merchant.example.com/return",
|
|
109
|
+
name="VIP",
|
|
110
|
+
)
|
|
111
|
+
|
|
112
|
+
print(order.trade_id)
|
|
113
|
+
print(order.payment_url)
|
|
114
|
+
```
|
|
115
|
+
|
|
116
|
+
## 占位订单
|
|
117
|
+
|
|
118
|
+
如果你要先创建订单,再让用户在收银台选择网络和币种:
|
|
119
|
+
|
|
120
|
+
```python
|
|
121
|
+
placeholder = client.create_order(
|
|
122
|
+
order_id="ORD202606240002",
|
|
123
|
+
amount=88.5,
|
|
124
|
+
currency="cny",
|
|
125
|
+
notify_url="https://merchant.example.com/notify",
|
|
126
|
+
)
|
|
127
|
+
|
|
128
|
+
print(placeholder.status) # OrderStatus.WAITING_SELECTION
|
|
129
|
+
print(placeholder.trade_id)
|
|
130
|
+
|
|
131
|
+
selected = client.switch_network(
|
|
132
|
+
trade_id=placeholder.trade_id,
|
|
133
|
+
token="USDT",
|
|
134
|
+
network="solana",
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
## EPay 兼容模式
|
|
139
|
+
|
|
140
|
+
构造 `submit.php` 跳转地址:
|
|
141
|
+
|
|
142
|
+
```python
|
|
143
|
+
url = client.build_epay_redirect_url(
|
|
144
|
+
out_trade_no="ORD202606240003",
|
|
145
|
+
money=100,
|
|
146
|
+
notify_url="https://merchant.example.com/notify",
|
|
147
|
+
return_url="https://merchant.example.com/return",
|
|
148
|
+
name="VIP",
|
|
149
|
+
)
|
|
150
|
+
|
|
151
|
+
print(url)
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
也可以直接请求网关并拿到它返回的收银台地址:
|
|
155
|
+
|
|
156
|
+
```python
|
|
157
|
+
redirect = client.create_epay_order(
|
|
158
|
+
out_trade_no="ORD202606240003",
|
|
159
|
+
money=100,
|
|
160
|
+
notify_url="https://merchant.example.com/notify",
|
|
161
|
+
return_url="https://merchant.example.com/return",
|
|
162
|
+
)
|
|
163
|
+
|
|
164
|
+
print(redirect.checkout_url)
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## 手动提交交易哈希
|
|
168
|
+
|
|
169
|
+
```python
|
|
170
|
+
result = client.submit_tx_hash(
|
|
171
|
+
trade_id="20260523171652123456001",
|
|
172
|
+
block_transaction_id="0xabc123",
|
|
173
|
+
)
|
|
174
|
+
|
|
175
|
+
print(result.status)
|
|
176
|
+
print(result.block_transaction_id)
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
## 回调验签
|
|
180
|
+
|
|
181
|
+
GMPay JSON 回调:
|
|
182
|
+
|
|
183
|
+
```python
|
|
184
|
+
payload = {
|
|
185
|
+
"pid": "1000",
|
|
186
|
+
"trade_id": "20260523171652123456001",
|
|
187
|
+
"order_id": "ORD202605230001",
|
|
188
|
+
"amount": 100,
|
|
189
|
+
"actual_amount": 14.29,
|
|
190
|
+
"receive_address": "TTestTronAddress001",
|
|
191
|
+
"token": "USDT",
|
|
192
|
+
"block_transaction_id": "0xabc123",
|
|
193
|
+
"status": 2,
|
|
194
|
+
"signature": "a1b2c3",
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
callback = client.parse_gmpay_callback(payload)
|
|
198
|
+
print(callback.trade_id)
|
|
199
|
+
```
|
|
200
|
+
|
|
201
|
+
EPay GET 回调:
|
|
202
|
+
|
|
203
|
+
```python
|
|
204
|
+
params = {
|
|
205
|
+
"pid": "1000",
|
|
206
|
+
"trade_no": "20260523171652123456001",
|
|
207
|
+
"out_trade_no": "ORD202605230001",
|
|
208
|
+
"type": "alipay",
|
|
209
|
+
"name": "VIP",
|
|
210
|
+
"money": "100.0000",
|
|
211
|
+
"trade_status": "TRADE_SUCCESS",
|
|
212
|
+
"sign": "a1b2c3",
|
|
213
|
+
"sign_type": "MD5",
|
|
214
|
+
}
|
|
215
|
+
|
|
216
|
+
callback = client.parse_epay_callback(params)
|
|
217
|
+
print(callback.out_trade_no)
|
|
218
|
+
```
|
|
219
|
+
|
|
220
|
+
## 二维码
|
|
221
|
+
|
|
222
|
+
安装可选依赖后,可以直接生成二维码:
|
|
223
|
+
|
|
224
|
+
```python
|
|
225
|
+
order = client.get_checkout("20260523171652123456001")
|
|
226
|
+
|
|
227
|
+
image = order.generate_qrcode()
|
|
228
|
+
image.save("epusdt-payment.png")
|
|
229
|
+
|
|
230
|
+
base64_data = order.get_qrcode_base64()
|
|
231
|
+
data_uri = order.get_qrcode_data_uri()
|
|
232
|
+
```
|
|
233
|
+
|
|
234
|
+
## API 一览
|
|
235
|
+
|
|
236
|
+
- `create_order(...)`
|
|
237
|
+
- `get_public_config()`
|
|
238
|
+
- `get_checkout(trade_id)`
|
|
239
|
+
- `check_status(trade_id)`
|
|
240
|
+
- `switch_network(trade_id, token, network)`
|
|
241
|
+
- `submit_tx_hash(trade_id, block_transaction_id)`
|
|
242
|
+
- `build_epay_params(...)`
|
|
243
|
+
- `build_epay_redirect_url(...)`
|
|
244
|
+
- `create_epay_order(...)`
|
|
245
|
+
- `verify_gmpay_callback(payload)`
|
|
246
|
+
- `verify_epay_callback(params)`
|
|
247
|
+
- `parse_gmpay_callback(payload)`
|
|
248
|
+
- `parse_epay_callback(params)`
|
|
249
|
+
|
|
250
|
+
## 开发
|
|
251
|
+
|
|
252
|
+
```bash
|
|
253
|
+
python -m venv .venv
|
|
254
|
+
. .venv/bin/activate
|
|
255
|
+
pip install -U pip build pytest
|
|
256
|
+
pip install -e .
|
|
257
|
+
pytest
|
|
258
|
+
python -m build
|
|
259
|
+
```
|
epusdt-0.2.0/README.md
ADDED
|
@@ -0,0 +1,227 @@
|
|
|
1
|
+
# Epusdt Python SDK
|
|
2
|
+
|
|
3
|
+
`epusdt` 的 Python SDK,按 `GMWalletApp/epusdt` 当前公开支付接口实现。
|
|
4
|
+
|
|
5
|
+
当前已覆盖的商户接入能力:
|
|
6
|
+
|
|
7
|
+
- `POST /payments/gmpay/v1/order/create-transaction`
|
|
8
|
+
- `GET /payments/gmpay/v1/config`
|
|
9
|
+
- `GET /pay/checkout-counter-resp/{trade_id}`
|
|
10
|
+
- `GET /pay/check-status/{trade_id}`
|
|
11
|
+
- `POST /pay/switch-network`
|
|
12
|
+
- `POST /pay/submit-tx-hash/{trade_id}`
|
|
13
|
+
- `GET/POST /payments/epay/v1/order/create-transaction/submit.php`
|
|
14
|
+
- GMPay / EPay 两套回调验签
|
|
15
|
+
|
|
16
|
+
## 安装
|
|
17
|
+
|
|
18
|
+
当前版本已经把包名配置为 `epusdt`,但还没有发布到 PyPI。
|
|
19
|
+
|
|
20
|
+
所以现在可用的安装方式是:
|
|
21
|
+
|
|
22
|
+
```bash
|
|
23
|
+
pip install git+https://github.com/Yufeifeio/epusdt-python-sdk.git
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
如果要启用二维码功能:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
pip install "epusdt[qrcode] @ git+https://github.com/Yufeifeio/epusdt-python-sdk.git"
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
如果以后发布到 PyPI,就可以直接使用:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install epusdt
|
|
36
|
+
pip install epusdt[qrcode]
|
|
37
|
+
pip install --upgrade epusdt
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
本地开发安装:
|
|
41
|
+
|
|
42
|
+
```bash
|
|
43
|
+
pip install -e .
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
## 功能说明
|
|
47
|
+
|
|
48
|
+
- 使用 `pid + secret_key`
|
|
49
|
+
- 主下单入口是 `GMPay v1`
|
|
50
|
+
- 支持创建 `status=4` 占位订单
|
|
51
|
+
- 支持后续 `switch-network`
|
|
52
|
+
- 支持 `submit-tx-hash` 手动补单
|
|
53
|
+
- 支持 `EPay submit.php` 重定向模式
|
|
54
|
+
- 支持 GMPay JSON 回调验签
|
|
55
|
+
- 支持 EPay GET 回调验签
|
|
56
|
+
- 支持二维码生成功能(可选依赖)
|
|
57
|
+
|
|
58
|
+
## 快速开始
|
|
59
|
+
|
|
60
|
+
```python
|
|
61
|
+
from epusdt import EpusdtClient
|
|
62
|
+
|
|
63
|
+
client = EpusdtClient(
|
|
64
|
+
base_url="https://pay.example.com",
|
|
65
|
+
pid="1000",
|
|
66
|
+
secret_key="epusdt_secret_key",
|
|
67
|
+
)
|
|
68
|
+
|
|
69
|
+
order = client.create_order(
|
|
70
|
+
order_id="ORD202606240001",
|
|
71
|
+
amount=100,
|
|
72
|
+
currency="cny",
|
|
73
|
+
token="usdt",
|
|
74
|
+
network="tron",
|
|
75
|
+
notify_url="https://merchant.example.com/notify",
|
|
76
|
+
redirect_url="https://merchant.example.com/return",
|
|
77
|
+
name="VIP",
|
|
78
|
+
)
|
|
79
|
+
|
|
80
|
+
print(order.trade_id)
|
|
81
|
+
print(order.payment_url)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
## 占位订单
|
|
85
|
+
|
|
86
|
+
如果你要先创建订单,再让用户在收银台选择网络和币种:
|
|
87
|
+
|
|
88
|
+
```python
|
|
89
|
+
placeholder = client.create_order(
|
|
90
|
+
order_id="ORD202606240002",
|
|
91
|
+
amount=88.5,
|
|
92
|
+
currency="cny",
|
|
93
|
+
notify_url="https://merchant.example.com/notify",
|
|
94
|
+
)
|
|
95
|
+
|
|
96
|
+
print(placeholder.status) # OrderStatus.WAITING_SELECTION
|
|
97
|
+
print(placeholder.trade_id)
|
|
98
|
+
|
|
99
|
+
selected = client.switch_network(
|
|
100
|
+
trade_id=placeholder.trade_id,
|
|
101
|
+
token="USDT",
|
|
102
|
+
network="solana",
|
|
103
|
+
)
|
|
104
|
+
```
|
|
105
|
+
|
|
106
|
+
## EPay 兼容模式
|
|
107
|
+
|
|
108
|
+
构造 `submit.php` 跳转地址:
|
|
109
|
+
|
|
110
|
+
```python
|
|
111
|
+
url = client.build_epay_redirect_url(
|
|
112
|
+
out_trade_no="ORD202606240003",
|
|
113
|
+
money=100,
|
|
114
|
+
notify_url="https://merchant.example.com/notify",
|
|
115
|
+
return_url="https://merchant.example.com/return",
|
|
116
|
+
name="VIP",
|
|
117
|
+
)
|
|
118
|
+
|
|
119
|
+
print(url)
|
|
120
|
+
```
|
|
121
|
+
|
|
122
|
+
也可以直接请求网关并拿到它返回的收银台地址:
|
|
123
|
+
|
|
124
|
+
```python
|
|
125
|
+
redirect = client.create_epay_order(
|
|
126
|
+
out_trade_no="ORD202606240003",
|
|
127
|
+
money=100,
|
|
128
|
+
notify_url="https://merchant.example.com/notify",
|
|
129
|
+
return_url="https://merchant.example.com/return",
|
|
130
|
+
)
|
|
131
|
+
|
|
132
|
+
print(redirect.checkout_url)
|
|
133
|
+
```
|
|
134
|
+
|
|
135
|
+
## 手动提交交易哈希
|
|
136
|
+
|
|
137
|
+
```python
|
|
138
|
+
result = client.submit_tx_hash(
|
|
139
|
+
trade_id="20260523171652123456001",
|
|
140
|
+
block_transaction_id="0xabc123",
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
print(result.status)
|
|
144
|
+
print(result.block_transaction_id)
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
## 回调验签
|
|
148
|
+
|
|
149
|
+
GMPay JSON 回调:
|
|
150
|
+
|
|
151
|
+
```python
|
|
152
|
+
payload = {
|
|
153
|
+
"pid": "1000",
|
|
154
|
+
"trade_id": "20260523171652123456001",
|
|
155
|
+
"order_id": "ORD202605230001",
|
|
156
|
+
"amount": 100,
|
|
157
|
+
"actual_amount": 14.29,
|
|
158
|
+
"receive_address": "TTestTronAddress001",
|
|
159
|
+
"token": "USDT",
|
|
160
|
+
"block_transaction_id": "0xabc123",
|
|
161
|
+
"status": 2,
|
|
162
|
+
"signature": "a1b2c3",
|
|
163
|
+
}
|
|
164
|
+
|
|
165
|
+
callback = client.parse_gmpay_callback(payload)
|
|
166
|
+
print(callback.trade_id)
|
|
167
|
+
```
|
|
168
|
+
|
|
169
|
+
EPay GET 回调:
|
|
170
|
+
|
|
171
|
+
```python
|
|
172
|
+
params = {
|
|
173
|
+
"pid": "1000",
|
|
174
|
+
"trade_no": "20260523171652123456001",
|
|
175
|
+
"out_trade_no": "ORD202605230001",
|
|
176
|
+
"type": "alipay",
|
|
177
|
+
"name": "VIP",
|
|
178
|
+
"money": "100.0000",
|
|
179
|
+
"trade_status": "TRADE_SUCCESS",
|
|
180
|
+
"sign": "a1b2c3",
|
|
181
|
+
"sign_type": "MD5",
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
callback = client.parse_epay_callback(params)
|
|
185
|
+
print(callback.out_trade_no)
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
## 二维码
|
|
189
|
+
|
|
190
|
+
安装可选依赖后,可以直接生成二维码:
|
|
191
|
+
|
|
192
|
+
```python
|
|
193
|
+
order = client.get_checkout("20260523171652123456001")
|
|
194
|
+
|
|
195
|
+
image = order.generate_qrcode()
|
|
196
|
+
image.save("epusdt-payment.png")
|
|
197
|
+
|
|
198
|
+
base64_data = order.get_qrcode_base64()
|
|
199
|
+
data_uri = order.get_qrcode_data_uri()
|
|
200
|
+
```
|
|
201
|
+
|
|
202
|
+
## API 一览
|
|
203
|
+
|
|
204
|
+
- `create_order(...)`
|
|
205
|
+
- `get_public_config()`
|
|
206
|
+
- `get_checkout(trade_id)`
|
|
207
|
+
- `check_status(trade_id)`
|
|
208
|
+
- `switch_network(trade_id, token, network)`
|
|
209
|
+
- `submit_tx_hash(trade_id, block_transaction_id)`
|
|
210
|
+
- `build_epay_params(...)`
|
|
211
|
+
- `build_epay_redirect_url(...)`
|
|
212
|
+
- `create_epay_order(...)`
|
|
213
|
+
- `verify_gmpay_callback(payload)`
|
|
214
|
+
- `verify_epay_callback(params)`
|
|
215
|
+
- `parse_gmpay_callback(payload)`
|
|
216
|
+
- `parse_epay_callback(params)`
|
|
217
|
+
|
|
218
|
+
## 开发
|
|
219
|
+
|
|
220
|
+
```bash
|
|
221
|
+
python -m venv .venv
|
|
222
|
+
. .venv/bin/activate
|
|
223
|
+
pip install -U pip build pytest
|
|
224
|
+
pip install -e .
|
|
225
|
+
pytest
|
|
226
|
+
python -m build
|
|
227
|
+
```
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
from .client import EpusdtClient
|
|
2
|
+
from .exceptions import (
|
|
3
|
+
APIError,
|
|
4
|
+
AuthenticationError,
|
|
5
|
+
ClientError,
|
|
6
|
+
EpusdtError,
|
|
7
|
+
NetworkError,
|
|
8
|
+
RequestTimeoutError,
|
|
9
|
+
ServerError,
|
|
10
|
+
SignatureError,
|
|
11
|
+
ValidationError,
|
|
12
|
+
)
|
|
13
|
+
from .models import (
|
|
14
|
+
CheckStatusResponse,
|
|
15
|
+
CheckoutOrder,
|
|
16
|
+
CreateOrderResponse,
|
|
17
|
+
EPayRedirectResponse,
|
|
18
|
+
EpayCallback,
|
|
19
|
+
EpayDefaults,
|
|
20
|
+
GmpayCallback,
|
|
21
|
+
ManualPaymentResponse,
|
|
22
|
+
Network,
|
|
23
|
+
OkpayConfig,
|
|
24
|
+
OrderStatus,
|
|
25
|
+
PaymentType,
|
|
26
|
+
PublicConfig,
|
|
27
|
+
SiteConfig,
|
|
28
|
+
SupportedAsset,
|
|
29
|
+
Token,
|
|
30
|
+
TradeStatus,
|
|
31
|
+
)
|
|
32
|
+
from .signature import (
|
|
33
|
+
build_epay_signing_string,
|
|
34
|
+
build_gmpay_signing_string,
|
|
35
|
+
generate_epay_signature,
|
|
36
|
+
generate_gmpay_signature,
|
|
37
|
+
verify_epay_signature,
|
|
38
|
+
verify_gmpay_signature,
|
|
39
|
+
)
|
|
40
|
+
|
|
41
|
+
__all__ = [
|
|
42
|
+
"APIError",
|
|
43
|
+
"AuthenticationError",
|
|
44
|
+
"CheckStatusResponse",
|
|
45
|
+
"CheckoutOrder",
|
|
46
|
+
"ClientError",
|
|
47
|
+
"CreateOrderResponse",
|
|
48
|
+
"EPayRedirectResponse",
|
|
49
|
+
"EpayCallback",
|
|
50
|
+
"EpayDefaults",
|
|
51
|
+
"EpusdtClient",
|
|
52
|
+
"EpusdtError",
|
|
53
|
+
"GmpayCallback",
|
|
54
|
+
"ManualPaymentResponse",
|
|
55
|
+
"Network",
|
|
56
|
+
"NetworkError",
|
|
57
|
+
"OkpayConfig",
|
|
58
|
+
"OrderStatus",
|
|
59
|
+
"PaymentType",
|
|
60
|
+
"PublicConfig",
|
|
61
|
+
"RequestTimeoutError",
|
|
62
|
+
"ServerError",
|
|
63
|
+
"SignatureError",
|
|
64
|
+
"SiteConfig",
|
|
65
|
+
"SupportedAsset",
|
|
66
|
+
"Token",
|
|
67
|
+
"TradeStatus",
|
|
68
|
+
"ValidationError",
|
|
69
|
+
"build_epay_signing_string",
|
|
70
|
+
"build_gmpay_signing_string",
|
|
71
|
+
"generate_epay_signature",
|
|
72
|
+
"generate_gmpay_signature",
|
|
73
|
+
"verify_epay_signature",
|
|
74
|
+
"verify_gmpay_signature",
|
|
75
|
+
]
|
|
76
|
+
|
|
77
|
+
__version__ = "0.2.0"
|
|
78
|
+
__url__ = "https://github.com/Yufeifeio/epusdt-python-sdk"
|