Add Stripe to your app

Use Stripe with Plaid Auth to send and receive payments


Plaid and Stripe have partnered to offer frictionless money transfers without the need to ever handle an account or routing number. Use Plaid Link to instantly authenticate your customer's account and automatically generate a Stripe bank account token so that you can accept ACH payments via their ACH API.

This guide is designed for those who already have a ACH-enabled account at both Stripe and Plaid. If that's not you, head over to the Stripe ACH docs to get started. You'll be able to sign up for a Plaid account from there.

Getting Started

You'll first want to familiarize yourself with Plaid Link, a drop-in client-side integration for the Plaid API that handles input validation, error handling, and multi-factor authentication.

Your customers will use Link to authenticate with their financial institution and select the depository account they wish to use for ACH transactions. From there, you'll receive a Plaid access_token, allowing you to leverage real-time balance checks and transaction data, and a Stripe bank_account_token, which allows you to move money via Stripe's ACH API without ever handling an account or routing number.

Instructions

Set up your Plaid and Stripe accounts

You'll need accounts at both Plaid and Stripe in order to use the Plaid Link + Stripe integration. You'll also need to connect your Plaid and Stripe accounts so that Plaid can facilitate the creation of bank account tokens on your behalf.

First, sign up for a Stripe account if you do not already have one and then verify that it is enabled for ACH access. To verify that your Stripe account is ACH enabled, head to the ACH Guide when you are logged in to your Stripe account. If you see:

Stripe ACH Guide

your account is not enabled. Click 'Accept Terms of Service' to enable your Stripe account for ACH. If you do not see the 'Accept Terms of Service' button, your Stripe account is already enabled for ACH access and you do not need to take any action.

Next, verify that your Plaid account is enabled for the integration. If you do not have a Plaid account, create one. Your account will be automatically enabled for integration access.

To verify that your Plaid account is enabled for the integration, go to the Integrations section of the account dashboard. If you see:

Unlinked Stripe account

your Plaid account is enabled for the integration but you have not connected your Stripe account.

Click the 'Connect With Stripe' button to connect your Plaid and Stripe accounts. This step is required so that Plaid can facilitate the creation of Stripe bank account tokens on your behalf.

Once your Stripe account is connected, you'll see:

linked Stripe account

Your Plaid account is now set up for the integration!

Create a link_token

In order to integrate with Plaid Link, you will first need to create a link_token. A link_token is a short-lived, one-time use token that is used to authenticate your app with Link. To create one, make a /link/token/create request with your client_id, secret, and a few other required parameters from your app server. View the documentation for a full list of link_token configurations.

To see your client_id and secret, visit the Plaid Dashboard.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
// Using Express
const express = require('express');
const app = express();
app.use(express.json());
const plaid = require('plaid');
const client = new plaid.Client({
clientID: process.env.PLAID_CLIENT_ID,
secret: process.env.PLAID_SECRET,
env: plaid.environments.sandbox,
});
app.post('/create_link_token', async (request, response) => {
try {
// Get the client_user_id by searching for the current user
const user = await User.find(...);
const clientUserId = user.id;
// Create the link_token with all of your configurations
const tokenResponse = await client.createLinkToken({
user: {
client_user_id: clientUserId,
},
client_name: 'My App',
products: ['auth'],
country_codes: ['US'],
language: 'en',
webhook: 'https://webhook.sample.com',
});
response.on({ link_token: tokenResponse.link_token });
} catch (e) {
// Display error on client
return response.send({ error: e.message });
}
});
Integrate with Plaid Link

Once you have a link_token, all it takes is a few lines of client-side JavaScript to launch Link. Then, in the onSuccess callback, you can call a simple server-side handler to exchange the Link public_token for a Plaid access_token and a Stripe bank account token.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
<button id="linkButton">Open Link - Institution Select</button>
<script src="https://cdn.plaid.com/link/v2/stable/link-initialize.js"></script>
<script>
(async function(){
var linkHandler = Plaid.create({
// Make a request to your server to fetch a new link_token.
token: (await $.post('/create_link_token')).link_token,
onLoad: function() {
// The Link module finished loading.
},
onSuccess: function(public_token, metadata) {
// The onSuccess function is called when the user has
// successfully authenticated and selected an account to
// use.
//
// When called, you will send the public_token
// and the selected account ID, metadata.account_id,
// to your backend app server.
//
// sendDataToBackendServer({
// public_token: public_token,
// account_id: metadata.account_id
// });
console.log('Public Token: ' + public_token);
console.log('Customer-selected account ID: ' + metadata.account_id);
},
onExit: function(err, metadata) {
// The user exited the Link flow.
if (err != null) {
// The user encountered a Plaid API error
// prior to exiting.
}
// metadata contains information about the institution
// that the user selected and the most recent
// API request IDs.
// Storing this information can be helpful for support.
},
});
})();
// Trigger the authentication view
document.getElementById('linkButton').onclick = function() {
linkHandler.open();
};
</script>

