- Need full control over the UI and user experience
- Want to implement custom enrollment flows
- Require advanced integration capabilities
- Card tokenization
- Secure payment method enrollment
- Direct API access
- Custom error handling
Requirements
Before starting the Yuno Android SDK integration, ensure your project meets the technical requirements:- Minimum SDK Version:
minSdkVersion21 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)
ProGuard / R8 Configuration
If your project hasminifyEnabled = true, add these rules to your proguard-rules.pro file to ensure the SDK works correctly, especially with AGP 8.x+ R8 full mode.
Official Yuno ProGuard / R8 rules
Official Yuno ProGuard / R8 rules
Why are these rules necessary?
AGP 8.x+ enables R8 full mode by default, which aggressively strips generic type signatures. Without-keepattributes Signature, Gson’s TypeToken<T> can fail at runtime with java.lang.Class cannot be cast to java.lang.reflect.ParameterizedType.SDK Version InformationVerify the current SDK version by accessing the Release notes or visiting the Yuno Android SDK repository.
Step 1: Create a customer
Create a customer using the Create Customer endpoint before enrolling payment methods.Step 2: Create a customer session
Create a newcustomer_session using the Create Customer Session endpoint:
- Include the customer ID in the request
- Store the returned
customer_sessionID - Generate a new
customer_sessionfor each payment method enrollment.
Step 3: Add the SDK to your project
- Add the repository source:
- Add the SDK dependency:
Internet Permission RequiredThe Yuno SDK automatically includes the
INTERNET permission, necessary for network requests. Ensure your AndroidManifest.xml contains:<uses-permission android:name="android.permission.INTERNET" />Step 4: Initialize Headless SDK with the public key
Retrieve your public API keys from the Yuno dashboard. If you haven’t implemented a custom application, create one. In theonCreate() method of your application class, call the initialize function (Yuno.initialize):
Step 5: Create an enrollment payment method object
Create an enrollment payment method object using the Enroll Payment Method endpoint to set up the Headless SDK integration for enrollment. When creating this object, specify which payment method type your customer can enroll in. Currently, the Headless SDK only supports the CARD payment method type.Card VerificationTo verify cards (zero value authorization) before enrollment, include the
verify object when creating the payment method object for the customer session.Step 6: Start the enrollment process
Use theapiClientEnroll function to start the enrollment process. This function requires configuration parameters that define how the enrollment will be processed. The following table describes the required parameters:
| Parameter | Description |
|---|---|
country_code | This parameter determines the country for which the payment process is being configured. The complete list of supported countries and their country_code is available on the Country coverage page. |
customer_session | 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 7: Generate a vaulted token
After collecting all required customer information, create avaulted_token using the apiClientEnroll.continueEnrollment function. Since this is an asynchronous function, use a try/catch block to handle any errors that may occur. The following example shows how to create a vaulted_token:
apiClientEnroll.continueEnrollment function returns an Observable type that extends LiveData. You can observe the response as a standard LiveData with type SingleLiveEvent<Map<String, Any?>>. This LiveData emits only once and returns a Map containing the complete response. Below is an example response from calling apiClientEnroll.continueEnrollment:
Enrollment flow states
TheapiClientEnroll.continueEnrollment function returns a response that includes a status field indicating the current state of the enrollment process. The following are the possible states returned:
| State | Description | Additional action required |
|---|---|---|
SUCCEEDED | The enrollment process was successfully completed without any errors. | No. |
FAIL | The 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. |
PROCESSING | The enrollment is currently in progress, awaiting approval or verification. | No. |
REJECT | The 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_ERROR | An 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. |
CANCELED | The user voluntarily canceled the enrollment process or exited before completion. | No. |
Webhook Status TrackingConsider using the enrollment status received via Webhooks. Yuno recommends always using this status to base and make business decisions on your platform.