@alipay/alipay-aipay 1.0.0 → 1.0.2
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.
- package/bin/alipay-aipay.js +6 -0
- package/dist/commands/install.d.ts +11 -0
- package/dist/commands/install.d.ts.map +1 -0
- package/dist/commands/install.js +182 -0
- package/dist/commands/install.js.map +1 -0
- package/dist/commands/prepare-tools.d.ts +5 -0
- package/dist/commands/prepare-tools.d.ts.map +1 -0
- package/dist/commands/prepare-tools.js +29 -0
- package/dist/commands/prepare-tools.js.map +1 -0
- package/dist/commands/uninstall.d.ts +10 -0
- package/dist/commands/uninstall.d.ts.map +1 -0
- package/dist/commands/uninstall.js +82 -0
- package/dist/commands/uninstall.js.map +1 -0
- package/dist/commands/update.d.ts +10 -0
- package/dist/commands/update.d.ts.map +1 -0
- package/dist/commands/update.js +155 -0
- package/dist/commands/update.js.map +1 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/dist/types.d.ts +43 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +2 -0
- package/dist/types.js.map +1 -0
- package/dist/utils/alipay-cli.d.ts +15 -0
- package/dist/utils/alipay-cli.d.ts.map +1 -0
- package/dist/utils/alipay-cli.js +221 -0
- package/dist/utils/alipay-cli.js.map +1 -0
- package/dist/utils/config.d.ts +48 -0
- package/dist/utils/config.d.ts.map +1 -0
- package/dist/utils/config.js +207 -0
- package/dist/utils/config.js.map +1 -0
- package/dist/utils/file.d.ts +55 -0
- package/dist/utils/file.d.ts.map +1 -0
- package/dist/utils/file.js +154 -0
- package/dist/utils/file.js.map +1 -0
- package/dist/utils/gpg.d.ts +14 -0
- package/dist/utils/gpg.d.ts.map +1 -0
- package/dist/utils/gpg.js +247 -0
- package/dist/utils/gpg.js.map +1 -0
- package/dist/utils/jq.d.ts +14 -0
- package/dist/utils/jq.d.ts.map +1 -0
- package/dist/utils/jq.js +221 -0
- package/dist/utils/jq.js.map +1 -0
- package/dist/utils/npm.d.ts +17 -0
- package/dist/utils/npm.d.ts.map +1 -0
- package/dist/utils/npm.js +42 -0
- package/dist/utils/npm.js.map +1 -0
- package/dist/utils/shell.d.ts +11 -0
- package/dist/utils/shell.d.ts.map +1 -0
- package/dist/utils/shell.js +54 -0
- package/dist/utils/shell.js.map +1 -0
- package/package.json +48 -7
- package/skill/SKILL.md +118 -0
- package/skill/references/integration/flow.md +487 -0
- package/skill/references/integration/modules/alipay-sdk-reminder.md +256 -0
- package/skill/references/integration/modules/checklist.md +122 -0
- package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +68 -0
- package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +77 -0
- package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +74 -0
- package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +73 -0
- package/skill/references/integration/modules/code-examples/csharp/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +58 -0
- package/skill/references/integration/modules/code-examples/csharp/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +128 -0
- package/skill/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.cs +500 -0
- package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +72 -0
- package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +80 -0
- package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +78 -0
- package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +77 -0
- package/skill/references/integration/modules/code-examples/java/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +66 -0
- package/skill/references/integration/modules/code-examples/java/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +135 -0
- package/skill/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.java +610 -0
- package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +51 -0
- package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +57 -0
- package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +55 -0
- package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +54 -0
- package/skill/references/integration/modules/code-examples/nodejs/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +77 -0
- package/skill/references/integration/modules/code-examples/nodejs/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +65 -0
- package/skill/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.js +461 -0
- package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +59 -0
- package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +67 -0
- package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +66 -0
- package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +65 -0
- package/skill/references/integration/modules/code-examples/php/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +56 -0
- package/skill/references/integration/modules/code-examples/php/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +107 -0
- package/skill/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.php +444 -0
- package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/345/205/263/351/227/255/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +57 -0
- package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +65 -0
- package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +63 -0
- package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//347/273/237/344/270/200/346/224/266/345/215/225/344/272/244/346/230/223/351/200/200/346/254/276/346/237/245/350/257/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +62 -0
- package/skill/references/integration/modules/code-examples/python/2-/347/275/221/347/253/231/346/224/257/344/273/230//347/273/237/344/270/200/346/224/266/345/215/225/344/270/213/345/215/225/345/271/266/346/224/257/344/273/230/351/241/265/351/235/242/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +48 -0
- package/skill/references/integration/modules/code-examples/python/3-APP/346/224/257/344/273/230/APP/346/224/257/344/273/230/346/216/245/345/217/243/344/273/243/347/240/201/347/244/272/344/276/213.md +43 -0
- package/skill/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.py +465 -0
- package/skill/references/integration/modules/interface-guide.md +90 -0
- package/skill/references/integration/modules/product-decision.md +90 -0
- package/skill/references/integration/modules/sandbox/a2m-sandbox-test.md +270 -0
- package/skill/references/integration/modules/sandbox/alipay-sandbox-tool.md +133 -0
- package/skill/references/integration/modules/sandbox/sandbox-setup-guide.md +218 -0
- package/skill/references/integration/modules/scripts/local_402_sandbox_pay.py +659 -0
- package/skill/references/normal/alipay-cli-env.md +214 -0
- package/skill/references/normal/rejection-guide.md +37 -0
- package/skill/references/normal/scripts/common.sh +32 -0
- package/skill/references/normal/scripts/detect_dev_tool.sh +46 -0
- package/skill/references/onboarding/flow.md +573 -0
- package/skill/references/onboarding/modules/app-release.md +415 -0
- package/skill/references/onboarding/modules/authorization.md +269 -0
- package/skill/references/onboarding/modules/error-handling.md +251 -0
- package/skill/references/onboarding/modules/mcc-reference.md +209 -0
- package/skill/references/onboarding/modules/product-sign.md +304 -0
- package/skill/references/onboarding/modules/scripts/app.sh +705 -0
- package/skill/references/onboarding/modules/scripts/ar_sign_apply.sh +248 -0
- package/skill/references/onboarding/modules/scripts/auth.sh +505 -0
- package/skill/references/onboarding/modules/scripts/error_handler.sh +452 -0
- package/skill/references/onboarding/modules/scripts/query_sign_status.sh +146 -0
- package/skill/references/onboarding/modules/scripts/service.sh +267 -0
- package/skill/references/onboarding/modules/scripts/upload_screenshots.sh +152 -0
- package/skill/references/onboarding/modules/service-registration.md +294 -0
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
# 统一收单交易关闭接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import json
|
|
7
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
8
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
9
|
+
from alipay.aop.api.request.AlipayTradeCloseRequest import AlipayTradeCloseRequest
|
|
10
|
+
from alipay.aop.api.domain.AlipayTradeCloseModel import AlipayTradeCloseModel
|
|
11
|
+
|
|
12
|
+
# 初始化SDK(Python 使用 PKCS#1 格式私钥,Java 使用 PKCS#8 格式,请勿混用)
|
|
13
|
+
config = AlipayClientConfig()
|
|
14
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
15
|
+
# 沙箱环境: config.server_url = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
|
|
16
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
17
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
18
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
19
|
+
config.charset = "utf-8"
|
|
20
|
+
config.sign_type = "RSA2"
|
|
21
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
22
|
+
|
|
23
|
+
request = AlipayTradeCloseRequest()
|
|
24
|
+
model = AlipayTradeCloseModel()
|
|
25
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER" # 商户订单号,与 trade_no 二选一
|
|
26
|
+
# model.trade_no = "ALIPAY_TRADE_NO_PLACEHOLDER" # 支付宝交易号,同时传时以 trade_no 为准
|
|
27
|
+
request.biz_model = model
|
|
28
|
+
|
|
29
|
+
response_content = client.execute(request)
|
|
30
|
+
response = json.loads(response_content)
|
|
31
|
+
result = response.get("alipay_trade_close_response", {})
|
|
32
|
+
|
|
33
|
+
if result.get("code") == "10000":
|
|
34
|
+
print("交易关闭成功")
|
|
35
|
+
else:
|
|
36
|
+
print(f"调用失败: {result.get('sub_code')} - {result.get('sub_msg')}")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 响应示例
|
|
40
|
+
### 正常示例
|
|
41
|
+
```json
|
|
42
|
+
{
|
|
43
|
+
"code": "10000",
|
|
44
|
+
"msg": "Success",
|
|
45
|
+
"trade_no": "ALIPAY_TRADE_NO_PLACEHOLDER",
|
|
46
|
+
"out_trade_no": "MERCHANT_ORDER_NO_PLACEHOLDER"
|
|
47
|
+
}
|
|
48
|
+
```
|
|
49
|
+
### 异常示例
|
|
50
|
+
```json
|
|
51
|
+
{
|
|
52
|
+
"code": "20000",
|
|
53
|
+
"msg": "Service Currently Unavailable",
|
|
54
|
+
"sub_code": "isp.unknow-error",
|
|
55
|
+
"sub_msg": "系统繁忙"
|
|
56
|
+
}
|
|
57
|
+
```
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
# 统一收单交易查询接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import json
|
|
7
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
8
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
9
|
+
from alipay.aop.api.request.AlipayTradeQueryRequest import AlipayTradeQueryRequest
|
|
10
|
+
from alipay.aop.api.domain.AlipayTradeQueryModel import AlipayTradeQueryModel
|
|
11
|
+
|
|
12
|
+
# 初始化SDK(Python 使用 PKCS#1 格式私钥,Java 使用 PKCS#8 格式,请勿混用)
|
|
13
|
+
config = AlipayClientConfig()
|
|
14
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
15
|
+
# 沙箱环境: config.server_url = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
|
|
16
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
17
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
18
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
19
|
+
config.charset = "utf-8"
|
|
20
|
+
config.sign_type = "RSA2"
|
|
21
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
22
|
+
|
|
23
|
+
request = AlipayTradeQueryRequest()
|
|
24
|
+
model = AlipayTradeQueryModel()
|
|
25
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER" # 商户订单号,与 trade_no 二选一
|
|
26
|
+
# model.trade_no = "ALIPAY_TRADE_NO_PLACEHOLDER" # 支付宝交易号,同时传时以 trade_no 为准
|
|
27
|
+
request.biz_model = model
|
|
28
|
+
|
|
29
|
+
response_content = client.execute(request)
|
|
30
|
+
response = json.loads(response_content)
|
|
31
|
+
result = response.get("alipay_trade_query_response", {})
|
|
32
|
+
|
|
33
|
+
if result.get("code") == "10000":
|
|
34
|
+
# trade_status: TRADE_SUCCESS/TRADE_FINISHED 表示支付成功,TRADE_CLOSED 表示已关闭
|
|
35
|
+
print(f"交易状态: {result.get('trade_status')}, 订单金额: {result.get('total_amount')}")
|
|
36
|
+
else:
|
|
37
|
+
print(f"调用失败: {result.get('sub_code')} - {result.get('sub_msg')}")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 响应示例
|
|
41
|
+
### 正常示例
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"code": "10000",
|
|
45
|
+
"msg": "Success",
|
|
46
|
+
"trade_no": "ALIPAY_TRADE_NO_PLACEHOLDER",
|
|
47
|
+
"out_trade_no": "MERCHANT_ORDER_NO_PLACEHOLDER",
|
|
48
|
+
"trade_status": "TRADE_SUCCESS",
|
|
49
|
+
"total_amount": "88.88",
|
|
50
|
+
"buyer_pay_amount": "8.88",
|
|
51
|
+
"receipt_amount": "15.25",
|
|
52
|
+
"buyer_logon_id": "159****5620",
|
|
53
|
+
"buyer_user_id": "<BUYER_USER_ID>",
|
|
54
|
+
"send_pay_date": "2014-11-27 15:45:57"
|
|
55
|
+
}
|
|
56
|
+
```
|
|
57
|
+
### 异常示例
|
|
58
|
+
```json
|
|
59
|
+
{
|
|
60
|
+
"code": "20000",
|
|
61
|
+
"msg": "Service Currently Unavailable",
|
|
62
|
+
"sub_code": "isp.unknow-error",
|
|
63
|
+
"sub_msg": "系统繁忙"
|
|
64
|
+
}
|
|
65
|
+
```
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
# 统一收单交易退款接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import json
|
|
7
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
8
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
9
|
+
from alipay.aop.api.request.AlipayTradeRefundRequest import AlipayTradeRefundRequest
|
|
10
|
+
from alipay.aop.api.domain.AlipayTradeRefundModel import AlipayTradeRefundModel
|
|
11
|
+
|
|
12
|
+
# 初始化SDK(Python 使用 PKCS#1 格式私钥,Java 使用 PKCS#8 格式,请勿混用)
|
|
13
|
+
config = AlipayClientConfig()
|
|
14
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
15
|
+
# 沙箱环境: config.server_url = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
|
|
16
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
17
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
18
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
19
|
+
config.charset = "utf-8"
|
|
20
|
+
config.sign_type = "RSA2"
|
|
21
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
22
|
+
|
|
23
|
+
request = AlipayTradeRefundRequest()
|
|
24
|
+
model = AlipayTradeRefundModel()
|
|
25
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER" # 商户订单号,与 trade_no 二选一
|
|
26
|
+
model.refund_amount = "200.12" # 退款金额,必填,单位为元
|
|
27
|
+
model.refund_reason = "正常退款" # 退款原因,选填
|
|
28
|
+
model.out_request_no = "OUT_REQUEST_NO_PLACEHOLDER" # 退款请求号,同一笔交易多次部分退款时必填且必须不同
|
|
29
|
+
request.biz_model = model
|
|
30
|
+
|
|
31
|
+
response_content = client.execute(request)
|
|
32
|
+
response = json.loads(response_content)
|
|
33
|
+
result = response.get("alipay_trade_refund_response", {})
|
|
34
|
+
|
|
35
|
+
if result.get("code") == "10000":
|
|
36
|
+
# fund_change: Y=发生了资金变化(退款成功),N=未发生资金变化
|
|
37
|
+
print(f"资金变化: {result.get('fund_change')}, 退款金额: {result.get('refund_fee')}")
|
|
38
|
+
else:
|
|
39
|
+
print(f"调用失败: {result.get('sub_code')} - {result.get('sub_msg')}")
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
## 响应示例
|
|
43
|
+
### 正常示例
|
|
44
|
+
```json
|
|
45
|
+
{
|
|
46
|
+
"code": "10000",
|
|
47
|
+
"msg": "Success",
|
|
48
|
+
"trade_no": "ALIPAY_TRADE_NO_PLACEHOLDER",
|
|
49
|
+
"out_trade_no": "MERCHANT_ORDER_NO_PLACEHOLDER",
|
|
50
|
+
"buyer_logon_id": "159****5620",
|
|
51
|
+
"fund_change": "Y",
|
|
52
|
+
"refund_fee": "88.88"
|
|
53
|
+
}
|
|
54
|
+
```
|
|
55
|
+
### 异常示例
|
|
56
|
+
```json
|
|
57
|
+
{
|
|
58
|
+
"code": "20000",
|
|
59
|
+
"msg": "Service Currently Unavailable",
|
|
60
|
+
"sub_code": "isp.unknow-error",
|
|
61
|
+
"sub_msg": "系统繁忙"
|
|
62
|
+
}
|
|
63
|
+
```
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
# 统一收单交易退款查询接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import json
|
|
7
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
8
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
9
|
+
from alipay.aop.api.request.AlipayTradeFastpayRefundQueryRequest import AlipayTradeFastpayRefundQueryRequest
|
|
10
|
+
from alipay.aop.api.domain.AlipayTradeFastpayRefundQueryModel import AlipayTradeFastpayRefundQueryModel
|
|
11
|
+
|
|
12
|
+
# 初始化SDK(Python 使用 PKCS#1 格式私钥,Java 使用 PKCS#8 格式,请勿混用)
|
|
13
|
+
config = AlipayClientConfig()
|
|
14
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
15
|
+
# 沙箱环境: config.server_url = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
|
|
16
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
17
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
18
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
19
|
+
config.charset = "utf-8"
|
|
20
|
+
config.sign_type = "RSA2"
|
|
21
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
22
|
+
|
|
23
|
+
request = AlipayTradeFastpayRefundQueryRequest()
|
|
24
|
+
model = AlipayTradeFastpayRefundQueryModel()
|
|
25
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER" # 商户订单号,与 trade_no 二选一
|
|
26
|
+
model.out_request_no = "OUT_REQUEST_NO_PLACEHOLDER" # 退款请求号,必填,同一笔交易多次部分退款时用于区分
|
|
27
|
+
request.biz_model = model
|
|
28
|
+
|
|
29
|
+
response_content = client.execute(request)
|
|
30
|
+
response = json.loads(response_content)
|
|
31
|
+
result = response.get("alipay_trade_fastpay_refund_query_response", {})
|
|
32
|
+
|
|
33
|
+
if result.get("code") == "10000":
|
|
34
|
+
# refund_status: REFUND_SUCCESS 表示退款成功,REFUND_PROCESSING 表示退款处理中
|
|
35
|
+
print(f"退款状态: {result.get('refund_status')}, 退款金额: {result.get('refund_amount')}")
|
|
36
|
+
else:
|
|
37
|
+
print(f"调用失败: {result.get('sub_code')} - {result.get('sub_msg')}")
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 响应示例
|
|
41
|
+
### 正常示例
|
|
42
|
+
```json
|
|
43
|
+
{
|
|
44
|
+
"code": "10000",
|
|
45
|
+
"msg": "Success",
|
|
46
|
+
"trade_no": "ALIPAY_TRADE_NO_PLACEHOLDER",
|
|
47
|
+
"out_trade_no": "MERCHANT_ORDER_NO_PLACEHOLDER",
|
|
48
|
+
"out_request_no": "OUT_REQUEST_NO_PLACEHOLDER",
|
|
49
|
+
"total_amount": "100.20",
|
|
50
|
+
"refund_amount": "12.33",
|
|
51
|
+
"refund_status": "REFUND_SUCCESS"
|
|
52
|
+
}
|
|
53
|
+
```
|
|
54
|
+
### 异常示例
|
|
55
|
+
```json
|
|
56
|
+
{
|
|
57
|
+
"code": "20000",
|
|
58
|
+
"msg": "Service Currently Unavailable",
|
|
59
|
+
"sub_code": "isp.unknow-error",
|
|
60
|
+
"sub_msg": "系统繁忙"
|
|
61
|
+
}
|
|
62
|
+
```
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
# 统一收单下单并支付页面接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
7
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
8
|
+
from alipay.aop.api.request.AlipayTradePagePayRequest import AlipayTradePagePayRequest
|
|
9
|
+
from alipay.aop.api.domain.AlipayTradePagePayModel import AlipayTradePagePayModel
|
|
10
|
+
|
|
11
|
+
# 初始化SDK(Python 使用 PKCS#1 格式私钥,Java 使用 PKCS#8 格式,请勿混用)
|
|
12
|
+
config = AlipayClientConfig()
|
|
13
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
14
|
+
# 沙箱环境: config.server_url = "https://openapi-sandbox.dl.alipaydev.com/gateway.do"
|
|
15
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
16
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
17
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
18
|
+
config.charset = "utf-8"
|
|
19
|
+
config.sign_type = "RSA2"
|
|
20
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
21
|
+
|
|
22
|
+
request = AlipayTradePagePayRequest()
|
|
23
|
+
request.notify_url = "https://your-domain.com/notify" # 异步通知地址,必须传入
|
|
24
|
+
request.return_url = "https://your-domain.com/return" # 同步跳转地址,必须传入
|
|
25
|
+
|
|
26
|
+
model = AlipayTradePagePayModel()
|
|
27
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER" # 商户订单号,必填
|
|
28
|
+
model.total_amount = "88.88" # 订单总金额,必填,单位为元
|
|
29
|
+
model.subject = "Iphone6 16G" # 订单标题,必填
|
|
30
|
+
model.product_code = "FAST_INSTANT_TRADE_PAY" # 网站支付固定值,必填
|
|
31
|
+
request.biz_model = model
|
|
32
|
+
|
|
33
|
+
# ⚠️ 网站支付必须使用 page_execute(),不能使用 execute()
|
|
34
|
+
# ⚠️ 使用 execute() 将无法获取支付表单,是最常见的集成错误
|
|
35
|
+
form_html = client.page_execute(request)
|
|
36
|
+
# page_execute 返回的是 HTML 表单字符串,前端需要渲染并自动提交
|
|
37
|
+
print(form_html)
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
## 响应示例
|
|
41
|
+
### 正常示例
|
|
42
|
+
```html
|
|
43
|
+
<form name="punchout_form" method="post" action="https://openapi.alipay.com/gateway.do?charset=UTF-8&method=alipay.trade.page.pay&format=json&sign=SIGN_PLACEHOLDER&version=1.0&app_id=20190xxxxxx&sign_type=RSA2×tamp=2014-07-24+03%3A07%3A50">
|
|
44
|
+
<input type="hidden" name="biz_content" value="{"out_trade_no":"MERCHANT_ORDER_NO_PLACEHOLDER","total_amount":"88.88","subject":"Iphone6 16G","product_code":"FAST_INSTANT_TRADE_PAY"}">
|
|
45
|
+
<input type="submit" value="立即支付" style="display:none" >
|
|
46
|
+
</form>
|
|
47
|
+
<script>document.forms[0].submit();</script>
|
|
48
|
+
```
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# APP支付接口 - Python 示例
|
|
2
|
+
|
|
3
|
+
## 请求示例
|
|
4
|
+
|
|
5
|
+
```python
|
|
6
|
+
import json
|
|
7
|
+
from alipay.aop.api.AlipayClientConfig import AlipayClientConfig
|
|
8
|
+
from alipay.aop.api.DefaultAlipayClient import DefaultAlipayClient
|
|
9
|
+
from alipay.aop.api.request.AlipayTradeAppPayRequest import AlipayTradeAppPayRequest
|
|
10
|
+
from alipay.aop.api.domain.AlipayTradeAppPayModel import AlipayTradeAppPayModel
|
|
11
|
+
|
|
12
|
+
# 初始化SDK
|
|
13
|
+
config = AlipayClientConfig()
|
|
14
|
+
config.server_url = "https://openapi.alipay.com/gateway.do"
|
|
15
|
+
config.app_id = "<-- 请填写您的AppId,例如:20190xxxxxx -->"
|
|
16
|
+
config.app_private_key = "<-- 请填写您的应用私钥,例如:MIIE...(脱敏示例) -->"
|
|
17
|
+
config.alipay_public_key = "<-- 请填写您的支付宝公钥,例如:MIIB...(脱敏示例) -->"
|
|
18
|
+
config.charset = "utf-8"
|
|
19
|
+
config.sign_type = "RSA2"
|
|
20
|
+
client = DefaultAlipayClient(alipay_client_config=config)
|
|
21
|
+
|
|
22
|
+
# 构造请求参数以调用接口
|
|
23
|
+
request = AlipayTradeAppPayRequest()
|
|
24
|
+
model = AlipayTradeAppPayModel()
|
|
25
|
+
|
|
26
|
+
model.out_trade_no = "MERCHANT_ORDER_NO_PLACEHOLDER"
|
|
27
|
+
model.total_amount = "9.00"
|
|
28
|
+
model.subject = "大乐透"
|
|
29
|
+
model.product_code = "QUICK_MSECURITY_PAY"
|
|
30
|
+
|
|
31
|
+
request.biz_model = model
|
|
32
|
+
# 第三方代调用模式下请设置app_auth_token
|
|
33
|
+
# request.add_other_text_param("app_auth_token", "<-- 请填写应用授权令牌 -->")
|
|
34
|
+
|
|
35
|
+
order_str = client.sdk_execute(request)
|
|
36
|
+
print(order_str)
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## 响应示例
|
|
40
|
+
### 正常示例
|
|
41
|
+
```
|
|
42
|
+
app_id=20190xxxxxx&biz_content=%7B%22time_expire%22%3A%222016-12-31+10%3A05%3A00%22%2C%22extend_params%22%3A%22%22%2C%22query_options%22%3A%22%5B%5C%22hyb_amount%5C%22%2C%5C%22enterprise_pay_info%5C%22%5D%22%2C%22subject%22%3A%22%E5%A4%A7%E4%B9%90%E9%80%8F%22%2C%22product_code%22%3A%22QUICK_MSECURITY_PAY%22%2C%22body%22%3A%22Iphone6+16G%22%2C%22passback_params%22%3A%22merchantBizType%253d3C%2526merchantBizNo%253dMERCHANT_BIZ_NO_PLACEHOLDER%22%2C%22specified_channel%22%3A%22pcredit%22%2C%22goods_detail%22%3A%22%22%2C%22merchant_order_no%22%3A%22MERCHANT_ORDER_NO_PLACEHOLDER%22%2C%22enable_pay_channels%22%3A%22pcredit%2CmoneyFund%2CdebitCardExpress%22%2C%22out_trade_no%22%3A%22MERCHANT_ORDER_NO_PLACEHOLDER%22%2C%22ext_user_info%22%3A%22%22%2C%22total_amount%22%3A%229.00%22%2C%22timeout_express%22%3A%2290m%22%2C%22disable_pay_channels%22%3A%22pcredit%2CmoneyFund%2CdebitCardExpress%22%2C%22agreement_sign_params%22%3A%22%22%7D&charset=UTF-8&format=json&method=alipay.trade.app.pay&sign=SIGN_PLACEHOLDER&sign_type=RSA2×tamp=2014-07-24+03%3A07%3A50&version=1.0
|
|
43
|
+
```
|