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

# 概览

> 覆盖控制器，以控制 SDK 如何渲染、提交和完成交易。

控制器是您的代码接收 SDK 事件的方式，并在需要时覆盖默认行为。只需实现您需要的控制器。

## 默认行为

| 控制器 | 未覆盖 | 已覆盖 |
| - | - | - |
| [`onStatus`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-status) | 您不会收到最终状态。 | 交易到达最终状态后，接收交易状态（`status`、`substatus`、`message`）。在 Web 上，它还会接收少数可重试的结果，这些结果会保持表单挂载。请参阅 [`onStatus`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-status)。 |
| [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)（iOS、Android、React Native） | SDK 以全屏方式呈现表单和操作视图（例如 3DS）。 | SDK 将视图和一个 `TransactionProcess` 交给您；将其嵌入并调用 `process.onSubmit()`。 |
| [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading) | SDK 显示其自己的加载指示器。 | SDK 隐藏其加载指示器，并发出 `isLoading: true/false`。 |
| [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment) | SDK 在令牌化之后创建支付。 | SDK 交付一次性令牌；您从 backend 创建支付并完成 resolve。 |
| [`onInstallmentSelected`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-installment-selected) | 不会发生任何事情，所选项仍会随支付一起传递。 | 接收买家在银行卡表单中选择的分期选项，当该选择不再有效时接收 `null`。 |
| [`onCardInfoChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-card-info-changed)（iOS、Android） | 不会发生任何事情。 | 接收购物者正在输入的银行卡的品牌、类型、类别、发卡机构和国家/地区，当该卡不再适用时接收 `null`。 |
| [`onShippingAddressChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-shipping-address-changed) | 钱包页面保留其总额；不会应用任何配送选项或错误。 | 接收每次收货地址的选择，并返回页面必须显示的总额、配送选项或错误。 |
| `onChange`（Web） | 不会发生任何事情。 | 在交易开始时，以及每当 SDK 渲染的表单的有效性发生变化时，接收 `{ form: { isValid } }`。 |

在每个集成中实现 `onStatus`。其他控制器是可选的。

Web 没有 `showView`：SDK 在您的 `elementSelector` 中渲染表单。要通过您自己的按钮提交表单，请设置 `showPayButton: false` 并调用 [`transaction.submit()`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view#web-submit-from-your-own-button)。

## 如何连接控制器

* \*\*Web。\*\*每个事件都是在交易配置上设置的普通函数。`onStatus`、`showLoading`、`createPayment` 和 `onChange` 是顶层字段。`onInstallmentSelected` 放在 `card` 中（`card: { onInstallmentSelected }`），`onShippingAddressChanged` 放在 `externalButtons` 中（`externalButtons: { onShippingAddressChanged }`）。
* \*\*iOS、Android。\*\*在应对事件的对象（您的 view model、activity 或专用类）上实现 `TransactionController`，并通过 `TransactionConfig` 的 `controller` 字段传入。每个事件对应该对象上的一个方法。`showView` 仅在移动端可用。在 Android 上，`onCardInfoChanged` 不是控制器方法：请将其链式调用在 `TransactionConfig` 上（`TransactionConfig(...).onCardInfoChanged { }`）。
* \*\*React Native。\*\*将一个普通对象作为 `TransactionConfig` 的 `controller` 字段传入。每个事件对应该对象的一个方法，您未实现的方法保持 SDK 默认行为。要从您实现的方法中将某次调用交还给 SDK，请使用其收到的参数调用 `SdkPayments.defaultShowView`、`SdkPayments.defaultShowLoading` 或 `SdkPayments.defaultCreatePayment`。

## 线程

在 iOS 和 Android 上，每个控制器方法都在主线程上调用。您可以直接在其中更新 UI。请自行将任何阻塞性工作（例如 `createPayment` 中的 backend 调用）移出主线程。在 React Native 上，控制器方法在 JavaScript 线程上运行。

## 各控制器页面

* [`onStatus`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-status)。必需。交易的最终结果。
* [接管 SDK](https://docs.y.uno/docs/yuno-sdk/controllers/take-over-the-sdk)：[`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)（iOS、Android、React Native）、[`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)、[`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。覆盖其中一个后，SDK 将不再自行执行该步骤。
* [监听事件](https://docs.y.uno/docs/yuno-sdk/controllers/listen-to-events)：[`onInstallmentSelected`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-installment-selected)、[`onCardInfoChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-card-info-changed)（iOS、Android）、[`onShippingAddressChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-shipping-address-changed)、`onChange`（Web）。仅供参考；无论是否实现它们，SDK 的行为都相同。


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