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

> 将 React Native Lite 集成（YunoSdk.startPaymentLite）迁移到统一的 Transaction API。

Lite 模式在您这一侧预先选择支付方式，然后交由 SDK 渲染表单并进行令牌化。在 React Native 1.x 中，SDK 随后通过 `onOneTimeToken` 发出一次性令牌，由您的 backend 创建支付，再由 `continuePayment` 恢复流程。在统一 API 中，这对应于带有 `createPayment` 控制器的 `Transaction.start(paymentSelected)`：SDK 会等待您的 backend，然后自行继续。

## 开始之前

* 将 `@yuno-payments/yuno-sdk-react-native` 升级到 2.0.0 并运行 `pod install`。您的公共 API 密钥以及您的 backend 创建的结账会话保持不变（[开始之前](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md#before-you-begin)）。
* 在 Android 上，`minSdkVersion` 现在为 23。如果您的 `android/build.gradle` 对 Yuno 模块应用了 Compose 编译器插件（1.x 的一种变通做法），请删除该代码块：使用 2.0.0 时，构建会失败并提示“The Compose Compiler requires the Compose Runtime to be on the class path”。
* 决定由谁创建支付。结账会话的 `workflow` 必须与该决定一致：

| 由谁创建支付 | 在 Lite 中您使用的是 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | `onOneTimeToken`、您的 backend 调用，然后是 `continuePayment` | 实现 `createPayment` | 默认（`SDK_CHECKOUT`） |
| SDK | `startPaymentSeamlessLite`（请参阅 [Seamless Lite](https://docs.y.uno/zh-hans/docs/yuno-sdk/migration/react-native/payment/seamless-lite.md)） | 不实现 `createPayment` | `SDK_SEAMLESS` |

> [!WARNING]
>
> 使用默认 workflow 的会话如果控制器中没有 `createPayment`，最终会以 `INTERNAL_ERROR` 结束：backend 会拒绝 SDK 创建支付。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。

## 对照

```tsx Before. Lite mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { YunoSdk, YunoStatus } from '@yuno-payments/yuno-sdk-react-native';

// 1. Initialize once at app startup
await YunoSdk.initialize({
  apiKey: 'your-public-api-key',
  countryCode: 'CO',
  yunoConfig: { language: 'en', saveCardEnabled: true },
});

// 2. Subscribe to the token and the result
const tokenSubscription = YunoSdk.onOneTimeToken(async (token) => {
  await myBackend.createPayment(token);
  await YunoSdk.continuePayment(checkoutSession, 'CO', true);
});
const statusSubscription = YunoSdk.onPaymentStatus((state) => {
  switch (state.status) {
    case YunoStatus.SUCCEEDED: console.log('Success'); break;
    case YunoStatus.REJECTED: console.log('Rejected'); break;
    case YunoStatus.FAILED: console.log('Failed'); break;
    case YunoStatus.PROCESSING: console.log('Processing'); break;
    case YunoStatus.CANCELLED_BY_USER: console.log('User cancelled'); break;
  }
});

// 3. Trigger the payment with a pre-selected method
await YunoSdk.startPaymentLite({
  checkoutSession,
  methodSelected: { paymentMethodType: 'CARD', vaultedToken: savedToken },
  showPaymentStatus: true,
});

// 4. Remove the subscriptions when the screen goes away
tokenSubscription.remove();
statusSubscription.remove();
```

```tsx After. Unified Transaction theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { SdkPayments, Transaction } from '@yuno-payments/yuno-sdk-react-native';

// 1. Initialize once at app startup
await SdkPayments.initialize('your-public-api-key');

// 2. Build the transaction with its controller
const transaction = new Transaction({
  checkoutSession,
  countryCode: 'CO',
  language: 'en',
  saveCardEnabled: true,
  showStatusScreen: true,
  controller: {
    createPayment: async (token) => {
      await myBackend.createPayment(token);
    },
    onStatus: (status) => {
      switch (status.status) {
        case 'SUCCEEDED': console.log('Success'); break;
        case 'DECLINED': console.log('Declined'); break;
        case 'REJECTED': console.log('Rejected'); break;
        case 'ERROR': console.log('Error'); break;
        case 'PENDING': console.log('Pending'); break;
        case 'INTERNAL_ERROR': console.log('Internal error'); break;
        case 'USER_CANCEL': console.log('User cancelled'); break;
      }
    },
  },
});

// 3. Trigger the payment with a pre-selected method
await transaction.start({ type: 'CARD', vaultedToken: savedToken });

// 4. Release it when the screen goes away
transaction.dispose();
```

## 变更内容

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

### 初始化与配置

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoSdk` | `SdkPayments` 和 `Transaction` | 已重命名 | `SdkPayments` 保留全局调用；与支付相关的一切都位于 `Transaction` 上。 |
| `YunoSdk.initialize({ apiKey, countryCode, yunoConfig, iosConfig, androidConfig })` | `SdkPayments.initialize(apiKey)` | 已重命名 | 现在它只接收密钥。其他参数移至 `TransactionConfig` 或不再存在（见后续各行）。 |
| `initialize` 的 `countryCode`，以及每个调用的可选 `countryCode` 参数 | `TransactionConfig.countryCode` | 已移动 | 每笔交易传入一次。 |
| `yunoConfig.language` | `TransactionConfig.language` | 已移动 | 按每笔交易传入，而不是在启动时传入一次。 |
| `yunoConfig.saveCardEnabled` | `TransactionConfig.saveCardEnabled` | 已移动 | 按每笔交易传入，而不是在启动时传入一次。 |
| `yunoConfig.keepLoader` | *（已移除）* | 已移除 | SDK 会保留其加载指示器。仅当您想使用自己的加载指示器时才实现 `showLoading`（请参阅“控制器”）。 |
| `yunoConfig.isDynamicViewEnabled`、`cardFormDeployed`、`CardFlow` 枚举 | *（已移除）* | 已移除 | 删除它们：SDK 只有一个卡片表单，展开式支付方式列表在您 Dashboard 的 Checkout Builder 中设置。 |
| `iosConfig`、`androidConfig` | *（已移除）* | 已移除 | 删除它们。 |
| `startPaymentLite` 的 `checkoutSession` | `TransactionConfig.checkoutSession` | 已移动 | 调用的参数变为配置字段。 |
| `startPaymentLite` 的 `showPaymentStatus` | `TransactionConfig.showStatusScreen` | 已移动 | 请参阅下方说明。 |
| *（无）* | `TransactionConfig.appearance` | 新增 | 可选。按每笔交易设置 SDK 视图的颜色和字体。请参阅[样式](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/styling.md)。 |

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

### 控制器

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| 事件订阅（`onPaymentStatus`、`onOneTimeToken`） | `TransactionConfig.controller` | 已重命名 | 监听器变为一个带有方法的普通对象，在配置中传入。无需移除任何订阅：当屏幕关闭时调用 `transaction.dispose()`。 |
| `YunoSdk.onPaymentStatus((state) => …)` | `onStatus(status)` | 已重命名 | 仍是唯一的结果 callback，每笔交易在终态时调用一次，SDK 显示其结果页面时也会调用。`state.status` 变为 `status.status`，`status.substatus` 和 `status.message` 为新增内容。`status` 和 `substatus` 来自 backend，与 backend 返回的值一致：不再发出 1.x 的 `FAILED` 和 `PROCESSING` 值，因此请改为处理 `DECLINED`、`REJECTED`、`ERROR` 和 `PENDING`。`CANCELLED_BY_USER` 现在为 `USER_CANCEL`。SDK 本身只会发出 `INTERNAL_ERROR` 和 `USER_CANCEL`。请参阅 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |
| `YunoSdk.onOneTimeToken(listener)` / `onOneTimeTokenInfo(listener)` + 您的 backend 调用 + `YunoSdk.continuePayment(checkoutSession, countryCode, showPaymentStatus)` | `createPayment(token)` | 已重命名 | 三个步骤合并为一个方法。`token` 是完整的一次性令牌对象，而不仅仅是令牌字符串：将 `token.token` 发送到您的 backend。创建支付并 resolve 返回的 Promise；随后 SDK 会查询状态，在需要时运行 3DS，并调用 `onStatus`。如果 Promise 被 reject，流程会停止：在 Android 上，`onStatus` 会收到 `INTERNAL_ERROR`，其 `message.code` 为 `MERCHANT_CREATE_PAYMENT_FAILED`；在 iOS 上，流程会关闭且不返回状态。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。 |
| `getLastOneTimeToken`、`getLastOneTimeTokenInfo`、`clearLastOneTimeToken`、`clearLastPaymentStatus` | *（已移除）* | 已移除 | 令牌通过 `createPayment` 送达，结果通过 `onStatus` 送达：没有任何缓存内容需要读取或清除。 |
| `YunoSdk.hideLoader()` | `showLoading(isLoading)` | 已重命名 | 可选。实现它后，SDK 会隐藏自己的加载指示器，并将加载状态报告给您。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |
| *（无）* | `showView(view, process, step)` | 新增 | 可选。使用 `<YunoView>` 将 SDK 的表单嵌入您自己的屏幕。请参阅 [`showView`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-view)。 |

### 入口点

| Lite | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoSdk.startPaymentLite({ checkoutSession, methodSelected, showPaymentStatus }, countryCode)` | `new Transaction(config).start(paymentSelected)` | 已重命名 | 构建配置，然后调用 `start`。您仍需选择支付方式并将其传入。`checkoutSession` 和 `showPaymentStatus` 已移至配置中（请参阅“初始化与配置”）。 |
| `methodSelected: { paymentMethodType, vaultedToken }` | `PaymentMethodSelected`：`{ type, vaultedToken }` | 已重命名 | `paymentMethodType` 现在为 `type`。请参阅 [`PaymentMethodSelected`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-pass#payment-method-selected)。 |
| `YunoSdk.receiveDeeplink(url)` | `transaction.handleDeeplink(url)` | 已重命名 | 将您的应用收到的 URL 转发给交易。请参阅[处理 deeplink](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/handle-deeplinks.md)。 |

## 相关内容

* [快速入门](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。


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