> ## 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，获得简化的卡支付 checkout 体验

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

本页面介绍适用于 Android 支付的 Yuno Lite SDK。此 SDK 提供简化的集成流程和基本的支付功能，非常适合符合以下情况的商户：

* 需要快速实现，且定制化需求极少
* 希望主要专注于卡支付处理
* 倾向于使用可处理支付流程的现成界面

Lite SDK 包含以下核心功能：

* 预构建的支付界面组件
* 卡支付处理
* 基本的支付状态处理
* 必要的错误管理

如果商户需要更高级的功能，例如多种支付方式、自定义界面或高级欺诈防范，请考虑改用 Yuno 的 [Full SDK](https://docs.y.uno/docs/sdks/full-checkout/android-payments)。

## 要求

在开始集成 Yuno Android SDK 之前，请确保您的项目满足[技术要求](https://docs.y.uno/zh-hans/docs/sdks/resources/references/android.md)。此外，请确保满足以下前提条件：

* 您必须拥有一个有效的 Yuno 账户。
* 您需要 Yuno API 凭证（`account_id`、`public-api-key` 和 `private-secret-key`），可从 Yuno Dashboard 的[开发者凭证部分](https://docs.y.uno/reference/getting-started/authentication.md)获取。

## 第 1 步：创建客户

在发起支付之前，使用 [Create customer endpoint](https://docs.y.uno/reference/customers/create-customer.md) 创建客户。此 endpoint 返回的客户 ID 将在创建 `checkout_session` 时使用。

## 第 2 步：创建结账会话

使用 [Create checkout session](https://docs.y.uno/zh-hans/reference/checkout-sessions/create-checkout-session.md) endpoint 创建新的 `checkout_session`，以初始化支付流程。

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

通过 Gradle 在您的项目中引入 Yuno SDK 文件。添加仓库源：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
maven { url "https://yunopayments.jfrog.io/artifactory/snapshots-libs-release" }
```

在 `build.gradle` 文件中加入以下代码，以添加 Yuno SDK 依赖项：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
dependencies {
    implementation 'com.yuno.payments:android-sdk:2.27.0'
}
```

## 第 4 步：使用公钥初始化 SDK

在您应用的 `onCreate()` 方法中调用 `Yuno.initialize()`，以初始化 SDK：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
class CustomApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    Yuno.initialize(
      this,
      PUBLIC_API_KEY,
      config = YunoConfig(
        saveCardEnabled = false,
        keepLoader = true,
        language = YunoLanguage.ENGLISH,
      )
    )
  }
}
```

### YunoConfig 自定义

| 选项 | 说明 |
| - | - |
| `saveCardEnabled` | 启用**保存卡片复选框**。 |
| `keepLoader` | 如果为 `true`，SDK 加载指示器会从 OTT 生成开始一直保持显示，直到调用 `continuePayment()`。请参阅 [keepLoader 参数](https://docs.y.uno/zh-hans/docs/sdks/resources/references/android.md#keeploader-parameter)。 |
| `language` | 以 `YunoLanguage` 值定义语言（例如 `SPANISH`、`ENGLISH`、`PORTUGUESE`）。 |
| `styles` | 预定义的[样式](https://docs.y.uno/zh-hans/docs/sdks/resources/references/android.md#styles)。 |

## 第 5 步：启动 checkout 流程

在您的 activity 中调用 `startCheckout` 方法：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
startCheckout(
  checkoutSession = "checkout_session",
  countryCode = "US",
  callbackPaymentState = { state, subState, message ->
    println("Payment State: $state, Substate: $subState, Error: ${message?.code}")
  }
)
```

### Callback 状态

| 状态 | 说明 |
| - | - |
| `SUCCEEDED` | 交易已成功完成。 |
| `FAIL` | 交易失败。 |
| `PROCESSING` | 处理中，等待验证。 |
| `REJECT` | 已拒绝（例如资金不足）。 |
| `CANCELED_BY_USER` | 用户取消了流程。 |

## 第 6 步：发起支付流程

调用 `startPaymentLite` 以启动流程：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
startPaymentLite(
    paymentSelected = PaymentSelected(
      paymentMethodType = "CARD",
      vaultedToken = null
    ),
    callbackOTT = { ott -> println("OTT: $ott") },
    callBackTokenWithInformation = { info -> println("Token Info: $info") },
    showPaymentStatus = true,
)
```

## 第 7 步：创建支付

获取一次性令牌（OTT）后，通过您的 backend 使用 [Create Payment](https://docs.y.uno/zh-hans/reference/payments/create-payment.md) API 创建支付。

## 第 8 步：继续支付（必需）

如果 API 响应包含 `sdk_action_required: true`，请调用 `continuePayment()`：

```kotlin theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
continuePayment(
    showPaymentStatus = true,
    checkoutSession = "checkout_session",
    countryCode = "US",
    callbackPaymentState = { state, subState, message -> ... }
)
```

> [!NOTE]
>
> **演示应用**
>
> 有关完整的实现示例，请参阅 [Yuno Android SDK 代码仓库](https://github.com/yuno-payments/yuno-sdk-android)。


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