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

# Render 模式

> 将 iOS Render 集成（Yuno.startPaymentRenderFlow + formView + submitForm）迁移到统一的 Transaction API。

Render 模式让您将 SDK 的支付表单嵌入到您自己的布局中：您从 `Yuno.startPaymentRenderFlow(...)` 获取一个 `YunoPaymentRenderFlowProtocol`，向其请求一个 `formView` 并放置在您想要的任意位置，然后在用户准备好支付时，从您自己的按钮调用 `submitForm()`。

在统一 API 中，同样的模式通过覆盖 [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view) 来实现。SDK 仍然提供表单视图；您会连同一个暴露 `onSubmit()` 的 `TransactionProcess` 控制对象一起收到它。

## 开始之前

* 将 `import YunoSDK` 替换为 `import SdkPayments`。您的公开 API 密钥以及您的 backend 创建的结账会话均保持不变（[开始之前](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md#before-you-begin)）。
* 决定由谁创建支付。结账会话的 `workflow` 必须与该决定一致：

| 由谁创建支付 | 在 Render 中您使用的是 | 在统一 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. Render mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import SwiftUI
import YunoSDK

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

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

    func yunoPaymentResult(_ result: Yuno.Result) { /* ... */ }

    // Called by the SDK during render mode (the only mode where this fires)
    func onLoading(isLoading: Bool) { /* show your own loader */ }
}

// 3. Embed the form, render layout yourself, submit from your button
struct CheckoutView: View {
    @StateObject var model = CheckoutModel()
    let selectedMethod: PaymentMethodSelected
    @State var paymentFlow: YunoPaymentRenderFlowProtocol?
    @State var formView: AnyView?

    var body: some View {
        VStack {
            Text("Checkout")
            // ... your products / shipping / etc.
            formView    // SDK form embedded here
            Button("Pay") {
                paymentFlow?.submitForm()
            }
        }
        .task {
            paymentFlow = await Yuno.startPaymentRenderFlow(
                paymentMethodSelected: selectedMethod,
                with: model
            )
            formView = await paymentFlow?.formView(
                paymentMethodSelected: selectedMethod,
                with: model
            )
        }
    }
}
```

```swift After. OnShowView override theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import SwiftUI
import SdkPayments

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

// 2. Implement the controller. Override showView + showLoading
final class CheckoutModel: SdkPayments.TransactionController, ObservableObject {

    @Published var formView: AnyView?
    @Published var process: SdkPayments.TransactionProcess?
    @Published var isLoading: Bool = false

    func showView(view: AnyView?, process: SdkPayments.TransactionProcess, step: SdkPayments.TransactionViewStep) {
        // step == .FORM for the data-capture form, .ACTION for a payment code or OTP view. 3DS and redirects are full-screen.
        self.formView = view
        self.process = process
    }

    func showLoading(isLoading: Bool) {
        self.isLoading = isLoading
    }

    func onStatus(status: SdkPayments.TransactionStatus) { /* ... */ }
}

// 3. Embed the delivered view, submit via process.onSubmit()
struct CheckoutView: View {
    @StateObject var model = CheckoutModel()
    let selectedMethod: SdkPayments.PaymentMethodSelected

