Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions SDKs/Card Enrollment/_order.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- android-enrollment
- ios-enrollment
- web-enrollment
160 changes: 160 additions & 0 deletions SDKs/Card Enrollment/android-enrollment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,160 @@
---
title: Enrollment Flows
deprecated: false
hidden: false
metadata:
robots: index
---

The Android 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](android-payments#include-the-library-in-your-project).

## Additional resources

- See [Choose the right integration for you](choose-your-integration) if you're unsure which flow to follow.
- Access the [Release notes](release-notes-android) or the [Yuno Android SDK repository](https://github.com/yuno-payments/yuno-sdk-android) to verify the latest SDK version available.

- [Full Checkout Enrollment (Android)](#full-checkout-enrollment-android): Automatic enrollment with pre-built UI components

## Requirements

* **Minimum SDK Version**: `minSdkVersion` 21 or above
* **Java**: Java 8 enabled
* **AndroidX**: Use AndroidX instead of older support libraries
* **Android Gradle Plugin**: 4.0.0 or above
* **ProGuard**: 6.2.2 or above
* **Kotlin Gradle Plugin**: 1.4.0 or above
* **ELF Page Size Support**: Compliant with Google's 16 KB ELF page alignment requirements (Android 15 / ARMv9 ready)
* Active Yuno account
* API credentials (obtain from the [Yuno Dashboard](https://dashboard.y.uno/) → **Developers** > **Credentials**)
* Create a customer using the [Create customer endpoint](ref:create-customer) before enrolling

## Parameters

For the full list of parameters, see the [Android SDK Common Reference](android-sdk-common-reference).

| Parameter | Description |
|-----------|-------------|
| `customerSession` | Customer session ID from Create customer session API. Required. |
| `countryCode` | ISO country code. Required. |
| `showEnrollmentStatus` | Show enrollment result screen. Optional; default true. |
| `callbackEnrollmentState` | Callback: enrollment state. Optional; requires `initEnrollment` in onCreate. |
| `requestCode` | Optional; use if capturing result via `onActivityResult`. |
| `countryCode` | Country for the enrollment. Required for `apiClientEnroll`. |
| `customerSession` | Customer session ID. Required for `apiClientEnroll`. |

## Full Checkout Enrollment (Android)

Yuno Full Checkout for Android provides enrollment with pre-built UI, card enrollment, status handling, and basic error management. See [Requirements](#requirements) above.

### Step 1: Create a customer

Create a customer in Yuno's system using the [Create customer endpoint](ref:create-customer) before enrolling payment methods. This endpoint returns a `customer_id`. Then create a customer session using the [Create Customer Session](ref:create-customer-session) endpoint; use the returned `customer_session` when calling the enrollment methods.

### Step 2: Include the library in your project

Add the Yuno library to your Android project:

#### Add the Repository

Add Yuno's Maven repository to your project's Gradle configuration:

```kotlin
maven { url "https://yunopayments.jfrog.io/artifactory/snapshots-libs-release" }
```

Add the dependency in `build.gradle`:

```kotlin
dependencies {
implementation 'com.yuno.payments:android-sdk:2.11.0'
}
```

#### Permissions

The Yuno SDK includes the `INTERNET` permission by default, which is required to make network requests.

```xml
<uses-permission android:name="android.permission.INTERNET" />
```

### Step 3: Initialize SDK with the public key

Initialize the SDK:

1. Get your Public API Key from the [Yuno Dashboard](https://dashboard.y.uno/)
2. Create a custom application class if you haven't already done so
3. In the `onCreate()` method of your application class, call `Yuno.initialize()` with your API key:

```kotlin
class CustomApplication : Application() {
override fun onCreate() {
super.onCreate()
Yuno.initialize(
this,
PUBLIC_API_KEY,
config = YunoConfig(),
)
}
}
```

Use the data class `YunoConfig` to customize the SDK's behavior. Include this configuration when calling `Yuno.initialize()`. The available options are:

```kotlin
data class YunoConfig(
val saveCardEnabled: Boolean = false,
val keepLoader: Boolean = false,
val cardFormDeployed: Boolean = false,
val language: YunoLanguage? = null,
val styles: YunoStyles? = null
)
```

> 🚧 cardFlow removed from YunoConfig
>
> Starting from version **2.11.0**, `cardFlow` is no longer part of `YunoConfig`. Card flow configuration is now handled exclusively through the **CheckoutBuilder**.

### Step 4: Enroll a new payment method

The enrollment process is a two-step flow. First, initialize the process to set up the necessary components. Then, start the UI flow to allow the user to enroll a payment method.

#### 4.1 Initialize the enrollment process

Call the `initEnrollment` method within your activity's `onCreate` method to prepare your app to handle the enrollment flow. This is a mandatory setup step required by the Android operating system to register the contract that allows the SDK to send the final enrollment status back to your app.

```kotlin
fun ComponentActivity.initEnrollment(
callbackEnrollmentState: ((String?) -> Unit)? = null
)
```

#### 4.2 Start the enrollment flow

Call the `startEnrollment` method to launch the user interface and begin the enrollment of a new payment method. You can call this method at any point after `initEnrollment` has been executed, such as when a user taps an "Enroll New Payment Method" button.

```kotlin
fun Activity.startEnrollment(
customerSession: String,
countryCode: String,
showEnrollmentStatus: Boolean = true,
callbackEnrollmentState: ((String?) -> Unit)? = null,
requestCode: Int
)
```

`startEnrollment` parameters:

| Parameter | Description |
| ------------------------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `customerSession` | The session customer associated with the current enrollment process. |
| `countryCode` | Country code where the payment is performed. See [Country coverage](country-coverage) for a complete list of supported countries and their codes. |
| `showEnrollmentStatus` | Indicates whether the enrollment status should be shown. This parameter is optional and defaults to `true`. |
| `callbackEnrollmentState` | A function that returns the current state of the enrollment process. This parameter is optional and defaults to `null`. To register this callback, you must call `initEnrollment` method in the `onCreate` method of the activity. Check the possible states that can be returned. |
| `requestCode` | It is an optional parameter you must inform if you are going to use the `onActivityResult` method to capture the enrollment states. |

## Common reference

For full parameter and customization details, see the [Android SDK Common Reference](android-sdk-common-reference).
Original file line number Diff line number Diff line change
@@ -1,21 +1,21 @@
---
title: Copy of Enrollment Flows
title: Enrollment Flows
deprecated: false
hidden: true
hidden: false
metadata:
robots: index
---

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 [payment flows](payment-flows-ios#include-the-library-in-your-project). This lets you complete [step 2](#step-2-include-the-library-in-your-project) and continue with the enrollment flow below.
Include the library in your project by following the same steps as in [Full Checkout](ios-payments#include-the-library-in-your-project).

## Additional resources

- See [Choose the right integration for you](choose-your-integration) if you're unsure which flow to follow.
- Access the [Release notes](release-notes-ios) or the [Yuno iOS SDK repository](https://github.com/yuno-payments/yuno-sdk-ios) to verify the latest SDK version available.

- [Lite Enrollment (iOS)](#lite-enrollment-ios): Lightweight enrollment with UI control and backend support
- [Headless Enrollment (iOS)](#headless-enrollment-ios): Full enrollment experience customization without requiring PCI compliance
- [Full Checkout Enrollment (iOS)](#full-checkout-enrollment-ios): Automatic enrollment with pre-built UI components

## Requirements

Expand All @@ -35,11 +35,11 @@ For the full list of parameters, see the [iOS SDK Common Reference](ios-sdk-comm
| `language` | Language code for the UI. Optional. |
| `viewController` | UIViewController that presents the enrollment flow. Required for delegate. |
| `yunoEnrollmentResult(_:)` | Delegate: enrollment finished with result. |
| `YunoConfig` (initialize) | Optional: appearance, saveCardEnabled, keepLoader. See Common Reference. |
| `YunoConfig` (initialize) | Optional: appearance, saveCardEnabled, keepLoader, hideCardholderName. See Common Reference. |

## Lite Enrollment (iOS)
## Full Checkout Enrollment (iOS)

The Yuno Lite iOS SDK provides enrollment with pre-built UI, card enrollment, status handling, and basic error management. Use it when you need minimal customization and a ready-to-use enrollment flow. See [Requirements](#requirements) above.
The Yuno Full Checkout iOS SDK provides enrollment with pre-built UI, card enrollment, status handling, and basic error management. See [Requirements](#requirements) above.

### Step 1: Create a customer and customer session

Expand Down Expand Up @@ -108,6 +108,7 @@ struct YunoConfig {
var appearance: Appearance? = nil
var saveCardEnabled: Bool = false
var keepLoader: Bool = false
var hideCardholderName: Bool = false
}
```

Expand Down Expand Up @@ -244,108 +245,6 @@ func yunoEnrollmentResult(_ result: Yuno.Result) {

For styling, themes, form options, and additional configurations, see [SDK customizations](ios-customizations).

## Headless Enrollment (iOS)

Headless (iOS) lets you enroll payment methods and tokenize cards for future use, with full control over the UI and direct API access. See [Requirements](#requirements) above.

### Step 1: Create a customer and customer session

Create a customer using the [Create Customer](ref:create-customer) endpoint before enrolling payment methods. Then create a new `customer_session` using the [Create Customer Session](ref:create-customer-session) endpoint and store the `customer_session` ID for the enrollment calls.

```json
POST /v1/customer-session

{
"country": "BR",
"customer_id": "6c85a4e3-0a6c-423d-a12a-10045320ab4a"
}
```

### Step 2: Add the SDK to 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](payment-flows-ios#include-the-library-in-your-project) there.

#### CocoaPods

```ruby
pod 'YunoSDK', '~> 2.11.1'
```

Run:

```ruby
pod install
```

#### Swift Package Manager

```swift
dependencies: [
.package(url: "https://github.com/yuno-payments/yuno-sdk-ios.git", .upToNextMajor(from: "2.11.1"))
]
```

### Step 3: Initialize Headless with the public key

Retrieve your public API keys from the [Yuno Dashboard](https://dashboard.y.uno/). Then initialize the SDK:

```swift
import YunoSDK

Yuno.initialize(
apiKey: "PUBLIC_API_KEY"
)
```

### Step 4: Start the enrollment process

Use `Yuno.apiClientEnroll` to configure the headless enrollment client:

```swift
var apiClientEnroll: YunoEnrollHeadless?

apiClientEnroll = try Yuno.apiClientEnroll(
countryCode: "CO",
customerSession: "eec6578e-ac2f-40a0-8065-25b5957f6dd3"
)
```

### Step 5: Generate a vaulted token

After collecting all user information, create a `vaulted_token` using `apiClientEnroll.continueEnrollment(data:)`. Use `do/catch` to handle errors:

```swift
let enrollmentCollectedData: EnrollmentCollectedData = EnrollmentCollectedData(
customerSession: "eec6578e-ac2f-40a0-8065-25b5957f6dd3",
paymentMethod: CollectedData(
type: "CARD",
card: CardData(
detail: CardData.Detail(
number: "4111111111111111",
expirationMonth: 12,
expirationYear: 25,
securityCode: "123",
holderName: "Andrea",
type: .credit
)
),
customer: Customer()
)
)

let result = try await apiClientEnroll.continueEnrollment(data: enrollmentCollectedData)
```

After enrolling the new card, you receive the `vaulted_token` and enrollment status in the result, which you can use for future payments or to update your customer records.

**When to use Headless Enrollment:**
- You need complete control over the enrollment UI
- You have specific design requirements
- You're building a highly customized enrollment experience

### Complementary features

For styling, themes, form options, and additional configurations, see [SDK customizations](ios-customizations).

## Common reference

Expand Down
Loading