Install
openclaw skills install huifu-payment-diagnostics-doctor基于证据的汇付/斗拱支付联调诊断 Skill,防止 AI 在联调失败后凭感觉乱猜原因。适用于汇付支付下单、查单、关单、退款、对账、签名验签、异步通知、前端收银台组件(checkout-js)拉起、最终支付状态确认、上线验收等失败场景;要求优先依据日志、请求响应、Webhook 轨迹、SDK 错误、商户配置和生产检查证据来诊断。(由汇付支付小开发者提供技术支持,如有错误及时联系更正)
openclaw skills install huifu-payment-diagnostics-doctor这个 Skill 是汇付/斗拱支付接入的联调诊断层,用来把“调不通”的现象拆成可验证的证据、原因和修复动作。
你的任务不是重新讲一遍汇付接口文档,而是像支付联调诊断员一样工作:
当用户提供真实日志、要求可靠联调清单、需要上线验收标准,或第一轮诊断不确定时,读取 references/diagnostic-playbook.md 做更深入的案例处理。
sys_id, product_id, huifu_id, project_id, notify_url, sub_openid, buyer_id, auth_code, or channel identifiers.If the user only says "Huifu payment does not work", do not give a long generic answer.
First classify what is known, then ask for the minimum missing evidence:
我先按联调问题来排。请贴这 5 样,敏感信息打码:
1. 你走的是聚合支付、托管支付,还是前端收银台组件(checkout-js)
2. 当前失败步骤:下单 / 预下单 / 查单 / 退款 / 异步通知 / 签名 / 前端拉起
3. 技术栈和 SDK 版本:Java / PHP / JS / 原生 HTTP
4. 一次失败请求的 URL 或接口名、请求体、响应体、HTTP 状态码
5. 本地日志里签名、请求头、订单号、回调处理相关的几行
If the user already provided logs or payloads, do not ask again. Start diagnosis immediately.
Collect evidence in layers. Stop when the current layer is enough to diagnose.
req_date, req_seq_id, hf_seq_id, huifu_id, project_idUse only for async notification problems:
Use only for front-end cashier component (checkout-js) or cashier launch problems:
Always classify into one primary bucket. Mention secondary buckets only if needed.
| Bucket | Use When | Main Question |
|---|---|---|
route | User has not identified product line or stage | Which Huifu path are we on? |
credential/environment | Test works but production fails, merchant id/key/project differs | Are endpoint, merchant, key, product, and project from the same environment? |
request-header | Attribution/source header missing or gateway rejects request metadata | Are Huifu-required HTTP headers present in the right place? |
signing | Sign/verify fails, response says signature invalid | Was the exact raw payload signed and verified with the right key pair? |
order-create | Order/preorder fails before payment can start | Are required fields, channel fields, amount, merchant id, and product config valid? |
checkout | 前端收银台组件(checkout-js)/收银台无法拉起,或返回异常前端状态 | Did hostingpay preorder succeed and is browser using safe, correct fields? |
final-state | Front-end says paid but backend says unpaid/unknown | Is final state confirmed by query/webhook/reconciliation? |
webhook | Async notification not received, verification fails, or Huifu retries | Can Huifu reach the endpoint and does handler verify/idempotently acknowledge? |
query-close | Query/close/close-query cannot locate the trade | Are original transaction identifiers from persisted create result used? |
refund | Refund/refund-query fails or repeats | Are original trade keys, refundable amount, and refund request id correct? |
reconciliation | Statement and local orders do not match | Are settlement date, fees, refunds, and local state transitions aligned? |
production-readiness | User asks if code can go live | Are secrets, final-state confirmation, idempotency, logging, and reconciliation safe? |
| User Symptom | Bucket | First Things To Check |
|---|---|---|
| "签名失败 / 验签失败" | signing | Raw body, key pair, JSON mutation, charset, timestamp |
| "jpt-x-skill-source 没有 / 来源头不对" | request-header | SDK config vs manual HTTP headers |
| "下单失败" | order-create | Required fields, environment, amount, channel-specific fields |
| "预下单成功但前端收银台拉不起" | checkout | project_id, preorder response, browser SDK, domain/callback |
| "前端成功但后台没成功" | final-state | Query/webhook final status, local state machine |
| "异步通知一直重试" | webhook | HTTP 200, response body, signature, idempotency |
| "查单查不到" | query-close | Stored req_date, req_seq_id, hf_seq_id, out_trans_id |
| "退款失败" | refund | Original trade id, amount, duplicate refund id, status |
| "对账不平" | reconciliation | Date window, refund timing, fee handling, missing final-state updates |
| "测试能用,生产不行" | credential/environment | Endpoint, merchant id, key pair, sys_id, product/project config |
Stop and ask one short question when continuing would create a wrong path.
Use when aggregation and hostingpay would require different documents or fields.
硬检查点
当前还不能判断你走的是聚合支付还是托管支付。
请先确认:你是在做聚合支付下单,还是托管支付/收银台预下单?
Use when the user wants front-end cashier component (checkout-js) guidance but has not confirmed hostingpay preorder and final confirmation.
硬检查点
前端收银台组件(checkout-js)不能单独成立,它依赖服务端托管预下单和最终状态确认。
请先确认:服务端是否已经能成功托管预下单,并且能查单或接收异步通知?
Use when the user asks for production-ready code but required real values are missing.
硬检查点
当前还缺生产联调必需值,直接给代码会变成伪完整模板。
请先确认:你要先补真实配置,还是只要带占位符的诊断模板?
Use when logs show behavior that conflicts with expected SDK header/signature behavior.
硬检查点
日志里的 SDK 行为和当前预期规则冲突,需要先确认实际 SDK 版本和调用入口。
请贴 SDK 包名、版本号、初始化代码片段,密钥打码。
credential/environmentCheck in this order:
sys_id, product_id, huifu_id, project_id belong to the same merchant/project.Common conclusion:
这类问题不是代码语法优先,而是环境一致性优先。先把 endpoint、商户号、系统号、产品号、项目号、密钥环境拉成一张表比对。
request-headerCheck:
jpt-x-skill-source is an HTTP header, not a data field.jpt-x-skill-huifu_id is an HTTP header when request data contains non-empty huifu_id.sys_id unless the current official rule says so.Ask for:
skill_source equivalent, secrets redactedsigningCheck in this order:
Do not debug business fields before signing is known correct.
order-createCheck:
notify_url and callback_url are correct for the environment.If order creation returns a business error code, summarize:
checkoutRemember: 前端收银台组件(checkout-js)只是浏览器层。它不能替代服务端托管预下单。
Check:
project_id is correct for the merchant project.Likely outputs:
现在问题不在前端收银台组件(checkout-js)本身,先回到托管预下单返回值。
or:
托管预下单已成功,问题集中在浏览器 SDK 初始化 / 域名回调配置。
final-stateUse when user says paid page returned success but backend status is pending/fail.
Check:
Rule:
前端成功只能代表流程完成或用户体验成功,不代表资金最终成功。
webhookCheck:
notify_url from the public internet.Common failure patterns:
query-closeCheck:
req_date and req_seq_id are not guessed from current date or regenerated order id.hf_seq_id or equivalent Huifu sequence is stored when available.If the trade cannot be found, first inspect persistence, not gateway availability.
refundCheck:
reconciliationCheck:
Output should include a difference table when data is provided.
production-readinessUse this when the user asks "can this go live".
Check:
Always prefer this format. Keep it concrete and short enough to act on.
判断
当前问题属于:<bucket>
置信度:<high | medium | low>
我现在依据的是:<which logs/payloads/symptoms>
已看到的证据
- <fact from user input>
- <fact from user input>
还缺的关键证据
- <only things needed next>
最可能原因
1. <cause>:为什么它最像
2. <cause>:为什么它次像
怎么验证
- <specific field/log/code point to compare>
- <specific replay/query/check>
修复动作
- 立即修复:<code/config/action>
- 数据修复:<orders/refunds/webhook states to repair, if any>
- 防复发:<logging/idempotency/test/reconciliation guard>
需要路由阅读
- <only 1-3 Huifu skill/reference names, if necessary>
If evidence is insufficient, keep the same structure but make 还缺的关键证据 the main section.
Input:
PHP SDK 请求返回验签失败。我们打印的 JSON 和发送的 JSON 好像一样。
Good response:
判断
当前问题属于:signing。
置信度:medium。
最可能原因
1. 签名输入或签名覆盖的业务数据与最终出站 payload 不一致:PHP 中间层可能重新 json_encode 或改写字段。
2. 密钥环境不一致:测试环境私钥配了生产环境汇付公钥,或反过来。
怎么验证
- 在签名前打印签名输入或关键 payload 的 SHA256,不打印明文敏感字段。
- 在 HTTP client 发送前再打印最终出站 payload 的 SHA256;如果当前路径是 raw-body 签名,两个值必须一致。
- 核对当前 endpoint、sys_id、huifu 公钥、商户私钥是否来自同一环境。
修复动作
- 立即修复:签名后不要再改签名覆盖的数据;raw-body 签名路径要发送签名使用的同一份字符串。
- 防复发:把签名输入 hash、发送前 payload hash、request id 写入联调日志。
Input:
前端收银台组件(checkout-js)回调成功了,但我们系统订单还是未支付。
Good response:
判断
当前问题属于:final-state,可能伴随 webhook/query 缺失。
置信度:medium。
最可能原因
1. 你们把前端收银台回调当成最终成功,但服务端没有查单或处理异步通知。
2. 异步通知失败或验签失败,导致本地订单没有从 pending 转 success。
怎么验证
- 查这笔订单是否执行过服务端查单,记录 Huifu 最终交易状态。
- 查 notify_url 是否收到通知、验签是否通过、handler 返回是否为成功响应。
修复动作
- 立即修复:前端回调只更新页面提示,后台订单状态必须由查单或异步通知更新。
- 数据修复:对 pending 订单按 Huifu 订单号批量查单并修正状态。
- 防复发:增加 pending 超时补查任务和 webhook 失败告警。
Input:
汇付一直重复通知,日志里我们已经处理成功了。
Good response:
判断
当前问题属于:webhook。
置信度:medium。
最可能原因
1. 业务处理成功,但 HTTP 响应状态或响应体不是汇付要求的成功格式。
2. 第二次重复通知触发本地唯一键异常,handler 返回 500,所以汇付继续重试。
怎么验证
- 看 notify handler 最终 HTTP status 和 response body,不只看业务日志。
- 用同一笔通知重复请求本地接口,确认第二次仍返回成功。
修复动作
- 立即修复:验签通过且状态已处理时,重复通知也返回成功。
- 数据修复:检查这笔订单是否被重复写入流水或状态被覆盖。
- 防复发:通知表按通知 id/订单 id 做幂等,业务异常和响应异常分开告警。
After classification, route only to the narrowest skill or reference family:
huifu-dougong-aggregation-*huifu-dougong-hostingpay-*huifu-dougong-hostingpay-checkout-jshuifu-dougong-pay-shared-base or shared references inside huifu-payment-integrationDo not list the full Huifu document set. A diagnostic answer should usually cite 0-3 follow-up documents.