Skip to main content

Android SDK


Integration

The Android SDK can be added either via Maven package management or downloaded directly and added manually as an AAR bundle.

build.gradle
implementation 'money.link:linkaccount:1.+'

Example

Create an instance of the LinkAccountDialog class using the LinkAccountDialog.create method passing along the sessionKey and environment arguments. The SDK provides two environments, LinkEnvironment.SANDBOX and LinkEnvironment.PRODUCTION (default). To display the created LinkAccountDialog instance the display method needs to be called passing along a supportFragmentManager.

Example
1import money.link.linkaccount.*
2
3val dialog = LinkAccountDialog(sessionKey, LinkEnvironment.PRODUCTION)
4dialog.display(supportFragmentManager)

After the LinkAccountDialog has finished, the result can be received using Android-recommended fragment communication options, a shared ViewModel or the Fragment Result API. For both options, the returned result will be of type LinkAccountResult, a type alias of a Kotlin Result type. On success, the value is a customer id of type LinkCustomerId. On failure, the value is an error of type LinkError. To receive the result using a shared ViewModel, a global instance of the LinkAccountResultViewModel has to be initialized using Android’s viewModels lazy delegate and observe the linkAccountResult before displaying the LinkAccountDialog.

Notice: The results of the LinkAccountDialog will be emitted only once and to only one observer.

Example
1import androidx.appcompat.app.AppCompatActivity
2import androidx activity.viewModels
3import money.link.linkaccount.*
4
5class MainActivity : AppCompatActivity() {
6
7	val viewModel: LinkAccountResultViewModel by viewModels()
8
9	override fun onCreate(savedInstanceState: Bundle?) {
10		super.onCreate(savedInstanceState)
11		viewModel.linkAccountResult.observe(this){ result ->
12			result.onSuccess { customerId ->
13				print("Customer ID is $customerId")
14			}
15
16			result.onFailure { error ->
17				print(error)
18			}
19		}
20	}
21}

To receive the result using the Fragment Result API a result listener needs to be set in the Activity or Fragment that receives the result. To set the result listener the setFragmentResultListener() has to be called from the receiver’s supportFragmentManager using the LINK_ACCOUNT_REQUEST_KEY. The result returned in the response bundle can be retrieved with the LINK_ACCOUNT_RESULT_KEY.

Example
1import androidx.appcompat.app.AppCompatActivity
2import androidx.fragment.app.FragmentResultListener
3import money.link.linkaccount.*
4
5class MainActivity : AppCompatActivity() {
6	override fun onCreate(savedInstanceState: Bundle?) {
7		super.onCreate(savedInstanceState)
8		supportFragmentManager.setFragmentResultListener(
9			LinkAccountDialog.LINK_ACCOUNT_REQUEST_KEY,
10			this,
11			FragmentResultListener { _, bundle ->
12				val serializedResult = bundle.getSerializable(LinkAccountDialog.LINK_ACCOUNT_RESULT_KEY)
13				(serializedResult as? LinkAccountResult)?.let { result ->
14					result.onSuccess { customerId ->
15						print("Customer ID is $customerId")
16					}
17
18					result.onFailure { error ->
19						print(error)
20					}
21				}
22			}
23		)
24	}
25}

Package

The money.link.linkaccount package contains everything necessary to kick off the linking flow and debug issues resulting from failed linking attempts.

Members

LinkAccountDialog

This class is the entry point to linking bank accounts. To begin initiating bank account linking, you create a LinkAccountDialog instance and then call the display function.

  • sessionKey

    string

    Your session key

  • environment

    LinkEnvironment

    Link environment

Methods

  • create

    (SessionKey, LinkEnvironment)

    Creates a new Link Account Dialog instance

  • Kicks off the linking flow

LinkError

  • statusCode

    int *OPTIONAL

    Error code

  • message

    string

    Error message

LinkEnvironment

  • production

    enum

    Enum type pointing to production

  • sandbox

    enum

    Enum type pointing to sandbox

LinkAccountResultViewModel

  • linkAccountResult

    LiveData<LinkAccountResult>

    Live data object that can be observed for results

LinkAccountResult

  • onSuccess

    string

    String value representing the customer ID

  • onFailure

    LinkError

    Encapsulates errors returned from account linking

LinkService

This class provides methods to retrieve customer info and lists of authorized accounts.
  • accessToken

    string

    Your access token

  • environment

    LinkEnvironment

    Link environment

Example

Create an instance of the LinkService class passing along the accessToken and environment arguments. Each method takes a customerId and a completion handler which returns a Kotlin Result type.

Example
1import money.link.linkaccount.LinkService
2
3val service = LinkService(accesstoken, LinkEnvironment.PRODUCTION)
4service.getCustomer(customerId) {
5	it.onSuccess {
6		print("Customer: ${it.firstName} ${it.lastName}")
7	}
8}

Methods

  • getCustomer

    (customerId: string, complete: (Result<

    LinkCustomer>) -> Unit)

    Retrieves customer info

  • getAccounts

    (customerId: string, complete: (Result<List<

    LinkAccount>>) -> Unit)

    Retrieves a list of authorized accounts

LinkCustomer

  • id

    string

    Customer ID

  • firstName

    string

    Customer’s first name

  • lastName

    string

    Customer’s last name

  • email

    string

    Customer’s email

  • status

    enum

    ACTIVE or CREATED

  • creationDate

    Date

    Account creation date

LinkAccount

  • accountId

    int

    Account ID

  • financialInstitutionId

    int

    Financial institution ID

  • financialInstitutionName

    string

    Financial Institution name

  • logoUrl

    URL | null

    URL for a financial institution’s logo, when available

  • lastFour

    string

    Last four digits of a bank account number

  • type

    enum

    CHECKING or SAVINGS

  • status

    enum

    ACTIVE or INACTIVE or ABANDON or CREATED

  • creationDate

    Date

    Account creation date