> ## Documentation Index
> Fetch the complete documentation index at: https://docs.y.uno/llms.txt
> Use this file to discover all available pages before exploring further.

> ## Agent Instructions
> Test in the sandbox first: base URL https://api-sandbox.y.uno (Test Mode in the Dashboard). Production is https://api.y.uno (Live Mode).
> Every API request needs the public-api-key and private-secret-key headers. Get them in the Dashboard at https://dashboard.y.uno/developers (Developers > Credentials); sandbox and production keys are different.
> Send an X-Idempotency-Key (a UUID) when creating payments, refunds and cancels, so retries do not create duplicates.
> Start with the Quickstart (https://docs.y.uno/docs/quickstart.md) and the agent guide (https://docs.y.uno/agents.md). To search these docs from a coding agent, connect the docs MCP server at https://docs.y.uno/mcp.

# 取消支付

> 介绍如何使用 Cancel Payment endpoint 手动取消待处理的支付。

本指南逐步介绍如何在 Yuno 中手动取消之前创建的支付。

> [!NOTE]
>
> **自动延迟取消**
>
> 如果您希望 Yuno 在指定的延迟时间后自动取消授权，可以在创建支付时配置 `delayed_cancel_settings`。自动释放冻结资金有助于提升客户体验。如需了解更多信息，请参阅 [Cancel and Capture Flow](https://docs.y.uno/zh-hans/docs/payment-features/Cancel-and-capture-flow.md) 指南。

> [!WARNING]
>
> **可取消的支付**
>
> 只有状态为 **PENDING** 的支付才能取消。有关可能的支付状态的更多详情，请参阅 [支付状态](https://docs.y.uno/zh-hans/docs/basic-concepts/payments-1.md) 页面。

## 要求

如需取消支付，您需要：

* 在 Yuno Dashboard 中获取您的 [API 凭证](https://docs.y.uno/zh-hans/docs/using-yuno/settings/developers-credentials.md)，包括：
  * `public-api-key`
  * `private-secret-key`
* 持有使用 [Create Payment endpoint](https://docs.y.uno/zh-hans/reference/payments/create-payment.md) 创建支付后收到的支付标识数据：
  * `id`：支付的唯一标识符，在创建支付后从参数 `id` 中获取。
  * `transaction_id`：交易的唯一标识符，在创建支付后从参数 `transaction.id` 中获取。

> [!NOTE]
>
> **探索 Yuno Postman Collections**
>
> Yuno 提供 [Postman Collections](https://docs.y.uno/reference/getting-started/postman-collections.md)，您可以使用它在本地复现这些用例。

## 取消支付

只有状态为 PENDING 的支付才能取消。请使用 [Cancel Payment endpoint](https://docs.y.uno/reference/payments/cancel-payment.md) 取消支付。如需标识要取消的支付，您需要提供其 `id` 和 `transaction_id`。

如需确认支付已成功取消，请检查 [Cancel Payment endpoint](https://docs.y.uno/reference/payments/cancel-payment.md) 响应中的参数是否包含以下值：

* `type = CANCEL`
* `status = SUCCEEDED`
* `payment.status = CANCELED`
* `payment.sub_status = CANCELED`

如果响应包含上述值，则表示取消成功。

### 检查支付状态

如果出于某种原因，您需要确认支付已取消：

* 使用 [Retrieve Payment by ID](https://docs.y.uno/reference/payments/retrieve-payment-by-id) 或 [Retrieve Payment by merchant\_order\_id](https://docs.y.uno/reference/payments/retrieve-payment-by-merchant-order-id.md) 获取支付的详细信息。
* 或者，设置 webhooks 以接收每个事件的通知。请参阅 [Webhooks](https://docs.y.uno/zh-hans/docs/webhooks/configure-webhooks.md) 指南，了解如何在 Yuno 中配置 webhooks。

## 另请参阅

* [捕获支付](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/capture-payments.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.