@alipay/alipay-aipay 1.2.2 → 1.5.0

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.
Files changed (104) hide show
  1. package/README.md +5 -0
  2. package/dist/commands/install.d.ts.map +1 -1
  3. package/dist/commands/install.js +13 -12
  4. package/dist/commands/install.js.map +1 -1
  5. package/dist/commands/uninstall.d.ts.map +1 -1
  6. package/dist/commands/uninstall.js +17 -9
  7. package/dist/commands/uninstall.js.map +1 -1
  8. package/dist/commands/update.d.ts.map +1 -1
  9. package/dist/commands/update.js +5 -5
  10. package/dist/commands/update.js.map +1 -1
  11. package/dist/index.js +4 -4
  12. package/dist/index.js.map +1 -1
  13. package/dist/utils/config.d.ts +5 -3
  14. package/dist/utils/config.d.ts.map +1 -1
  15. package/dist/utils/config.js +34 -12
  16. package/dist/utils/config.js.map +1 -1
  17. package/dist/utils/file.d.ts +8 -0
  18. package/dist/utils/file.d.ts.map +1 -1
  19. package/dist/utils/file.js +161 -9
  20. package/dist/utils/file.js.map +1 -1
  21. package/dist/utils/jq.d.ts.map +1 -1
  22. package/dist/utils/jq.js +8 -0
  23. package/dist/utils/jq.js.map +1 -1
  24. package/package.json +9 -5
  25. package/skill/SKILL.md +15 -169
  26. package/skill/VERSION +1 -1
  27. package/skill/references/integration/flow.md +388 -291
  28. package/skill/references/integration/modules/alipay-sdk-reminder.md +5 -3
  29. package/skill/references/integration/modules/checklist.md +54 -32
  30. package/skill/references/integration/modules/code-examples/csharp/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +199 -0
  31. 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 +8 -4
  32. 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 +6 -2
  33. package/skill/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.cs +3 -1
  34. package/skill/references/integration/modules/code-examples/java/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +184 -0
  35. 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 +4 -1
  36. 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 +5 -2
  37. package/skill/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.java +3 -1
  38. package/skill/references/integration/modules/code-examples/nodejs/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +135 -0
  39. 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 +16 -10
  40. 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 +10 -4
  41. package/skill/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.js +2 -1
  42. package/skill/references/integration/modules/code-examples/php/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +157 -0
  43. 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 +4 -1
  44. 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 +5 -2
  45. package/skill/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.php +2 -1
  46. package/skill/references/integration/modules/code-examples/python/1-/351/200/232/347/224/250/346/216/245/345/217/243//345/274/202/346/255/245/351/200/232/347/237/245/345/244/204/347/220/206/344/273/243/347/240/201/347/244/272/344/276/213.md +128 -0
  47. 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 +4 -1
  48. 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 +5 -1
  49. package/skill/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.py +4 -2
  50. package/skill/references/integration/modules/interface-contract/aipay-interface-contract.md +52 -0
  51. package/skill/references/integration/modules/interface-contract/apppay-interface-contract.md +45 -0
  52. package/skill/references/integration/modules/interface-contract/common-trade-contract.md +42 -0
  53. package/skill/references/integration/modules/interface-contract/notify-url-contract.md +68 -0
  54. package/skill/references/integration/modules/interface-contract/webpay-interface-contract.md +44 -0
  55. package/skill/references/integration/modules/interface-guide.md +38 -71
  56. package/skill/references/integration/modules/product-decision.md +18 -35
  57. package/skill/references/integration/modules/sandbox/a2m-sandbox-test.md +62 -94
  58. package/skill/references/integration/modules/sandbox/alipay-sandbox-tool.md +43 -40
  59. package/skill/references/integration/modules/sandbox/sandbox-setup-guide.md +93 -114
  60. package/skill/references/integration/modules/scripts/local_402_sandbox_pay.py +358 -148
  61. package/skill/references/integration/modules/scripts/sandbox_config.sh +299 -0
  62. package/skill/references/integration/modules/troubleshooting-flow.md +28 -0
  63. package/skill/references/normal/alipay-cli-env.md +15 -5
  64. package/skill/references/normal/full-process-routing.md +82 -0
  65. package/skill/references/normal/json/customer-messages.json +942 -0
  66. package/skill/references/normal/json/policy-rules.json +179 -0
  67. package/skill/references/normal/rejection-guide.md +12 -7
  68. package/skill/references/normal/scripts/alipay_cli_env.mjs +33 -0
  69. package/skill/references/normal/scripts/alipay_cli_env.sh +55 -0
  70. package/skill/references/normal/scripts/common.sh +151 -0
  71. package/skill/references/normal/scripts/detect_dev_tool.sh +5 -1
  72. package/skill/references/normal/scripts/flow_loader.mjs +241 -0
  73. package/skill/references/normal/scripts/integration_context_runner.mjs +166 -0
  74. package/skill/references/normal/scripts/integration_message_runner.mjs +1023 -0
  75. package/skill/references/normal/scripts/interaction_reply.mjs +133 -0
  76. package/skill/references/normal/scripts/onboarding_discovery_runner.mjs +224 -0
  77. package/skill/references/normal/scripts/onboarding_message_runner.mjs +451 -0
  78. package/skill/references/normal/scripts/onboarding_recovery_runner.mjs +96 -0
  79. package/skill/references/normal/scripts/open_official_url.sh +82 -0
  80. package/skill/references/normal/scripts/platform_compat.mjs +39 -0
  81. package/skill/references/normal/scripts/project_route_inspector.sh +132 -0
  82. package/skill/references/normal/scripts/python_script_runner.mjs +56 -0
  83. package/skill/references/normal/scripts/render_customer_message.mjs +1288 -0
  84. package/skill/references/normal/scripts/self_update.mjs +160 -0
  85. package/skill/references/normal/scripts/telemetry.mjs +1327 -0
  86. package/skill/references/normal/self-update.md +18 -51
  87. package/skill/references/normal/telemetry.md +26 -0
  88. package/skill/references/onboarding/flow.md +421 -309
  89. package/skill/references/onboarding/modules/app-release.md +44 -438
  90. package/skill/references/onboarding/modules/authorization.md +25 -281
  91. package/skill/references/onboarding/modules/error-handling.md +31 -237
  92. package/skill/references/onboarding/modules/product-sign.md +25 -294
  93. package/skill/references/onboarding/modules/scripts/app.sh +445 -169
  94. package/skill/references/onboarding/modules/scripts/ar_sign_apply.sh +47 -28
  95. package/skill/references/onboarding/modules/scripts/auth.sh +484 -167
  96. package/skill/references/onboarding/modules/scripts/download_key_tool.sh +157 -0
  97. package/skill/references/onboarding/modules/scripts/error_handler.sh +101 -130
  98. package/skill/references/onboarding/modules/scripts/network_retry.sh +96 -0
  99. package/skill/references/onboarding/modules/scripts/query_sign_status.sh +20 -71
  100. package/skill/references/onboarding/modules/scripts/service.sh +154 -89
  101. package/skill/references/onboarding/modules/scripts/sign_status_parser.sh +58 -0
  102. package/skill/references/onboarding/modules/scripts/upload_screenshots.sh +34 -20
  103. package/skill/references/onboarding/modules/service-registration.md +20 -317
  104. package/skill/references/runtime-entry.md +63 -0
