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
1Plaid.initialize(this)
Is no longer part of the API and can be removed.
Opening Link
Creating Configuration
2.x.x | 3.x.x |
---|---|
com.plaid.link.configuration.LinkConfiguration | com.plaid.link.configuration.LinkPublicKeyConfiguration |
LinkPublicKeyConfiguration .paymentToken | Use the LinkPublicKeyConfiguration .token field instead |
com.plaid.link.configuration.AccountSubtype | com.plaid.link.result.LinkAccountSubtype |
com.plaid.link.configuration.AccountType | com.plaid.link.result.LinkAccountType |
PlaidEnvironment | deprecated |
PlaidProduct | deprecated |
1val linkTokenConfiguration = linkTokenConfiguration {2 token = "LINK_TOKEN_FROM_SERVER"3 logLevel = if (BuildConfig.DEBUG) LinkLogLevel.VERBOSE else LinkLogLevel.ERROR4}
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.
1val 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
.
1Plaid.openLink(activity, configuration)
1this@MyActivity.openPlaidLink(configuration)
1this@MyFragment.openPlaidLink(configuration)
Instead you will need to call open
on the PlaidHandler
you created, passing in
an Activity
or Fragment
.
1plaidHandler.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 fromString
tocom.plaid.link.result.LinkAccountSubtype
accountType
has been removed, it is now acom.plaid.link.result.LinkAccountType
object withinLinkAccountSubtype
1private val linkResultHandler = LinkResultHandler(2 // ...3 onSuccess = { it: LinkSuccess ->4 // Send public_token to your server, exchange for access_token5 val publicToken = it.publicToken6 val metadata = it.metadata7 metadata.accounts.forEach { account ->8 val accountId = account.id9 val accountName = account.name10 val accountMask = account.mask11 val accountSubType = account.subtype12 }13 val institutionId = metadata.institution?.id14 val institutionName = metadata.institution?.name15 }16)
LinkError
errorCode
has been typed as anErrorCode
objecterrorType
has been removed fromLinkError
and added to theErrorCode
objecterrorJson
field has been added with raw JSON from server
LinkExitMetadata
institutionId
andinstitutionName
moved intoinstitution
which is aLinkInstitution
and renamed toid
andname
objectexitStatus
removedmetadataJson
field has been added with raw JSON from server
1private val linkResultHandler = LinkResultHandler(2 // ...3 onExit = {4 val error = it.error5 error?.let { error ->6 val errorCode = error.errorCode7 val errorType = error.errorCode.errorType8 val errorMessage = error.errorMessage9 val displayMessage = error.displayMessage10 }11 val metadata = it.metadata12 val institutionId = metadata.institution?.id13 val institutionName = metadata.institution?.name14 val linkSessionId = metadata.linkSessionId;15 val requestId = metadata.requestId;16 }17)
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