Seamless SDK (Payment Android)
This guide walks you through integrating the Yuno Flow SDK into your Android project.
Step 1: Add the Yuno SDK to 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
The Yuno SDK requires network permissions. Ensure the INTERNET
permission is included in your AndroidManifest.xml
:
<uses-permission android:name="android.permission.INTERNET" />
Step 2: Initialize the SDK with your public key
First, you 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() // Customize configurations if needed
)
}
}
Use the YunoConfig
data class to set additional configurations for the SDK. The customization options are listed and described in the following table:
Option | Description |
---|---|
cardFlow | Defines the card form flow. The default option is CardFormType.ONE_STEP . |
saveCardEnabled | Enables the save card checkbox for card flows. |
language | Sets the SDK language. By default, the SDK will use the device language. |
isDynamicViewEnabled | Enables or disables the dynamic view. Default is false . |
The following code block presents an example of YunoConfig
:
data class YunoConfig(
val cardFlow: CardFormType = CardFormType.ONE_STEP,
val saveCardEnabled: Boolean = false,
val language: YunoLanguage? = null
)
Step 3: Initiate the Checkout Process
To start a payment, use the startCheckout
method in the activity’s onCreate()
where the SDK is called.
startCheckout(
checkoutSession = "checkout_session",
countryCode = "country_code_iso",
callbackPaymentState = { paymentState ->
// Handle payment state updates here
}
)
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 States
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: Start the payment process
To start a payment process, you have to call the method startPaymentSeamlessLite
.
startPaymentSeamlessLite(
paymentSelected: PaymentSelected,
callbackPaymentState: ((String?) -> Unit)?, //Optional - Default null
showPaymentStatus: Boolean, //Optional - Default true - If you wish to use your own payment result screen set this param in false. The default shows the SDK result screen.
)
Below is a description of the parameters to start the payment:
Parameter | Description |
---|---|
paymentSelected | Specifies the payment method, either through a vaulted token or a selected payment type. |
callbackPaymentState | This is an optional parameter. This function handles the state updates. |
showPaymentStatus | This is an optional parameter. When true , displays the SDK’s default result screen. |
You will receive the payment status via callbackPaymentState
, which will indicate whether the payment was successful or if an issue occurred.
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
.
Updated 11 days ago