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

> 将 Android Render 集成（Activity.startPaymentRender + YunoPaymentRenderListener）迁移到统一的 Transaction API。

Render 模式让您可以将 SDK 的支付表单嵌入您自己的布局中：您调用 `startPaymentRender(…)`，并收到一个 `YunoPaymentFragmentController` 以及一个传递 SDK 的 `Fragment` 的 `YunoPaymentRenderListener.showView(fragment)` callback。您将其放入布局中，并从您自己的按钮调用 `controller.submitForm()`（3DS 步骤则调用 `controller.continuePayment()`）。

在统一 API 中，同样的模式通过覆盖 [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view) 来实现。SDK 仍会向您提供一个 `Fragment`；您会同时收到一个公开 `onSubmit()` 和 `onClose()` 的 `TransactionProcess` 控制对象。后续步骤（3DS / 重定向）不再是单独的调用。SDK 在需要时会发出第二次 `step = ACTION` 的 `showView`。

## 开始之前

* 将 `com.yuno.sdk.*`、`com.yuno.payments.features.*` 和 `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` 必须与该决定一致：

| 由谁创建支付 | 在 Render 中您的做法 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | 实现了 `returnOneTimeToken`（headless-render 变体） | 覆盖 `createPayment` | 默认（`SDK_CHECKOUT`） |
| SDK | 未实现 `returnOneTimeToken` | 不覆盖 | `SDK_SEAMLESS` |

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

## 对照

```kotlin Before. Render mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import androidx.fragment.app.Fragment
import com.yuno.sdk.payments.render.startPaymentRender
import com.yuno.sdk.payments.render.YunoPaymentFragmentController
import com.yuno.sdk.payments.render.YunoPaymentRenderListener
import com.yuno.payments.features.payment.models.OneTimeTokenModel
import com.yuno.presentation.core.components.PaymentSelected

class CheckoutActivity : ComponentActivity(), YunoPaymentRenderListener {

    private var controller: YunoPaymentFragmentController? = null

    fun pay(paymentSelected: PaymentSelected) {
        controller = startPaymentRender(
            checkoutSession = "session-from-backend",
            countryCode = "CO",
            submitButton = false,
            showPaymentStatus = false,
            coroutineScope = lifecycleScope,
            paymentSelected = paymentSelected,
            controller = this,
        )
    }

    override fun showView(fragment: Fragment) {
        // Embed in your layout
        supportFragmentManager.beginTransaction()
            .replace(R.id.yuno_form_container, fragment)
            .commit()
    }

    override fun loadingListener(isLoading: Boolean) { /* show your own loader */ }

    override fun returnStatus(resultCode: Int, paymentStatus: String, paymentSubStatus: String?) {
        // resultCode + paymentStatus
    }

    override fun returnOneTimeToken(oneTimeToken: String, additionalData: OneTimeTokenModel?) {
        // (only fires in the headless-render variant)
    }

    fun onPayButton() {
        controller?.submitForm()
    }

    // Called after the merchant's backend returns from 3DS / redirect
    fun onContinuePayment() {
        controller?.continuePayment()
    }
}
```

```kotlin After. showView override theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import androidx.fragment.app.Fragment
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.TransactionProcess
import com.yuno.payments.sdk.api.models.TransactionViewStep
import com.yuno.payments.sdk.api.models.PaymentMethodSelected
import com.yuno.payments.sdk.api.models.TransactionStatus

class CheckoutActivity : ComponentActivity(), TransactionController {

    private var process: TransactionProcess? = null

    fun pay(paymentSelected: PaymentMethodSelected) {
        val config = TransactionConfig(
            checkoutSession = "session-from-backend",
            countryCode = "CO",
            controller = this,
        )

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

    // 1. Embed the delivered fragment (called once per step: FORM, then ACTION for 3DS if applicable)
    override fun showView(view: Fragment, process: TransactionProcess, step: TransactionViewStep) {
        this.process = process
        supportFragmentManager.beginTransaction()
            .replace(R.id.yuno_form_container, view)
            .commit()
    }

    // 2. Override showLoading if you want to render your own loader
    override fun showLoading(isLoading: Boolean) { /* show your own loader */ }

    // 3. Final status arrives through onStatus
    override fun onStatus(status: TransactionStatus) {
        // status.status: "SUCCEEDED" / "REJECTED" / ...
    }

    fun onPayButton() {
        process?.onSubmit()
    }
}
```

