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

# Postman 集合

> 导入 Yuno Postman 集合和环境，然后通过 5 个请求完成第一笔 sandbox 支付

Yuno Postman 集合包含 [API 参考](https://docs.y.uno/zh-hans/reference/getting-started/api-reference-overview.md)中的每个 endpoint，顺序与侧边栏相同。导入两个文件，粘贴您的 sandbox 密钥，即可发送第一笔支付。

> [card] [集合](https://docs.y.uno/files/postman/Yuno_API.postman_collection.json)
>
> `Yuno_API.postman_collection.json`

> [card] [Sandbox 环境](https://docs.y.uno/files/postman/Yuno_Sandbox.postman_environment.json)
>
> `Yuno_Sandbox.postman_environment.json`

您需要：

* [Postman](https://www.postman.com/downloads/)，桌面版或 Web 版
* 一个 Yuno sandbox 账户
* 该账户中一个配置了路由的银行卡连接。[Yuno Testing Gateway](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/yuno-testing-gateway.md) 无需凭证。如果没有银行卡路由，第 3 步中的测试支付会失败。

## 第 1 步：导入集合和环境

1. 在 Postman 中，选择 **Import**。
2. 粘贴此 URL，或拖入已下载的文件：

```text theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
https://docs.y.uno/files/postman/Yuno_API.postman_collection.json
```

3. 以同样的方式导入环境：

```text theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
https://docs.y.uno/files/postman/Yuno_Sandbox.postman_environment.json
```

> [!NOTE]
>
> **集合和环境是分开的**
>
> 集合包含请求。环境包含您的 API 密钥和账户。Postman 两者都需要。

## 第 2 步：添加您的 sandbox 密钥

1. 打开左侧面板中的 **Environments**，然后选择 **Yuno Sandbox**。

![已选择 Yuno Sandbox 环境，浅色模式](https://mintcdn.com/yuno-3979e326/GspgIeXMm7YcceoM/images/reference/postman-collections/image2-light.png?fit=max\&auto=format\&n=GspgIeXMm7YcceoM\&q=85\&s=1b44e1dc58e68ce3a0300c1ca9e0dbe1)

2. 填写以下 3 个变量。您可以在 [Yuno Dashboard](https://dashboard.y.uno/developers) 中找到它们。

| 变量 | 值 |
| - | - |
| `public_api_key` | 您的公共 API 密钥 |
| `private_secret_key` | 您的私有密钥 |
| `account_id` | 运行这些支付的账户 |

> [!NOTE]
>
> **Sandbox 密钥需要测试模式**
>
> 在 Yuno Dashboard 中，复制 API 密钥之前，请将顶部栏中的[上下文标签](https://docs.y.uno/zh-hans/docs/using-yuno/account-context.md)设置为 **Test**。如果标签处于 **Live**，密钥将仅适用于生产环境，无法在 sandbox 环境中通过身份验证。

3. 使用右上角的选择器，将 **Yuno Sandbox** 设置为当前环境。

![环境选择器下拉菜单，浅色模式](https://mintcdn.com/yuno-3979e326/GspgIeXMm7YcceoM/images/reference/postman-collections/image3-light.png?fit=max\&auto=format\&n=GspgIeXMm7YcceoM\&q=85\&s=b8c7bb4267fa8d87757b4d4c9a40ddf7)

## 第 3 步：发送您的第一笔支付

打开 **Start here: your first payment** 文件夹，按顺序发送这 5 个请求。

| 请求 | 作用 | 保存的内容 |
| - | - | - |
| 1. Create a customer | 创建付款人 | `customer_id` |
| 2. Create a checkout session | 打开 SDK 将使用的会话 | `checkout_session` |
| 3. Create a payment | 使用 `DIRECT` 工作流向测试卡扣款 | `payment_id`, `transaction_id` |
| 4. Retrieve the payment | 读取支付及其状态 | |
| 5. Refund the payment | 对该交易退款 | |

每个请求都会保存下一个请求所需的 ID，因此您无需复制粘贴任何内容。第 3 步之后，支付的状态为 `status: SUCCEEDED`。第 5 步之后，其状态为 `status: REFUNDED`。

> [!NOTE]
>
> 第 3 步发送的是原始测试卡号。这在 sandbox 中可行。在生产环境中，这需要 PCI 认证，而 SDK 集成会改为发送一次性令牌。

## 集合的工作方式

* **结构与 API 参考相同。** 每个侧边栏分组是一个文件夹，每个 endpoint 页面是一个请求，并且每个请求都链接回其页面。
* **身份验证已配置好。** `public-api-key` 和 `private-secret-key` 标头从环境中读取。
* **幂等性自动处理。** 每次发送时，`X-Idempotency-Key` 都会获得一个新的 UUID，并保存为 `last_idempotency_key`。
* **ID 自动传递。** 成功的创建请求会将其 ID（`customer_id`、`payment_id`、`subscription_id` 等）保存为集合变量，后续请求会使用它。
* **每个文档化的场景都是一个已保存的示例。** 打开请求下的示例，例如 **Create Payment** 中的银行卡、钱包和银行转账请求体，即可查看每个请求体及其响应。
* **错误附有说明。** 调用失败时，Postman 控制台会打印错误码、消息和 trace ID。需要帮助时，请将 trace ID 发送给支持团队。

## 安全地重试请求

请求超时时，您无法知道它是否已经成功。使用新的幂等键再次发送可能会创建第二笔支付。

1. 打开集合的 **Variables** 选项卡。
2. 将 `last_idempotency_key` 的值复制到 `retry_idempotency_key`。
3. 再次发送同一请求。如果第一个请求创建了支付，Yuno 会返回该支付，而不会创建新支付。
4. 清空 `retry_idempotency_key`，以便后续请求获得新键。

有关重试可能返回的其他响应，请参阅[幂等性](https://docs.y.uno/zh-hans/reference/getting-started/authentication.md#idempotency)。

## 从命令行运行

同样的文件可以通过 [Newman](https://github.com/postmanlabs/newman) 运行，例如在 CI 中。请使用一份已填入您的密钥的环境文件副本，并且不要将该副本纳入版本控制。

```sh theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
npx newman run Yuno_API.postman_collection.json \
  -e Yuno_Sandbox.postman_environment.json \
  --folder "Start here: your first payment"
```

## 生产环境

导入 [`Yuno_Production.postman_environment.json`](https://docs.y.uno/files/postman/Yuno_Production.postman_environment.json)，然后填入您的生产密钥。使用此环境发送的请求会转移真实资金。每次发送生产环境请求时，集合都会在控制台中打印警告。

## 始终保持同步

该集合由构建 API 参考的同一份 [OpenAPI 规范](https://docs.y.uno/openapi.json)生成。重新导入即可获得新的 endpoint。

## 实用资源

* [`Yuno_API.postman_collection.json`](https://docs.y.uno/files/postman/Yuno_API.postman_collection.json)
* [`Yuno_Sandbox.postman_environment.json`](https://docs.y.uno/files/postman/Yuno_Sandbox.postman_environment.json)
* [`Yuno_Production.postman_environment.json`](https://docs.y.uno/files/postman/Yuno_Production.postman_environment.json)
* [OpenAPI 规范](https://docs.y.uno/openapi.json)
* [身份验证](https://docs.y.uno/zh-hans/reference/getting-started/authentication.md)


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