Overview
Version 2.0+ of the Android SDK introduces breaking changes that require changes in your application code if you had previously integrated an early version. See the Migration Guide for further details.
SDK Updates
New versions of the SDK are released frequently, not only to add new features and address issues in the SDK, but also to continuously improve the conversion of merchant login flows. As a result, it is strongly recommended that you frequently update your SDK version across any platforms where you invoke the SDK.
New versions of the SDK are released frequently, not only to add new features and address issues in the SDK, but also to continuously improve the conversion of merchant login flows. As a result, it is strongly recommended that you frequently update your SDK version across any platforms where you invoke the SDK.
Installation
1
Add Maven Central
Follow the best-practice installation approach outlined below, which works seamlessly for both Java and Kotlin projects. Adding Maven Central to your root-level
build.gradle
file ensures that the Android Gradle plugin (and all other dependencies) are properly resolved and kept up-to-date.2
Add the Knot SDK to your app
In your module-level Gradle file (typically
app/build.gradle
), configure your Android settings-such as the minimum SDK version and Java 8 support-to ensure compatibility with the SDK. The Knot SDK Requires Android API level 21
or greater.3
Include the Knot SDK dependency
Include the Knot SDK dependency so that Gradle can fetch the SDK from Maven Central.Replace
<latest-version>
with the current version provided by Knot.4
Import Knot SDK
Initialization
Your backend will create a session by calling Create Session and provide it to your frontend. To initialize the Knot SDK, you must first configure the session with aKnotConfiguration
class. The configuration allows you to set the environment, entry point, and other user experience configurations.
It’s expected that your integration with Knot will retrieve and pass a new session into the SDK on each initialization.
Configure the session
TheKnotConfiguration
and CustomerConfiguration
classes are used to initialize the SDK with specific parameters.
KnotConfiguration
Name | Type | Description |
---|---|---|
sessionId | String | The session created by calling /session/create in your backend. |
clientId | String | Your organization’s client ID. Note that this varies between development and production environments. |
environment | Environment | The desired environment (development or production ). |
product | Product | Optional. Ignored in version 2.0.12+ and fully deprecated in the next major version. The Knot product the session will inherit — the same as the type of session created (e.g. card_switcher , transaction_link ). |
merchantIds | int[] | Optional. A list of merchant ID(s) to display. It is recommended to provide 0 or 1 merchant IDs depending on your desired user experience. |
useCategories | Bool | Optional. Whether to display merchant categories and therefore group merchants into categories for discoverability. Default: true . |
useSearch | Bool | Optional. Whether to display the search bar, enabling users to search for merchants. Default: true . |
domainUrls | String[] | Optional. A set of domains for which Knot should explicitly not clear cookies. |
entryPoint | String | Optional. The specific entry point from within your app where you are initializing the Knot SDK (e.g. onboarding ). The following special characters are not permitted in entrypoint strings: |
CustomerConfiguration
This class is entirely optional and infrequently used, typically only when you offer Knot for multiple, differently-named card programs in the same app. The Knot team will set pre-defined values for each parameter that you can then subsequently pass into the SDK. Passing a value that is not pre-defined will result in an
onError
callback. To take advantage of this functionality, please contact the Knot team who will be happy to assist you.Name | Type | Description |
---|---|---|
cardName | String | Optional. The differentiated display name for the card product, used inside the Knot SDK (e.g. Debit Card , Credit Card ). This value will override the default value Card . |
customerName | String | Optional. The differentiated display name for the company, used both as a standalone and prepended to the cardName (e.g. Smart Bank , Payment Corp ). This value will override your default customer name value. Only recommended if you issue cards under multiple brands. |
logoId | String | Optional. The differentiated logo for the company. This value will override your default logo. |
"Your [customerName] [cardName | Card] was added."
Open the session
To begin the flow, use theopen
method with a context
, a KnotConfiguration
instance, and an optional KnotEventDelegate
.
Single Merchant Flow
If you decide to use List Merchants to retrieve a list of merchants, list them in your app, and then open the SDK with a single merchant, you can do so by passing a merchant ID when configuring the session in theKnotConfiguration.
If a single merchant ID is provided, the user will be sent directly to that merchant’s login experience in the SDK. More in Retrieving & Listing Merchants. The merchant ID is the same across all environments.
Although available, it is not recommended that you provide a long list of merchants in order to remove a few, but rather “hide” certain merchants that you desire from your Customer Dashboard.
Entry Points
In your app’s user experience, you may choose to integrate Knot in one or multiple places (e.g. from different tabs or screens). How users behave when interacting with Knot from each of these “entry points” may vary and it will be useful for you to be able to differentiate these groups of users by entry point in order to assess the value of each entry point. You can provide a value for the entry point inKnotConfiguration.entryPoint
when configuring the session . This value will be returned in the AUTHENTICATED
webhook.
Categories & Search
Users are presented with a list of merchants in the SDK (unless you provide a single merchant as described above). Accompanying the list is a set of categories and a search experience. Each of these components is visible to users by default (as set in Knot’s backend). You can choose to remove either of them by settinguseCategories: false
and useSearch: false
in KnotConfiguration
. This is not recommended.
Events
To receive updates from the SDK, implementKnotEventDelegate
in your class.
onSuccess
This event is called when a user successfully logged in to the merchant and their card was switched. This event takes a single string argument representing the merchant’s name.
onError
This event is called when an error occurs during SDK initialization. It emits a KnotError
enum as described below.
Error Case | Description | Debugging Steps |
---|---|---|
INVALID_SESSION | The session is invalid. | Ensure KnotConfiguration.environment matches the environment the sessionId was created for (development or production ). |
EXPIRED_SESSION | The session has expired. | Sessions are valid for 30 minutes. It is best practice to ensure that you create a new session every time a user invokes the SDK using Create Session. |
INVALID_CLIENT_ID | The client ID is invalid. | Verify that the value you are providing for KnotConfiguration.clientId is for the environment matching the value you are providing for KnotConfiguration.environment (i.e. development or production ). If you provide your production clientId but set environment: development , you will experience this error. |
INTERNAL_ERROR | An internal error occurred. | Simply retry invoking the SDK with a new sessionId . |
MERCHANT_ID_NOT_FOUND | The merchant ID is required. | The type of sessionId you are providing on invokation of the SDK requires that you also provide a value in KnotConfiguration.merchantIds to ensure the user is directed to a specific merchant’s login flow in the SDK. You can retrieve a list of merchant IDs (the same in all environments) in List Merchants. |
INVALID_CARD_NAME | The card name is invalid. | The value you are providing for customerConfiguration.cardName must exactly match an allowlisted value for your organization. Please reach out to the Knot team for access to this allowlist. |
INVALID_CUSTOMER_NAME | The customer name is invalid. | The value you are providing for customerConfiguration.customerName must exactly match an allowlisted value for your organization. Please reach out to the Knot team for access to this allowlist. |
INVALID_LOGO_ID | The logo ID is invalid. | The value you are providing for customerConfiguration.logoId must exactly match an allowlisted value for your organization. Please reach out to the Knot team for access to this allowlist. |
onExit
This event is called when a user closes the SDK.
onEvent
This event is called when certain events occur in the SDK. With this callback, you will be able to understand how a user is progressing through their lifecycle of authenticating to a merchant. It emits a KnotEvent
class as described below.
KnotEvent.event
property.
Name | Description |
---|---|
REFRESH_SESSION_REQUEST | Emitted when the session used to initialize the SDK needs to be refreshed. |
MERCHANT_CLICKED | Emitted when a user clicks on a merchant from the merchant list. |
LOGIN_STARTED | Emitted when a user submits their credentials to login to the merchant. |
AUTHENTICATED | Emitted when a user successfully logs in to the merchant. |
OTP_REQUIRED | Emitted when a user needs to enter an OTP code to login to the merchant. |
SECURITY_QUESTIONS_REQUIRED | Emitted when a user needs to enter answers to security questions to login to the merchant. |
APPROVAL_REQUIRED | Emitted when a user needs to approve the login - often via a push notification or directly in the merchant’s mobile app - to login to the merchant. |
ZIPCODE_REQUIRED | Emitted when a user needs to enter their zip code to login to the merchant. |
LICENSE_REQUIRED | Emitted when a user needs to enter their drivers license to login to the merchant. |
Other Options
Get current SDK version
If you need to retrieve the current SDK version for your own use case, implement the following:Close the SDK
If you need to explicitly close the SDK, use the below method, otherwise end users will naturally close the SDK as they interact with the interface.Maintain cookies
Knot clears cookies for security purposes. If your app relies on cookies, you can allowlist specific domains using thedomainUrls
configuration in KnotConfiguration
. This is uncommon.