Trustly Android SDK

Trustly fully supports native Android apps. On this page, you will find instructions on how-to configure Trustly in Android apps.

Trustly Android SDK has been created for Android to simplify the process of implementing the functionality needed when using Trustly within an Android app. It provides a self-contained WebView that enables the Trustly Checkout within your application.


Please note that when rendering the Trustly Checkout from a native app you are required to pass your application's URLScheme as an attribute to the order initiation request. By doing so, Trustly can redirect users back to your app after using external identification apps such as Mobile BankID.

It's a straightforward process; you can follow any Tutorial on Android Custom URL Schemes. The URL scheme can be registered using the following method:

  • Include it in the "URLScheme" attribute when making an API call to Trustly.
  • It's important that the "URLScheme" attribute is only sent if the order is triggered by users from within the app.
  • For any other transaction instances (ex. desktop or interaction via mobile browser directly) the "URLScheme" attribute must not be included.
Attribute nameDescriptionTypeExample
URLSchemeThe URL scheme used to redirect users back to your appTextyourCustomURLScheme://


    "method": "Deposit",
    "params": {
        "Signature": "f4ThjuMqbsdG6u ... S16VbzD4h==",
        "UUID": "258a2184-2842-b485-25ca-293525152425",
        "Data": { 
            "Username": "merchant_username",
            "Password": "merchant_password",
            "Attributes": {
                "Country": "SE",
                "Locale": "sv_SE",

Configure Trustly Android SDK:

Authenticate to Github Packages

To authenticate with Github Packages you need to add your GitHub username and a GitHub Access Token to your project level build.gradle file.

Make sure that you your token have both read and write permissions for packages.


Do not commit these credentials to your repo.

Add library to your dependencies

Go to app -> build.gradle and add the following code to your dependencies:

implementation ''


NOTE: The latest version of the SDK (3.0.1) does not support the older version of the Trustly Checkout. If you do use the older Checkout, please use version 2.0.0 of the SDK. If you're not sure what version of the Trustly Checkout you are using, please contact our integration support for help.

Create WebView

Go to app -> src -> main-> res -> layout -> activity_main.xml and add the following code:


Modify MainActivity
Import dependencies inside your MainActivity:

import android.os.Bundle;

import android.webkit.WebView;
import com.trustlyAndroidLibrary.TrustlyWebView;

Add the following code to your MainActivity:


protected void onCreate(Bundle savedInstanceState) {



   WebView main = findViewById(;

   final TrustlyWebView trustlyView = new TrustlyWebView(this, 
   "< Insert Trustly Url >");


Add permission for Internet

Go to app -> src -> main -> AndroidManifest.xml and add the following code:

<uses-permission android:name="android.permission.INTERNET"/>

Checkout Events

If you want more control of your Checkout flow you can choose to opt-in to receiving and handling Checkout events.

You opt-in by creating an implementation of the TrustlyEventHandler interface.

public interface TrustlyEventHandler {

  void onTrustlyCheckoutSuccess(TrustlySDKEventObject eventObject);

  void onTrustlyCheckoutRedirect(TrustlySDKEventObject eventObject);

  void onTrustlyCheckoutAbort(TrustlySDKEventObject eventObject);

  void onTrustlyCheckoutError(TrustlySDKEventObject eventObject);


and passing your implementation to the TrustlyWebView.

TrustlyEventHandler eventHandler = new TrustlyEventHandlerImplementation();
TrustlyWebView trustlyView = new TrustlyWebView(this, trustlyCheckoutUrl, eventHandler);


If you choose to subscribe for TrustlyCheckoutEvents you will need to handle all opening of third party applications yourself!