@alipay/alipay-aipay 1.0.2 → 1.2.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/dist/commands/install.d.ts.map +1 -1
- package/dist/commands/install.js +71 -22
- package/dist/commands/install.js.map +1 -1
- package/dist/commands/prepare-tools.d.ts.map +1 -1
- package/dist/commands/prepare-tools.js +16 -4
- package/dist/commands/prepare-tools.js.map +1 -1
- package/dist/commands/update.d.ts.map +1 -1
- package/dist/commands/update.js +9 -9
- package/dist/commands/update.js.map +1 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/utils/alipay-cli.d.ts +6 -0
- package/dist/utils/alipay-cli.d.ts.map +1 -1
- package/dist/utils/alipay-cli.js +38 -22
- package/dist/utils/alipay-cli.js.map +1 -1
- package/dist/utils/file.d.ts +9 -2
- package/dist/utils/file.d.ts.map +1 -1
- package/dist/utils/file.js +33 -3
- package/dist/utils/file.js.map +1 -1
- package/dist/utils/gpg.d.ts.map +1 -1
- package/dist/utils/gpg.js +97 -53
- package/dist/utils/gpg.js.map +1 -1
- package/dist/utils/jq.d.ts.map +1 -1
- package/dist/utils/jq.js +6 -9
- package/dist/utils/jq.js.map +1 -1
- package/dist/utils/npm.d.ts.map +1 -1
- package/dist/utils/npm.js +2 -6
- package/dist/utils/npm.js.map +1 -1
- package/dist/utils/shell.d.ts +15 -2
- package/dist/utils/shell.d.ts.map +1 -1
- package/dist/utils/shell.js +216 -12
- package/dist/utils/shell.js.map +1 -1
- package/package.json +3 -4
- package/skill/SKILL.md +77 -11
- package/skill/VERSION +1 -0
- package/skill/references/integration/flow.md +154 -136
- package/skill/references/integration/modules/alipay-sdk-reminder.md +29 -13
- package/skill/references/integration/modules/checklist.md +49 -19
- 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 +3 -3
- package/skill/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.cs +27 -13
- 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 +3 -3
- package/skill/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.java +31 -12
- 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 +5 -4
- package/skill/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.js +69 -37
- 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 +3 -3
- package/skill/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.php +38 -17
- 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 +3 -3
- package/skill/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.py +31 -18
- package/skill/references/integration/modules/interface-guide.md +7 -3
- package/skill/references/integration/modules/sandbox/a2m-sandbox-test.md +77 -48
- package/skill/references/integration/modules/sandbox/alipay-sandbox-tool.md +8 -5
- package/skill/references/integration/modules/sandbox/sandbox-setup-guide.md +157 -117
- package/skill/references/integration/modules/scripts/local_402_sandbox_pay.py +35 -4
- package/skill/references/normal/alipay-cli-env.md +13 -11
- package/skill/references/normal/self-update.md +59 -0
- package/skill/references/onboarding/flow.md +202 -282
- package/skill/references/onboarding/modules/app-release.md +91 -35
- package/skill/references/onboarding/modules/authorization.md +49 -22
- package/skill/references/onboarding/modules/error-handling.md +19 -14
- package/skill/references/onboarding/modules/product-sign.md +23 -20
- package/skill/references/onboarding/modules/scripts/app.sh +139 -40
- package/skill/references/onboarding/modules/scripts/auth.sh +183 -101
- package/skill/references/onboarding/modules/scripts/error_handler.sh +148 -18
- package/skill/references/onboarding/modules/scripts/query_sign_status.sh +17 -11
- package/skill/references/onboarding/modules/scripts/service.sh +208 -37
- package/skill/references/onboarding/modules/scripts/upload_screenshots.sh +1 -1
- package/skill/references/onboarding/modules/service-registration.md +72 -29
|
@@ -21,6 +21,7 @@ from urllib.parse import quote
|
|
|
21
21
|
|
|
22
22
|
PAY_ENDPOINT = "http://aicashier.dl.alipaydev.com/openclawpay/agent/v1/pay"
|
|
23
23
|
PAY_URL_PREFIX = "https://render.alipay.com/p/yuyan/180020010001290755/pay.html?schema="
|
|
24
|
+
A2M_SANDBOX_SERVICE_ID = "api_mock_service_id"
|
|
24
25
|
DEFAULT_PAYMENT_NEEDED_FILE = "/tmp/402_needed_file.txt"
|
|
25
26
|
DEFAULT_PAY_RETRIES = 3
|
|
26
27
|
DEFAULT_PAY_RETRY_DELAY_SECONDS = 2.0
|
|
@@ -462,6 +463,12 @@ def command_run(args: argparse.Namespace) -> int:
|
|
|
462
463
|
)
|
|
463
464
|
|
|
464
465
|
decoded_bill = b64decode_json(payment_needed)
|
|
466
|
+
method_data = decoded_bill.get("method") if isinstance(decoded_bill.get("method"), dict) else {}
|
|
467
|
+
if method_data.get("service_id") != A2M_SANDBOX_SERVICE_ID:
|
|
468
|
+
raise RuntimeError(
|
|
469
|
+
f"沙箱联调 method.service_id 必须为 {A2M_SANDBOX_SERVICE_ID},"
|
|
470
|
+
"请修正用户服务的沙箱运行配置后重试"
|
|
471
|
+
)
|
|
465
472
|
cashier_payload = build_cashier_payload(decoded_bill, buyer_id, args.buyer_signature)
|
|
466
473
|
|
|
467
474
|
(artifact_dir / "payment_needed.txt").write_text(payment_needed, encoding="utf-8")
|
|
@@ -514,12 +521,13 @@ def command_run(args: argparse.Namespace) -> int:
|
|
|
514
521
|
"errorMessage": pay_response.get("errorMessage"),
|
|
515
522
|
}
|
|
516
523
|
write_json(artifact_dir / "state.json", state)
|
|
524
|
+
retry_mode = " --auto-complete" if args.auto_complete else ""
|
|
517
525
|
raise RuntimeError(
|
|
518
526
|
"收银接口未返回 payScheme,无法生成付款链接。"
|
|
519
527
|
f"过程产物已保存:{artifact_dir}。"
|
|
520
528
|
"如果是 PAY_SUBMIT_FAILED/系统繁忙,可稍后复用同一个 Payment-Needed 重试:\n"
|
|
521
529
|
f"python3 {shell_quote(Path(__file__).resolve())} run "
|
|
522
|
-
f"--reuse-artifact {shell_quote(artifact_dir)}"
|
|
530
|
+
f"--reuse-artifact {shell_quote(artifact_dir)}{retry_mode}"
|
|
523
531
|
)
|
|
524
532
|
|
|
525
533
|
pay_url = pay_url_from_response(pay_response)
|
|
@@ -528,9 +536,24 @@ def command_run(args: argparse.Namespace) -> int:
|
|
|
528
536
|
state["tradeNo"] = trade_no
|
|
529
537
|
write_json(artifact_dir / "state.json", state)
|
|
530
538
|
|
|
539
|
+
print(f"\n过程产物目录:{artifact_dir}")
|
|
540
|
+
|
|
541
|
+
if args.auto_complete:
|
|
542
|
+
print("\n继续执行 Payment-Proof 服务端联调...")
|
|
543
|
+
complete_args = argparse.Namespace(
|
|
544
|
+
artifact_dir=str(artifact_dir),
|
|
545
|
+
payment_proof=args.payment_proof,
|
|
546
|
+
buyer_signature=args.buyer_signature,
|
|
547
|
+
)
|
|
548
|
+
result = command_complete(complete_args)
|
|
549
|
+
if result == 0:
|
|
550
|
+
print("\n按量付费沙箱服务端联调通过。")
|
|
551
|
+
print("\n沙箱付款体验链接(可选):")
|
|
552
|
+
print(pay_url)
|
|
553
|
+
return result
|
|
554
|
+
|
|
531
555
|
print("\n请在浏览器打开以下链接,并使用沙箱买家账号完成付款:")
|
|
532
556
|
print(pay_url)
|
|
533
|
-
print(f"\n过程产物目录:{artifact_dir}")
|
|
534
557
|
print("付款成功后运行:")
|
|
535
558
|
print(f"python3 {Path(__file__).resolve()} complete --artifact-dir {artifact_dir}")
|
|
536
559
|
|
|
@@ -619,7 +642,10 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
619
642
|
run_parser.add_argument("--reuse-artifact", help="复用上一轮 run 产物中的 url/method/body/content-type/payment_needed")
|
|
620
643
|
run_parser.add_argument("--pay-endpoint", default=PAY_ENDPOINT)
|
|
621
644
|
run_parser.add_argument("--artifact-dir", help="生成过程产物的目录")
|
|
622
|
-
run_parser.add_argument(
|
|
645
|
+
run_parser.add_argument(
|
|
646
|
+
"--payment-proof",
|
|
647
|
+
help="使用 --auto-complete 或 --wait 时可选的最终 payment_proof 值",
|
|
648
|
+
)
|
|
623
649
|
run_parser.add_argument("--pay-retries", type=int, default=DEFAULT_PAY_RETRIES, help="沙箱收银接口临时失败时的重试次数")
|
|
624
650
|
run_parser.add_argument(
|
|
625
651
|
"--pay-retry-delay",
|
|
@@ -628,12 +654,17 @@ def build_parser() -> argparse.ArgumentParser:
|
|
|
628
654
|
help="沙箱收银接口重试间隔秒数",
|
|
629
655
|
)
|
|
630
656
|
run_parser.add_argument("--dry-run", action="store_true", help="调用收银接口前停止")
|
|
657
|
+
run_parser.add_argument(
|
|
658
|
+
"--auto-complete",
|
|
659
|
+
action="store_true",
|
|
660
|
+
help="生成付款链接后连续携带 Payment-Proof 重试原始服务",
|
|
661
|
+
)
|
|
631
662
|
run_parser.add_argument("--wait", action="store_true", help="等待付款后立刻重试原始服务")
|
|
632
663
|
run_parser.set_defaults(func=command_run)
|
|
633
664
|
|
|
634
665
|
complete_parser = subparsers.add_parser("complete", help="携带 Payment-Proof 重试原始服务")
|
|
635
666
|
complete_parser.add_argument("--artifact-dir", required=True, help="run 命令生成的过程产物目录")
|
|
636
|
-
complete_parser.add_argument("--payment-proof", help="可选 payment_proof
|
|
667
|
+
complete_parser.add_argument("--payment-proof", help="可选 payment_proof;未传时由脚本按沙箱联调约定处理")
|
|
637
668
|
complete_parser.add_argument("--buyer-signature", help="买家签名占位值")
|
|
638
669
|
complete_parser.set_defaults(func=command_complete)
|
|
639
670
|
|
|
@@ -36,7 +36,7 @@ fi
|
|
|
36
36
|
- `alipay-cli login`、`alipay-cli whoami`、`alipay-cli logout`
|
|
37
37
|
- `alipay-cli mcp call ...`
|
|
38
38
|
- `alipay-cli file upload ...`
|
|
39
|
-
- `export ALIPAY_CLI_BIN="$HOME/.local/bin" && curl -fsSL https://opengw.alipay.com/alipaycli/install | bash`
|
|
39
|
+
- `export ALIPAY_CLI_BIN="$HOME/.local/bin" && curl -fsSL https://opengw.alipay.com/alipaycli/install | ALIPAY_CLI_SKIP_PGP=true ALIPAY_CLI_SKIP_VERIFY=true bash`
|
|
40
40
|
- 按量付费沙箱测试中会访问用户服务或沙箱收银接口的 `local_402_sandbox_pay.py`
|
|
41
41
|
|
|
42
42
|
**执行要求:**
|
|
@@ -55,20 +55,22 @@ fi
|
|
|
55
55
|
|
|
56
56
|
## 3. 前置依赖:GPG 与 jq
|
|
57
57
|
|
|
58
|
-
|
|
58
|
+
`npx -y @alipay/alipay-aipay@latest install` 会优先保障 `alipay-cli` 可用;如果 `alipay-cli` 已安装或可直接安装成功,不需要额外安装 GPG。
|
|
59
|
+
|
|
60
|
+
只有在 `alipay-cli` 首次安装失败,且失败输出指向缺少 GPG/GnuPG 时,后台准备任务才会把 GPG 作为兜底依赖检查:
|
|
59
61
|
```bash
|
|
60
62
|
which gpg 2>/dev/null
|
|
61
63
|
```
|
|
62
64
|
|
|
63
|
-
|
|
65
|
+
确认 GPG 未安装时,按系统安装:
|
|
64
66
|
|
|
65
67
|
| 操作系统 | 安装命令 |
|
|
66
68
|
|----------|----------|
|
|
67
|
-
| macOS | `brew install gnupg
|
|
69
|
+
| macOS | 优先执行 `brew install gnupg`;失败或卡住时配置 Homebrew bottle 镜像后重试 |
|
|
68
70
|
| Linux (Debian/Ubuntu) | `sudo apt-get install -y gnupg` |
|
|
69
71
|
| Linux (CentOS/RHEL) | `sudo yum install -y gnupg2` |
|
|
70
72
|
|
|
71
|
-
> ⚠️ macOS
|
|
73
|
+
> ⚠️ macOS 的 Homebrew 包名是 `gnupg`。安装器不会阻塞等待 GPG 安装;只有在 `alipay-cli` 缺失、首次安装失败且失败输出指向缺少 GPG/GnuPG 时,后台准备任务才会先使用 Homebrew 当前配置执行一次 `brew install gnupg`。如果默认安装失败或卡住,再并行探测清华、阿里云、中科大三个 bottle 镜像,选择最快可用镜像后用镜像重试一次。自动安装使用“无输出超时”:45 秒没有 stdout/stderr 输出才认为命令卡住;默认安装首轮最多 2 分钟,镜像兜底最多 8 分钟。
|
|
72
74
|
>
|
|
73
75
|
> 手动执行时可任选一个镜像源,例如清华:
|
|
74
76
|
> ```bash
|
|
@@ -125,7 +127,7 @@ jq --version
|
|
|
125
127
|
|
|
126
128
|
```bash
|
|
127
129
|
mkdir -p ~/.local/bin
|
|
128
|
-
export ALIPAY_CLI_BIN="$HOME/.local/bin" && curl -fsSL https://opengw.alipay.com/alipaycli/install | bash
|
|
130
|
+
export ALIPAY_CLI_BIN="$HOME/.local/bin" && curl -fsSL https://opengw.alipay.com/alipaycli/install | ALIPAY_CLI_SKIP_PGP=true ALIPAY_CLI_SKIP_VERIFY=true bash
|
|
129
131
|
```
|
|
130
132
|
|
|
131
133
|
### 4.2 PATH 处理
|
|
@@ -184,12 +186,12 @@ AI 编程工具检测使用通用脚本 `scripts/detect_dev_tool.sh`。shell 脚
|
|
|
184
186
|
│ ↓ │
|
|
185
187
|
│ 不存在 │
|
|
186
188
|
│ │ │
|
|
187
|
-
│ ↓
|
|
188
|
-
│ 检测 GPG ────┼──无→ 后台尝试安装 GPG → 安装 CLI 到 ~/.local/bin
|
|
189
|
-
│ ↓ │
|
|
190
|
-
│ 有 GPG │
|
|
191
|
-
│ ↓ │
|
|
189
|
+
│ ↓
|
|
192
190
|
│ 设置 ALIPAY_CLI_BIN="$HOME/.local/bin" 后执行安装脚本
|
|
191
|
+
│ ↓
|
|
192
|
+
│ 安装失败且提示缺少 GPG? ─┼──是→ 检测 GPG ──无→ 后台尝试安装 GPG(macOS 配置 bottle 镜像)
|
|
193
|
+
│ │ │
|
|
194
|
+
│ │ └──GPG 就绪后重试安装 CLI 到 ~/.local/bin
|
|
193
195
|
│ ↓ │
|
|
194
196
|
│ 安装失败? ───┼──是→ 提示指定可写目录手动安装
|
|
195
197
|
│ ↓ │
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# Skill 启动自更新检查
|
|
2
|
+
|
|
3
|
+
本文件定义 `alipay-aipay` Skill 启动时的自更新检查。该检查用于降低用户继续使用旧版 Skill 的概率,但不得阻断支付集成或签约入驻主流程。
|
|
4
|
+
|
|
5
|
+
## 执行原则
|
|
6
|
+
|
|
7
|
+
- 每次触发本 Skill 时,先执行本检查。
|
|
8
|
+
- 如果本轮对话中刚成功执行过 `npx -y @alipay/alipay-aipay@latest install`,或等价的 `@latest install --target ...` 命令,则视为自更新检查已完成,直接继续当前业务流程,不再查询 npm latest,也不再重复执行安装。
|
|
9
|
+
- 本检查不作为业务阻塞确认点,不单独询问用户是否更新。
|
|
10
|
+
- 若当前 Agent 环境要求联网或写入用户 Skill 目录授权,则按环境权限机制处理;不得在 Skill 内另设业务确认点。
|
|
11
|
+
- 任何读取版本、查询 npm、执行更新失败的情况,都只输出简短提示并继续当前业务流程。
|
|
12
|
+
- 更新命令必须使用 `--skip-tools`,只更新 Skill 文件,不重新检查或安装 GPG、alipay-cli、jq。
|
|
13
|
+
|
|
14
|
+
## 版本读取
|
|
15
|
+
|
|
16
|
+
1. 读取当前 `SKILL.md` 所在目录下的 `VERSION` 文件作为本地版本。
|
|
17
|
+
2. 如果 `VERSION` 不存在,或内容不是合法 SemVer 版本号(例如 `latest` 或 `v1`),将当前安装视为“未知版本/旧版安装”,直接进入「未知版本更新规则」,不要再猜测其他安装记录文件。
|
|
18
|
+
3. 如果成功读取本地版本,执行以下命令查询 npm latest:
|
|
19
|
+
```bash
|
|
20
|
+
npm view @alipay/alipay-aipay version --json
|
|
21
|
+
```
|
|
22
|
+
4. 如果无法获取 npm latest,跳过更新并继续当前业务流程。
|
|
23
|
+
|
|
24
|
+
## 更新规则
|
|
25
|
+
|
|
26
|
+
如果本地版本低于 npm latest,自动执行 Skill 更新。
|
|
27
|
+
|
|
28
|
+
更新命令必须覆盖当前正在使用的 Skill 目录。取当前 `SKILL.md` 所在目录的父目录作为 `<当前Skill父目录>`,执行:
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
ALIPAY_AIPAY_EXTRA_SKILL_DIRS="<当前Skill父目录>" npx -y @alipay/alipay-aipay@latest install --target all --skip-tools
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
说明:
|
|
35
|
+
- `ALIPAY_AIPAY_EXTRA_SKILL_DIRS` 确保当前正在使用的 Skill 父目录会被纳入更新目标,避免只更新当前项目目录下的 `.agents/.codex/.claude`。
|
|
36
|
+
- `--target all` 继续覆盖安装器解析到的全部目标目录。
|
|
37
|
+
- `--skip-tools` 避免在启动检查中触发 GPG、alipay-cli、jq 的检查或安装。
|
|
38
|
+
|
|
39
|
+
## 未知版本更新规则
|
|
40
|
+
|
|
41
|
+
如果当前 Skill 目录没有 `VERSION`,或 `VERSION` 内容不是合法 SemVer 版本号,不做不可靠的版本推断,直接执行同一条更新命令:
|
|
42
|
+
|
|
43
|
+
```bash
|
|
44
|
+
ALIPAY_AIPAY_EXTRA_SKILL_DIRS="<当前Skill父目录>" npx -y @alipay/alipay-aipay@latest install --target all --skip-tools
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
说明:
|
|
48
|
+
- 这是对旧版安装的确定性兼容路径;更新成功后,新安装器会写入 `VERSION`,后续启动即可走正常版本比较。
|
|
49
|
+
- 如果该命令因网络、npm、权限或执行环境限制失败,输出简短提示并继续当前业务流程。
|
|
50
|
+
|
|
51
|
+
## 输出要求
|
|
52
|
+
|
|
53
|
+
- 已是最新:输出一句简短提示即可。
|
|
54
|
+
- 发现新版本并开始更新:输出本地版本、npm latest 和更新目标摘要。
|
|
55
|
+
- 未知版本并开始更新:输出“未检测到 VERSION,尝试安装 latest”及更新目标摘要。
|
|
56
|
+
- 更新成功:提示更新已完成,并继续当前业务流程。
|
|
57
|
+
- 更新失败或权限受限:提示本次自更新未完成,继续使用当前已加载版本执行流程。
|
|
58
|
+
|
|
59
|
+
不得输出长篇安装日志;如需日志,以命令输出或工具环境记录为准。
|