> For the complete documentation index, see [llms.txt](https://docs.goassay.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.goassay.ai/developers/zh/di-ceng-yuan-li/settlement.md).

# 结算与保留期

了解客户托管余额、付款暂扣、提供方收款、退款和欠款调用。

托管余额是客户为调用存放在支付合约中的资金。调用可以在检查完成前返回数据，也可以在提供方收到付款前通过检查。阅读收据时，请分别看待服务判定、付款暂扣和收款状态。

## 资金如何流转

本地付费调用流程使用 **Robinhood Chain** 上的 **USDG**。钱包批准带上限和有效期的支付密钥。该密钥可为单笔付款签名，不能提取客户余额。

| 阶段       | 资金状态                         | 下一步                |
| -------- | ---------------------------- | ------------------ |
| 托管余额已充值  | 客户余额在合约中。                    | 可在限额内用于获授权调用。      |
| 调用预留     | Assay 在联系提供方前预留调用金额。         | 结果检查决定释放预留，还是允许付款。 |
| 已提供服务并结算 | 调用获准收费。已签名付款可能仍等待兑付。         | Assay 提交上链。        |
| 链上付款暂扣   | 兑付从客户余额扣除金额，并保存暂扣付款。提供方尚未收到。 | 暂扣期后收款，或在允许时退款。    |
| 已收款      | 合约将提供方份额转至结算付款钱包，将费用转至金库。    | 此暂扣付款不能再退款。        |
| 已退款      | 暂扣付款全额退回客户托管余额，或释放兑付前的预留。    | 提供方不会收到该笔付款。       |

抽成比例在付款兑付时冻结。即使配置比例之后改变，收款仍使用冻结比例。暂扣付款退款会恢复客户余额，但不会恢复链上已消耗的支出窗口额度。

## 暂扣期

默认暂扣期为**从链上兑付起一小时**，并非从智能体收到回答时开始。每笔付款保存自己的 `collectableAt`；之后修改配置不会改变该截止时间。

对于符合条件且尚未关闭或已被认定成立的问题报告，Assay 不会收取其暂扣付款。如果报告在仍可退款时被认定成立，兑付方会将暂扣全额退回客户托管余额。被阻止提供方仍暂扣的付款也会退款，而非收款。

| 时间           | 规则                                                          |
| ------------ | ----------------------------------------------------------- |
| 默认暂扣期        | 3,600 秒。                                                    |
| 可配置暂扣期       | 新兑付为 60–86,400 秒。                                           |
| 保证可提交报告的截止时间 | `collectableAt` 减去 60 秒之前，并取决于收据的资格状态。已提供服务但等待兑付的调用也可能符合条件。 |
| 常规收款         | 指定兑付方可从 `collectableAt` 起收款。                                |
| 合约兜底机制       | 从 `collectableAt` 加 7 天起，任何人都可向记录的提供方发起收款；仍执行暂停和阻止检查。       |
| 合约退款截止时间     | 到 `collectableAt` 加 7 天时，`refundHeld` 永久关闭。                 |

请使用收据的问题报告截止时间，不要自行按默认值计算。之后提交的报告可能影响提供方质量，但不保证退款。应用会因报告而暂缓收款；合约的公开收款兜底机制不会读取应用中的争议状态。

## 收款失败时

即使调用已提供服务，签名也可能变得无法收款。结果取决于原因：

| 状态                       | 客户资金                   | 提供方付款和后续调用                       |
| ------------------------ | ---------------------- | -------------------------------- |
| 仍在重试，或交易结果未知             | 预留保持。                  | Assay 先检查链上状态，再决定是否需要重新发送。       |
| 提供方丧失收款资格                | 释放预留；客户不收费。            | 不记入任何人的收入。                       |
| 欠款调用（`DEBT_OUTSTANDING`） | 原签名窗口因非提供方原因到期后，金额仍预留。 | 提供方未收到付款；替代付款成功前停止新的付费调用。免费调用继续。 |
| 到期 30 天后核销               | 释放预留。                  | 提供方仍未收到付款。调用仍欠款，仍阻止付费调用。         |
| 后续退款或作废决定使欠款作废           | 释放预留。                  | 无需再支付该笔已作废欠款。                    |

要结清欠款调用，请使用 Assay 应用的充值流程，为同一次已提供服务的调用签署替代付款。它保留提供方、金额和请求身份，不会再次运行提供方。已核销欠款需要重新预留，因为原预留已释放。Assay 不会垫付自己的资金向这些提供方付款。

## 提供方结算付款和最终确认

在此合约付款流程中，收款会将提供方份额直接转至结算付款钱包。后端的 `SETTLED` 调用是服务判定，不能证明转账已发生。链上报告收款后，才会记入提供方收入。

交易已提交也不同于获得成功收据。充值只有通过后端最终确认检查，按配置的确认深度或最终确定区块头确认后，才可支出。兑付和收款各有交易检查。不存在一个固定时长，能让所有阶段都最终确定。

<details>

<summary>可选：提取和权限延迟</summary>

客户提取需要先发起请求，等待一小时，再领取。待处理提取会排除此链上的付费路由。降低上限或撤销支付密钥，也会在一小时的收紧延迟内保留先前链上权限，但不会超过密钥有效期。即使在合约延迟期间，后端也会拒绝已撤销密钥的新付款。本地签名限额与合约上限的区别见[支出限额](/developers/zh/shi-yong-gong-ju-ru-men/spending-limits.md)。

</details>

## 延伸阅读

* [付费流程](/developers/zh/shi-yong-gong-ju-ru-men/how-paying-works.md)
* [重试与幂等](/developers/zh/shi-yong-gong-ju-jin-jie/retries-and-idempotency.md)

## 下一步

* [智能合约](/developers/zh/can-kao/smart-contracts.md)


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation by asking a question.

Perform an HTTP GET request on the following URL with the `ask` and `goal` query parameters:

```
GET https://docs.goassay.ai/developers/zh/di-ceng-yuan-li/settlement.md?ask=<question>&goal=<user_goal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is what the user is ultimately trying to achieve, the reason they need the answer. Sharing it helps GitBook give you a better, more relevant answer. A goal is most helpful when it describes the outcome the user wants rather than restating the question. For example, with `ask=how do I create an API token`, a goal like `automate deployments from our CI pipeline` lets GitBook tailor the answer to that use case.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
