Android SDK installation and configuration

The Zettle Payments SDK for Android lets you take card payments from any Android app, using a Zettle card reader. The following describes how to install, configure and initialise the Zettle SDK for Android.

Prerequisites

  • Developer environment, for example Android Studio
  • Android version 5 (API level 21) and higher
  • Client ID from the Developer Portal, Getting started
  • GitHub token, see Getting started

Install the SDK

Add dependencies

The Zettle Payment SDKs for Android is available as packages from the GitHub package hosting service. To include the Android SDK in your project, you need to add a dependency to the package service, using your GitHub Token.

To get the SDK packages, add the following to the build.gradle file in your project:

1
maven {
2
url = uri("https://maven.pkg.github.com/iZettle/sdk-android")
3
credentials(HttpHeaderCredentials) {
4
name "Authorization"
5
value "Bearer <Your GitHub Token>" // More about auth tokens https://help.github.com/en/github/authenticating-to-github/creating-a-personal-access-token-for-the-command-line
6
}
7
authentication {
8
header(HttpHeaderAuthentication)
9
}
10
}
11
dependencies {
12
implementation 'com.izettle.payments:android-sdk-ui:<SDK version>'
13
}

To avoid conflicts in the .kotlin_module META-INF, it is recommended to exclude META-INF by adding the following:

1
android {
2
packagingOptions {
3
exclude 'META-INF/*.kotlin_module'
4
}
5
}

AndroidX is used in some libraries, so you will also get them as dependencies.

Targeting Android 12

Note: Make sure to use the latest version of the SDK or at least version 1.25.6.

Configure the SDK

Authentication

To be able to log in a user through the Zettle SDK user interface, you must add the OAuthActivity to your manifest.

Remember to replace the redirect URL data with your own in the intent filter, to be able to receive the result from the login (which will take place in a web view).

For SDK version 1.30.1 and above, add the following OAuthActivity to your manifest:

1
<activity
2
android:exported="true"
3
android:name="com.izettle.android.auth.OAuthActivity"
4
android:launchMode="singleTask"
5
android:taskAffinity="@string/oauth_activity_task_affinity">
6
<intent-filter>
7
<data
8
android:host="[redirect url host]"
9
android:scheme="[redirect url scheme]" />
10
<action android:name="android.intent.action.VIEW" />
11
<category android:name="android.intent.category.DEFAULT" />
12
<category android:name="android.intent.category.BROWSABLE" />
13
</intent-filter>
14
</activity>

For SDK versions below 1.30.1, add the following OAuthActivity to your manifest:

1
<activity
2
android:name="com.izettle.android.auth.OAuthActivity"
3
android:launchMode="singleTask"
4
android:taskAffinity="@string/oauth_activity_task_affinity">
5
<intent-filter>
6
<data
7
android:host="[redirect url host]"
8
android:scheme="[redirect url scheme]" />
9
<action android:name="android.intent.action.VIEW" />
10
<category android:name="android.intent.category.DEFAULT" />
11
<category android:name="android.intent.category.BROWSABLE" />
12
</intent-filter>
13
</activity>

This setup procedure is not required. You can handle the authentication flow yourself and provide the token to the SDK. For more information about this option, see Initialisation.