@@ -1,13 +1,13 @@
1
1
  #!/bin/bash
2
2
  #=============================================================================
3
3
  # 脚本名称: ar_sign_apply.sh
4
- # 功能描述: 提交产品签约申请,支持按量付费、网站支付、APP支付三种模式
4
+ # 功能描述: 提交产品签约申请,支持AI 按量付费、AI 网页应用收款、AI 移动应用收款三种模式
5
5
  # 调用位置: Step 5.1 产品签约
6
- # 调用前置: 脚本通过 error_handler.sh 间接初始化 DEV_TOOL_NAME;需传入 --sales-code 和 --mcc-code,或兼容使用同名环境变量
6
+ # 调用前置: 脚本通过 error_handler.sh 间接初始化 DEV_TOOL_NAME/PLATFORM_ID;需传入 --sales-code 和 --mcc-code,或兼容使用同名环境变量
7
7
  # 用法:
8
- # 按量付费: bash ar_sign_apply.sh --product aipay --sales-code <code> --mcc-code <code>
9
- # 网站支付: bash ar_sign_apply.sh --product webpay --sales-code <code> --mcc-code <code> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3>
10
- # APP支付: bash ar_sign_apply.sh --product apppay --sales-code <code> --mcc-code <code> --app-name <name> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3>
8
+ # AI 按量付费: bash ar_sign_apply.sh --product aipay --sales-code <code> --mcc-code <code>
9
+ # AI 网页应用收款: bash ar_sign_apply.sh --product webpay --sales-code <code> --mcc-code <code> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3>
10
+ # AI 移动应用收款: bash ar_sign_apply.sh --product apppay --sales-code <code> --mcc-code <code> --app-name <name> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3>
11
11
  # 返回值:
