@alipay/alipay-aipay 1.7.0 → 1.7.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.
Files changed (169) hide show
  1. package/README.md +30 -0
  2. package/dist/commands/install-current.js +15 -7
  3. package/dist/commands/install.js +20 -16
  4. package/dist/commands/uninstall.js +8 -3
  5. package/dist/commands/update.js +34 -16
  6. package/dist/index.js +10 -4
  7. package/dist/utils/channels.js +67 -0
  8. package/dist/utils/config.js +15 -11
  9. package/dist/utils/file.js +23 -10
  10. package/dist/utils/npm.js +19 -33
  11. package/package.json +8 -3
  12. package/skill/SKILL.md +2 -0
  13. package/skill/references/normal/json/release-channel.json +1 -0
  14. package/skill/references/normal/scripts/self_update.mjs +62 -17
  15. package/skill/references/normal/self-update.md +3 -1
  16. package/skill-pre/SKILL.md +65 -0
  17. package/skill-pre/VERSION +1 -0
  18. package/skill-pre/references/integration/flow.md +602 -0
  19. package/skill-pre/references/integration/modules/alipay-sdk-reminder.md +281 -0
  20. package/skill-pre/references/integration/modules/checklist.md +154 -0
  21. package/skill-pre/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
  22. package/skill-pre/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
  23. package/skill-pre/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 +83 -0
  24. package/skill-pre/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 +80 -0
  25. package/skill-pre/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
  26. package/skill-pre/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 +62 -0
  27. package/skill-pre/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 +132 -0
  28. package/skill-pre/references/integration/modules/code-examples/csharp/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +640 -0
  29. package/skill-pre/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
  30. package/skill-pre/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
  31. package/skill-pre/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 +96 -0
  32. package/skill-pre/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 +81 -0
  33. package/skill-pre/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
  34. package/skill-pre/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 +69 -0
  35. package/skill-pre/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 +138 -0
  36. package/skill-pre/references/integration/modules/code-examples/java/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemoController.md +623 -0
  37. package/skill-pre/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
  38. package/skill-pre/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
  39. package/skill-pre/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 +63 -0
  40. package/skill-pre/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 +59 -0
  41. package/skill-pre/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
  42. package/skill-pre/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 +84 -0
  43. package/skill-pre/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 +71 -0
  44. package/skill-pre/references/integration/modules/code-examples/nodejs/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +498 -0
  45. package/skill-pre/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
  46. package/skill-pre/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
  47. package/skill-pre/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 +73 -0
  48. package/skill-pre/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 +69 -0
  49. package/skill-pre/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
  50. package/skill-pre/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 +59 -0
  51. package/skill-pre/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 +110 -0
  52. package/skill-pre/references/integration/modules/code-examples/php/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +806 -0
  53. package/skill-pre/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
  54. package/skill-pre/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
  55. package/skill-pre/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 +70 -0
  56. package/skill-pre/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 +65 -0
  57. package/skill-pre/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
  58. package/skill-pre/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 +51 -0
  59. package/skill-pre/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 +47 -0
  60. package/skill-pre/references/integration/modules/code-examples/python/4-/346/214/211/351/207/217/344/273/230/350/264/271/A2MPaymentDemo.md +541 -0
  61. package/skill-pre/references/integration/modules/interface-contract/aipay-interface-contract.md +52 -0
  62. package/skill-pre/references/integration/modules/interface-contract/apppay-interface-contract.md +45 -0
  63. package/skill-pre/references/integration/modules/interface-contract/common-trade-contract.md +42 -0
  64. package/skill-pre/references/integration/modules/interface-contract/notify-url-contract.md +68 -0
  65. package/skill-pre/references/integration/modules/interface-contract/webpay-interface-contract.md +44 -0
  66. package/skill-pre/references/integration/modules/interface-guide.md +61 -0
  67. package/skill-pre/references/integration/modules/product-decision.md +73 -0
  68. package/skill-pre/references/integration/modules/sandbox/a2m-sandbox-test.md +235 -0
  69. package/skill-pre/references/integration/modules/sandbox/alipay-sandbox-tool.md +142 -0
  70. package/skill-pre/references/integration/modules/sandbox/sandbox-setup-guide.md +239 -0
  71. package/skill-pre/references/integration/modules/scripts/local_402_sandbox_pay.py +900 -0
  72. package/skill-pre/references/integration/modules/scripts/sandbox_config.sh +347 -0
  73. package/skill-pre/references/integration/modules/troubleshooting-flow.md +28 -0
  74. package/skill-pre/references/normal/alipay-cli-env.md +169 -0
  75. package/skill-pre/references/normal/conversation-telemetry.md +101 -0
  76. package/skill-pre/references/normal/full-process-routing.md +92 -0
  77. package/skill-pre/references/normal/integration-worker.md +90 -0
  78. package/skill-pre/references/normal/json/customer-messages.json +1 -0
  79. package/skill-pre/references/normal/json/managed-jq-assets.json +1 -0
  80. package/skill-pre/references/normal/json/policy-rules.json +1 -0
  81. package/skill-pre/references/normal/json/release-channel.json +1 -0
  82. package/skill-pre/references/normal/rejection-guide.md +41 -0
  83. package/skill-pre/references/normal/scripts/agent_platform.mjs +43 -0
  84. package/skill-pre/references/normal/scripts/alipay_cli_env.mjs +34 -0
  85. package/skill-pre/references/normal/scripts/alipay_cli_env.sh +55 -0
  86. package/skill-pre/references/normal/scripts/alipay_cli_refresh.mjs +129 -0
  87. package/skill-pre/references/normal/scripts/auth_runtime_runner.mjs +60 -0
  88. package/skill-pre/references/normal/scripts/checklist_sections.mjs +43 -0
  89. package/skill-pre/references/normal/scripts/common.sh +365 -0
  90. package/skill-pre/references/normal/scripts/conversation_telemetry.mjs +105 -0
  91. package/skill-pre/references/normal/scripts/detect_dev_tool.sh +79 -0
  92. package/skill-pre/references/normal/scripts/flow_loader.mjs +237 -0
  93. package/skill-pre/references/normal/scripts/integration_context_runner.mjs +151 -0
  94. package/skill-pre/references/normal/scripts/integration_message_runner.mjs +1456 -0
  95. package/skill-pre/references/normal/scripts/interaction_reply.mjs +140 -0
  96. package/skill-pre/references/normal/scripts/managed_jq.mjs +215 -0
  97. package/skill-pre/references/normal/scripts/onboarding_discovery_runner.mjs +387 -0
  98. package/skill-pre/references/normal/scripts/onboarding_message_runner.mjs +1425 -0
  99. package/skill-pre/references/normal/scripts/onboarding_recovery_runner.mjs +100 -0
  100. package/skill-pre/references/normal/scripts/open_official_url.sh +205 -0
  101. package/skill-pre/references/normal/scripts/platform_compat.mjs +42 -0
  102. package/skill-pre/references/normal/scripts/preview_runtime.mjs +151 -0
  103. package/skill-pre/references/normal/scripts/project_route_inspector.sh +132 -0
  104. package/skill-pre/references/normal/scripts/python_script_runner.mjs +58 -0
  105. package/skill-pre/references/normal/scripts/render_customer_message.mjs +1792 -0
  106. package/skill-pre/references/normal/scripts/runtime.mjs +271 -0
  107. package/skill-pre/references/normal/scripts/self_update.mjs +376 -0
  108. package/skill-pre/references/normal/scripts/telemetry.mjs +2102 -0
  109. package/skill-pre/references/normal/self-update.md +7 -0
  110. package/skill-pre/references/normal/telemetry.md +70 -0
  111. package/skill-pre/references/onboarding/assets/keygen.html +927 -0
  112. package/skill-pre/references/onboarding/flow.md +607 -0
  113. package/skill-pre/references/onboarding/modules/app-release.md +90 -0
  114. package/skill-pre/references/onboarding/modules/authorization.md +43 -0
  115. package/skill-pre/references/onboarding/modules/error-handling.md +62 -0
  116. package/skill-pre/references/onboarding/modules/product-sign.md +49 -0
  117. package/skill-pre/references/onboarding/modules/scripts/app.sh +1485 -0
  118. package/skill-pre/references/onboarding/modules/scripts/ar_sign_apply.sh +331 -0
  119. package/skill-pre/references/onboarding/modules/scripts/auth.sh +1040 -0
  120. package/skill-pre/references/onboarding/modules/scripts/download_key_tool.sh +4 -0
  121. package/skill-pre/references/onboarding/modules/scripts/error_handler.sh +841 -0
  122. package/skill-pre/references/onboarding/modules/scripts/mcc.sh +1085 -0
  123. package/skill-pre/references/onboarding/modules/scripts/network_retry.sh +135 -0
  124. package/skill-pre/references/onboarding/modules/scripts/query_sign_status.sh +105 -0
  125. package/skill-pre/references/onboarding/modules/scripts/service.sh +528 -0
  126. package/skill-pre/references/onboarding/modules/scripts/sign_status_parser.sh +58 -0
  127. package/skill-pre/references/onboarding/modules/scripts/upload_screenshots.sh +208 -0
  128. package/skill-pre/references/onboarding/modules/scripts/upload_special_license.sh +195 -0
  129. package/skill-pre/references/onboarding/modules/service-registration.md +40 -0
  130. package/skill-pre/references/runtime-entry.md +99 -0
  131. package/dist/commands/install-current.d.ts +0 -4
  132. package/dist/commands/install-current.d.ts.map +0 -1
  133. package/dist/commands/install-current.js.map +0 -1
  134. package/dist/commands/install.d.ts +0 -10
  135. package/dist/commands/install.d.ts.map +0 -1
  136. package/dist/commands/install.js.map +0 -1
  137. package/dist/commands/prepare-tools.d.ts +0 -5
  138. package/dist/commands/prepare-tools.d.ts.map +0 -1
  139. package/dist/commands/prepare-tools.js.map +0 -1
  140. package/dist/commands/uninstall.d.ts +0 -10
  141. package/dist/commands/uninstall.d.ts.map +0 -1
  142. package/dist/commands/uninstall.js.map +0 -1
  143. package/dist/commands/update.d.ts +0 -10
  144. package/dist/commands/update.d.ts.map +0 -1
  145. package/dist/commands/update.js.map +0 -1
  146. package/dist/index.d.ts +0 -2
  147. package/dist/index.d.ts.map +0 -1
  148. package/dist/index.js.map +0 -1
  149. package/dist/types.d.ts +0 -42
  150. package/dist/types.d.ts.map +0 -1
  151. package/dist/types.js.map +0 -1
  152. package/dist/utils/alipay-cli.d.ts +0 -20
  153. package/dist/utils/alipay-cli.d.ts.map +0 -1
  154. package/dist/utils/alipay-cli.js.map +0 -1
  155. package/dist/utils/config.d.ts +0 -52
  156. package/dist/utils/config.d.ts.map +0 -1
  157. package/dist/utils/config.js.map +0 -1
  158. package/dist/utils/file.d.ts +0 -77
  159. package/dist/utils/file.d.ts.map +0 -1
  160. package/dist/utils/file.js.map +0 -1
  161. package/dist/utils/jq.d.ts +0 -17
  162. package/dist/utils/jq.d.ts.map +0 -1
  163. package/dist/utils/jq.js.map +0 -1
  164. package/dist/utils/npm.d.ts +0 -17
  165. package/dist/utils/npm.d.ts.map +0 -1
  166. package/dist/utils/npm.js.map +0 -1
  167. package/dist/utils/shell.d.ts +0 -24
  168. package/dist/utils/shell.d.ts.map +0 -1
  169. package/dist/utils/shell.js.map +0 -1
