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

# Seamless 模式

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

Seamless 是最简单的旧版入口点：单个 `await` 调用即可返回最终结果。没有 delegate，没有 callback。您传入一个 `SeamlessParams` 和一个 `PaymentMethodSelected`；SDK 渲染表单、进行令牌化、创建支付、运行 3DS，并返回一个 `Yuno.Result`。

在统一 API 中，同样的流程是 `Transaction.start(paymentSelected:)` 的 **默认行为**。除 `onStatus` 外，无需覆盖任何控制器。唯一的结构性变化是结果交付模型：以前是异步返回，现在是通过 `onStatus` 的 callback。

## 开始之前

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

| 由谁创建支付 | 在 Seamless 中您使用的是 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | 无对应项：Seamless 从不允许您创建支付 | 覆盖 `createPayment` | 默认（`SDK_CHECKOUT`） |
| 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. Seamless 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")

// 2. Trigger the payment from a single async call
func pay(paymentSelected: PaymentMethodSelected) async {
    let params = SeamlessParams(
        checkoutSession: "session-from-backend",
        countryCode: "CO",
        language: "en",
        viewController: nil
    )

    let result = await Yuno.startPaymentSeamlessLite(
        with: params,
        paymentSelected: paymentSelected,
        showPaymentStatus: true
    )

    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
    }
}
```

```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 a minimal 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. Trigger the payment
    func pay(paymentSelected: SdkPayments.PaymentMethodSelected) {
        let config = SdkPayments.TransactionConfig(
            checkoutSession: "session-from-backend",
            countryCode: "CO",
            language: "en",
            controller: self,
            showStatusScreen: true,
            viewController: nil
        )

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

## 变更内容

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

### 初始化与配置

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `import YunoSDK` | `import SdkPayments` | 重命名 | |
| `Yuno.initialize(apiKey:)` | `SdkPayments.initialize(apiKey:)` | 重命名 | `callback:` 参数已移除；如果您需要等待，请使用 `async` 重载。 |
| 在 `YunoConfig.appearance` 中传入的 `Yuno.Appearance` | `SdkPayments.TransactionConfig.appearance` 中的 `SdkPayments.Appearance` | 重命名 | 初始化方法相同；去掉 `Yuno.` 前缀，并在每笔交易中传入，而不是在启动时传入一次。 |
| `SeamlessParams.checkoutSession`、`.countryCode`、`.language`、`.viewController` | `SdkPayments.TransactionConfig` 上的相同字段 | 迁移 | 值相同；`viewController` 仍仅适用于 iOS，在 SwiftUI 中为可选。配置还接收 `controller`（请参阅“控制器”）。 |
| `startPaymentSeamlessLite` 的 `showPaymentStatus:` 参数 | `SdkPayments.TransactionConfig.showStatusScreen` | 迁移 | 请参阅下方的说明。 |

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

### 控制器

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| *（无 delegate）* | `SdkPayments.TransactionController` | 新增 | 即使是最简单的情况也需要一个控制器实例：让一个类遵循该协议并只实现 `onStatus`，然后将其作为 `TransactionConfig.controller` 传入。SDK 不会持有它：请在整个交易期间保持其存活。 |
| 由 `await` 返回的 `Yuno.Result` | 带有 `SdkPayments.TransactionStatus` 的 `onStatus(status:)` | 迁移 | 结果现在基于 callback：您无法内联 `await` 它，因此如果您的代码在返回值上串联了逻辑，或将其返回给调用方，请将其重构为在 `onStatus` 中做出响应。仍是唯一的结果 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` 不再是可选值。 |

### 入口点

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `Yuno.startPaymentSeamlessLite(with:paymentSelected:showPaymentStatus:)`，包括 `async` 和 `callback:` 两种重载 | `SdkPayments.Transaction(config:).start(paymentSelected:)` | 重命名 | 构建配置，然后调用 `start`。无需 `await`，也无需传入 callback：结果会在 `onStatus` 中送达。您仍需选择支付方式并将其传入。 |
| `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 的分步指南；新的“Seamless 等效方案”现在是默认路径。
* [`onStatus`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-status)。交付最终状态的控制器。
* [`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)。迁移过程几乎相同；在统一 API 中，Seamless 和 Lite 合并为同一条默认路径。


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