> ## 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.

# 支付流程

> 逐步介绍 Yuno 交易中的客户、结账会话、支付详情和支付创建步骤

尽管 Yuno 提供多种支付选项，但基本支付流程始终遵循相同的顺序。本指南逐步拆解该流程及其中的关键要素，说明在使用 Yuno 的 SDK 或 API 时支付如何流转。

## Yuno 支付流程

支付流程包括以下步骤：

**1. 创建客户**

Yuno 中的支付通常关联到一个[客户](https://docs.y.uno/zh-hans/docs/basic-concepts/customers.md)。系统会存储客户的姓名、地址和电话号码等详细信息。Yuno 使用这些信息，通过不同的[支付方式](https://docs.y.uno/zh-hans/docs/basic-concepts/payment-methods.md)和处理商处理支付。
创建客户时，Yuno 会生成一个唯一标识符，供后续步骤使用。

> [!NOTE]
>
> 支付也可以在没有客户的情况下创建。如果您在创建结账会话时使用了 `customer_id`，则在创建支付时，请在 `customer_payer.id` 中发送同一客户。

**2. 创建结账会话**

要通过 Yuno SDK 或 Checkout 处理支付，请创建[结账会话](https://docs.y.uno/zh-hans/docs/basic-concepts/sessions.md#checkout-session)。该会话将客户与支付关联起来，并存储关键交易详情。Yuno 会加载与您账户关联的所有可用[支付方式](https://docs.y.uno/zh-hans/docs/basic-concepts/payment-methods.md)。

> [!NOTE]
>
> 直接集成（服务器到服务器）会跳过此步骤，在创建支付时直接提供交易详情。请在支付请求中将 `workflow` 设置为 `DIRECT`（或 `REDIRECT`）。否则，API 会要求提供 `checkout` 对象。

**3. 收集支付详情**

要处理支付，您需要收集客户的支付信息。

* **SDK 集成**：Yuno 的 SDK 会安全地捕获敏感数据，并生成一次性令牌（OTT）。
* **直接集成**：您直接在自己的服务器上收集支付详情（需要满足 PCI 合规要求），并将其发送到支付 endpoint。

> [!NOTE]
>
> OTT 是 Yuno SDK 使用的一种临时性、一次性代码，用于为商户增强安全性。

**4. 创建支付**

[支付](https://docs.y.uno/zh-hans/docs/basic-concepts/payments-1.md)代表最终交易。使用前面步骤中收集的数据（客户 ID 和支付信息）来处理最终交易。

> [!NOTE]
>
> 某些字段是可选的，但可以提升用户体验。如果您决定包含这些信息，请留意必填字段。

> [!NOTE]
>
> 创建支付请求需要 `X-Idempotency-Key` 标头。请发送一个唯一值（例如 UUID），以便安全地重试该请求。请参阅[幂等性](https://docs.y.uno/reference/getting-started/authentication.md#idempotency)。

创建支付后，Yuno 会通过 [webhooks](https://docs.y.uno/zh-hans/docs/basic-concepts/webhooks-1.md) 向您通知更新。此外，Yuno 还提供可集成到支付流程中的[欺诈预防](https://docs.y.uno/zh-hans/docs/basic-concepts/fraud)解决方案。


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