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

# Web 样式

> 自定义 Yuno Web SDK 的外观和行为，使其与您的品牌保持一致。

> [!NOTE]
>
> **This page documents a legacy SDK.** Starting a new integration? Use the [Yuno SDK](https://docs.y.uno/docs/yuno-sdk/get-started.md). Already on a legacy SDK? Follow the [migration guide](https://docs.y.uno/docs/yuno-sdk/migration/overview.md).
>
> The new **Yuno SDK** (Web v2.x, iOS v3.x, Android v3.x, React Native v2.x) replaces the Full, Lite, Seamless, Render, Headless, and Secure Fields SDKs with one API across every platform. Legacy SDKs remain supported side by side during the transition and are scheduled for deprecation in **2027**. Contact your Account Manager for migration planning.

Yuno Web SDK 提供多种配置选项，用于修改其视觉呈现和功能流程。您可以控制从显示模式（Modal 与 Element）到银行卡表单精细 CSS 注入的所有内容。

> [!TIP]
>
> 如需了解所有初始化参数及其可能取值的完整列表，请访问 [Web SDK 参考](https://docs.y.uno/zh-hans/docs/sdks/resources/references/web.md)。

## 显示模式

`renderMode` 参数决定支付表单如何呈现给您的客户。您可以选择弹出式模态框，也可以将 SDK 直接嵌入页面上的某个 HTML 元素中。

| 模式 | 描述 |
| :- | :- |
| `modal` | 在屏幕居中的叠加层中显示支付流程。**默认模式。** |
| `element` | 在您应用中的指定容器内渲染 SDK。需要提供 `elementSelector`。 |

### 示例：作为元素嵌入

如果您选择 `element`，则必须为容器提供一个选择器。APM 表单和操作表单（例如 PIX 二维码）将挂载到此处。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  renderMode: {
    type: 'element',
    elementSelector: {
      apmForm: "#form-element",
      actionForm: "#action-form-element"
    } 
  },
})
```

***

## 银行卡表单自定义

`card` 配置对象可用于修改敏感银行卡数据字段（卡号、有效期、CVV）的外观。这些字段在安全的 iframe 中渲染，以符合 PCI 合规要求。

### CSS 注入

使用 `styles` 属性将自定义 CSS 直接注入银行卡表单 iframe。这样可以让 SDK 与您网站的视觉风格保持一致。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  card: {
    // Inject a raw CSS string to style inputs and buttons inside the iframe
    styles: `
      .Yuno-input {
        border-radius: 8px;
        border: 1px solid #E0E0E0;
        padding: 12px;
      }
      .Yuno-label {
        font-family: 'Inter', sans-serif;
        color: #333333;
      }
    `,
    cardSaveEnable: true, // Shows the "Save card for future payments" checkbox
  },
})
```

### 自定义字体

您页面的字体在银行卡 iframe 内不可用。使用 `fonts` 属性在 iframe 内加载字体文件，然后在 `styles` 中按名称引用该字体系列。`fonts` 只负责加载文件，`styles` 负责应用它们。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  card: {
    fonts: [
      {
        familyName: 'Inter',
        files: [
          { weight: 400, url: 'https://cdn.example.com/fonts/inter-400.woff2' },
          { weight: 600, url: 'https://cdn.example.com/fonts/inter-600.woff2' },
        ],
      },
    ],
    styles: `
      .Yuno-input, .Yuno-label {
        font-family: 'Inter', sans-serif;
      }
    `,
  },
})
```

| 字段 | 类型 | 描述 |
| :- | :- | :- |
| `familyName` | string | 在 `styles` 的 `font-family` 中引用的字体系列名称。 |
| `files` | array | 每个字重对应一个条目。 |
| `files[].weight` | number | 文件的字重，例如 `400` 或 `600`。 |
| `files[].url` | string | 字体文件的 URL，例如 `.woff2` 文件。 |

> [!NOTE]
>
> iframe 从与您页面不同的源加载文件，因此字体托管方必须允许跨源请求（发送 `Access-Control-Allow-Origin` 标头）。如果某个文件加载失败，表单会回退到您 `font-family` 字体栈中的下一个字体。对于 [Secure Fields](https://docs.y.uno/docs/sdks/customization/secure-fields/payment-secure-fields)，请改为向每个字段传入 `options.externalFonts`。

### 自定义标签和文本

您可以覆盖默认的占位符和按钮标签，以更好地匹配您应用的语气或语言要求。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  card: {
    texts: {
      cardPlaceholder: "0000 0000 0000 0000",
      cvvPlaceholder: "CVC",
      expirationDatePlaceholder: "MM/YY",
      submitButton: "Authorize Payment"
    }
  },
})
```

***

## 通用 UI 控制

修改 SDK 的通用行为，例如加载指示器、发卡机构表单和按钮可见性。

### SDK 加载指示器控制

默认情况下，Yuno 会在过渡期间显示加载旋转图标。如果您希望使用自己应用的加载状态，可以将其隐藏。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  showLoading: true, // Set to false to hide the Yuno loading spinner
})
```

### Pay 按钮可见性

如果您希望完全通过自己的 UI 逻辑触发支付，可以隐藏 SDK 内置的“Pay”按钮。

> [!WARNING]
>
> 如果您隐藏 Pay 按钮，则**必须**以编程方式调用 `yuno.submitOneTimeTokenForm()` 才能继续支付。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  showPayButton: false, // Hides the main payment submission button
})

// Triggering the submission from your own code
document.getElementById('my-custom-submit').addEventListener('click', () => {
  yuno.submitOneTimeTokenForm();
});
```

***

## 高级流程管理

### 性能与重试

如果交易失败，您可以在不卸载表单的情况下更新会话，从而为重试提供更流畅的用户体验。

| 参数 | 用途 |
| :- | :- |
| `automaticallyUnmount` | 设置为 `false` 可在令牌创建后保持银行卡表单处于挂载状态，便于重试。 |
| `updateCheckoutSession` | 在不卸载 SDK 的情况下注入新的结账会话的方法。可在失败后用它切换支付方式。详情请参阅 [updateCheckoutSession](https://docs.y.uno/zh-hans/docs/sdks/resources/references/web.md#updatecheckoutsession)。 |

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
yuno.startCheckout({
  automaticallyUnmount: false, // Prevents the form from closing after token creation
});

// On rejection, notify the SDK and update the session
yuno.notifyError();
yuno.updateCheckoutSession(newCheckoutSession);
```

### WebView 注意事项（Mercado Pago）

如果您在 **WebView** 环境中集成并使用 Mercado Pago Checkout Pro，则必须处理 `continuePayment()` 返回的重定向结果。

```javascript theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const result = await yuno.continuePayment();

if (result && result.action === 'REDIRECT_URL') {
   // Redirect the customer manually using result.redirect.init_url
   window.location.assign(result.redirect.init_url);
}
```


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