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

# Lite SDK（Android 注册）

> 在 Android 上使用 Lite 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.

> [!WARNING]
>
> **Orientation: Choosing Your Integration Flow**, before you begin, please review the [Official Integration Flow](https://docs.y.uno/docs/sdks/overview/understanding-flows.md).
>
> * **Standard Flow ([Full Checkout](https://docs.y.uno/docs/sdks/full-checkout/web-payments))**: Recommended for most merchants. Yuno handles the UI, security, and automatic updates for payment methods.
> * **Custom Flow (This SDK)**: Use this only if you require full control over the UX. **Note**: You will be responsible for manually handling payment statuses, 3DS transitions, and fraud routing data collection.

按照本分步指南，在您的应用中实现并启用 Yuno Lite Android SDK 的注册功能。

## 第 1 步：在项目中引入库

在开始实现 Lite SDK 之前，请参阅[快速入门指南](https://docs.y.uno/zh-hans/docs/sdks/overview/quickstart.md)，了解如何将 SDK 正确集成到您的项目中的详细说明。

选择最适合您的开发工作流程和技术要求的集成方式。完成 SDK 集成后，您可以继续执行以下步骤来实现 Lite 注册功能。

## 第 2 步：初始化 SDK

在您的 `Application` 类中提供有效的 `PUBLIC_API_KEY`，以初始化 Yuno SDK：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
class MyApplication : Application() {
    override fun onCreate() {
        super.onCreate()
        Yuno.initialize(
            this,
            apiKey = "YOUR_PUBLIC_API_KEY",
            config = YunoConfig()
        )
    }
}
```

> [!NOTE]
>
> **凭证**
>
> 如需了解更多信息，请参阅凭证页面：[/reference/getting-started/authentication](https://docs.y.uno/reference/getting-started/authentication.md)

## 第 3 步：创建客户会话

要开始注册流程，您需要提供 `customer_session`。首先，您需要创建一个客户。使用 [Create Customer](https://docs.y.uno/reference/customers/create-customer.md) endpoint 创建新客户。在响应中，您将收到客户 `id`，用于创建客户会话。

创建客户后，您就可以创建客户会话。使用客户 `id` 和 [Create Customer Session](https://docs.y.uno/reference/customer-sessions-enrollment/create-customer-session.md) endpoint。`customer_session` 将在响应中提供。每次注册新的支付方式时，您都需要一个新的 `customer_session`。

在您的服务器上，还需要为该客户会话创建一个[注册支付方式对象](https://docs.y.uno/reference/payment-methods-checkout/enroll-payment-method-checkout.md)，以定义客户可以注册哪种支付方式。请将您的私有 API 密钥保存在服务器上。

## 第 4 步：启动注册流程

要提供 Lite 注册体验，您必须先初始化注册流程，然后再启动界面。

### 初始化注册

在您的 activity 的 `onCreate` 方法中调用 `initEnrollment`，为注册流程准备 SDK。

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
override fun onCreate(savedInstanceState: Bundle?) {
    super.onCreate(savedInstanceState)
    
    initEnrollment { state, message ->
        Log.d("YunoEnrollment", "Enrollment state: $state, error: ${message?.code}")
    }
}
```

### 启动注册界面

使用会话和配置参数调用 `startEnrollment`，以显示注册表单。

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
startEnrollment(
    customerSession = "CUSTOMER_SESSION",
    countryCode = "US",
    showEnrollmentStatus = true,
)
```

### 参数

使用以下选项配置 Lite 注册：

| 参数 | 说明 |
| - | - |
| `customerSession` | 指当前注册的[客户会话](https://docs.y.uno/reference/customer-sessions-enrollment/create-customer-session.md)。 |
| `countryCode` | 此参数指定要为其设置注册的国家/地区代码。 |
| `showEnrollmentStatus` | 控制注册过程中 Yuno 加载/加载动画页面的可见性。默认值为 `true`。 |

## 第 5 步：注册状态

注册流程完成时，SDK 会调用在 `initEnrollment` 中提供的 callback，并传入状态；在 `INTERNAL_ERROR` 时，还会传入描述失败原因的 [`StatusMessage`](https://docs.y.uno/zh-hans/docs/sdks/resources/references/android#statusmessage-error-details)（在其他所有状态下为 `null`）。

### 可能的状态值

* `SUCCEEDED`：注册成功。
* `FAIL`：注册失败。
* `PROCESSING`：注册正在处理中。
* `REJECT`：注册被拒绝。
* `CANCELED`：用户取消了注册。

> [!NOTE]
>
> **演示应用**
>
> 除了提供的代码示例外，您还可以访问 [Yuno Android SDK 代码仓库](https://github.com/yuno-payments/yuno-sdk-android)，查看 Yuno SDK 的完整实现。

## 错误处理

在您的应用中处理 SDK 返回的错误，例如注册失败或验证错误。有关 HTTP 状态和响应代码，请参阅 API 参考中的[状态和响应代码](https://docs.y.uno/reference/getting-started/response-codes.md)。

## 保持更新

访问[版本说明](https://docs.y.uno/changelog/android.md)，了解最新的 SDK 更新和版本历史。


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