> ## 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（iOS 注册）

> 在 iOS 上通过注册 delegate 流程，使用 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 iOS SDK 的注册功能。

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

在开始实现 Lite SDK 之前，请参阅[快速入门指南](https://docs.y.uno/zh-hans/docs/sdks/overview/quickstart.md)，了解如何将 SDK 正确集成到您的项目中的详细说明。SDK 通过 Swift Package Manager 安装，使用 `YunoSDK` 或 `YunoSDK-Static`。YunoSDK 已不再在 CocoaPods 上发布；最后一个 CocoaPods 版本是 2.30.0。

选择最适合您应用的产品。完成 SDK 集成后，您可以继续执行以下步骤来实现 Lite 注册功能。

## 第 2 步：初始化 SDK

在您的 `AppDelegate`（或 SwiftUI 的 `App` 结构体）中提供有效的 `PUBLIC_API_KEY`，以初始化 Yuno SDK：

```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
import UIKit
import YunoSDK

@main
class AppDelegate: UIResponder, UIApplicationDelegate {
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        Yuno.initialize(
            apiKey: "YOUR_PUBLIC_API_KEY",
            config: YunoConfig()
        )
        return true
    }
}
```

> [!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`。

## 第 4 步：采用 YunoEnrollmentDelegate

为处理注册流程，您的类（通常是 `UIViewController`）必须采用 `YunoEnrollmentDelegate` 协议。

> [!NOTE]
>
> **Swift 6 并发要求**
>
> 如果您使用 Swift 6，则需要在实现 `YunoEnrollmentDelegate` 协议时考虑特定的并发事项。有关详细的实现选项和最佳实践，请参阅 [Swift 6 并发](https://docs.y.uno/zh-hans/docs/sdks/resources/swift-6-concurrency.md)指南。

```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
class EnrollmentViewController: UIViewController, @preconcurrency YunoEnrollmentDelegate {
    // Required delegate properties
    var customerSession: String { "CUSTOMER_SESSION" }
    var countryCode: String { "US" }
    var viewController: UIViewController? { self }

    func yunoEnrollmentResult(_ result: Yuno.Result) {
        switch result.status {
        case .succeeded:
            print("Enrollment succeeded!")
        case .fail:
            print("Enrollment failed")
        case .reject:
            print("Enrollment rejected")
        case .processing:
            print("Enrollment processing")
        case .internalError:
            print("Internal error")
        case .userCancelled:
            print("User canceled")
        @unknown default:
            break
        }
    }
}
```

### Delegate 属性

| 属性 | 说明 |
| - | - |
| `customerSession` | 指当前注册的[客户会话](https://docs.y.uno/reference/customer-sessions-enrollment/create-customer-session.md)。 |
| `countryCode` | 此参数指定为其设置注册的国家代码。 |
| `viewController` | 用于呈现注册 UI 的视图控制器。 |

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

实现 delegate 后，调用 `enrollPayment` 以启动注册 UI：

```swift theme={"theme":{"light":"github-dark","dark":"github-dark-dimmed"}}
Yuno.enrollPayment(with: self, showPaymentStatus: true)
```

### 参数

| 参数 | 说明 |
| - | - |
| `with` | 实现 `YunoEnrollmentDelegate` 的对象。 |
| `showPaymentStatus` | 控制 SDK 是否在注册流程结束后显示其自身的状态页面。 |

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

## 错误处理

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

## 保持更新

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


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