12
12
  # 成功: FLOW:AI_PAY_SIGN_CONTINUE | FLOW:PC_WEB_SIGN_CONTINUE | FLOW:APP_SIGN_CONTINUE
13
13
  # 失败: exit 1(由 handle_error 输出详细错误信息)
@@ -22,9 +22,11 @@ else
22
22
  echo "❌ 缺少错误处理脚本: ${SCRIPT_DIR}/error_handler.sh"
23
23
  exit 1
24
24
  fi
25
+ source "${SCRIPT_DIR}/network_retry.sh"
25
26
 
26
27
  require_command jq || exit 1
27
28
  require_command alipay-cli || exit 1
29
+
28
30
  if ! command -v python3 >/dev/null 2>&1 && ! command -v uuidgen >/dev/null 2>&1; then
29
31
  echo "❌ 缺少依赖命令: python3 或 uuidgen"
30
32
  exit 1
@@ -101,6 +103,9 @@ if [ -n "$PRODUCT_TYPE" ] && [ "$PRODUCT_TYPE" != "$EXPECTED_PRODUCT_TYPE" ]; th
101
103
  exit 1
102
104
  fi
103
105
 
106
+ PRODUCT_TYPE="${PRODUCT_TYPE:-$EXPECTED_PRODUCT_TYPE}"
107
+ init_alipay_cli_product "$PRODUCT_TYPE" || exit 1
108
+
104
109
  if [ -z "$BIZ_REQUEST_NO" ]; then
105
110
  echo "❌ 无法生成 bizRequestNo"
106
111
  exit 1
@@ -108,7 +113,7 @@ fi
108
113
 
109
114
  # 场景判断(精确比较而非子串匹配)
110
115
  if [ "$SALES_CODE" = "I1080300001000160457" ]; then
111
- # ============ 按量付费签约 JSON(无截图) ============
116
+ # ============ AI 按量付费签约 JSON(无截图) ============
112
117
  REQUEST_JSON=$(jq -n \
113
118
  --arg bizRequestNo "$BIZ_REQUEST_NO" \
114
119
  --arg mccCode "$MCC_CODE" \
@@ -128,13 +133,10 @@ if [ "$SALES_CODE" = "I1080300001000160457" ]; then
128
133
  ctx: {}
129
134
  }')
130
135
 
131
- RESULT=$(export PLATFORM=${DEV_TOOL_NAME} && alipay-cli mcp call ar-sign.apply \
132
- -d "$REQUEST_JSON" --json 2>/dev/null)
133
-
134
136
  elif [ "$SALES_CODE" = "I1080300001000041203" ]; then
135
- # ============ 网站支付签约 JSON(有截图) ============
137
+ # ============ AI 网页应用收款签约 JSON(有截图) ============
136
138
  if [ -z "$PICURL1" ] || [ -z "$PICURL2" ] || [ -z "$PICURL3" ]; then
137
- echo "❌ 网站支付需要 3 个上传后的图片引用值"
139
+ echo "❌ AI 网页应用收款需要 3 个上传后的图片引用值"
138
140
  exit 1
139
141
  fi
140
142
 
@@ -166,17 +168,14 @@ elif [ "$SALES_CODE" = "I1080300001000041203" ]; then
166
168
  ctx: {}
167
169
  }')
168
170
 
169
- RESULT=$(export PLATFORM=${DEV_TOOL_NAME} && alipay-cli mcp call ar-sign.apply \
170
- -d "$REQUEST_JSON" --json 2>/dev/null)
171
-
172
171
  elif [ "$SALES_CODE" = "I1080300001000041313" ]; then
173
- # ============ APP支付签约 JSON(有 APP 名称和截图) ============
172
+ # ============ AI 移动应用收款签约 JSON(有 APP 名称和截图) ============
174
173
  if [ -z "$PICURL1" ] || [ -z "$PICURL2" ] || [ -z "$PICURL3" ]; then
175
- echo "❌ APP支付需要 3 个上传后的图片引用值"
174
+ echo "❌ AI 移动应用收款需要 3 个上传后的图片引用值"
176
175
  exit 1
177
176
  fi
178
177
  if [ -z "$APP_NAME" ]; then
179
- echo "❌ APP支付需要 --app-name"
178
+ echo "❌ AI 移动应用收款需要 --app-name"
180
179
  exit 1
181
180
  fi
182
181
 
@@ -209,14 +208,33 @@ elif [ "$SALES_CODE" = "I1080300001000041313" ]; then
209
208
  ctx: {}
210
209
  }')
211
210
 
