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

> 将 Android Seamless 集成（Activity.startPaymentSeamlessLite）迁移到统一 Transaction API。

Seamless 是 Android 上最简单的旧版入口：通过 `startCheckout(…)` 连接启动器后，只需一次 `startPaymentSeamlessLite(paymentSelected, …)` 调用即可交出全部工作：SDK 渲染表单、进行令牌化、创建支付、运行 3DS，并通过 `callbackPaymentState` lambda 返回结果。

在统一 API 中，同一流程是 `Transaction.start(activity, paymentSelected)` 的**默认行为**。除 `onStatus` 外无需覆盖任何控制器。结构上的变化在于结果传递模型：以前是传给启动调用的 lambda，现在通过 `TransactionController` 上的 `onStatus` 以 callback 形式传递。

## 开始之前

* 将 `com.yuno.sdk.*` 和 `com.yuno.presentation.*` 导入替换为对应的 `com.yuno.payments.sdk.api.*` 导入（“代码对照”一节已列出）。您的公共 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)。

## 代码对照

```kotlin Before. Seamless mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import com.yuno.sdk.Yuno
import com.yuno.sdk.payments.startCheckout
import com.yuno.sdk.payments.startPaymentSeamlessLite
import com.yuno.presentation.core.components.PaymentSelected

class CheckoutActivity : ComponentActivity() {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

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

        // 2. Wire up the checkout launcher
        startCheckout(
            checkoutSession = "session-from-backend",
            countryCode = "CO",
        )
    }

    // 3. Trigger the payment with a single call; result arrives in the lambda
    fun pay(paymentSelected: PaymentSelected) {
        startPaymentSeamlessLite(
            paymentSelected = paymentSelected,
            showPaymentStatus = true,
            callbackPaymentState = { state, subState ->
                when (state) {
                    "SUCCEEDED"         -> println("Success")
                    "REJECT"            -> println("Rejected")
                    "FAIL"              -> println("Failed")
                    "PROCESSING"        -> println("Processing")
                    "INTERNAL_ERROR"    -> println("Internal error")
                    "CANCELED_BY_USER"  -> println("User cancelled")
                }
            },
        )
    }
}
```

```kotlin After. Unified Transaction theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import com.yuno.payments.sdk.api.SdkPayments
import com.yuno.payments.sdk.api.Transaction
import com.yuno.payments.sdk.api.TransactionConfig
import com.yuno.payments.sdk.api.TransactionController
import com.yuno.payments.sdk.api.models.PaymentMethodSelected
import com.yuno.payments.sdk.api.models.TransactionStatus

class CheckoutActivity : ComponentActivity(), TransactionController {

    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)

        // 1. Initialize once at app startup
        SdkPayments.initialize(applicationContext, apiKey = "your-public-api-key")
    }

    // 2. Implement a minimal controller
    override fun onStatus(status: TransactionStatus) {
        when (status.status) {
            "SUCCEEDED"      -> println("Success")
            "DECLINED"       -> println("Declined")
            "REJECTED"       -> println("Rejected")
            "ERROR"          -> println("Error")
            "PENDING"        -> println("Pending")
            "INTERNAL_ERROR" -> println("Internal error")
            "USER_CANCEL"    -> println("User cancelled")
        }
    }

    // 3. Trigger the payment
    fun pay(paymentSelected: PaymentMethodSelected) {
        val config = TransactionConfig(
            checkoutSession = "session-from-backend",
            countryCode = "CO",
            language = "en",
            controller = this,
            showStatusScreen = true,
        )

        Transaction(config = config)
            .start(activity = this, paymentSelected = paymentSelected)
    }
}
```

## 变更内容

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

### 初始化和配置

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `import com.yuno.sdk.*` | `import com.yuno.payments.sdk.api.*` | 重命名 | |
| `Yuno.initialize(context, apiKey)` | `SdkPayments.initialize(context, apiKey)` | 重命名 | |
| `startCheckout` 的 `checkoutSession`、`countryCode` 参数 | `TransactionConfig` 上的相同字段 | 移动 | 值不变；配置还接收 `controller`（参见“控制器”）。 |
| `startPaymentSeamlessLite` 的 `showPaymentStatus` 参数 | `TransactionConfig.showStatusScreen` | 移动 | 参见下方说明。 |

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

### 控制器

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| *（无控制器：传给启动调用的 lambda）* | `TransactionController` | 新增 | 即使是最简单的情况也需要一个控制器实例：实现仅包含 `onStatus` 的 `TransactionController`，并将其作为 `TransactionConfig.controller` 传入。SDK 不会保留它：请在整个交易期间保持其存活。 |
| `callbackPaymentState: (state, subState) -> Unit` | `onStatus(status: TransactionStatus)` | 移动 | 结果通过控制器送达，而不是通过传给启动调用的 lambda。它仍是唯一的结果 callback，每笔交易触发一次，SDK 显示其结果页面时也是如此。原始的 `(state, subState)` 组合变为 `TransactionStatus` 对象：`status` 和 `substatus` 来自 backend，与 backend 返回的值一致。旧版的 `REJECT`、`FAIL` 和 `PROCESSING` 字符串不再发出：请改为处理 `DECLINED`、`REJECTED`、`ERROR` 和 `PENDING`。`CANCELED_BY_USER` 现在为 `USER_CANCEL`。SDK 自身只发出 `INTERNAL_ERROR` 和 `USER_CANCEL`。参见 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |

### 入口点

| Seamless | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `startCheckout(…)` + `startPaymentSeamlessLite(paymentSelected, showPaymentStatus, callbackPaymentState)` | `Transaction(config).start(activity, paymentSelected)` | 重命名 | 先构建配置，再调用 `start`：单一入口点，结果在 `onStatus` 中送达。您仍需自行选择支付方式并传入。`Activity` 扩展函数变为对普通 `Transaction` 实例的一次调用，构造该实例不需要 `Activity`。 |
| `PaymentSelected` | `PaymentMethodSelected` | 重命名 | 作用相同：即您传给 `start` 的值。 |

## 相关内容

* [快速入门](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/android/payment/lite.md)。几乎相同的迁移；在统一 API 中，Seamless 和 Lite 合并为同一默认路径。


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