> ## 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 模式

> 将 iOS Lite 集成（Yuno.startPaymentLite）迁移到统一的 Transaction API。

Lite 模式在商户端预先选定支付方式，然后交给 SDK 来渲染表单、令牌化、创建支付、处理 3DS 并回报结果。在统一 API 中，这是 `Transaction.start(paymentSelected:)` 的**默认行为**。无需覆盖任何控制器。

## 开始之前

* 将 `import YunoSDK` 替换为 `import SdkPayments`。您的公共 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 | 无对应项：只有 Seamless 允许 SDK 创建支付 | 不覆盖 | `SDK_SEAMLESS` |

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

## 并排对比

```swift Before. Lite mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import YunoSDK

// 1. Initialize once at app startup
Yuno.initialize(
    apiKey: "your-public-api-key",
    config: YunoConfig(
        appearance: customAppearance,
        saveCardEnabled: true,
        keepLoader: false
    )
)

// 2. Implement the delegate
final class Checkout: YunoPaymentDelegate {
    var checkoutSession: String = "session-from-backend"
    var countryCode: String = "CO"
    var language: String? = "en"
    var viewController: UIViewController?

    func yunoPaymentResult(_ result: Yuno.Result) {
        switch result.status {
        case .succeeded:      print("Success")
        case .reject:         print("Rejected")
        case .fail:           print("Failed")
        case .processing:     print("Processing")
        case .internalError:  print("Internal error")
        case .userCancelled:  print("User cancelled")
        @unknown default:     break
        }
    }

    // 3. Start the payment
    func pay(paymentSelected: PaymentMethodSelected) {
        Yuno.startPaymentLite(
            with: self,
            paymentSelected: paymentSelected,
            showPaymentStatus: true
        )
    }
}
```

```swift After. Unified Transaction theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import SdkPayments

// 1. Initialize once at app startup
SdkPayments.initialize(apiKey: "your-public-api-key")

// 2. Implement the controller
final class Checkout: SdkPayments.TransactionController {

    func onStatus(status: SdkPayments.TransactionStatus) {
        switch status.status {
        case "INTERNAL_ERROR":  print("Internal error")
        case "USER_CANCEL":     print("User cancelled")
        // Handle other backend statuses (e.g. SUCCEEDED, DECLINED, PENDING) as needed.
        default:                break
        }
    }

    // 3. Start the payment
    func pay(paymentSelected: SdkPayments.PaymentMethodSelected) {
        let config = SdkPayments.TransactionConfig(
            checkoutSession: "session-from-backend",
            countryCode: "CO",
            language: "en",
            appearance: customAppearance,    // optional
            controller: self,
            showStatusScreen: true,
            saveCardEnabled: true
        )

        SdkPayments.Transaction(config: config)
            .start(paymentSelected: paymentSelected)
    }
}
```

## 变更内容

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

### 初始化和配置

| Lite | 统一 API | 变更 | 处理方式 |
| - | - | - | - |
| `import YunoSDK` | `import SdkPayments` | 已重命名 | |
| `Yuno.initialize(apiKey:config:)` | `SdkPayments.initialize(apiKey:)` | 已重命名 | `YunoConfig` 已不存在：其字段移至 `SdkPayments.TransactionConfig`（见后续各行）。`callback:` 参数也已移除；如果需要等待，请使用 `async` 重载。 |
| `YunoConfig.appearance` | `SdkPayments.TransactionConfig.appearance` | 已移动 | 按每笔交易传入，而不是在启动时传入一次。 |
| `Yuno.Appearance` | `SdkPayments.Appearance` | 已重命名 | 初始化器相同；去掉 `Yuno.` 前缀。 |
| `YunoConfig.saveCardEnabled` | `SdkPayments.TransactionConfig.saveCardEnabled` | 已移动 | 默认为 `false`。设为 `true` 时，卡片表单会显示保存卡片复选框（仅限支付），且默认不勾选。 |
| `YunoConfig.keepLoader` | *（已移除）* | 已移除 | SDK 会保留其加载器。仅当您想使用自己的加载器时才覆盖 `showLoading`（参见“控制器”）。 |
| `YunoPaymentDelegate.checkoutSession`、`.countryCode`、`.language`、`.viewController` | `SdkPayments.TransactionConfig` 上的相同字段 | 已移动 | delegate 属性变为配置字段。`viewController` 仍仅适用于 iOS，并且在 SwiftUI 中为可选项。 |
| `startPaymentLite` 的 `showPaymentStatus:` 参数 | `SdkPayments.TransactionConfig.showStatusScreen` | 已移动 | 参见下方说明。 |

