eliosfund / plaid-php-sdk
Plaid SDK for Laravel and PHP.
Installs: 3 770
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 0
Forks: 0
Open Issues: 0
Requires
- php: ^8.2
- illuminate/support: ^10.0|^11.0|^12.0
- saloonphp/saloon: ^3.10.1
Requires (Dev)
- laravel/pint: ^1.19
- mockery/mockery: ^1.6.12
- pestphp/pest: ^2.36
- pestphp/pest-plugin-arch: ^2.7
- pestphp/pest-plugin-type-coverage: ^2.8.7
- phpstan/phpstan: ^1.12.13
This package is auto-updated.
Last update: 2025-06-15 22:10:59 UTC
README
A PHP package to help kickstart your next Plaid integration.
Introduction
The Plaid PHP SDK is a PHP package that provides a simple and easy-to-use interface for interacting with the Plaid API.
Table of Contents
Installation
You can install the package using Composer:
composer require eliosfund/plaid-php-sdk
Getting Started
To get started, a new instance of the Plaid
client should be created. You can then use the instance to interact with the Plaid API. In the following example, we request a public link token that can then be used to initialize a Link
session.
<?php use Plaid\Environment; use Plaid\Plaid; // Create the Plaid client $plaid = new Plaid( clientId: env('PLAID_CLIENT_ID'), clientSecret: env('PLAID_SECRET'), environment: Environment::SANDBOX ); // Request a public link token $token = $plaid ->link() ->publicTokenCreate([ "client_name" => env('APP_NAME'), "products" => ["auth"], "country_codes" => ["US"], "language" => "en", "user" => [ "client_user_id" => "1" ] ]) ->json('link_token');
Versioning
A specific Plaid API version can be used by adding a Plaid-Version
header to the request. The following example demonstrates how to request a specific version of the Auth
endpoint.
<?php use Plaid\Environment; use Plaid\Exceptions\PlaidException; use Plaid\Http\Requests\Auth\GetRequest; use Plaid\Plaid; // Create the Plaid client $plaid = new Plaid( clientId: env('PLAID_CLIENT_ID'), clientSecret: env('PLAID_SECRET'), accessToken: $accessToken, environment: Environment::SANDBOX ); // Create a request $request = new GetRequest(); $request->headers()->add('Plaid-Version', '2020-09-14'); // Send the request $data = $plaid->send($request)->json();
Error Handling
The Plaid PHP SDK throws exceptions when an API error occurs. You can catch these exceptions and handle them accordingly with a standard try/catch
block. All errors thrown by the SDK extend the PlaidException
class. For a more elegant approach to error handling, consider using the promise-based approach.
<?php use Plaid\Environment; use Plaid\Exceptions\PlaidException; use Plaid\Plaid; // Create the Plaid client $plaid = new Plaid( clientId: env('PLAID_CLIENT_ID'), clientSecret: env('PLAID_SECRET'), environment: Environment::SANDBOX ); // Perform a request try { $transactions = $plaid->transactions([ 'start_date' => '2021-01-01', 'end_date' => '2021-01-31' ])->get()->json(); } catch (PlaidException $exception) { // Handle API exceptions } catch (Exception $e) { // Handle PHP exceptions }
Promise Support
The Plaid PHP SDK can send asynchronous requests using a promise-based approach. This allows you to handle both successful and failed requests in a more elegant way.
<?php use Plaid\Environment; use Plaid\Http\Requests\Auth\GetRequest; use Plaid\Plaid; use Saloon\Exceptions\Request\RequestException; use Saloon\Http\Response; // Create the Plaid client $plaid = new Plaid( clientId: env('PLAID_CLIENT_ID'), clientSecret: env('PLAID_SECRET'), accessToken: $accessToken, environment: Environment::SANDBOX ); // Create a promise $promise = $plaid->sendAsync(new GetRequest()); // Send the request $promise ->then(function (Response $response) { // Handle successful response }) ->otherwise(function (RequestException $exception) { // Handle failed request }); // Force the promise to be resolved $promise->wait();
Products Supported
Currently, the following Plaid products are supported:
- Auth
- Identity
- Link
- Sandbox
- Transactions
- Transfer
Contributing
Please see here for more details about contributing.