Lite SDK (Enrollment Android)

The Yuno Lite SDK for Android provides a pre-built UI solution focused on payment method enrollment. This SDK offers a streamlined integration process with essential enrollment functionality, making it ideal for merchants who:

  • Need a quick implementation with minimal customization requirements
  • Want to focus primarily on payment method enrollment
  • Prefer a ready-to-use UI that handles the enrollment flow

The Lite SDK includes core features like:

  • Pre-built enrollment UI components
  • Card enrollment processing
  • Basic enrollment status handling
  • Essential error management

For merchants requiring more advanced features like multiple payment methods, custom UI, or advanced fraud prevention, consider using our Full SDK instead.

Requirements

Before starting the Yuno Android SDK integration, make sure your project meets the technical requirements. In addition, ensure the following prerequisites are in place:

Step 1: Create a customer

Before enrolling payment methods, you need to create a customer in Yuno's system. Use the Create customer endpoint to obtain a customer_id. This identifier will be used to associate enrolled payment methods with the specific customer.

The endpoint will return a customer_session that you'll need to use when calling the enrollment methods.

Step 2: Include the library in your project

Follow these steps to add the Yuno Lite SDK to your Android project:

Add the Repository

First, add Yuno's Maven repository to your project's Gradle configuration:

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

After, include the code below in the file build.gradle to add the Yuno SDK dependency to the application.

dependencies {
    implementation 'com.yuno.payments:android-sdk:{last_version}'
}

Permissions

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

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

Step 3: Initialize SDK with the public key

To initialize the SDK, follow these steps:

  1. Get your Public API Key from the Yuno Dashboard
  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 as shown below:
class CustomApplication : Application() {
  override fun onCreate() {
    super.onCreate()
    Yuno.initialize(
      this,
      "your api key",
      config: YunoConfig, // This is a data class to use custom configs in the SDK.
    )
  }
}

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

data class YunoConfig(
    val cardFlow: CardFormType = CardFormType.ONE_STEP, // Optional: Defines the card form flow type. ONE_STEP shows a single screen for card details, TWO_STEP splits it across multiple screens.
    val saveCardEnabled: Boolean = false, // Determines whether to display the "Save card" checkbox on card flows.
    val keepLoader: Boolean = false, // If true, keeps the Yuno loading screen visible until payment creation and continuation. Requires an additional step described later.
    val cardFormDeployed: Boolean = false, // Full SDK only: If true, displays the card form within the payment methods list. If false, shows the card form on a separate screen.
    val language: YunoLanguage? = null, // Sets the SDK language. If null or not provided, defaults to the device language.
    val styles: YunoStyles? = null // Enables SDK-wide UI customization.
)

The following table includes descriptions for each customization available.

Customization optionDescription
cardFlowIt is an optional configuration that defines Payment and Enrollment Card flow. By default, the CardFormType.ONE_STEP option is used. Check the section Render options for more information
saveCardEnabledEnables the Save card checkbox on card flows. Check the Save card section for more information.
keepLoaderKeep Yuno's loading screen until you create and continue with payment. To use this feature, you need to use the function startCompletePaymentFlow(), described in the next sections. Check the Loader for additional information.
languageDefines the language to be used in the payment forms. If you don't send or provide a null value, Yuno SDK will use the device language. You can set it to one of the available language options:

- es (Spanish)
- en (English)
- pt (Portuguese)
stylesEnables SDK-wide UI customization. Use it to define global visual styles like font family and button appearance (color, padding, radius, typography) through a YunoStyles object. For more information, check the styles section.

Loading Screen Persistence

To ensure that the Yuno loading screen persists until you create and proceed with the payment, you need to use the startCompletePaymentFlow()(loader-android) function.

You also need to update your manifest to use your application:

<application android:name=".CustomApplication"></application>

Step 4: Enroll a new payment method

To create the enrollment flow, you need to call the initEnrollment method on the onCreate method of your activity. This process is required because Yuno's Lite SDK uses it to register the contract to give you the final enrollment state.

fun ComponentActivity.initEnrollment(
    callbackEnrollmentState: ((String?) -> Unit)? = null, //Default null | To register this callback is a must to call ```initEnrollment``` method on the onCreate method of activity.
)

To start the enrollment of a new payment method, you need to use the startEnrollment method. When you call the startEnrollment method, the enrollment flow of a new payment method will start.

fun Activity.startEnrollment(
    customerSession: String,
  	// The complete list of country codes is available on https://docs.y.uno/docs/country-coverage-yuno-sdk
    countryCode: String,
    showEnrollmentStatus: Boolean = true, //Optional - Default true
    callbackEnrollmentState: ((String?) -> Unit)? = null, // Default null | To register this callback is a must to call ```initEnrollment``` method on the onCreate method of activity.
  	requestCode: Int, // Optional. Use this option to capture the status when using the onActivityResult
)

Below is a description of the startEnrollment parameters.

ParameterDescription
customerSessionThe session customer associated with the current enrollment process.
countryCodeCountry code where the payment is performed. See Country coverage for a complete list of supported countries and their codes.
showEnrollmentStatusIndicates whether the enrollment status should be shown. This parameter is optional and defaults to true.
callbackEnrollmentStateA 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.
requestCodeIt is an optional parameter you must inform if you are going to use the onActivityResult method to capture the enrollment states.

Callback Enrollment State

The callbackEnrollmentState parameter is a function that returns the current enrollment process status. You only need to provide this function if you want to track the enrollment status.

To check the current enrollment state at any time, use the AppCompatActivity.enrollmentStatus() function. This function is optional and accepts the same parameters as startEnrollment. The following code block shows the function signature:

