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

# Lite 模式

> 将 Web Lite 集成（yuno.startCheckout + yuno.mountCheckoutLite）迁移到统一的 Transaction API。

Lite 模式过去在商户端预先选择支付方式，然后交给 SDK 渲染该支付方式的表单、进行令牌化、创建支付、处理 3DS 并报告结果。在统一 API 中，这是 `transaction.start({ paymentMethod })` 的**默认行为**。除 `onStatus` 外，无需覆盖任何控制器。

## 开始之前

* 加载统一 SDK 包而不是旧版包，并按照对照代码所示进行初始化：`window.Yuno.initialize(...)` 变为 `SdkPayments.initialize(...)`。您的公共 API 密钥以及您的 backend 创建的结账会话保持不变（[开始之前](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md#before-you-begin)）。
* 决定由谁创建支付。结账会话的 `workflow` 必须与该决定一致：

| 由谁创建支付 | 在 Lite 中您的做法 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | 已实现 `yunoCreatePayment` | 覆盖 `createPayment` | 默认（`SDK_CHECKOUT`） |
| SDK | 没有 `yunoCreatePayment` | 不覆盖 | `SDK_SEAMLESS` |

> [!WARNING]
>
> 使用默认 workflow 且未覆盖 `createPayment` 的会话会以 `INTERNAL_ERROR` 结束：backend 会拒绝 SDK 创建支付。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。

## 对照

```typescript Before. Lite mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
// 1. Initialize once at page startup
const yuno = await window.Yuno.initialize('your-public-api-key')

// 2. Configure the checkout
await yuno.startCheckout({
    checkoutSession: 'session-from-backend',
    elementSelector: '#root',
    countryCode: 'CO',
    language: 'en',
    renderMode: { type: 'modal' },
    yunoPaymentResult: (status) => {
        console.log('Final status:', status)
    },
    yunoError: (error) => {
        console.log('Error', error)
    },
})

// 3. Mount Lite for the pre-selected payment method
await yuno.mountCheckoutLite({
    paymentMethodType: 'PIX',
    vaultedToken: null,
})
```

```typescript After. Unified Transaction theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
// 1. Initialize once at page startup
const sdkPayments = await SdkPayments.initialize('your-public-api-key')

// 2. Build the transaction and start with the pre-selected method
const transaction = sdkPayments.transaction({
    checkoutSession: 'session-from-backend',
    countryCode: 'CO',
    language: 'en',
    elementSelector: '#root',
    onStatus: (result) => {
        console.log('Final status:', result.status)
    },
})

await transaction.start({
    paymentMethod: { type: 'PIX' },
})
```

## 变更内容

按您编辑代码的顺序分组。**重命名**：作用相同，名称变更。**移动**：值相同，归属对象变更。**移除**：无需调用任何内容。最后一列是除重命名之外您唯一需要做的事。

### 初始化和配置

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `window.Yuno.initialize(publicApiKey)` | `SdkPayments.initialize(publicApiKey)` | 重命名 | 全局对象是 `window.SdkPayments`。与之前一样，对其使用 `await`：它会解析为您用来创建交易的 `SdkPayments` 实例。 |
| `startCheckout` 配置中的 `checkoutSession`、`countryCode`、`language` | 交易配置中的相同字段 | 移动 | 字段相同，单一工厂方法：`sdkPayments.transaction({ checkoutSession, countryCode, language, … })`。 |
| `startCheckout` 配置中的 `elementSelector` | 交易配置中的 `elementSelector` | 移动 | 支付表单必需。`start({ paymentMethod })` 会在该元素内渲染表单，缺少该元素时会抛出异常。它接受 CSS 选择器或 `HTMLElement`。Headless 流程会忽略它。钱包和列表视图在 `.mount()` 上使用各自的 `elementSelector`（请参阅 [`getPaymentMethodsViews`](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/payment-methods-list)）。 |
| `renderMode: { type: 'modal' \| 'element', elementSelector }` | 交易配置中的 `elementSelector` | 移动 | 模态框模式已不再存在。表单会在您于交易配置中传入的元素内渲染。 |
| `card: CardConfig` | 交易配置中的 `card: CardConfig` | 移动 | 结构相同。 |
| `startCheckout` 配置中的 `showPayButton` | 交易配置中的 `showPayButton` | 移动 | 含义相同。仅适用于支付流程。 |

### Callback

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `yunoPaymentResult(status, subStatus?)` | `onStatus(result)` | 重命名 | 仍然是唯一的结果 callback，现在是交易配置中的一个字段。它接收一个 `TransactionStatus` 对象（`status`、`substatus`、`message`），而不是两个位置参数：`status` 不再是 Lite 的联合类型。`result.status` 包含 API 报告的支付状态（`READY_TO_PAY`、`CREATED`、`SUCCEEDED`、`REFUNDED`、`REJECTED`、`CANCELED`、`ERROR`、`DECLINED`、`PENDING`、`EXPIRED`、`VERIFIED`），外加两个 SDK 值：`INTERNAL_ERROR`（SDK 或 backend 错误，详细信息见 `result.message`）和 `USER_CANCEL`（您在得到结果之前卸载了组件）。将您的 `SUCCEEDED`、`REJECT`、`FAIL`、`PROCESSING` 和 `READY` 分支映射到这些值。`subStatus` 变为 `result.substatus`。请参阅 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |
| `yunoCreatePayment(ott, info)` | `createPayment(token) => Promise<void>` | 重命名 | 可选。基于 Promise，单个参数：`token` 是 `OneTimeToken` 加上 `checkout_session`，即该令牌所属的会话（在可重试的拒绝之后会轮换）。使用 `token.token` 和 `token.checkout_session` 创建支付，然后 resolve：resolve 即相当于过去的 `continuePayment()`，随后由 SDK 编排 3DS 和状态轮询。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。 |
| `yunoError(message, data?)` | *（已移除）* | 移除 | 所有最终结果都通过 `onStatus`（设置了 `message` 的 `TransactionStatus`）或被拒绝的 `start()` Promise 传递。 |
| `onLoading({ isLoading, type })` | `showLoading(isLoading)` | 重命名 | 可选。去掉了已弃用的 `type` 字段。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |

### 入口点

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `yuno.startCheckout(config)` | `sdkPayments.transaction(config)` | 重命名 | 单一工厂方法：使用配置（上述字段和 callback）构建交易，然后调用 `start`。 |
| `yuno.mountCheckoutLite({ paymentMethodType, vaultedToken })` | `transaction.start({ paymentMethod: { type: paymentMethodType, vaultedToken } })` | 重命名 | Lite 的预先选择变为 `start()` 的 `paymentMethod` 参数。 |
| `yuno.submitOneTimeTokenForm()` | `transaction.submit()` | 重命名 | 通过您自己的按钮提交 `start()` 挂载的表单。与 `showPayButton: false` 一起使用。请参阅 [Web：通过您自己的按钮提交](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view.md#web-submit-from-your-own-button)。 |
| `yuno.continuePayment()` | *（已移除）* | 移除 | 删除该调用。Lite 要求在 `yunoCreatePayment` 内部调用它来推进流程；现在当 `createPayment` resolve 时，SDK 会自动编排 3DS 和状态轮询。 |

## 相关内容

* [快速入门](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md)。完整的统一 API 演练。
* [`TransactionConfig`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-pass#transaction-config)。完整的字段参考。
* [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。值和 substatus。


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