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

# onInstallmentSelected

> 当买家在卡片表单中选择分期付款选项时调用。

当买家在卡片表单中选择分期付款选项时（包括列表加载时自动选择第一个选项），会调用 `onInstallmentSelected`。它仅用于提供信息：无论如何，所选项都会随支付一起传递，因此覆盖它是可选的。可以用它在您自己的 UI 中反映所选的分期方案（例如，更新订单摘要）。

可在 Web、iOS、Android 和 React Native 上使用。在 Web 上，请在交易配置的 `card` 字段中设置它。SDK 会从其渲染的每个卡片表单中调用它。

## 您收到的内容

| 字段 | 类型 | 说明 |
| - | - | - |
| `installment` | Int | 所选的分期付款期数。 |
| `label` | String | 与向买家渲染时完全一致的选项标签。 |
| `amount.currency` | String | 金额的币种代码。 |
| `amount.value` | String | 每期金额。 |
| `amount.totalValue`（在 Web 上为 `amount.total_value`） | String | 所有分期付款的总金额。 |
| `installmentId` | String? | 仅限 Web（1.11.28+ 和 2.4.0+）。该选项所属分期付款方案的 ID。同一方案的选项共享该 ID，因此请将其与 `installment` 组合使用来识别选项。随一次性令牌一起发送。 |
| `type` | String? | 仅限 Web（1.11.28+ 和 2.4.0+）。分期付款方案类型。 |
| `rate` | Number? | 仅限 Web（1.11.28+ 和 2.4.0+）。该选项的 APR，取自 `financialCosts` 的 `APR` 条目。没有时为 `undefined`。 |
| `financialCosts` | Array? | 仅限 Web（1.11.28+ 和 2.4.0+）。该分期付款选项的财务成本明细，包含 `type`、`rate` 和 `formattedValue`。 |
| `additionalData` | Map? | 在 iOS 上（`[String: Any]?`），为 backend 发送的该方案原始 `additional_data` 对象；当 backend 未发送或其为空时为 `nil`。在 Android 和 Web 上为保留字段；目前为 `null`（在 Web 上为 `undefined`）。 |
| `isMerchantInstallment` | Boolean? | 在 iOS 和 Android 上为保留字段；目前为 `null`。在 Web 上，当方案来自您的 `card.onGetInstallments` hook 时为 `true`，为 Yuno 方案时为 `false`。 |

当 backend 未为该选项提供金额时，`amount` 为 `null`（在 Web 上为 `undefined`）。当方案来自 `card.onGetInstallments`（`isMerchantInstallment: true`）时，`installmentId`、`type`、`rate` 和 `financialCosts` 为 `undefined`，并且一次性令牌以 `installment: null` 创建。

## `null` 传递

当之前报告的选择不再有效时（可用的分期付款发生了变化，通常是因为买家编辑了卡号，而新卡没有分期付款方案），控制器会收到 `null`（在 iOS 上为 `nil`）。请将其视为“不再选择任何分期付款”。每次失效最多触发一次；新的选择会重新启用它。

## 签名

> [tab] Web
>
> ```typescript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> const transaction = sdkPayments.transaction({
>   checkoutSession,
>   countryCode: 'CO',
>   elementSelector: '#payment-form',
>   onStatus: (result) => console.log(result.status),
>   card: {
>     onInstallmentSelected: (installment) => {
>       if (installment) orderSummary.showFinancing(installment.label)
>       else orderSummary.clearFinancing()
>     },
>   },
> })
> ```

> [tab] iOS
>
> ```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> func onInstallmentSelected(_ installment: InstallmentSelected?) {
>     if let installment {
>         orderSummary.showFinancing(installment.label)
>     } else {
>         orderSummary.clearFinancing()
>     }
> }
> ```

> [tab] Android
>
> ```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> override fun onInstallmentSelected(installment: InstallmentSelected?) {
>     installment?.let {
>         orderSummary.showFinancing(it.label)
>     } ?: orderSummary.clearFinancing()
> }
> ```

> [tab] React Native
>
> ```tsx theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
> onInstallmentSelected: (installment) => {
>   if (installment) {
>     orderSummary.showFinancing(installment.label);
>   } else {
>     orderSummary.clearFinancing();
>   }
> },
> ```

## 相关内容

* [监听事件](https://docs.y.uno/docs/yuno-sdk/controllers/listen-to-events)。其他提供信息的控制器。
* [`onStatus`](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/on-status)。交易的最终结果。
* [控制器概览](https://docs.y.uno/zh-hans/docs/yuno-sdk/controllers/overview.md)。各平台如何接入控制器。


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