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

# Full 模式

> 将 React Native Full 集成（YunoPaymentMethods + YunoSdk.startPayment）迁移到统一的 Transaction API。

Full 模式通过 `<YunoPaymentMethods>` 组件渲染 Yuno 的支付方式列表，并由 `YunoSdk.startPayment()` 使用购物者选择的支付方式进行支付。在统一 API 中，该列表是一个视图：您通过 `getPaymentMethodsViews` 从交易中请求它，并使用 `<YunoView>` 渲染。购物者的选择通过 `onPaymentSelected` 送达，您再将其传给 `transaction.start()`。

## 开始之前

* 将 `@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` 必须与该决定一致：

| 由谁创建支付 | 在 Full 中您使用的是 | 在统一 API 中 | 会话 `workflow` |
| - | - | - | - |
| 您的 backend | `onOneTimeToken`、您的 backend 调用，然后是 `continuePayment` | 实现 `createPayment` | 默认（`SDK_CHECKOUT`） |
| SDK | Full 中没有对应项 | 不实现 `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. Full mode theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import { YunoSdk, YunoPaymentMethods } from '@yuno-payments/yuno-sdk-react-native';

function PaymentScreen({ checkoutSession }) {
  const [isMethodSelected, setIsMethodSelected] = useState(false);

  useEffect(() => {
    const tokenSubscription = YunoSdk.onOneTimeToken(async (token) => {
      await myBackend.createPayment(token);
      await YunoSdk.continuePayment(checkoutSession, 'CO', true);
    });
    const statusSubscription = YunoSdk.onPaymentStatus((state) => {
      console.log('Final status:', state.status);
    });
    return () => {
      tokenSubscription.remove();
      statusSubscription.remove();
    };
  }, [checkoutSession]);

  return (
    <>
      <YunoPaymentMethods
        checkoutSession={checkoutSession}
        countryCode="CO"
        onPaymentMethodSelected={(event) => setIsMethodSelected(event.isSelected)}
        onPaymentMethodError={(event) => console.warn(event.message)}
      />
      <Button
        title="Pay"
        disabled={!isMethodSelected}
        onPress={() => YunoSdk.startPayment(true)}
      />
    </>
  );
}
```

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

function PaymentScreen({ checkoutSession }) {
  const [transaction, setTransaction] = useState<Transaction | null>(null);
  const [listView, setListView] = useState<YunoViewHandle | null>(null);
  const [selected, setSelected] = useState<PaymentMethodSelected | null>(null);

  useEffect(() => {
    let active = true;
    const created = new Transaction({
      checkoutSession,
      countryCode: 'CO',
      showStatusScreen: true,
      controller: {
        createPayment: async (token) => {
          await myBackend.createPayment(token);
        },
        onStatus: (status) => {
          console.log('Final status:', status.status);
        },
      },
    });
    setTransaction(created);
    created
      .getPaymentMethodsViews([{ kind: 'PAYMENT_METHOD_LIST' }], {
        onPaymentSelected: setSelected,
      })
      .then((views) => {
        if (active) setListView(views[0]?.view ?? null);
      })
      .catch((error) => {
        if (active) console.warn('Could not load the payment methods', error);
      });
    return () => {
      active = false;
      created.dispose();
    };
  }, [checkoutSession]);

  return (
    <>
      {listView ? <YunoView view={listView} /> : null}
      <Button
        title="Pay"
        disabled={!transaction || !selected}
        onPress={() => selected && transaction?.start(selected)}
      />
    </>
  );
}
```

## 变更内容

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

### 初始化与配置

| Full | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoSdk.initialize({ apiKey, countryCode, yunoConfig, iosConfig, androidConfig })` | `SdkPayments.initialize(apiKey)` | 已重命名 | 现在它只接收密钥。其他参数移至 `TransactionConfig` 或不再存在（见后续各行）。 |
| `initialize` 和 `<YunoPaymentMethods>` 的 `countryCode` | `TransactionConfig.countryCode` | 已移动 | 每笔交易传入一次。 |
| `<YunoPaymentMethods>` 的 `checkoutSession` | `TransactionConfig.checkoutSession` | 已移动 | 列表读取请求它的那笔交易的会话。 |
| `yunoConfig.language`、`yunoConfig.saveCardEnabled` | `TransactionConfig.language`、`TransactionConfig.saveCardEnabled` | 已移动 | 按每笔交易传入，而不是在启动时传入一次。 |
| `yunoConfig.keepLoader`、`isDynamicViewEnabled`、`cardFormDeployed`、`iosConfig`、`androidConfig`、`CardFlow` 枚举 | *（已移除）* | 已移除 | 删除它们。除非您实现 `showLoading`，否则 SDK 会保留其加载指示器；SDK 只有一个卡片表单，展开式列表在您 Dashboard 的 Checkout Builder 中设置。 |
| `startPayment` 的 `showPaymentStatus` 参数 | `TransactionConfig.showStatusScreen` | 已移动 | 现在默认关闭：设置 `showStatusScreen: true` 即可保留 SDK 结果页面。 |

