Quick Start

This guide outlines the essential steps for integrating Ottu Android Checkout SDK into your mobile application. It provides a concise flow from setup to callback handling, helping developers achieve a seamless checkout experience.

This video guides you step-by-step through the Android SDK integration process. Watch it to quickly learn how to set up, configure, and see the key features in action.

1

Add JitPack Repository

In your settings.gradle.kts file, add JitPack to the repositories section under dependencyResolutionManagement:

2

Add the SDK Dependency

Include the Ottu Checkout SDK in your app-level build.gradle.kts file:

1

Add FrameLayout to the Layout File

Inside activity_main.xml (located in the res/layout folder), add a FrameLayout with the ID ottuPaymentView: android:id="@+id/ottuPaymentView"

2

Import Required Modules

Usually, Android Studio automatically imports the necessary modules. However, for reference, the Ottu SDK requires the following imports:

3

Extend the Activity Class

Ensure that the Activity integrating with the Checkout SDK inherits from AppCompatActivity:

4

Declare Checkout Fragment Variable

Add a member variable for the CheckoutSdkFragment object:

5

Initialize Checkout SDK

Inside the onCreate function, add the SDK initialization code:

6

(Optional) Implement Result and Error Dialogs

Uncomment showResultDialog and showErrorDialog in the code above and add their implementations as methods inside the same MainActivity:

7

Clean Up Memory

To ensure proper resource management, override the onDestroy method:

8

Verify Imports

Finally, confirm that all required imports are present. Android Studio usually detects and adds them automatically.

Notes on Initialization Parameters

Not all parameters in Checkout.init are mandatory. The required parameters are:

  • sessionId – ID of the created transaction

  • merchantId – Same as the domain used in HTTP requests

  • apiKey – Public API key used for authorization

Recommended optional parameters:

  • formsOfPayment

  • setupPreload (to reduce initialization time)

setupPreload is an object taken from the transaction creation response. When passed to the SDK, it prevents it from requesting the transaction details on its own and therefore speed-ups the initialization process by several seconds. This setupPreload is a decoded JSON object to a TransactionDetails For reference, check the example: here

The SDK triggers three main callbacks:

  • successCallback – Invoked upon successful payment.

  • cancelCallback – Triggered when the user cancels the transaction.

  • errorCallback – Activated on errors during the checkout process.

Developers should customize the logic within these callbacks to handle transaction results appropriately.

Last updated