Skip to main content
The iOS SDK makes it easy to implement enrollment flows for saving payment methods to a customer account. Include the library in your project by following the same steps as in full-checkout.

Additional resources

Requirements

Parameters

For the full list of parameters, see the iOS SDK Common Reference.
ParameterDescription
customerSessionCustomer session ID from Create customer session API. Required.
countryCodeISO country code (e.g. BR). Required.
languageLanguage code for the UI. Optional.
viewControllerUIViewController that presents the enrollment flow. Required for delegate.
yunoEnrollmentResult(_:)Delegate: enrollment finished with result.
YunoConfig (initialize)Optional: appearance, saveCardEnabled, keepLoader. See Common Reference.

full-checkout Enrollment (iOS)

The Yuno full-checkout iOS SDK provides enrollment with pre-built UI, card enrollment, status handling, and basic error management. See Requirements above.

Step 1: Create a customer and customer session

Create a customer in Yuno’s system using the Create customer endpoint before enrolling payment methods. This endpoint will return a customer_id that you’ll use to associate enrolled payment methods with the specific customer. Then create a customer session using the Create Customer Session endpoint. The session information will be used when calling the enrollment methods.
POST /v1/customer-session

{
  "country": "BR",
  "customer_id": "6c85a4e3-0a6c-423d-a12a-10045320ab4a"
}
The response includes a customer_session ID that you’ll use in the next step.

Step 2: Include the library in your project

Including the library in your project is done in the same way as in payment flows. Follow the steps in Include the library in your project there.

CocoaPods

pod 'YunoSDK', '~> 2.11.1'
Run:
pod install

Swift Package Manager

dependencies: [
    .package(url: "https://github.com/yuno-payments/yuno-sdk-ios.git", .upToNextMajor(from: "2.11.1"))
]
Check the Release notes or Yuno iOS SDK repository for the current SDK version.

Step 3: Initialize SDK with the public key

Initialize the SDK:
  1. Get your Public API Key from the Yuno Dashboard
  2. Initialize the SDK by calling Yuno.initialize() with your API key:
import YunoSDK

Yuno.initialize(
    apiKey: "PUBLIC_API_KEY",
    config: YunoConfig(),
    callback: { (value: Bool) in }
)
Use the YunoConfig data class to customize the SDK’s behavior. Include this configuration when calling Yuno.initialize(). For example:
struct YunoConfig {
    var appearance: Appearance? = nil
    var saveCardEnabled: Bool = false
    var keepLoader: Bool = false
}

Step 4: Implement the enrollment delegate

Create a class that adopts the YunoEnrollmentDelegate protocol:
protocol YunoEnrollmentDelegate: AnyObject {
    var customerSession: String { get }
    var countryCode: String { get }
    var language: String? { get }
    var viewController: UIViewController? { get }

    func yunoEnrollmentResult(_ result: Yuno.Result)
}

class ViewController: UIViewController, YunoEnrollmentDelegate {
    var customerSession: String { "cus_ses_123456" }
    var countryCode: String { "BR" }
    var language: String? { "en" }
    var viewController: UIViewController? { self }

    func yunoEnrollmentResult(_ result: Yuno.Result) {
        switch result {
        case .succeeded:
            print("Enrollment successful")
        case .fail:
            print("Enrollment failed")
        case .processing:
            print("Enrollment processing")
        case .reject:
            print("Enrollment rejected")
        case .userCancelled:
            print("User canceled")
        case .internalError:
            print("Internal error")
        }
    }
}

Options

ParameterDescription
customerSessionThe unique identifier for the customer session.
countryCodeCountry code where the enrollment is performed. See Country Coverage for supported countries.
languageLanguage code for the enrollment forms (e.g., "en", "es", "pt"). See Supported languages.
viewControllerThe UIViewController used to present the enrollment flow. Required for proper UI presentation.
yunoEnrollmentResult(_:)Called when the enrollment process completes with the final result.

Step 5: Start the enrollment process

Call the enrollPayment() method to display the enrollment flow:
func startEnrollment() {
    Yuno.enrollPayment(with: self, showPaymentStatus: true)
}
The SDK presents a full-screen UIViewController modally using the viewController provided in your delegate. In SwiftUI, wrap a UIViewController and return it via the viewController property.

Options

ParameterTypeDescription
delegateYunoEnrollmentDelegateThe delegate object that handles enrollment callbacks.
showPaymentStatusBoolWhether to display status views during the enrollment process. When true, the SDK displays default status screens. When false, you handle status display through callbacks.
In SwiftUI, wrap a UIViewController and return it from the viewController property so the SDK can present the UI. Only needed when the enrollment flow uses deep links. If your payment method does not use deep links, skip this step. Otherwise, handle the return in your AppDelegate:
func application(_ app: UIApplication,
                 open url: URL,
                 options: [UIApplication.OpenURLOptionsKey: Any] = [:]) -> Bool {

    guard url.scheme == "yunoexample" else { return false }

    return Yuno.receiveDeeplink(url, showStatusView: true)
}
Make sure the url.scheme matches the callback_url used when creating the customer_session.

Step 7: Handle enrollment result

The SDK calls your yunoEnrollmentResult(_:) delegate method with the final status:
func yunoEnrollmentResult(_ result: Yuno.Result) {
    switch result {
    case .succeeded:
        print("Enrollment successful")
        // Navigate to success screen or update UI
    case .fail:
        print("Enrollment failed")
        // Show error message
    case .processing:
        print("Enrollment still processing")
        // Show processing message
    case .reject:
        print("Enrollment rejected")
        // Show rejection message
    case .userCancelled:
        print("User canceled")
        // Handle cancellation
    case .internalError:
        print("Internal error occurred")
        // Show error message
    }
}

Enrollment Result States

StateDescriptionAction Required
succeededEnrollment completed successfullyNo
failEnrollment failed due to validation or technical issuesYes - Investigate and retry
processingEnrollment in progress, awaiting approvalNo
rejectEnrollment rejected (invalid data, fraud detection, etc.)Yes - Inform user and suggest actions
internalErrorUnexpected internal error occurredYes - Technical intervention required
userCancelledUser canceled the enrollmentNo
Yuno.Result does not include tokens or error messages; it only returns a high-level status.

Complementary features

For styling, themes, form options, and additional configurations, see SDK customizations.

Common reference

For full parameter and customization details, see the iOS SDK Common Reference.