### 支付方式列表

| Full | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `<YunoPaymentMethods checkoutSession countryCode />` | `transaction.getPaymentMethodsViews([{ kind: 'PAYMENT_METHOD_LIST' }], listController)` + `<YunoView view={view} />` | 已重命名 | 从交易中请求列表，然后渲染它返回的视图。钱包按钮来自同一调用：Android 上为 `{ kind: 'GOOGLE_PAY' }`，iOS 上为 `{ kind: 'APPLE_PAY' }`。请参阅[支付方式列表](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/payment-methods-list.md)。 |
| `onPaymentMethodSelected({ isSelected })` | `listController.onPaymentSelected(paymentSelected)` | 已重命名 | 现在您收到的是 `PaymentMethodSelected` 本身，SDK 预选时 `selectionSource` 为 `'AUTO'`，用户点按时为 `'USER'`。保存它并将其传给 `start()`。 |
| `onSizeChanged({ height })` | `<YunoView>` 尺寸调整，`listController.onHeightChange(height)` | 已重命名 | `<YunoView>` 会根据原生内容自行调整尺寸。仅当您自行布局列表时才实现 `onHeightChange`。 |
| `onPaymentMethodError({ message })` | `controller.onStatus(status)` | 已移动 | 加载失败的列表会通过 `onStatus` 报告 `INTERNAL_ERROR`。 |
| *（无）* | `listController.onUnenroll(success)` | 新增 | 可选。报告从列表中移除已保存支付方式的结果。 |

### 控制器

| Full | 统一 API | 变更 | 操作 |
| - | - | - | - |
| 事件订阅（`onPaymentStatus`、`onOneTimeToken`） | `TransactionConfig.controller` | 已重命名 | 监听器变为一个带有方法的普通对象，在配置中传入。无需移除任何订阅：当屏幕关闭时调用 `transaction.dispose()`。 |
| `YunoSdk.onPaymentStatus((state) => …)` | `onStatus(status)` | 已重命名 | `state.status` 变为 `status.status`，旁边还有 `substatus` 和 `message`。`status` 和 `substatus` 来自 backend：请处理 `DECLINED`、`REJECTED`、`ERROR` 和 `PENDING`，而不是 1.x 的 `FAILED` 和 `PROCESSING`；并处理 `USER_CANCEL`，而不是 `CANCELLED_BY_USER`。SDK 本身只会发出 `INTERNAL_ERROR` 和 `USER_CANCEL`。请参阅 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |
| `onOneTimeToken(listener)` + 您的 backend 调用 + `YunoSdk.continuePayment(…)` | `createPayment(token)` | 已重命名 | 创建支付并 resolve 返回的 Promise：SDK 会自行继续（3DS、状态）。`token` 是完整的一次性令牌对象：将 `token.token` 发送到您的 backend。请参阅 [`createPayment`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/create-payment)。 |
| `getLastOneTimeToken*`、`clearLast*` | *（已移除）* | 已移除 | 令牌通过 `createPayment` 送达，结果通过 `onStatus` 送达。 |
| `YunoSdk.hideLoader()` | `showLoading(isLoading)` | 已重命名 | 可选。实现它即可显示您自己的加载指示器。请参阅 [`showLoading`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/show-loading)。 |

### 入口点

| Full | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `YunoSdk.startPayment(showPaymentStatus)` | `transaction.start(selected)` | 已重命名 | 传入您的列表控制器收到的 `PaymentMethodSelected`。快捷钱包按钮在被点按时会自行启动支付。 |
| `YunoSdk.receiveDeeplink(url)` | `transaction.handleDeeplink(url)` | 已重命名 | 请参阅[处理 deeplink](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/handle-deeplinks.md)。 |

## 相关内容

* [支付方式列表](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/payment-methods-list.md)。类型、列表控制器和快捷按钮。
* [快速入门](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md)。统一 API 的完整演练。
* [`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.