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.
第 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 的完整实现。