跳转到主要内容
This page documents a legacy SDK. Starting a new integration? Use the Yuno SDK. Already on a legacy SDK? Follow the migration guide.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.
Orientation: Choosing Your Integration Flow, before you begin, please review the Official Integration Flow.
  • Standard Flow (Full Checkout): 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 之前,请参阅快速入门指南,了解如何将 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:
凭证如需了解更多信息,请参阅凭证页面:/reference/getting-started/authentication

第 3 步:创建客户会话

要开始注册流程,您需要提供 customer_session。首先,您需要创建一个客户。使用 Create Customer endpoint 创建新客户。在响应中,您将收到客户 id,用于创建客户会话。 创建客户后,您就可以创建客户会话。使用客户 id 和 Create Customer Session endpoint。customer_session 将在响应中提供。每次注册新的支付方式时,您都需要一个新的 customer_session。

第 4 步:采用 YunoEnrollmentDelegate

为处理注册流程,您的类(通常是 UIViewController)必须采用 YunoEnrollmentDelegate 协议。
Swift 6 并发要求如果您使用 Swift 6,则需要在实现 YunoEnrollmentDelegate 协议时考虑特定的并发事项。有关详细的实现选项和最佳实践,请参阅 Swift 6 并发指南。

Delegate 属性

第 5 步:启动注册流程

实现 delegate 后,调用 enrollPayment 以启动注册 UI:

参数

演示应用除了提供的代码示例外,您还可以访问 Yuno iOS SDK 代码库,获取 Yuno SDK 的完整实现。

错误处理

在您的应用中处理 SDK 返回的错误,例如注册失败或验证错误。有关 HTTP 状态码和响应代码,请参阅 API 参考中的状态和响应代码。

保持更新

请访问版本说明,了解最新的 SDK 更新和版本历史。