2.x to 3.x Migration Guide

Reference for migrating the Link Android SDK from 2.x to 3.x

Summary of changes

Plaid released the Android 3.0.0 SDK on September 20th, 2020. Upgrading to the new 3.x SDK allows you to take advantage of a unified mobile API and support all new features. This article provides a guide on how to upgrade a Plaid integration from the Android 2.x SDK to the 3.x SDK.

Remove initialize

1
Plaid.initialize(this)

Is no longer part of the API and can be removed.

Opening Link

Creating Configuration
2.x.x3.x.x
com.plaid.link.configuration.LinkConfigurationcom.plaid.link.configuration.LinkPublicKeyConfiguration
LinkPublicKeyConfiguration.paymentTokenUse the LinkPublicKeyConfiguration.token field instead
com.plaid.link.configuration.AccountSubtypecom.plaid.link.result.LinkAccountSubtype
com.plaid.link.configuration.AccountTypecom.plaid.link.result.LinkAccountType
PlaidEnvironmentdeprecated
PlaidProductdeprecated
1
2
3
4
val linkTokenConfiguration = linkTokenConfiguration {
token = "LINK_TOKEN_FROM_SERVER"
logLevel = if (BuildConfig.DEBUG) LinkLogLevel.VERBOSE else LinkLogLevel.ERROR
}
PlaidHandler

Create a PlaidHandler - A PlaidHandler is a one-time use object used to open a Link session. It should be created as early as possible, since it must be completed before Link opens, and if delayed until just before Link opening it can have a perceptible impact on Link startup time.

1
val plaidHandler: PlaidHandler = Plaid.create(application, linkTokenConfiguration)
Opening Link

We've removed the openLink functions on the Plaid object as well as the Kotlin extension functions for Activity and Fragment.

1
Plaid.openLink(activity, configuration)
1
this@MyActivity.openPlaidLink(configuration)
1
this@MyFragment.openPlaidLink(configuration)

Instead you will need to call open on the PlaidHandler you created, passing in an Activity or Fragment.

1
plaidHandler.open(activity)

Handling Results

LinkResultHandler

com.plaid.link.result.PlaidLinkResultHandler has been renamed to com.plaid.link.result.LinkResultHandler

LinkSuccessMetadata

LinkSuccessMetadata.rawMetadata renamed to LinkSuccessMetadata.metadata

LinkAccount

Fields renamed

  • accountId -> id
  • accountName -> name
  • accountNumber -> mask
  • accountSubtype -> subtype also type changed from String to com.plaid.link.result.LinkAccountSubtype
  • accountType has been removed, it is now a com.plaid.link.result.LinkAccountType object within LinkAccountSubtype
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
private val linkResultHandler = LinkResultHandler(
// ...
onSuccess = { it: LinkSuccess ->
// Send public_token to your server, exchange for access_token
val publicToken = it.publicToken
val metadata = it.metadata
metadata.accounts.forEach { account ->
val accountId = account.id
val accountName = account.name
val accountMask = account.mask
val accountSubType = account.subtype
}
val institutionId = metadata.institution?.id
val institutionName = metadata.institution?.name
}
)
LinkError
  • errorCode has been typed as an ErrorCode object
  • errorType has been removed from LinkError and added to the ErrorCode object
  • errorJson field has been added with raw JSON from server
LinkExitMetadata
  • institutionId and institutionName moved into institution which is a LinkInstitution and renamed to id and name object
  • exitStatus removed
  • metadataJson field has been added with raw JSON from server
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
private val linkResultHandler = LinkResultHandler(
// ...
onExit = {
val error = it.error
error?.let { error ->
val errorCode = error.errorCode
val errorType = error.errorCode.errorType
val errorMessage = error.errorMessage
val displayMessage = error.displayMessage
}
val metadata = it.metadata
val institutionId = metadata.institution?.id
val institutionName = metadata.institution?.hame
val linkSessionId = metadata.linkSessionId;
val requestId = metadata.requestId;
}
)

Handling Events

LinkEventMetadata metadataJson added with raw JSON from server

Exceptions

All exceptions moved from com.plaid.link.internal.exceptions to com.plaid.link.exceptions