- Need full control over the payment UI and user experience
- Want to build custom payment flows
- Require advanced integration capabilities
- Direct API access for payment processing
- Token generation for payment methods
- 3DS authentication handling
- Fraud prevention data collection
Requirements
Before starting the Yuno Android SDK integration, ensure your project meets the technical requirements. Also, ensure the following prerequisites are in place:- 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.Latest SDK VersionCheck the Release notes or visit the Yuno Android SDK repository to verify the current SDK version available.
Step 1: Create a customer
Create a customer using the Create customer endpoint before initiating payments. This step is required to:- Identify the person making the payment
- Enable saved payment method functionality (if enabled)
- Track payment history
checkout_session.
Step 2: Create a checkout session
Create a newcheckout_session using the Create checkout session endpoint to initialize the payment flow. Make sure to:
- Include the customer ID obtained from the previous step
- Store the returned
checkout_sessionID for use in later steps
checkout_session is unique for each payment attempt and cannot be reused.
Step 3: Include the library in your project
Include the Yuno SDK in your project through Gradle. Add the repository source:build.gradle file:
INTERNET permission, which is required to make network requests.
<uses-permission android:name="android.permission.INTERNET" />
Step 4: Initialize headless SDK with the public key
Import Yuno and provide a valid PUBLIC_API_KEY to initialize the Headless SDK. If you don’t have your API credentials, see the Developers (Credentials) page to check how to retrieve them from the dashboard. Create a custom application if you haven’t already. In theonCreate() method of your application class, initialize the SDK by calling the Yuno.initialize() function:
For a detailed explanation of the
keepLoader parameter and mandatory error handling, see the Android Reference Guide.Step 5: Start the checkout process
Call theapiClientPayment function after your customer selects a payment method to start the checkout process. This function requires configuration parameters and initiates the collection of information needed for 3DS authentication and fraud prevention tools configured in your routing.
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. |
checkout_session | Refers to the current payment’s checkout session created using the Create Checkout Session endpoint. Example: '438413b7-4921-41e4-b8f3-28a5a0141638' |
Step 6: Generate token
After collecting the user information, create a one-time token (OTT) using theapiClientPayment.generateToken function. Since this is an asynchronous function, use a try/catch block to handle any errors that may occur. The following examples show two different scenarios for creating a one-time token:
- Example 1: Create a one-time token using a card as the payment method and including all required card information.
- Example 2: Create a one-time token using the
vaulted_tokeninformation.
Benefits of using a vaulted token
When you use a vaulted token with the SDK, all the fraud information from the providers you configured in your card routing is collected and attached to the one-time token. You can also add installment information and a security code if the provider requires it.Example 1
Example 2
LiveData. You can observe the response as a common LiveData with the following type SingleLiveEvent<Map<String, Any?>>, which is a LiveData that only emits once. The response type is a Map containing the whole response. The following code block shows examples of responses after calling the apiClientPayment.generateToken function.
Example 1
Example 2
sdk_action_required parameter that defines if additional actions are necessary.
The following code block shows an example of observing the response:
Step 7: Create the payment
After generating the one-time token, create the payment by calling the Create Payment endpoint. Include the one-time token obtained in Step 6 in thepayment_method.token parameter of your request. The following code block shows an example of a payment creation request:
sdk_action_required parameter that indicates whether additional actions are needed to complete the payment:
- For synchronous payment methods, the payment completes instantly. In this case,
sdk_action_requiredwill befalsein the API response and the payment process ends - For payment flows requiring additional SDK interaction,
sdk_action_requiredwill betrue. When this happens, proceed to Step 8 for next steps
Step 8: Continue the payment (if required)
When a payment created from your backend requires an additional step — for example, a 3DS challenge — the Create Payment endpoint response includes:- Status
PENDINGand sub-statusWAITING_ADDITIONAL_STEP sdk_action_required = true
continueCardPayment to let the SDK resume the payment. The SDK executes the pending action internally, including rendering the 3DS challenge, waits for the result, and delivers the final payment state to your callback.
Function signature
Parameters
| Parameter | Type | Description |
|---|---|---|
activity | ComponentActivity | The activity the SDK uses to present the pending action. |
showPaymentStatus | Boolean | If true, the SDK shows its payment status screen when the flow finishes. Set it to false to use only the callback. |
callbackPaymentState | ((String?, String?) -> Unit)? | Invoked on the main thread with the final payment state and sub-status once the flow completes. |
Usage
Payment states
| State | Meaning |
|---|---|
SUCCEEDED | The payment was completed successfully. |
PROCESSING | The payment is still being processed. |
REJECT | The payment was rejected by the provider. |
FAIL | The payment failed. |
CANCELED_BY_USER | The customer abandoned the additional step. |
INTERNAL_ERROR | An unexpected error occurred while resuming the payment. |
continueCardPayment supports CARD payments only.
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.Loader
The loader functionality is controlled through thekeepLoader parameter in the YunoConfig data class, which is documented inline in the SDK configuration section above.
SDK customization
You can change the SDK appearance to match your brand. For more information, see the SDK customization page.Access the Demo AppIn addition to the code examples provided, you can see the Yuno repository to complete Yuno Android SDKs implementation.