See the Link parameter reference for complete documentation on possible configurations.

Plaid.create accepts one argument, a configuration Object, and returns an Object with three functions, open, exit, and destroy. Calling open will display the "Institution Select" view, calling exit will close Link, and calling destroy will clean up the iframe.

Write server-side handler

The Link module handles the entire onboarding flow securely and quickly, but does not actually retrieve account data for a user. Instead, the 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 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. In order to avoid any confusion about which account your user wishes to use with Stripe, it is recommended to 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 element.

Once you have identified the account you will use, you will send Plaid the account_id property of the account along with the access_token you obtained from /item/public_token/exchange. Plaid will automatically create and return a Stripe bank account token for this account, which can then be used to move money via Stripe's ACH API. The bank account token will be linked to the Stripe account you linked in your Plaid Dashboard.

Note that the Stripe bank account token is a one-time use token. To store bank account information for later use, you can use a Stripe customer object and create an associated bank account from the token, or you can use a Stripe Custom account and create an associated external bank account from the token. The Plaid access_token, on the other hand, does not expire and should be persisted securely.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
// 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 client = new plaid.Client({
clientID: process.env.PLAID_CLIENT_ID,
secret: process.env.PLAID_SECRET,
environment: plaid.environments.sandbox,
});
const exchangePublicTokenResponse = await client.exchangePublicToken(
'[Plaid Link public token]',
);
const accessToken = exchangePublicTokenResponse.access_token;
// Generate a bank account token
const stripeTokenResponse = await client.createStripeToken(
accessToken,
'[Account ID]',
);
const bankAccountToken = stripeTokenResponse.stripe_bank_account_token;

For a valid request, the API will return a JSON response similar to:

1
2
3
4
{
"stripe_bank_account_token": "btok_5oEetfLzPklE1fwJZ7SG",
"request_id": "[Unique request ID]"
}

For possible error codes, see the full listing of Plaid error codes.

Note: The account_id parameter is required if you wish to receive a Stripe bank account token.

Test with Sandbox credentials

You can create Stripe bank account tokens in all three API environments:

Plaid's Sandbox API environment is compatible with Stripe's "test mode" API. To test the integration in Sandbox mode, simply use the Plaid Sandbox credentials when launching Link with a link_token created in the Sandbox environment. The Stripe bank account token created in the Sandbox environment will always match the Stripe bank test account with account number 000123456789 and routing number 110000000, and with the Stripe account that is linked in the Plaid developer dashboard.

Use Stripe's ACH API in test mode to create test transfers using the bank account tokens you retrieve from Plaid's Sandbox API environment.

When testing in the Sandbox, you have the option to use the /sandbox/public_token/create endpoint instead of the end-to-end Link flow to create a public_token. When using the /sandbox/public_token/create-based flow, the Select Account flow will be bypassed and the accounts array will not be populated. On Sandbox, instead of using the accounts array, you can call /accounts/get and test with any returned account ID associated with an account with the subtype checking or savings.

Get ready for production

Your account is immediately enabled for our Sandbox and Development environments (https://sandbox.plaid.com and https://development.plaid.com), which allows you to test with Sandbox API credentials and up to 100 live users. To move to Production, please request access from the Dashboard.

Next steps

Once you're successfully retrieving Stripe bank_account_tokens, you're ready to make ACH transactions with Stripe. Head to Stripe's ACH guide to get started, and if you have any issues, please reach out to Stripe Support.

Troubleshooting

Stripe bank account token not returned

When a stripe_bank_account_token is not returned, a typical cause is that your Stripe and Plaid accounts have not yet been linked. First, be sure that your Stripe account has been configured to accept ACH transfers. Then, link your Stripe account to your Plaid account and re-try your request.

Stripe::InvalidRequestError: No such token

The Stripe::InvalidRequestError: No such token error is returned by Stripe when a test mode bank_account_token is used in a live Stripe API call. To avoid this error, make sure you are not mixing Plaid's Sandbox environment with Stripe's production environment.

Support and questions

Find answers to many common integration questions and concerns, such as pricing, sandbox and test mode usage in our docs.

If you're still stuck, open a support ticket with information describing the issue that you're experiencing and we'll get back to you as soon as we can.