fun AppCompatActivity.enrollmentStatus(
    customerSession: String,
    countryCode: String,
    showEnrollmentStatus: Boolean = false, //Optional - Default false
    callbackEnrollmentState: ((String?) -> Unit)? = null, //Optional - You can send again another callback that is gonna override the one you sent on initEnrollment function.
)

Optional Function

Using the function enrollmentStatus is optional. It isn't a requirement to complete the enrollment process.

Note

If you provide a new callback when calling the function enrollmentStatus, it will override the callback you set when calling the function initEnrollment.

The possible states are presented in the following code block:

const val ENROLLMENT_STATE_SUCCEEDED = "SUCCEEDED"
const val ENROLLMENT_STATE_FAIL = "FAIL"
const val ENROLLMENT_STATE_PROCESSING = "PROCESSING"
const val ENROLLMENT_STATE_REJECT = "REJECT"
const val ENROLLMENT_STATE_INTERNAL_ERROR = "INTERNAL_ERROR"
const val ENROLLMENT_STATE_CANCELED_BY_USER = "CANCELED"

The following table provide additional information about the possible states:

StateDescriptionAdditional action required
SUCCEEDEDThe enrollment process was successfully completed without any errors.No.
FAILThe enrollment attempt failed due to errors such as data validation issues, server connection failures, or technical problems.Yes. Investigate the cause of failure (validation, network, server) and take corrective measures.
PROCESSINGThe enrollment is currently in progress, awaiting approval or verification.No.
REJECTThe enrollment was rejected due to reasons such as missing requirements or detected inconsistencies.Yes. Inform the user of the rejection, provide the reason if possible, and suggest next steps.
INTERNAL_ERRORAn unexpected internal error occurred within the system handling the enrollment process.Yes. Requires technical intervention to review the system, fix internal issues, and retry or inform the user.
CANCELEDThe user voluntarily canceled the enrollment process or exited before completion.No.

Using the OnActivityResult method

The onActivityResult method is automatically invoked when an activity returns a result. You can use this option to execute actions whenever the enrollment status changes. To process the enrollment result, follow these steps:

Deprecated

The onActivityResult method is a deprecated solution. If you are performing a new Android integration, Yuno recommends using initEnrollment() contract, which follows Google's best practices.

Request Code

If you are using the onActivityResult method but did not inform a requestCode when calling the startEnrollment in Step 3, you must use the YUNO_ENROLLMENT_REQUEST_CODE provided by Yuno.

  1. First, override the onActivityResult method. It ensures that the hierarchy calls are respected.
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {  
    super.onActivityResult(requestCode, resultCode, data)  
}
  1. After, check if the requestCode to verify if it corresponds to YUNO_ENROLLMENT_REQUEST_CODE. Since you are running Yuno in your app, you can import the YUNO_ENROLLMENT_REQUEST_CODE to use it.
if (requestCode == YUNO_ENROLLMENT_REQUEST_CODE) {  
    // Specific enrollment processing  
}
  1. If the requestCode matches, you can handle the enrollment result. In this case, you can extract the enrollment state using the YUNO_ENROLLMENT_RESULT key provided by the Yuno library. You can create a onEnrollmentStateChangefunction to handle the state changes.
onEnrollmentStateChange(data?.getStringExtra(YUNO_ENROLLMENT_RESULT))

The following code block presents an example of code to use the OnActivityResult method to execute functions when the enrollment status changes.

override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)
    
    if (requestCode == YUNO_ENROLLMENT_REQUEST_CODE) {
        // Handle the enrollment result
        val enrollmentState = data?.getStringExtra(YUNO_ENROLLMENT_RESULT)
        onEnrollmentStateChange(enrollmentState)
    }
}

fun onEnrollmentStateChange(enrollmentState: String?) {
    // Implement your logic to handle different enrollment states here
    when (enrollmentState) {
        "SUCCEEDED" -> {
            // Handle successful enrollment
        }
        "FAIL" -> {
            // Handle failed enrollment
        }
        // Add other states as needed
    }
}

Step 5: Get enrollment status

To register a callback to get the final enrollment state, it is necessary to call the initEnrollment method on the onCreate method of activity.

Complementary features

Yuno Android SDK provides additional services and configurations you can use to improve customers' experience. Use the SDK customization to change the SDK appearance to match your brand or to configure the loader.

styles

With the styles customization option, you can define global visual styles like through a YunoStyles object. It lets you apply consistent branding across the SDK by customizing button appearance and typography.

data class YunoStyles(
    val buttonStyles: YunoButtonStyles? = null,
    val fontFamily: FontFamily? = null
)
ParameterDescription
buttonStylesCustomizes the primary buttons displayed in the SDK.
fontFamilySets the font family used across all SDK text elements.

The YunoButtonStyles object lets you define specific settings for button appearance:

data class YunoButtonStyles(
    val backgroundColor: Color? = null,
    val contentColor: Color? = null,
    val cornerRadius: Dp? = null,
    val elevation: Dp? = null,
    val padding: Dp? = null,
    val fontFamily: FontFamily? = null,
    val fontSize: TextUnit? = null,
    val fontStyle: FontStyle? = null
)

To use the styles customization option, you have to use the YunoConfig data class, described in Step 2.

Loader

The Loader enables you to control the use of the loader component.

Save card for future payments

In addition, you can display a checkbox to save or enroll cards using cardSaveEnable: true. Below, you can find examples of the checkbox for both card form renders:

Render options

You can choose between two card form render options. The following screenshots demonstrate the difference between cardFormType ONE_STEP and STEP_BY_STEP:

SDK customization

You can change the SDK appearance to match your brand. For more information, access the SDK customization page.

Demo App

In addition to the code examples provided, you can access the Yuno repository to complete Yuno Android SDKs implementation.