## 变更内容

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

### 初始化和配置

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `import com.yuno.sdk.*` | `import com.yuno.payments.sdk.api.*` | 重命名 | |
| `startPaymentRender` 的 `checkoutSession`、`countryCode` 参数 | `TransactionConfig` 上的相同字段 | 移动 | 该调用的参数变为配置字段。 |
| `startPaymentRender` 的 `submitButton` 参数 | *（已移除）* | 移除 | 删除它：在统一 API 中，提交按钮完全由您负责。覆盖 `showView` 后，SDK 永远不会渲染提交按钮；请在您的布局中渲染它，并在点击时调用 `process.onSubmit()`（请参阅“视图”）。 |
| `startPaymentRender` 的 `showPaymentStatus` 参数 | `TransactionConfig.showStatusScreen` | 移动 | 作用相同。 |
| `startPaymentRender` 的 `coroutineScope` 参数 | *（已移除）* | 移除 | 删除它：SDK 自行管理其作用域。 |

### 控制器

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoPaymentRenderListener` | `TransactionController` | 重命名 | 实现同一个类，并将其作为 `TransactionConfig.controller` 传入（之前它是 `startPaymentRender` 的 `controller` 参数）。SDK 不会持有它：请在整个交易期间保持其存活。 |
| `returnStatus(resultCode, paymentStatus, paymentSubStatus)` | `onStatus(status: TransactionStatus)` | 重命名 | 仍是唯一的结果 callback，每个交易调用一次，SDK 显示其结果页面时也会调用。`resultCode`（`PAYMENT_RESULT_*` 整数）已被移除：请改为根据 `status.status` 进行分支处理。状态字符串现在封装在一个 `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)。 |
| `returnOneTimeToken(oneTimeToken, additionalData)` | `createPayment(token: Map<String, Any>)` | 重命名 | 可选。它仅在 headless-render 变体中触发，因此只与非 seamless 的 headless 路径相关。如果您使用过它，请覆盖 `createPayment`：`token` 是以 map 形式表示的完整一次性令牌。创建支付后返回。如果处理程序抛出异常，流程将停止且不会调用 `onStatus`，因此请自行显示错误。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment) 和 [Headless 迁移](https://docs.y.uno/zh-hans/docs/yuno-sdk/migration/android/payment/headless.md)。 |
| `loadingListener(isLoading)` | `showLoading(isLoading)` | 重命名 | 语义相同。Render 是加载指示器 callback 真正被调用的旧版模式，因此现有的 Render 集成几乎肯定需要迁移这一项。覆盖后，SDK 会隐藏其自身的加载指示器，并将状态报告给您。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |

### 视图

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoPaymentRenderListener.showView(fragment)` | `showView(view, process, step)` | 重命名 | 由推送代替拉取：您不再需要调用任何方法来获取 fragment，SDK 会在就绪时将其交付给您的处理程序。`process` 替代 `YunoPaymentFragmentController`。`showView` 在每个交易中可能被调用多次，`step` 会告诉您收到的是哪个步骤：`FORM` 表示数据捕获表单，`ACTION` 表示 3DS 挑战或外部重定向。请决定如何将它们分别嵌入您的布局中。请参阅 [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)。 |
| `controller.submitForm()` | `process.onSubmit()` | 重命名 | 作用相同。在 `showView` 中收到的 `TransactionProcess` 上调用它。 |
| `controller.continuePayment()` | *（已移除）* | 移除 | 删除该调用。3DS 由 SDK 处理：当需要 3DS 挑战或重定向时，SDK 会自行触发第二次 `showView(view, process, step = ACTION)`，您可以继续将其嵌入您的布局中。您无需调用任何方法。 |

### 入口点

| Render | 统一 API | 变更 | 操作 |
| - | - | - | - |
| 返回 `YunoPaymentFragmentController` 的 `startPaymentRender(checkoutSession, countryCode, …, paymentSelected, controller)` | `Transaction(config).start(activity, paymentSelected)` | 重命名 | 先构建配置，再调用 `start`：`Transaction` 是唯一的入口点，所选项传给 `start`。覆盖 `showView` 以将表单保留在您的布局中（请参阅“视图”）。 |
| `PaymentSelected` | `PaymentMethodSelected` | 重命名 | 作用相同：即您传给 `start` 的值。 |

## 相关内容

* [`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/android/payment/lite.md)。适用于您无需自行嵌入表单的情况。


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