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

# 从 Stripe Elements 迁移

> 将 Stripe 的 PaymentIntents、SetupIntents、Elements 和 webhook 对应到 Yuno 的等效功能。

> [!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.

如果您的 checkout 目前运行在 Stripe Elements 上，迁移到 Yuno 改变的是 checkout 层，您的 Stripe 账户保持不变。Yuno 将 Stripe 作为您启用的服务提供商之一进行连接，因此现有的 Stripe 处理会继续正常运行，同时您可以添加路由、其他服务提供商以及 Yuno 的 checkout。本页面将每个 Stripe 概念对应到您在 Yuno 上使用的内容。

## 概念

| Stripe | Yuno | 说明 |
| :- | :- | :- |
| PaymentIntent | [结账会话](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md) 加 [创建支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md) | 会话携带金额、国家和客户信息，并加载您账户上已启用的支付方式。支付由您的服务器使用 SDK 返回的一次性令牌创建。 |
| `client_secret` | `checkout_session` | 由您的服务器使用私钥创建，并传递给浏览器。在生产环境中 2.5 小时后过期。 |
| SetupIntent | [注册](https://docs.y.uno/zh-hans/docs/payment-features/enrollment/enroll-payment-methods.md)，或带有 `vault_on_success: true` 的支付 | 客户会话加上 `mountEnrollmentLite` 可以存储卡片而不扣款。`vault_on_success` 会在首次成功支付时存储卡片。两者都会返回 `vaulted_token`。 |
| PaymentMethod id（`pm_...`） | `vaulted_token` | 之后通过 [存储凭证](https://docs.y.uno/zh-hans/docs/payment-features/stored-credentials.md) 发送 `payment_method.vaulted_token` 进行扣款。 |
| Customer（`cus_...`） | [客户](https://docs.y.uno/reference/customers/create-customer.md) | 在创建会话之前创建客户，并传入其 id。 |
| `capture_method: 'manual'` | `payment_method.detail.card.capture: false` | 然后 [捕获](https://docs.y.uno/reference/payments/capture-authorization.md) 或 [取消](https://docs.y.uno/reference/payments/cancel-payment.md) 该授权。请参阅 [取消与捕获流程](https://docs.y.uno/zh-hans/docs/payment-features/Cancel-and-capture-flow.md)。 |
| `payment_method.card.fingerprint` | Payment Method 对象上的 `fingerprint` | 在您的组织内，同一卡号的值保持稳定。请参阅 [卡片 Fingerprint](https://docs.y.uno/zh-hans/docs/security-and-compliance/fingerprint.md)。 |
| Radar 规则和阻止列表 | [风险条件](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/risk-conditions.md) | 应用于您路由上的规则、阻止列表、允许列表和审核列表。 |
| Stripe Billing 订阅 | [订阅](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/index.md) 配合 [智能重试](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/retries.md) | 如果您保留 Stripe Billing，请参阅 [使用 Yuno 处理 Stripe Billing 订阅](https://docs.y.uno/zh-hans/docs/payment-features/subscriptions/stripe-billing.md)。 |
| 通过 Stripe 进行 3D Secure | [3D Secure](https://docs.y.uno/zh-hans/docs/security-and-compliance/3d-secure.md) | Yuno 在路由到的服务提供商上执行 3DS，并在购物者必须完成挑战时返回 `checkout.sdk_action_required`。 |

## Checkout 组件

| Stripe Elements | Yuno Web SDK | 指南 |
| :- | :- | :- |
| Payment Element | Seamless SDK | [Seamless SDK（Web）](https://docs.y.uno/zh-hans/docs/sdks/seamless-sdk/web-payments.md) |
| Card Element | Lite SDK 卡片组件，或在您自己掌控表单时使用 Secure Fields | [Lite SDK（Web）](https://docs.y.uno/zh-hans/docs/sdks/lite-web/payment.md)，[Secure Fields](https://docs.y.uno/docs/sdks/customization/secure-fields/payment-secure-fields) |
| 拆分的卡片字段（`cardNumber`、`cardExpiry`、`cardCvc`） | Secure Fields 的 `pan`、`expiration`、`cvv` | [Secure Fields](https://docs.y.uno/docs/sdks/customization/secure-fields/payment-secure-fields) |
| Express Checkout Element | Lite SDK `mountExternalButtons`（Apple Pay、Google Pay、PayPal） | [Lite SDK（Web）](https://docs.y.uno/zh-hans/docs/sdks/lite-web/payment.md) |
| `stripe.confirmPayment` | `yuno.startPayment` 加上您服务器的创建支付调用 | [React 和 Next.js](https://docs.y.uno/zh-hans/docs/sdks/web-frameworks/react-and-nextjs.md) |
| `stripe.confirmSetup` | `yuno.mountEnrollmentLite` | [Web 注册](https://docs.y.uno/zh-hans/docs/sdks/card-enrollment/web-enrollment.md) |
| `elements.update({ amount })` | `yuno.updateCheckoutSession(newSession)` | [Web 参考](https://docs.y.uno/zh-hans/docs/sdks/resources/references/web.md#updatecheckoutsession) |
| `@stripe/react-stripe-js` | `@yuno-payments/sdk-web`，配合 React 页面中的模式 | [React 和 Next.js](https://docs.y.uno/zh-hans/docs/sdks/web-frameworks/react-and-nextjs.md) |
| Appearance API | Checkout Builder 和 SDK 样式 | [Checkout Builder](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/checkout-builder.md)，[Web 样式](https://docs.y.uno/zh-hans/docs/sdks/customization/web/styling.md) |

## 支付流程对比

> [tab] Stripe Elements
>
> 1. 服务器创建 PaymentIntent 并返回 `client_secret`。
> 2. 浏览器使用该 secret 挂载 Payment Element。
> 3. 浏览器调用 `stripe.confirmPayment`。
> 4. Stripe 进行重定向或直接完成；您的服务器监听 `payment_intent.succeeded`。

> [tab] Yuno（Lite SDK / Secure Fields）
>
> 1. 服务器创建 [结账会话](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md) 并返回 `checkout_session`。
> 2. 浏览器使用该会话挂载 SDK，并调用 `yuno.startPayment()`。
> 3. SDK 在 `createPayment` 中为您提供一次性令牌；您的服务器使用 `payment_method.token` 和 `checkout.session` 调用 [创建支付](https://docs.y.uno/zh-hans/reference/payments/create-payment.md)。
> 4. 如果响应中包含 `checkout.sdk_action_required: true`，浏览器会调用 `yuno.continuePayment()` 处理 3DS 或重定向。您的服务器通过监听 `payment.purchase` webhook 获取最终状态。

> [tab] Yuno（Seamless SDK）
>
> 1. 服务器创建 [结账会话](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md) 并返回 `checkout_session`。
> 2. 浏览器使用该会话挂载 Seamless SDK，并调用 `yuno.startPayment()`。
> 3. SDK 根据您账户上的结账会话创建支付。您的服务器通过监听 `payment.purchase` webhook 获取最终状态。
> 4. 对于 3DS 或重定向，SDK 会自动处理挑战，并在 `paymentResult` 中返回结果。

两种路径共有的一个结构性差异：您的私钥永远不会发送到浏览器。结账会话在您的服务器上创建，对于 Lite SDK 和 Secure Fields，支付也在服务器上创建。

## Webhooks

Yuno 为每个对象发送一种事件类型，并在 payload 中携带状态，因此多个 Stripe 事件会合并为一个 Yuno 事件。请参阅 [Webhooks](https://docs.y.uno/zh-hans/docs/webhooks/index.md) 和 [配置 Webhooks](https://docs.y.uno/zh-hans/docs/webhooks/configure-webhooks.md)。

| Stripe 事件 | Yuno 事件 | 读取内容 |
| :- | :- | :- |
| `payment_intent.succeeded`、`payment_intent.payment_failed`、`payment_intent.canceled` | `payment.purchase` | `status`（`SUCCEEDED`、`DECLINED`、`PENDING`、`ERROR`）和 `sub_status` |
| `charge.captured` | `payment.capture` | 交易状态 |
| `charge.refunded` | `payment.refund` | 退款交易状态 |
| `charge.dispute.created`、`charge.dispute.updated`、`charge.dispute.closed` | `payment.chargeback` | `status`（`IN_DISPUTE`、`CHARGEBACK`、`SUCCEEDED`）和 `sub_status`（`RECEIVED`、`PENDING_REVIEW`、`LOST`、`APPROVED`）。请参阅 [拒付管理](https://docs.y.uno/zh-hans/docs/payouts-and-disputes/chargeback-management.md)。 |
| `setup_intent.succeeded` | `enrollment.enroll` | `status` `ENROLLED` 和 `vaulted_token` |
| `customer.subscription.*`、`invoice.paid`、`invoice.payment_failed` | `subscription.*`（`active`、`past_due`、`cycle_executed`、`cancel` 等） | 订阅状态和周期结果 |
| `review.opened`、`review.closed` | `payment.fraud_screening` | 筛查结果 |

每个 Yuno webhook 都携带 `data.idempotency_key` 和 `x-hmac-signature` 标头；请按照 [验证 Webhook 签名](https://docs.y.uno/zh-hans/docs/webhooks/verify-webhook-signatures-hmac.md) 中的说明进行验证。

## 已保存的卡片

保存在 Stripe 中的卡片可以迁移到 Yuno，这样回头客无需重新输入。Yuno 支持通过 [令牌迁移流程](https://docs.y.uno/zh-hans/docs/security-and-compliance/data-migration-processes/token-migration-process.md) 在服务提供商之间进行经过 PGP 加密的令牌迁移。由于 Yuno 会为每个存储令牌保存网络交易 id，定期系列扣款无需重新认证即可继续；请参阅 [存储凭证](https://docs.y.uno/zh-hans/docs/payment-features/stored-credentials.md)。

## 迁移顺序

**1. 在 Yuno 上连接 Stripe**

将您的 Stripe 账户添加为连接，并将其放到一条路由上。此时购物者不会察觉任何变化。请参阅 [设置支付连接](https://docs.y.uno/zh-hans/docs/direct-integration-use-cases/set-up-payment-connection.md)。

**2. 替换 checkout**

按照 [React 和 Next.js](https://docs.y.uno/zh-hans/docs/sdks/web-frameworks/react-and-nextjs.md) 将 Payment Element 替换为 Seamless SDK，或将 Card Element 替换为 Lite SDK 或 Secure Fields。先在同一个 Stripe 连接上运行，以便在相同条件下比较批准率。

**3. 迁移 webhook**

将您现有的处理程序订阅到上表中的 Yuno 事件，并将状态逻辑切换为 Yuno 的 `status` 和 `sub_status` 值。

**4. 迁移已保存的卡片**

执行令牌迁移，并将已存储卡片的扣款切换为使用 `vaulted_token`。

**5. 添加服务提供商和路由**

流量稳定后，添加其他服务提供商，并让 [路由](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/routing.md) 和 [Monitors](https://docs.y.uno/zh-hans/docs/using-yuno/dashboard-overview/monitors.md) 决定每笔支付的去向。


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