Prerequisites
Before you begin, ensure you have:- A Straddle account with API access
- A Plaid account with API access
Implementation Steps
1. Set up Plaid Link for user bank account connection
1. Set up Plaid Link for user bank account connection
Integrate Plaid Link into your frontend to allow users to securely connect their bank account. Plaid Link is the front-end module that facilitates the connection between the user’s bank account and your application.
2. Obtain an access token from Plaid
2. Obtain an access token from Plaid
Once the user connects their bank account using Plaid Link, Plaid will return a public token. Exchange this public token for an access token via Plaid’s API, which will allow you to access the user’s account information.
3. Use the access token to get a Straddle processor token from Plaid
3. Use the access token to get a Straddle processor token from Plaid
With the access token obtained from Plaid, request a Straddle processor token from Plaid. This token allows you to link the user’s bank account to Straddle’s payment processing system.
4. Use the Straddle processor token to create a paykey via Straddle's Bridge API
4. Use the Straddle processor token to create a paykey via Straddle's Bridge API
Pass the Straddle processor token to Straddle’s Bridge API. Straddle will return a
paykey which is linked to the user’s bank account, allowing future transactions to be processed.5. Store and use the paykey for future transactions
5. Store and use the paykey for future transactions
Store the
paykey securely in your system. Use this paykey to create charges, initiate payments, or perform other transactions via Straddle’s API in the future.Setting Up Plaid
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 /link/token/create documentation for a full list of link_token configurations.
To see your client_id and secret, visit the Plaid Dashboard.
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 Straddle processor_token.
Obtaining a Straddle Processor Token from Plaid
Once you have the access token, you can use it to obtain a Straddle processor token. This token is specific to Straddle and allows secure communication between Plaid and Straddle.'straddle' is the specific processor you’re requesting the token for. This tells Plaid to generate a token compatible with Straddle’s systems.
Using the Straddle Bridge API with Plaid Token
Once you have obtained the Straddle processor token from Plaid, you can use it to create a paykey via Straddle’s Bridge API. Here’s the correct HTTP request format:Bridge a Plaid Token
YOUR_STRADDLE_API_KEY with your actual Straddle API key, and fill in the appropriate values for customer_id and plaid_token. The metadata field is optional but can be useful for storing additional information related to the Plaid account.
Handling the Straddle API Response
The Straddle API will respond with a paykey object. Here’s an example of what you might receive:source field is set to “plaid” in this case, indicating that the paykey was created using a Plaid token.
You should store this paykey securely for future use in transactions.
Best Practices and Security Considerations
- Token Security: Never expose Plaid access tokens or Straddle processor tokens to the frontend. Always handle these server-side.
- Error Handling: Implement robust error handling for both Plaid and Straddle API calls.
- Metadata Usage: Use the metadata field to store relevant information, such as the Plaid account ID, for future reference.
- Token Refreshing: Be aware of token expiration policies for both Plaid and Straddle. Implement token refresh mechanisms as needed.
- Compliance: Ensure you’re complying with both Plaid and Straddle’s terms of service and data handling requirements.
- Logging: Implement comprehensive logging for debugging and audit purposes, but be careful not to log sensitive information.
Troubleshooting Common Issues
- Invalid Processor Token: Ensure you’re using ‘straddle’ as the processor when requesting the token from Plaid.
- Authentication Errors: Double-check your API keys for both Plaid and Straddle.
- Expired Tokens: If you’re getting authentication errors, your tokens might have expired. Implement a token refresh mechanism.
- Account Not Supported: Some bank accounts may not be supported for ACH transactions. Handle these cases gracefully in your UI.
- Rate Limiting: Be aware of rate limits on both Plaid and Straddle APIs. Implement appropriate backoff strategies if you hit these limits.