Linking external accounts SDK

How to use the Bond external accounts SDK to link a card account to an external account.

Overview

The linking external accounts SDK provided by Bond allows you to create an application that acts as a building block for your software solution when you need to interact with a customer's external account. For example, without having to write the code yourself, you can use the SDK to:

  • Link to an external account.
  • Make micro-deposits to verify the account.

The accounts API allows you to link a customer's Bond card to their verified external bank account. The customer can then transfer funds back and forth between their card account and the linked external account. Once the link is established, we use the linked_account_id identifier to represent the customer's external account.

The linking external account SDK provided by Bond is a JavaScript wrapper that uses Promises which makes it easy for you to handle the asynchronous, external account requests made to our API. See the full documentation here.

The SDK provides a BondExternalAccounts class that contains several methods that map to the calls and parameters described in the Linking accounts API documentation.

Getting the SDK

Using npm you can get the SDK with

npm install --save bond-sdk-web

or via our CDN.

Using the SDK

Listed below are some examples of how to use the SDK for external accounts.

Import script example

The following "import-scripts" code is a generic example of how you can use the SDK and initialize BondAccountConnection.
Vanilla Javascript:

  import sdk from 'https://cdn.skypack.dev/bond-sdk-web';
  const bondExternalAccounts = new sdk.BondExternalAccounts({live: false});

or using node.js:

import { BondExternalAccounts } from 'bond-sdk-web';
const bondExternalAccounts = new BondExternalAccounts({ live: false });

passing { live: true } if using the live environment.

Linking an external account

The following code is an example of using the SDK to link an external account for a customer or business. This can be done via OAuth with a two-step process. Please note that implementing an OAuth flow requires pre-registering a redirectUri with the Bond Support team and requires localStorage access within the user's browser. Initialize the OAuth flow in your app with:

bondExternalAccounts
  .linkAccount({
    customerId: "CUSTOMER_ID", // or businessId: "BUSINESS_ID"
    identity: "TEMP_IDENTITY_TOKEN",
    authorization: "TEMP_AUTH_TOKEN",
    redirectUri: "REDIRECT_URI",
  })
  .then(data => {
    // code...
  })
  .catch(error => {
    // code...
  });

Once the OAuth flow is initiated, the user will be navigated to the institution's website to continue the verification process. Upon completion, the user will be redirected back to the configured redirectUri. From this page, the SDK is re-initialized to finalize the account linking process:

bondExternalAccounts
  .handleOAuthRedirect({
    identity: "TEMP_IDENTITY_TOKEN",
    authorization: "TEMP_AUTH_TOKEN",
  });

Alternatively, a non-OAuth account linking flow can be initiated in one step with:

bondExternalAccounts
  .linkAccount({
    customerId: "CUSTOMER_ID", // or businessId: BUSINESS_ID
    identity: "TEMP_IDENTITY_TOKEN",
    authorization: "TEMP_AUTH_TOKEN",
  });

For details, see Linking external accounts.

Making micro deposits

The following code is an example of using the SDK to make micro deposits.

bondExternalAccounts
  .microDeposit({
    linkedAccountId: "LINKED_ACCOUNT_ID",
    identity: "TEMP_IDENTITY_TOKEN",
    authorization: "TEMP_AUTH_TOKEN",
  })
  .then(data => {
    // code...
  })
  .catch(error => {
    // code...
  });

Deleting linked external accounts

The following code is an example of using the SDK to delete linked external accounts.

bondExternalAccounts
  .deleteExternalAccount({
    accountId: "LINKED_ACCOUNT_ID",
    identity: "TEMP_IDENTITY_TOKEN",
    authorization: "TEMP_AUTH_TOKEN",
  })
  .then(data => {
    // code...
  })
  .catch(error => {
    // code...
  });

More information

For a complete specification and interactive examples, see Linking external accounts in the Bond API Reference.