@@ -0,0 +1,331 @@
1
+ #!/bin/bash
2
+ #=============================================================================
3
+ # 脚本名称: ar_sign_apply.sh
4
+ # 功能描述: 提交产品签约申请,支持AI 按量付费、AI 网页应用收款、AI 移动应用收款三种模式
5
+ # 调用位置: Step 5.1 产品签约
6
+ # 调用前置: 脚本通过 error_handler.sh 间接初始化 DEV_TOOL_NAME/PLATFORM_ID;需传入 --sales-code 和 --mcc-code,或兼容使用同名环境变量
7
+ # 用法:
8
+ # AI 按量付费: bash ar_sign_apply.sh --product aipay --sales-code <code> --mcc-code <code> --mcc-context-receipt <receipt> [--special-qualification-group-index <1-based> --special-license-json <json>]
9
+ # AI 网页应用收款: bash ar_sign_apply.sh --product webpay --sales-code <code> --mcc-code <code> --mcc-context-receipt <receipt> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3> [--special-qualification-group-index <1-based> --special-license-json <json>]
10
+ # AI 移动应用收款: bash ar_sign_apply.sh --product apppay --sales-code <code> --mcc-code <code> --mcc-context-receipt <receipt> --app-name <name> --picurl1 <imageRef1> --picurl2 <imageRef2> --picurl3 <imageRef3> [--special-qualification-group-index <1-based> --special-license-json <json>]
11
+ # 返回值:
12
+ # 成功: FLOW:AI_PAY_SIGN_CONTINUE | FLOW:PC_WEB_SIGN_CONTINUE | FLOW:APP_SIGN_CONTINUE
13
+ # 失败: exit 1(由 handle_error 输出详细错误信息)
14
+ #=============================================================================
15
+
16
+ SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
17
+
18
+ # 一次性 source error_handler(含 unwrap_mcp)
19
+ if [ -f "${SCRIPT_DIR}/error_handler.sh" ]; then
20
+ source "${SCRIPT_DIR}/error_handler.sh"
21
+ else
22
+ echo "❌ 缺少错误处理脚本: ${SCRIPT_DIR}/error_handler.sh"
23
+ exit 1
24
+ fi
25
+ source "${SCRIPT_DIR}/network_retry.sh"
26
+
27
+ require_command jq || exit 1
28
+ require_command alipay-cli || exit 1
29
+
30
+ if ! command -v python3 >/dev/null 2>&1 && ! command -v uuidgen >/dev/null 2>&1; then
31
+ echo "❌ 缺少依赖命令: python3 或 uuidgen"
32
+ exit 1
33
+ fi
34
+
35
+ # 生成 UUID 作为 bizRequestNo
36
+ BIZ_REQUEST_NO=$(python3 -c "import uuid; print(uuid.uuid4())" 2>/dev/null || uuidgen | tr '[:upper:]' '[:lower:]')
37
+
38
+ # 优先使用 --product 参数,未传时从环境变量继承
39
+ PRODUCT_TYPE="${PRODUCT_TYPE:-}"
40
+ PICURL1=""
41
+ PICURL2=""
42
+ PICURL3=""
43
+ APP_NAME=""
44
+ MCC_CONTEXT_RECEIPT=""
45
+ SPECIAL_QUALIFICATION_GROUP_INDEX=""
46
+ SPECIAL_LICENSE_JSON='[]'
47
+
48
+ # 解析参数
49
+ while [[ $# -gt 0 ]]; do
50
+ case $1 in
51
+ --product)
52
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
53
+ PRODUCT_TYPE="$2"; shift 2 ;;
54
+ --sales-code)
55
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
56
+ SALES_CODE="$2"; shift 2 ;;
57
+ --mcc-code)
58
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
59
+ MCC_CODE="$2"; shift 2 ;;
60
+ --mcc-context-receipt)
61
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
62
+ MCC_CONTEXT_RECEIPT="$2"; shift 2 ;;
63
+ --special-qualification-group-index)
64
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
65
+ SPECIAL_QUALIFICATION_GROUP_INDEX="$2"; shift 2 ;;
66
+ --picurl1)
67
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
68
+ PICURL1="$2"; shift 2 ;;
69
+ --picurl2)
70
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
71
+ PICURL2="$2"; shift 2 ;;
72
+ --picurl3)
73
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
74
+ PICURL3="$2"; shift 2 ;;
75
+ --app-name)
76
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
77
+ APP_NAME="$2"; shift 2 ;;
78
+ --special-license-json)
79
+ [ $# -ge 2 ] || { echo "❌ 缺少参数值: $1"; exit 1; }
80
+ SPECIAL_LICENSE_JSON="$2"; shift 2 ;;
81
+ *)
82
+ echo "❌ 未知参数: $1"; exit 1 ;;
83
+ esac
84
+ done
85
+
86
+ if [ -z "$SALES_CODE" ] || [ -z "$MCC_CODE" ]; then
87
+ echo "❌ 缺少必需参数(请传入 --sales-code 和 --mcc-code,或设置 SALES_CODE/MCC_CODE 环境变量)"
88
+ exit 1
89
+ fi
90
+ if [ -z "$MCC_CONTEXT_RECEIPT" ]; then
91
+ echo "❌ 签约提交必须绑定本轮 MCC_CONTEXT_RECEIPT"
92
+ exit 1
93
+ fi
94
+ if [ -n "$SPECIAL_QUALIFICATION_GROUP_INDEX" ] && ! [[ "$SPECIAL_QUALIFICATION_GROUP_INDEX" =~ ^[1-9][0-9]*$ ]]; then
95
+ echo "❌ 特殊资质组合序号必须是从 1 开始的整数"
96
+ exit 1
97
+ fi
98
+
99
+ if [ -n "$PRODUCT_TYPE" ] && [ "$PRODUCT_TYPE" != "aipay" ] && [ "$PRODUCT_TYPE" != "webpay" ] && [ "$PRODUCT_TYPE" != "apppay" ]; then
100
+ echo "❌ --product 参数值无效: ${PRODUCT_TYPE}(仅支持 aipay|webpay|apppay)"
101
+ exit 1
102
+ fi
103
+
104
+ case "$SALES_CODE" in
105
+ "I1080300001000160457")
106
+ EXPECTED_PRODUCT_TYPE="aipay"
107
+ ;;
108
+ "I1080300001000041203")
109
+ EXPECTED_PRODUCT_TYPE="webpay"
110
+ ;;
111
+ "I1080300001000041313")
112
+ EXPECTED_PRODUCT_TYPE="apppay"
113
+ ;;
114
+ *)
115
+ echo "❌ 未知 SALES_CODE: $SALES_CODE"
116
+ exit 1
117
+ ;;
118
+ esac
119
+
120
+ if [ -n "$PRODUCT_TYPE" ] && [ "$PRODUCT_TYPE" != "$EXPECTED_PRODUCT_TYPE" ]; then
121
+ echo "❌ --product 与 SALES_CODE 不匹配:--product=${PRODUCT_TYPE}, SALES_CODE=${SALES_CODE}"
122
+ echo "📋 期望 --product=${EXPECTED_PRODUCT_TYPE}"
123
+ exit 1
124
+ fi
125
+
126
+ PRODUCT_TYPE="${PRODUCT_TYPE:-$EXPECTED_PRODUCT_TYPE}"
127
+ init_alipay_cli_product "$PRODUCT_TYPE" || exit 1
128
+
129
+ if [ -z "$BIZ_REQUEST_NO" ]; then
130
+ echo "❌ 无法生成 bizRequestNo"
131
+ exit 1
132
+ fi
133
+
134
+ if ! printf '%s' "$SPECIAL_LICENSE_JSON" | jq -e '
135
+ def safe_text:
136
+ type == "string" and length > 0 and all(explode[]; . >= 32 and . != 127);
137
+ type == "array" and
138
+ all(.[]; (type == "object") and
139
+ (.licenseType | safe_text) and
140
+ (.licensePic | safe_text) and
141
+ ((keys - ["licenseType","licensePic"]) | length == 0)
142
+ )
143
+ ' >/dev/null 2>&1; then
144
+ echo "❌ 特殊资质 specialLicense 必须是 [{licenseType, licensePic}] 数组,licensePic 使用上传返回的图片引用值"
145
+ exit 1
146
+ fi
147
+
148
+ SPECIAL_CONTEXT_JSON=$(jq -cn \
149
+ --arg productType "$PRODUCT_TYPE" \
150
+ --arg salesCode "$SALES_CODE" \
151
+ --arg mccCode "$MCC_CODE" \
152
+ --arg mccContextReceipt "$MCC_CONTEXT_RECEIPT" \
153
+ --arg qualificationGroupIndex "$SPECIAL_QUALIFICATION_GROUP_INDEX" \
154
+ --argjson specialLicense "$SPECIAL_LICENSE_JSON" \
155
+ '{
156
+ productType: $productType,
157
+ salesCode: $salesCode,
158
+ mccCode: $mccCode,
159
+ mccContextReceipt: $mccContextReceipt,
160
+ qualificationGroupIndex: $qualificationGroupIndex,
161
+ specialLicense: $specialLicense
162
+ }') || exit 1
163
+ if ! printf '%s' "$SPECIAL_CONTEXT_JSON" | node "$ERROR_RENDERER" --validate-signing-special-license-context >/dev/null 2>&1; then
164
+ echo "❌ 特殊资质与本轮 MCC 上下文或所选资质组合不一致,已停止签约提交"
165
+ exit 1
166
+ fi
167
+
168
+ # 场景判断(精确比较而非子串匹配)
169
+ if [ "$SALES_CODE" = "I1080300001000160457" ]; then
170
+ # ============ AI 按量付费签约 JSON(无截图) ============
171
+ REQUEST_JSON=$(jq -n \
172
+ --arg bizRequestNo "$BIZ_REQUEST_NO" \
173
+ --arg mccCode "$MCC_CODE" \
174
+ --arg salesCode "$SALES_CODE" \
175
+ --argjson specialLicense "$SPECIAL_LICENSE_JSON" \
176
+ '{
177
+ request: {
178
+ bizFeatures: {},
179
+ bizRequestNo: $bizRequestNo,
180
+ businessProperty: ({mccCode: $mccCode} + (if ($specialLicense | length) > 0 then {specialLicense: $specialLicense} else {} end)),
181
+ channelCode: "B_SK_SH_RPC",
182
+ extension: {},
183
+ orderType: "NEW_SIGN",
184
+ salesProductCodes: [$salesCode]
185
+ },
186
+ ctx: {}
187
+ }')
188
+
189
+ elif [ "$SALES_CODE" = "I1080300001000041203" ]; then
190
+ # ============ AI 网页应用收款签约 JSON(有截图) ============
191
+ if [ -z "$PICURL1" ] || [ -z "$PICURL2" ] || [ -z "$PICURL3" ]; then
192
+ echo "❌ AI 网页应用收款需要 3 个上传后的图片引用值"
193
+ exit 1
194
+ fi
195
+
196
+ REQUEST_JSON=$(jq -n \
197
+ --arg bizRequestNo "$BIZ_REQUEST_NO" \
198
+ --arg mccCode "$MCC_CODE" \
199
+ --arg salesCode "$SALES_CODE" \
200
+ --arg picUrl1 "$PICURL1" \
201
+ --arg picUrl2 "$PICURL2" \
202
+ --arg picUrl3 "$PICURL3" \
203
+ --argjson specialLicense "$SPECIAL_LICENSE_JSON" \
204
+ '{
205
+ request: {
206
+ bizFeatures: {},
207
+ bizRequestNo: $bizRequestNo,
208
+ businessProperty: ({mccCode: $mccCode} + (if ($specialLicense | length) > 0 then {specialLicense: $specialLicense} else {} end) + {
209
+ webAppDTO: {
210
+ placeType: "ONLINE_WEBAPP",
211
+ appType: "PC_WEB",
212
+ appStatus: "OFFLINE",
213
+ screenshot: [$picUrl1, $picUrl2, $picUrl3]
214
+ }
215
+ }),
216
+ channelCode: "B_SK_SH_RPC",
217
+ extension: {},
218
+ orderType: "NEW_SIGN",
219
+ salesProductCodes: [$salesCode]
220
+ },
221
+ ctx: {}
222
+ }')
223
+
224
+ elif [ "$SALES_CODE" = "I1080300001000041313" ]; then
225
+ # ============ AI 移动应用收款签约 JSON(有 APP 名称和截图) ============
226
+ if [ -z "$PICURL1" ] || [ -z "$PICURL2" ] || [ -z "$PICURL3" ]; then
227
+ echo "❌ AI 移动应用收款需要 3 个上传后的图片引用值"
228
+ exit 1
229
+ fi
230
+ if [ -z "$APP_NAME" ]; then
231
+ echo "❌ AI 移动应用收款需要 --app-name"
232
+ exit 1
233
+ fi
234
+
235
+ REQUEST_JSON=$(jq -n \
236
+ --arg bizRequestNo "$BIZ_REQUEST_NO" \
237
+ --arg mccCode "$MCC_CODE" \
238
+ --arg salesCode "$SALES_CODE" \
239
+ --arg appName "$APP_NAME" \
240
+ --arg picUrl1 "$PICURL1" \
241
+ --arg picUrl2 "$PICURL2" \
242
+ --arg picUrl3 "$PICURL3" \
243
+ --argjson specialLicense "$SPECIAL_LICENSE_JSON" \
244
+ '{
245
+ request: {
246
+ bizFeatures: {},
247
+ bizRequestNo: $bizRequestNo,
248
+ businessProperty: ({mccCode: $mccCode} + (if ($specialLicense | length) > 0 then {specialLicense: $specialLicense} else {} end) + {
249
+ nativeAppDTO: {
250
+ placeType: "ONLINE_NATIVEYAPP",
251
+ name: $appName,
252
+ appStatus: "OFFLINE",
253
+ screenshot: [$picUrl1, $picUrl2, $picUrl3]
254
+ }
255
+ }),
256
+ channelCode: "B_SK_SH_RPC",
257
+ extension: {},
258
+ orderType: "NEW_SIGN",
259
+ salesProductCodes: [$salesCode]
260
+ },
261
+ ctx: {}
262
+ }')
263
+
264
+ else
265
+ echo "❌ 未知 SALES_CODE: $SALES_CODE"
266
+ exit 1
267
+ fi
268
+
269
+ require_alipay_cli_local_state_access_or_emit || exit "$?"
270
+ export PLATFORM="${DEV_TOOL_NAME}" PLATFORM_ID="${PLATFORM_ID:-}"
271
+ run_network_retry RESULT write sign_apply -- alipay-cli mcp call ar-sign.apply \
272
+ -d "$REQUEST_JSON" --json
273
+ RETRY_RC=$?
274
+ if [ "$RETRY_RC" -eq 75 ]; then
275
+ RECONCILE_OUTPUT=$(ALIPAY_AIPAY_SUPPRESS_LOCAL_FS_RETRY_MARKER=1 bash "${SCRIPT_DIR}/query_sign_status.sh" --sales-code "$SALES_CODE" --product-type "$PRODUCT_TYPE" 2>&1 || true)
276
+ RECONCILED_STATUS=$(printf '%s\n' "$RECONCILE_OUTPUT" | sed -n 's/^ALIPAY_AIPAY_INTERNAL:SIGN_STATUS=//p' | tail -1)
277
+ if [ "$RECONCILED_STATUS" = "SIGN_SUBMITTED" ] || [ "$RECONCILED_STATUS" = "SIGNED_EFFECTIVE" ]; then
278
+ emit_control "SIGN_APPLY_RESULT=SUCCESS"
279
+ emit_stage_metric "onboarding.confirm_signing"
280
+ case "$PRODUCT_TYPE" in
281
+ aipay) emit_control "FLOW:AI_PAY_SIGN_CONTINUE" ;;
282
+ webpay) emit_control "FLOW:PC_WEB_SIGN_CONTINUE" ;;
283
+ apppay) emit_control "FLOW:APP_SIGN_CONTINUE" ;;
284
+ esac
285
+ exit 0
286
+ fi
287
+ echo "❌ 签约提交响应不明且现有查询无法排除传播延迟,结果标记为 UNKNOWN,禁止自动重复提交"
288
+ emit_control "SIGN_APPLY_RESULT=UNKNOWN"
289
+ exit 1
290
+ elif [ "$RETRY_RC" -eq "${ALIPAY_CLI_LOCAL_STATE_PERMISSION_EXIT_CODE:-77}" ]; then
291
+ exit "$RETRY_RC"
292
+ elif [ "$RETRY_RC" -ne 0 ]; then
293
+ echo "❌ 签约提交因明确未发送的网络异常在自动重试两次后仍未恢复"
294
+ emit_control "SIGN_APPLY_RESULT=FAILED"
295
+ exit 1
296
+ fi
297
+
298
+ # 错误检测(先于业务解析,handle_error 内部会自动解包信封)
299
+ if ! handle_error "$RESULT" "MCP_AUTHENTICATED_CALL"; then
300
+ emit_control "SIGN_APPLY_RESULT=FAILED"
301
+ exit 1
302
+ fi
303
+
304
+ # 解包 MCP 信封后解析业务字段
305
+ BUSINESS=$(unwrap_mcp "$RESULT")
306
+ SUCCESS=$(echo "$BUSINESS" | jq -r '.success // false')
307
+
308
+ if [ "$SUCCESS" = "true" ]; then
309
+ emit_control "✅ 签约提交成功"
310
+ emit_control "SIGN_APPLY_STATUS=SUBMITTED"
311
+ emit_control "SIGN_APPLY_RESULT=SUCCESS"
312
+ emit_stage_metric "onboarding.confirm_signing"
313
+ # 签约提交成功后无需等待审核,立即推进后续步骤
314
+ # AI 按量付费: 继续 5.2 服务注册 → 5.3 应用发布
315
+ # AI 网页应用收款/AI 移动应用收款: 继续 5.3 应用发布
316
+ if [ "$SALES_CODE" = "I1080300001000160457" ]; then
317
+ emit_control "FLOW:AI_PAY_SIGN_CONTINUE"
318
+ elif [ "$SALES_CODE" = "I1080300001000041313" ]; then
319
+ emit_control "FLOW:APP_SIGN_CONTINUE"
320
+ else
321
+ emit_control "FLOW:PC_WEB_SIGN_CONTINUE"
322
+ fi
323
+ else
324
+ # handle_error 已处理 ERROR/CLI_ERROR 路径并透出详细错误信息
325
+ # 此处为防御性兜底:handle_error 返回成功但 success 非 true 的极端场景
326
+ ERROR_MSG=$(echo "$BUSINESS" | jq -r '.error.message // .errorMessage // "未知错误"')
327
+ ERROR_MSG=$(sanitize_customer_error_text "$ERROR_MSG")
328
+ echo "❌ 签约提交失败: $ERROR_MSG"
329
+ emit_control "SIGN_APPLY_RESULT=FAILED"
330
+ exit 1
331
+ fi