Full SDK (Android)
On this page, you find all the steps to add, configure, and use the Full SDK 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 cardFormDeployed: Boolean = false, // This is only for SDK FULL, This is to choose if show card form deployed on payment methods list (TRUE) or if show normal card form in another screen (FALSE)
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. |
cardFormDeployed | This option is only available for Full SDK. If TRUE , the system presents the card form deployed on the payment methods list. If FALSE , presents the normal card form on another screen. |
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 Full 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. |
The possible states returned by the callbackPaymentState
are presented below:
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: Add the SDK view to the checkout
When implementing the Full SDK version, ensure you incorporate the following view by instantiating our PaymentMethodListView
class in your layout to display available payment methods. In addition, add the .setOnSelectedEvent
method, which is a lambda function, to allow the merchant to know when to enable or disable the pay button.
<com.yuno.payments.features.payment.ui.views.PaymentMethodListView
android:id="@+id/list_payment_methods"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
Step 5: Initiate the payment process
To start a payment process, you have to call the method startPayment()
.
startPayment(
showStatusYuno: Boolean,
callbackOTT: (String?) -> Unit = this::onTokenUpdated,
callBackTokenWithInformation: (OneTimeTokenModel?) -> Unit = this::onTokenComplete
)
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. |
Step 6: Get the OTT (One Time Token)
Once the customer fills out the requested data in Yuno's payment forms, you will obtain the OTT, 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 7: 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.
- 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 can find examples of the checkbox for both card form renders.
- 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 16 days ago