> [!NOTE]
>
> \*\*SDK 结果页面现在默认关闭。\*\*设置 `showStatusScreen: true` 即可保留它。

### 控制器

| Lite | 统一 API | 变更 | 处理方式 |
| - | - | - | - |
| `YunoPaymentDelegate` | `SdkPayments.TransactionController` | 已重命名 | 让同一个类遵循该协议，并将其作为 `TransactionConfig.controller` 传入。与之前一样，SDK 不会保留它：请在整个交易期间保持其存活。 |
| `yunoPaymentResult(_:)` | `onStatus(status:)` | 已重命名 | 仍是唯一的结果 callback，每笔交易调用一次，SDK 显示其结果页面时也是如此。`status` 和 `substatus` 来自 backend；SDK 自身只发出 `INTERNAL_ERROR` 和 `USER_CANCEL`。参见 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |
| `Yuno.Result.message` | `SdkPayments.TransactionStatus.message` | 已重命名 | 作用相同。`source` 现在是枚举（`.sdk` / `.backend`），且 `code` 不再是可选项。 |
| `yunoCreatePayment(with:)` / `(with:information:)` | `createPayment(token:)` | 已重命名 | 可选。一个处理程序取代两种变体；`token` 是以字典形式提供的完整一次性令牌。创建支付后返回：返回即相当于以前的 `continuePayment()`。如果处理程序抛出错误，流程会停止且不会调用 `onStatus`，因此请自行显示错误。参见 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。 |
| `YunoLoaderDelegate.onLoading(isLoading:)` | `showLoading(isLoading:)` | 已重命名 | 可选。Lite 从未调用它。如果您现在覆盖它，SDK 会隐藏自己的加载器并将状态报告给您。参见 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |
| 使用 `YunoInstallmentSelected` 的 `onInstallmentSelected(_:)` | 使用 `SdkPayments.InstallmentSelected` 的 `onInstallmentSelected(_:)` | 已重命名 | 可选。触发条件和字段相同；只有 payload 类型发生变化。参见 [`onInstallmentSelected`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-installment-selected)。 |
| `YunoShippingDelegate.onShippingAddressChanged(_:shippingInfo:)` | 通过 `SdkPayments.ShippingAddressHandling` 使用 `onShippingAddressChanged(_:shippingInfo:)` | 已移动 | 可选。让控制器遵循该协议；类型去掉了 `Yuno` 前缀，基于完成回调的变体已移除。参见 [`onShippingAddressChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-shipping-address-changed)。 |

### 入口点

| Lite | 统一 API | 变更 | 处理方式 |
| - | - | - | - |
| `Yuno.startPaymentLite(with:paymentSelected:showPaymentStatus:)` | `SdkPayments.Transaction(config:).start(paymentSelected:)` | 已重命名 | 先构建配置，然后调用 `start`。您仍然需要选择支付方式并将其传入。 |
| `Yuno.continuePayment()` | *（已移除）* | 已移除 | 删除该调用：从 `createPayment` 返回即可恢复流程。仅当您需要 SDK 在支付创建后立即停止时，才将 [`autoContinuePayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-pass#autocontinuepayment) 设为 `false`。 |
| `Yuno.receiveDeeplink(_:)` | `SdkPayments.handleDeeplink(_:)` | 已重命名 | 作用相同：转发您的应用在外部重定向后收到的 URL。参见[处理 deeplink](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/handle-deeplinks.md)。 |
| `Yuno.hideLoader()` | *（已移除）* | 已移除 | 删除该调用：SDK 会自行关闭其加载器。如果覆盖了 `showLoading`，您将改为收到 `isLoading: false`。 |

## 相关内容

* [快速入门](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。
* [迁移 / Seamless](https://docs.y.uno/zh-hans/docs/yuno-sdk/migration/ios/payment/seamless.md)。几乎相同的迁移；Seamless 和 Lite 合并为同一条默认路径。


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