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

# 上线

> 将可正常运行的 sandbox 集成迁移到生产环境：Live 密钥、已发布的路由、经过验证的 webhooks、3DS 与 PCI 范围，以及第一笔真实支付。

入门

指南

一笔成功的 sandbox 支付只是起点。在发送真实交易之前，请与您的工程和运营团队一起完成以下五个步骤。

激活 Live Mode
发布 Live 路由
验证 webhooks
执行一笔真实支付和退款

### 1. 激活 Live Mode 并切换到生产环境密钥

您的组织最初只能访问 Test Mode。要获得 Live Mode，请从 Dashboard 首页提交激活请求。组织状态会从“Inactive”变为“Under Verification”，在 Yuno 验证账户期间，Test Mode 仍然可用。请参阅 [环境](https://docs.y.uno/zh-hans/docs/using-yuno/environments.md)。

启用 Live Mode 后：

* 从 **Developers** 复制 Live 密钥。Yuno 为 Test 和 Live 分别保留不同的密钥。请参阅 [Developers 凭据](https://docs.y.uno/zh-hans/docs/using-yuno/settings/developers-credentials.md)。
* 检查密钥前缀。Sandbox 密钥以 `sandbox_` 开头，生产环境密钥以 `prod_` 开头。Yuno SDK 会根据该前缀选择环境。请参阅 [Yuno SDK 入门](https://docs.y.uno/docs/yuno-sdk/get-started.md)。
* 将您的服务器指向生产环境基础 URL，该 URL 列于 [Developers](https://docs.y.uno/zh-hans/docs/developers.md) 页面。
* 将 `private-secret-key` 保存在您的服务器上，不要放在 GitHub 仓库等公开位置。请参阅 [身份验证](https://docs.y.uno/reference/getting-started/authentication.md)。

### 2. 连接生产环境服务提供商并发布路由

Yuno Test Payment Gateway 仅在 sandbox 中可用，因此生产环境支付需要连接到真实的服务提供商。

1. 将上下文标签设置为 **Live**，打开 [Connections](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/connections.md)，连接您上线时使用的每个服务提供商。
2. 打开 **Routing**，查看 **Not published** 选项卡。所有已有连接但没有路由的支付方式都会列在其中。
3. 创建路由，添加服务提供商步骤，然后点击 **Publish**。请参阅 [路由](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/routing.md)。
4. 打开 **Checkout builder**，开启已有已发布路由的支付方式，然后点击 **Publish settings**。在您发布之前，更改会一直保持 **Not published** 状态。

### 3. 设置生产环境 webhook 与安全重试

在履行订单之前，请在服务器上通过 webhook 或支付 API 确认每笔支付的结果。

* [配置生产环境 webhook](https://docs.y.uno/zh-hans/docs/webhooks/configure-webhooks.md)，使用返回 HTTP 200 的公共 HTTPS URL。如果投递未收到 HTTP 200，Yuno 会重试，因此同一事件可能会多次到达。退款和拒付事件与其对应的支付携带相同的 `data.payment.idempotency_key`，因此请将每个已处理的事件按 `account_id`、`type_event` 和幂等性键三者组合记录，并跳过已记录的事件。请参阅 [去重](https://docs.y.uno/zh-hans/docs/webhooks/index.md#de-duplication)。
* 开启 **Use HMAC Authentication**，在解析 JSON 之前，使用为该 webhook 配置的密钥，根据原始请求体验证 `x-hmac-signature` 标头。请参阅 [验证 webhook 签名](https://docs.y.uno/zh-hans/docs/webhooks/verify-webhook-signatures-hmac.md)。
* 创建支付时发送 `X-Idempotency-Key`。如果结果不明确（超时、连接错误或 `500`），请使用相同的键重试。`400 REQUEST_IN_PROCESS` 表示第一个请求仍在处理中，请在几秒后使用相同的键重试。`400 IDEMPOTENCY_DUPLICATED` 表示该键下不存在支付，请更正请求并使用新键发送。请参阅 [幂等性](https://docs.y.uno/reference/getting-started/authentication.md#idempotency)。
* 当 webhook 或请求的结果不明确时，使用 [检索支付](https://docs.y.uno/reference/payments/retrieve-payment-by-id-v2.md) 恢复支付的状态。

### 4. 确定 3DS 与 PCI 范围

**3D Secure**。由您决定卡支付是否使用 3DS2。在 **Routing** > **Card Routes** > **3DS Step** 下，将 3DS 步骤添加到 Card 路由中服务提供商步骤之前。3DS DIRECT 还需要收单机构数据：每个卡组织的收单机构 BIN、商户 ID、MCC、商户名称和 URL，以及国家代码。请参阅 [3D Secure](https://docs.y.uno/zh-hans/docs/security-and-compliance/3d-secure.md)。

**PCI DSS**。使用 Yuno SDK（或旧版 Full、Lite 或 Secure Fields SDK）时，卡数据从客户的浏览器或应用发送到 Yuno，您的服务器只接收令牌，因此大多数商户符合 SAQ A 的条件。如果您的服务器发送原始卡号（如快速入门中的 `DIRECT` workflow），您的系统就处于 PCI DSS 范围内。请参阅 [PCI 合规](https://docs.y.uno/zh-hans/docs/security-and-compliance/pci-compliance.md)。

### 5. 执行真实支付和退款，然后监控首批支付

测试卡仅用于 sandbox。在 Live Mode 下，针对您上线的每个服务提供商和支付方式，使用真实卡执行一笔小额支付，然后将其退款。

* 按照 [支付退款](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/refund-payments.md) 进行退款。每次退款调用都需要一个 `X-Idempotency-Key`，且每次尝试使用新值。在同一笔交易上发起另一笔退款之前，请等待当前退款达到 `SUCCEEDED`、`DECLINED` 或 `ERROR`。
* 退款是立即确认还是保持 `PENDING`，以及是否允许部分退款，取决于服务提供商。请检查您上线时使用的每个服务提供商的行为。
* 在 Live Mode 下打开 Dashboard 中的 **Payments**，查看每笔支付和交易、进行筛选并导出报告。请参阅 [Payments](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/payments.md)。
* 查看 [服务状态](https://status.y.uno) 了解故障事件；当结果与预期不符时，请附上支付 ID 发送邮件至 [support@y.uno](mailto:support@y.uno)。

## 测试正常路径之外的情况

上线之前，请证明您的应用能够处理以下每种情况。在 sandbox 中使用 [Yuno Testing Gateway](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/yuno-testing-gateway.md)，并参考每个服务提供商的测试说明。Sandbox 结果并不能证明每个生产环境服务提供商的实际行为。

| 场景 | 您的应用必须表现出的结果 |
| - | - |
| 已批准的支付 | backend 确认结果，并且只履行一次订单。 |
| 拒绝 | 订单保持未支付状态，客户可以重试。 |
| 身份验证或重定向 | 客户完成操作，服务器确认最终状态。 |
| 待处理的异步支付 | 订单等待 webhook 或支付 API 的确认。 |
| 发送请求后超时 | 使用相同的 `X-Idempotency-Key` 重试不会创建第二笔支付。 |
| 重复或延迟的 webhook | 该事件不会重复履行订单，也不会覆盖较新的状态。 |
| 浏览器在完成前关闭 | 仍由 webhook 或服务器上的支付查询决定结果。 |
| 退款或取消 | 服务提供商的结果与您的订单或账簿记录一致。 |

## 下一步

<ol>
  <li>[故障排除](https://docs.y.uno/zh-hans/docs/troubleshooting.md)参考 新集成最先遇到的错误：响应、原因及修复方法。</li>
  <li>[Webhooks](https://docs.y.uno/zh-hans/docs/webhooks/index.md)指南 投递、重试、去重，以及用于配置和验证 webhook 的页面。</li>
  <li>[支付流程](https://docs.y.uno/zh-hans/docs/how-yuno-works/how-yuno-payment-flow-works.md)概念 支付的每个步骤，逐字段说明。</li>
  <li>[创建支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md)参考 创建支付的调用所使用的请求和响应结构。</li>
</ol>


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