Use Plaid Auth

Documentation | Checkbook
1084

📘

Plaid documentation

Check out the Plaid official guide for more details on how to use Checkbook with Plaid.

Get a Plaid access_token

The Plaid Link module returns a public_token and an accounts array, which is a property on the metadata object, via the onSuccess callback. Exchange this public_token for a Plaid access_token using the /item/public_token/exchange Plaid API endpoint.

The accounts array will contain information about bank accounts associated with the credentials entered by the user, and may contain multiple accounts if the user has more than one bank account at the institution. If you want the user to specify only a single account to link so you know which account to use with Checkbook, set Select Account to "enabled for one account" in the Plaid Developer Dashboard. When this setting is selected, the accounts array will always contain exactly one account.

Create a Checkbook processor_token

Once you have identified the account you will use, you will send the access_token and account_id property of the account to Plaid via the /processor/token/create Plaid API endpoint in order to create a Checkbook processor_token.

You can create Checkbook processor_tokens in all three API environments:

# Change sandbox to development to test with live users and change
# to production when you're ready to go live!
client = Client(
    client_id=PLAID_CLIENT_ID,
    secret=PLAID_SECRET,
    environment='sandbox',
)
exchange_token_response = client.Item.public_token.exchange('[Plaid Link public_token]')
access_token = exchange_token_response['access_token']
# Create a processor token for a specific account id.
create_response = client.Processor.ProcessorTokenCreate(access_token, account_id, "checkbook")
processor_token = create_response['processor_token']
# Exchange token
curl -X POST https://sandbox.plaid.com/item/public_token/exchange \
  -H 'Content-Type: application/json' \
  -d '{
    "client_id": "[Plaid Client ID]",
    "secret": "[Plaid secret]",
    "public_token": "[Public token]"
  }'
# Create a processor token for a specific account id.
curl -X POST https://sandbox.plaid.com/processor/token/create \
  -H 'Content-Type: application/json' \
  -d '{
    "client_id": "PLAID_CLIENT_ID",
    "secret": "PLAID_SECRET",
    "access_token": "ACCESS_TOKEN",
    "account_id": "ACCOUNT_ID",
    "processor": "checkbook"
  }'
// Change sandbox to development to test with live users and change
// to production when you're ready to go live!
const plaid = require('plaid');
const plaidClient = new plaid.Client({
  clientID: process.env.PLAID_CLIENT_ID,
  secret: process.env.PLAID_SECRET,
  env: plaid.environments.sandbox,
});
try {
  const exchangeTokenResponse = await plaidClient.exchangePublicToken(publicToken);
  const accessToken = exchangeTokenResponse.access_token;
  // Create a processor token for a specific account id.
  const processorTokenResponse = await plaidClient.createProcessorToken(accessToken, accountId, 'checkbook');
  const processorToken = processorTokenResponse.processor_token;
} catch (err) {
  // handle error
}

Add a bank account

Retrieve the bank account(s) associated with the Plaid token. Once you have the Checkbook processor_token, you can use it to securely retrieve account and routing numbers from Plaid. Just call the POST /v3/bank/iav/plaid endpoint with the processor_token.

After getting the bank accounts list you can add one of the bank accounts to Checkbook by following the instructions from the Instant Account Verification page.