Lite SDK (Payment Android)
On this page, you find all the steps to add, configure, and use the Lite SDK to perform a payment in your Android project.
Step 1: Include the library in your project
Ensure the Yuno SDK file is included in your project through Gradle. Then, add the repository source using the following code line:
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 2: Initialize SDK with the public key
First, you need to retrieve your Public API Keys from the Yuno dashboard.
If you haven't implemented a custom application, create one. In the onCreate()
method of your application class, call the initialize function (Yuno.initialize
) as shown in the example 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 SDK behavior. Include this configuration in the Yuno.initialize
:
data class YunoConfig(
val cardFlow: CardFormType = CardFormType.ONE_STEP, // This is optional, CardFormType.ONE_STEP by default, this is to choose Payment and Enrollment Card flow.
val saveCardEnabled: Boolean = false, // This is to choose if show save card checkbox on cards flows.
val keepLoader: Boolean = false // This is to choose if keep Yuno loading screen until you create and continue with payment, this need an additional step that is shown below.
val language: YunoLanguage? = null, //This is to choose the language of the SDK, if you send null or don't send it, Yuno SDK will take device language.
val isDynamicViewEnabled: Boolean = false, //This is to choose if you want to use dynamic view or not, if you send false or don't send it, Yuno SDK will take false.
)
In the next table, you find the descriptions for each customization option available.
Customization option | Description |
---|---|
cardFlow | It is an optional configuration that defines Payment and Enrollment Card flow. By default, the CardFormType.ONE_STEP option is used. |
saveCardEnabled | Enables the Save card checkbox on card flows. |
keepLoader | Keep 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. |
language | Define the language used to present the SDK. If you don't send or provide a null value, Yuno SDK will use the device language. The available options are: - ENGLISH - SPANISH - PORTUGUESE - INDONESIAN - MALAYSIAN |
isDynamicViewEnabled | Defines if you want to use the dynamic view. In the case you don't provide a value, Yuno SDK will use the FALSE option. |
To ensure that the Yuno loading screen persists until you create and proceed with the payment, you need to use the startCompletePaymentFlow()
function.
You also need to update your manifest to use your application:
<application android:name=".CustomApplication"></application>
Step 3: Start the checkout process
To start a new payment process with the Lite SDK, you need to call the startCheckout
method on onCreate
of activity that calls the SDK:
startCheckout(
checkoutSession: "checkout_session",
// The complete list of country_codes is available on https://docs.y.uno/docs/country-coverage-yuno-sdk
countryCode: "country_code_iso",
callbackPaymentState: ((String?) -> Unit)?,
merchantSessionId: String? = null //Optional - Default null
)
Below is a description of the required parameters to start the checkout.
Parameter | Description |
---|---|
checkoutSession | The checkout session is related to the payment. |
countryCode | Country code where the payment is performed. The complete list of supported countries and their country code is available on the Country coverage page. |
callbackPaymentState | It's a function that returns the current payment process. Sending this function is not mandatory if you do not need the result. |
Callback Payment State
The callbackPaymentState
parameter is a function that returns the current payment process. Sending this function is not mandatory if you do not need the result. The possible states are:
const val PAYMENT_STATE_SUCCEEDED = "SUCCEEDED"
const val PAYMENT_STATE_FAIL = "FAIL"
const val PAYMENT_STATE_PROCESSING = "PROCESSING"
const val PAYMENT_STATE_REJECT = "REJECT"
const val PAYMENT_STATE_INTERNAL_ERROR = "INTERNAL_ERROR"
const val PAYMENT_STATE_STATE_CANCELED_BY_USER = "CANCELED"
Step 4: Initiate the payment process
To start a payment process, you have to call the method startPaymentLite
.
startPaymentLite(
paymentSelected: PaymentSelected,
callbackOTT:(String?) -> Unit, //Optional - Default null,
callBackTokenWithInformation:(OneTimeTokenModel?) -> Unit, //Optional - Default null
showPaymentStatus: Boolean, //Optional - Default true
)
Below is a description of the required parameters to start the payment.
Parameter | Description |
---|---|
showStatusYuno | A boolean that specifies whether the payment status should be displayed within the Yuno interface. |
callbackOTT | A required function that returns the updated One-Time Token (OTT) needed to complete the payment process. |
callBackTokenWithInformation | A function that supplies detailed information about the OTT, wrapped in a OneTimeTokenModel object, allowing for comprehensive handling of token details. |
You need to send an additional parameter, which is the vaulted token and/or the payment type that the user selected to make the payment.
PaymentSelected(
id : String "payment_vaulted_token",
type : String "payment_type",
)
Step 5: Get the OTT (One Time Token):
Once the customer fills out the requested data in Yuno's payment forms, you will obtain the OTT, which is a required parameter to create a payment via the Payments API POST/payments. You can obtain this data from theonActivityResult
, received from the callback.
Callback One Time Token (OTT)
The callbackOTT
parameter, provided when initiating the payment in Step 4, is a mandatory function that returns an OTT. The OTT is required to complete the back-to-back payments.
Important
The merchant is responsible for handling the loader. Yuno offers an option to use our loader; however, the merchant can use their own loader and must make the corresponding configurations.
Step 6: Create the Payment
Once you have completed the steps described before, you can create a payment. The back-to-back payment creation must be carried out using the Create Payment endpoint. The merchant should call their backend to create the payment within Yuno, using the OTT (One Time Token) and the checkout session.
Continue
We recommend integrating the SDK continuePayment
method after the payment is created because certain asynchronous payment methods require additional action from the customer to complete it. The create_payment API will inform you of this scenario via the response field sdk_action_required
, which will return TRUE
. The yuno.continuePayment()
function will display the additional screens to the customers, where they can carry out the necessary actions to complete the payment. Otherwise, this step is not necessary. You need to call continuePayment
method as presented below:
continuePayment(
showPaymentStatus: Boolean, //Optional - Default true
callbackPaymentState: ((String?) -> Unit)?, //Optional - Default null
)
To show your payment status screens, you should send FALSE
in the showPaymentStatus
parameter. Then, get the payment state by callback.
Complementary Features
Yuno Android SDK provides additional services and configurations you can use to improve customers' experience. Use the SDK Customizations to change the SDK appearance to match your brand or to configure the loader.
Yuno Android SDK provides additional services and configurations you can use to improve customers' experience:
- Loader: Control the use of the loader.
- Save card for future payments: In addition, you can display a checkbox for save or enroll cards using
cardSaveEnable: true
. Below, you find an example of the checkbox for card form render.
- You also can choose one of the render options for the card form. Below you find screenshots presenting the difference between the
cardFormType
ONE_STEP
andSTEP_BY_STEP
.
- SDK Customizations: Change the SDK appearance to match your brand.
Demo App
In addition to the code examples provided, you can access the Yuno repository for a complete implementation of Yuno Android SDKs.
Updated 12 days ago