212
- RESULT=$(export PLATFORM=${DEV_TOOL_NAME} && alipay-cli mcp call ar-sign.apply \
213
- -d "$REQUEST_JSON" --json 2>/dev/null)
214
-
215
211
  else
216
212
  echo "❌ 未知 SALES_CODE: $SALES_CODE"
217
213
  exit 1
218
214
  fi
219
215
 
216
+ export PLATFORM="${DEV_TOOL_NAME}" PLATFORM_ID="${PLATFORM_ID:-}"
217
+ run_network_retry RESULT write sign_apply -- alipay-cli mcp call ar-sign.apply \
218
+ -d "$REQUEST_JSON" --json
219
+ RETRY_RC=$?
220
+ if [ "$RETRY_RC" -eq 75 ]; then
221
+ RECONCILE_OUTPUT=$(bash "${SCRIPT_DIR}/query_sign_status.sh" --sales-code "$SALES_CODE" --product-type "$PRODUCT_TYPE" 2>&1 || true)
222
+ RECONCILED_STATUS=$(printf '%s\n' "$RECONCILE_OUTPUT" | sed -n 's/^ALIPAY_AIPAY_INTERNAL:SIGN_STATUS=//p' | tail -1)
223
+ if [ "$RECONCILED_STATUS" = "SIGN_SUBMITTED" ] || [ "$RECONCILED_STATUS" = "SIGNED_EFFECTIVE" ]; then
224
+ case "$PRODUCT_TYPE" in
225
+ aipay) emit_control "FLOW:AI_PAY_SIGN_CONTINUE" ;;
226
+ webpay) emit_control "FLOW:PC_WEB_SIGN_CONTINUE" ;;
227
+ apppay) emit_control "FLOW:APP_SIGN_CONTINUE" ;;
228
+ esac
229
+ exit 0
230
+ fi
231
+ echo "❌ 签约提交响应不明且现有查询无法排除传播延迟,结果标记为 UNKNOWN,禁止自动重复提交"
232
+ exit 1
233
+ elif [ "$RETRY_RC" -ne 0 ]; then
234
+ echo "❌ 签约提交因明确未发送的网络异常在自动重试两次后仍未恢复"
235
+ exit 1
236
+ fi
237
+
220
238
  # 错误检测(先于业务解析,handle_error 内部会自动解包信封)
221
239
  if ! handle_error "$RESULT"; then
222
240
  exit 1
@@ -227,22 +245,23 @@ BUSINESS=$(unwrap_mcp "$RESULT")
227
245
  SUCCESS=$(echo "$BUSINESS" | jq -r '.success // false')
228
246
 
229
247
  if [ "$SUCCESS" = "true" ]; then
230
- echo "✅ 签约提交成功"
231
- echo "$BUSINESS" | jq '.resultObj // .data // {}'
248
+ emit_control "✅ 签约提交成功"
249
+ emit_control "SIGN_APPLY_STATUS=SUBMITTED"
232
250
  # 签约提交成功后无需等待审核,立即推进后续步骤
233
- # 按量付费: 继续 5.2 服务注册 → 5.3 应用发布
234
- # 网站支付/APP支付: 继续 5.3 应用发布
251
+ # AI 按量付费: 继续 5.2 服务注册 → 5.3 应用发布
252
+ # AI 网页应用收款/AI 移动应用收款: 继续 5.3 应用发布
235
253
  if [ "$SALES_CODE" = "I1080300001000160457" ]; then
236
- echo "FLOW:AI_PAY_SIGN_CONTINUE"
254
+ emit_control "FLOW:AI_PAY_SIGN_CONTINUE"
237
255
  elif [ "$SALES_CODE" = "I1080300001000041313" ]; then
238
- echo "FLOW:APP_SIGN_CONTINUE"
256
+ emit_control "FLOW:APP_SIGN_CONTINUE"
239
257
  else
240
- echo "FLOW:PC_WEB_SIGN_CONTINUE"
258
+ emit_control "FLOW:PC_WEB_SIGN_CONTINUE"
241
259
  fi
242
260
  else
243
261
  # handle_error 已处理 ERROR/CLI_ERROR 路径并透出详细错误信息
244
- # 此处为防御性兜底:handle_error 返回成功但 success=false 的极端场景
262
+ # 此处为防御性兜底:handle_error 返回成功但 success 非 true 的极端场景
245
263
  ERROR_MSG=$(echo "$BUSINESS" | jq -r '.error.message // .errorMessage // "未知错误"')
264
+ ERROR_MSG=$(sanitize_customer_error_text "$ERROR_MSG")
246
265
  echo "❌ 签约提交失败: $ERROR_MSG"
247
266
  exit 1
248
267
  fi