> ## 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.mountEnrollmentLite + yuno.apiClientEnroll）迁移到统一 Transaction API。

注册有两种与支付模式相对应的子模式：UI 驱动的流程（`mountEnrollmentLite`）和 headless 流程（`apiClientEnroll`）。在统一 API 中，两者都合并到同一个 `Transaction` 类中。变化在于**您传入的会话**（使用 `customerSession` 而不是 `checkoutSession`），以及**您是否在 `paymentMethod.data` 中提供预先收集的数据**。

## 开始之前

* 加载统一 SDK 包而不是旧版包，并按照代码对照所示进行初始化：`window.Yuno.initialize(...)` 变为 `SdkPayments.initialize(...)`。您的公共 API 密钥以及您的 backend 创建的客户会话保持不变（[开始之前](https://docs.y.uno/zh-hans/docs/yuno-sdk/get-started.md#before-you-begin)）。
* 无需创建支付。注册配置不接受 `createPayment`、`showPayButton` 或其他仅用于支付的字段。请将它们移除。

## 代码对照

### Enrollment Lite（UI）

```typescript Before. Enrollment Lite theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const yuno = await window.Yuno.initialize('your-public-api-key')

await yuno.mountEnrollmentLite({
    customerSession: 'session-from-backend',
    countryCode: 'CO',
    language: 'en',
    showPaymentStatus: true,
    yunoEnrollmentStatus: ({ status, vaultedToken }) => {
        if (status === 'CREATED' && vaultedToken) {
            // Store against customer
            console.log('vault token:', vaultedToken)
        }
    },
})
```

```typescript After. Unified Transaction (enrollment) theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const sdkPayments = await SdkPayments.initialize('your-public-api-key')

const transaction = sdkPayments.transaction({
    customerSession: 'session-from-backend',
    countryCode: 'CO',
    language: 'en',
    elementSelector: '#root',
    onStatus: (result) => {
        // Same payload shape as payment flows: status / substatus / message.
        if (result.status === 'ENROLLED') {
            // Enrollment succeeded. Retrieve the vaulted token from your
            // backend's list-customer-payment-methods endpoint.
        }
    },
})

await transaction.start()
```

### Enrollment Headless

```typescript Before. Enrollment headless theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const yuno = await window.Yuno.initialize('your-public-api-key')

const apiClientEnroll = await yuno.apiClientEnroll({
    customer_session: 'session-from-backend',
    country_code: 'CO',
})

const enrollment = await apiClientEnroll.continueEnrollment({
    payment_method: {
        type: 'CARD',
        card: {
            detail: {
                holder_name: 'John Doe',
                number: '4111111111111111',
                security_code: '123',
                expiration_month: 12,
                expiration_year: 28,
            },
        },
    },
})

console.log('vault token:', enrollment.vaulted_token)
```

```typescript After. Unified Transaction (enrollment headless) theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
const sdkPayments = await SdkPayments.initialize('your-public-api-key')

const transaction = sdkPayments.transaction({
    customerSession: 'session-from-backend',
    countryCode: 'CO',
    onStatus: (result) => {
        if (result.status === 'ENROLLED') {
            // Enrollment succeeded. Retrieve the vaulted token from your
            // backend's list-customer-payment-methods endpoint.
        }
    },
})

await transaction.start({
    paymentMethod: {
        type: 'CARD',
        data: {
            card: {
                holderName: 'John Doe',
                number: '4111111111111111',
                securityCode: '123',
                expirationMonth: 12,
                expirationYear: 28,
            },
        },
    },
})
```

## 变更内容

按您编辑代码的顺序分组。**重命名**：作用相同，名称变化。**移动**：值相同，归属对象变化。**移除**：无需调用任何内容。最后一列是重命名之外您唯一需要做的事。

### 初始化和配置

| 注册 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `window.Yuno.initialize(publicApiKey)` | `SdkPayments.initialize(publicApiKey)` | 重命名 | 全局对象是 `window.SdkPayments`。与之前一样，对它使用 `await`：它会解析为您用来创建交易的 `SdkPayments` 实例。 |
| `mountEnrollmentLite` 中的 `customerSession` / `apiClientEnroll` 的 `customer_session` 参数 | 交易配置中的 `customerSession` | 移动 | 只有一个工厂方法：您传入哪个会话决定了流程，支付传入 `checkoutSession`，注册传入 `customerSession`。`createPayment`、`showPayButton` 以及其他仅用于支付的配置字段不属于注册配置，因为注册没有 `/v1/payments` 的对应项。 |
| `mountEnrollmentLite` 中的 `countryCode`、`language` | 交易配置中的相同字段 | 移动 | |
| *（无：SDK 将自己的容器附加到 `body`）* | 交易配置中的 `elementSelector` | 新增 | 可选：注册表单在该元素内渲染。没有它时，SDK 会像以前一样将自己的容器附加到 `body`。Headless 注册会忽略它。 |
| `showPaymentStatus: true` | `showStatusScreen: true` | 重命名 | `TransactionConfig` 中的同一字段。对于注册，默认为 `true`。 |
| `payment_method.card.detail` 下的 `holder_name`、`number`、`security_code`、`expiration_month`、`expiration_year`（`continueEnrollment` 的参数） | `paymentMethod.data.card` 下的 `holderName`、`number`、`securityCode`、`expirationMonth`、`expirationYear` | 移动 | 预先收集的卡数据直接在 `start()` 中传入（请参阅“入口点”）。 |

### Callback

| 注册 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `yunoEnrollmentStatus({ status, vaultedToken })` | `onStatus(result)` | 重命名 | `result` 包含 `status`、`substatus` 和 `message`，与支付流程的结构相同。`result.status` 包含 API 报告的注册状态（`CREATED`、`EXPIRED`、`REJECTED`、`READY_TO_ENROLL`、`ENROLL_IN_PROCESS`、`UNENROLL_IN_PROCESS`、`ENROLLED`、`DECLINED`、`CANCELED`、`ERROR`、`UNENROLLED`、`PENDING`），以及两个 SDK 值：`INTERNAL_ERROR`（详情见 `result.message`）和 `USER_CANCEL`（您在得到结果之前卸载了组件）。注册成功时返回 `status: 'ENROLLED'` 和 `substatus: 'CREATED'`：请检查 `result.status === 'ENROLLED'`。**`vaultedToken` 不再传递给客户端**：请通过您 backend 的列出客户支付方式 endpoint 获取它，并将其与您的客户关联存储。请参阅 [`Status`](https://docs.y.uno/zh-hans/docs/yuno-sdk/reference/objects-you-receive#status)。 |
| `yunoError(message, data?)` | *（已移除）* | 移除 | 错误通过 `onStatus`（设置了 `message` 的 `TransactionStatus`）或被拒绝的 `start()` Promise 传递。 |

### 入口点

| 注册 | 统一 API | 变更 | 操作 |
| - | - | - | - |
| `yuno.mountEnrollmentLite({ customerSession, … })` | `sdkPayments.transaction({ customerSession, elementSelector, … }).start()` | 重命名 | 不带参数的 `start()` 即 UI 注册：在配置中设置 `elementSelector` 后，SDK 会在该元素内为创建客户会话时指定的支付方式渲染表单。 |
| `yuno.apiClientEnroll({ customer_session, country_code })` + `.continueEnrollment({ payment_method })` | `sdkPayments.transaction({ customerSession }).start({ paymentMethod: { type: 'CARD', data: { card } } })` | 重命名 | `start({ paymentMethod: { type, data } })` 即 headless 注册：结构与 headless 支付相同，但使用 `customerSession`；配置中的 `elementSelector` 会被忽略。该调用不再返回存储的令牌（请参阅“Callback”）。 |

## 相关内容

* [注册](https://docs.y.uno/zh-hans/docs/yuno-sdk/features/enrollment.md)。完整的注册指南。
* [`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)。payload 结构和状态值。


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