    var body: some View {
        VStack {
            Text("Checkout")
            // ... your products / shipping / etc.
            if model.isLoading { ProgressView() }
            model.formView
            Button("Pay") {
                model.process?.onSubmit()
            }
        }
        .task {
            let config = SdkPayments.TransactionConfig(
                checkoutSession: "session-from-backend",
                countryCode: "CO",
                controller: model
            )
            SdkPayments.Transaction(config: config)
                .start(paymentSelected: selectedMethod)
        }
    }
}
```

## 变更内容

按您编辑代码的顺序分组。**重命名**：作用相同，名称变更。**迁移**：值相同，归属变更。**移除**：无需调用。**新增**：没有旧版对应项。最后一列是除重命名之外您唯一需要做的事。

### 初始化与配置

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `import YunoSDK` | `import SdkPayments` | 重命名 | |
| `Yuno.initialize(apiKey:)` | `SdkPayments.initialize(apiKey:)` | 重命名 | `callback:` 参数已移除；如果您需要等待，请使用 `async` 重载。 |
| 在 `YunoConfig.appearance` 中传入的 `Yuno.Appearance` | `SdkPayments.TransactionConfig.appearance` 中的 `SdkPayments.Appearance` | 重命名 | 初始化方法相同；去掉 `Yuno.` 前缀，并在每笔交易中传入，而不是在启动时传入一次。 |
| `YunoPaymentDelegate.checkoutSession`、`.countryCode`、`.language`、`.viewController` | `SdkPayments.TransactionConfig` 上的相同字段 | 迁移 | delegate 属性变为配置字段。`viewController` 仍仅适用于 iOS，在 SwiftUI 中为可选。 |

### 控制器

| Render | 统一 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:)` | 重命名 | 语义相同。Render 是唯一真正调用它的旧版模式，因此现有的 Render 集成几乎肯定需要迁移这一项。覆盖后，SDK 会隐藏自己的加载指示器，并将状态报告给您。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |
| 使用 `YunoInstallmentSelected` 的 `onInstallmentSelected(_:)` | 使用 `SdkPayments.InstallmentSelected` 的 `onInstallmentSelected(_:)` | 重命名 | 可选。触发条件和字段相同；只有 payload 类型发生变化。当购物者在 SDK 的卡片表单中选择或更改分期时触发，包括 SDK 的默认自动选择；当该选择不再适用时，以 `nil` 触发。请参阅 [`onInstallmentSelected`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-installment-selected)。 |
| `YunoShippingDelegate.onShippingAddressChanged(_:shippingInfo:)` | 通过 `SdkPayments.ShippingAddressHandling` 的 `onShippingAddressChanged(_:shippingInfo:)` | 迁移 | 可选。让控制器遵循该协议；类型去掉了 `Yuno` 前缀，基于 completion 的变体已移除。async 签名和作用相同：在 Apple Pay 支付表单上实时更新配送信息。该协议继承自 `TransactionController`，因此 SDK 会从您在配置中传入的 `controller` 获取它。请参阅 [`onShippingAddressChanged`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-shipping-address-changed)。 |

### 视图

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `paymentFlow.formView(paymentMethodSelected:with:)` | `showView(view:process:step:)` | 迁移 | 推送而非拉取：您不再获取视图，SDK 会在视图就绪时将其交给您的处理程序。将其缓存在您的模型中，并从那里渲染。`showView` 在每笔交易中可能被调用多次：`step == .FORM` 用于数据捕获表单，`step == .ACTION` 用于操作视图，例如支付码或 OTP。3DS 挑战和重定向从不经过 `showView`：SDK 会以全屏方式呈现它们。请参阅 [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)。 |
| `paymentFlow.submitForm()` | `process.onSubmit()` | 重命名 | 作用相同。在您于 `showView` 中收到的 `TransactionProcess` 上调用它。 |
| *（无）* | `SdkPayments.defaultShowView(view:process:step:)` | 新增 | 对于您不想嵌入的步骤，从您的 `showView` 覆盖中调用它（例如，嵌入 `.FORM`，并将 `.ACTION` 交还给 SDK）。 |

### 入口点

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `Yuno.startPaymentRenderFlow(paymentMethodSelected:with:)` | `SdkPayments.Transaction(config:).start(paymentSelected:)` | 重命名 | 构建配置，然后调用 `start`：Transaction 是唯一的入口点，所选项传给 `start`。覆盖 `showView` 以将表单保留在您的布局中（请参阅“视图”）。 |
| `paymentFlow.continuePayment()` | *（已移除）* | 移除 | 删除该调用：从 `createPayment` 返回即可恢复流程。SDK 会自行以全屏方式运行 3DS 和重定向；您不再在您的布局中渲染它们。仅当您需要 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`。 |

## 相关内容

* [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)。控制器和 `TransactionProcess` 的完整参考。
* [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。加载状态控制器。
* [`TransactionConfig`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-pass#transaction-config)。完整的字段参考。
* [迁移 / Lite](https://docs.y.uno/zh-hans/docs/yuno-sdk/migration/ios/payment/lite.md)。适用于您不需要自行嵌入表单的情况。


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