Loading...
Mobile SDKAndroid

Integration

Follow the instructions below to integrate the Volt Mobile SDK for Android in your project.


Install the SDK

Android Volt Mobile SDK is available through Github packages.

Generate github personal token (as described in Github documentation) with read:packages scope.

Add maven repository to the build.gradle file of your project. Github personal access token and username for whom token is created are required to be able to fetch dependency.

repositories {
    google()
    //...
    maven {
        url = uri("https://maven.pkg.github.com/volt-io/android-sdk")
        credentials {
            username = "$GITHUB_USERNAME"
            password = "$GITHUB_PERSONAL_TOKEN"
        }
    }
}

Add dependency in build.gradle of your app module.

dependencies {
    //...
    implementation("io.volt:checkout-global-sdk:X.Y.Z")
}

Latest SDK version can be found here

Initialise SDK

Implement AuthTokenProvider

Mobile SDK does not store any secrets, like username, password etc. You must handle auth methods on app side by implementing io.volt.sdk.network.AuthTokenProvider in order for SDK to authenticate with API. Use this to handle authentication with Volt's API.

interface AuthTokenProvider {

    @Throws(Exception::class)
    fun getToken(): String

    @Throws(Exception::class)
    fun refreshToken(): String
}

getToken method is called by SDK when bank list is loaded and for payment creation.

refreshToken method is called by SDK when token from getToken is invalid.

Initialise SDK in Appllication.onCreate

Checkout is a singleton and should be initialized in application onCreate method.

import io.volt.sdk.Checkout

class App : Application() {

    override fun onCreate() {
        super.onCreate()
        Checkout.init(
            appContext = applicationContext,
            customerId = "<customer-id>",
            isSandbox = true,
            authTokenProvider = AuthTokenProviderImplementation(...)
        )
    }
}

where:

ParameterDescription
appContextAndroid application context
customerIdVolt customer ID (UUID)
isSandboxBoolean indicating if Sanbox or Production environment should be used
authTokenProviderInstance of AuthTokenProvider implementation

How is this guide?

Last updated on

On this page