Requirements
To execute the enrollment process, you need to provide thecustomer_session to start the enrollment process in Step 3. To acquire the customer_session, you need to:
- Create a customer: A customer is required to enroll in payments. Use the Create Customer endpoint to create new customers. In the response, you will receive the customer
id, which you use to create the customer session. - Create the customer session: Use the customer
idand the Create Customer Session endpoint to receive thecustomer_session.
Step 1: Include the library in your project
The first step is to install Yuno SDK to your iOS project.Check iOS SDK VersionsTo view all available versions, visit the release page on the Yuno iOS SDK repository.
- Cocoapods: If you do not have a Podfile, follow the CocoaPods guide to create one. After creating the Podfile, you will integrate the Yuno SDK with Cocoapods by adding the line below to your Podfile:
- Swift Package Manager: Set up the Swift package, and then add Yuno SDK as a dependency, as presented in the following code block:
Step 2: Initialize Headless SDK with the public key
To initialize the Headless SDK, you need to import Yuno and provide a valid PUBLIC_API_KEY. If you don’t have your API credentials, access the Developers (Credentials) page to check how to retrieve them from the dashboard. The code block below presents an example of importing and initializing theYuno.
Swift 6 Concurrency RequirementsIf you’re using Swift 6, you’ll need to handle concurrency correctly when using the SDK’s asynchronous methods. See the Swift 6 Concurrency guide for detailed implementation options and best practices.
UISceneDelegate InitializationIf your app uses a
UISceneDelegate, you can initialize Yuno within your SceneDelegate. However, if you prefer to initialize Yuno in a different part of your app, the initialization method provides a callback that notifies you when the process has finished.Step 3: Create a customer session
To start the enrollment process, you need to provide thecustomer_session. First, you need to create a customer. You need a customer to enroll payments with. Use the Create Customer endpoint to create new customers. In the response, you will receive the customer id, which you use to create the customer session.
After creating the customer, you can create the customer session. Use the customer id and the Create Customer Session endpoint. The customer_session will be provided in the response. You need a new customer_session every time you enroll in a new payment method.
Step 4: Create an enrollment payment method object
You need an enrollment payment method object to set Headless SDK integration for enrollment. You can create one using the Enroll Payment Method endpoint. While creating the payment method object, you need to define which payment method your customer can enroll in. Currently, only CARD is available for Headless SDK.Card VerificationTo verify cards with zero value authorization before enrollment, include the
verify object when creating the payment method object for the customer session.Step 5: Start the enrollment process
Next, you will start the checkout process using theapiClientEnroll function, providing the necessary configuration parameters.
Parameters
The following table lists all required parameters and their descriptions.
| Parameter | Description |
|---|---|
countryCode | This parameter determines the country for which the payment process is being configured. The complete list of supported countries and their countryCode is available on the Country coverage page. |
customerSession | Refers to the current enrollment’s customer session received as a response to the Create Customer Session endpoint. Example: ‘438413b7-4921-41e4-b8f3-28a5a0141638’ |
Step 6: Generate a vaulted token
After collecting all user information, you can start the enrollment. First, you need to create avaulted_token using the function apiClientEnroll.continueEnrollment. As it is an asynchronous function, you can use do/catch to ensure you will correctly handle triggered errors. Below, you will find an example of creating a vaulted_token:
vaulted_token, which you can use to make payments in the future without asking for your customer’s card information. The following code block presents an example of a response from the apiClientEnroll.continueEnrollment function. The response is a dictionary of type [String: String].
Using Webhooks for Enrollment StatusConsider using the enrollment status received via Webhooks. Yuno recommends always using this status to base and make business decisions on your platform.
Access the Demo ApplicationIn addition to the code examples provided, you can access the Yuno repository for a complete implementation of Yuno iOS SDKs.