dpods / plaid-api-php-client
PHP API Client for Plaid.com
Installs: 20 070
Dependents: 1
Suggesters: 0
Security: 0
Stars: 14
Watchers: 1
Forks: 10
Open Issues: 1
Requires
- php: >=5.3.0
This package is not auto-updated.
Last update: 2020-02-12 06:33:32 UTC
README
PHP Client for the plaid.com API
This is a PHP port of the official python client library for the Plaid API
Table of Contents
Install
$ composer require dpods/plaid-api-php-client
Documentation
The module supports only a select few Plaid API endpoints at the moment. For complete information about the Plaid.com API, head to the Plaid Documentation.
Examples
Exchange a public token for an access token
Exchange a public_token
from Plaid Link for a Plaid access token:
$clientId = '*****'; $secret = '*****'; $publicKey = '*****'; $publicToken = '<public_token from Plaid Link>'; // Available environments are 'sandbox', 'development', and 'production' $client = new Client($clientId, $secret, $publicKey, 'sandbox'); $response = $client->item()->publicToken()->exchange($publicToken); $accessToken = $response['access_token'];
Retrieve Transactions
$response = $client->transactions()->get($accessToken, '2018-01-01', '2018-01-31'); $transactions = $response['transactions'];
Asset Reports
There are multiple steps to retrieving an Asset Report.
- Create the report
- Filter unwanted accounts out of report
- Retrieve the report as JSON or PDF
- Refresh a previously created or filtered report
- Remove a report
Create an Asset Report
// an array of previously generated access_tokens $accessTokens = ['<access_token(s) returned from exchange token call(s)>']; $daysRequested = 180; // all of these are optional $options = [ 'client_report_id' => '<user supplied id for reference', 'webhook' => 'https://your-application.io/webhook', 'user' => [ 'client_user_id' => '<user supplied id>', 'first_name' => 'Testynthia', 'middle_name' => 'T.', 'last_name' => 'Tertestdez', 'ssn' => '123-45-6789', 'phone_number' => '555-555-1234', 'email' => 'test@test.com' ] ]; $response = $this->client->assetReport()->create($accessTokens, $daysRequested, $options);
Create Asset Report Response
{ "asset_report_id": "<asset_report guid>", "asset_report_token": "<assets-sandbox-guid>", "request_id": "<request_id>" }
Filter an Asset Report
$assetReportToken = '<returned in asset report creation call>'; $accountIdsToExclude = ['<credit_card_id>', '<401k_account_id>']; $response = $this->client->assetReport()->filter($assetReportToken, $accountIdsToExclude);
Filter Asset Report Repsonse
{ "asset_report_id": "<asset_report guid>", "asset_report_token": "<assets-sandbox-guid>", "request_id": "<request_id>" }
Retrieve an Asset Report
// retrieve the report in JSON format $response = $this->client->assetReport()->get($accessReportToken); // retrieve the report in PDF format $response = $this->client->assetReport()->getPdf($accessReportToken); file_put_contents('asset-report.pdf', $response);
Retrieve Asset Report Response
The JSON results of an asset report can be reviewed in plaid's documentation.
The /asset_report/pdf/get endpoint returns binary PDF data, which can be saved into a local file.
Refresh an Asset Report
// $daysRequested is optional and only needed if you want to override the value sent when report was created // $options is optional, only required for overrides to previous values $response = $this->client->assetReport()->refresh($assetReportToken, $daysRequested, $options);
Refresh Asset Report Response
{ "asset_report_id": "<asset_report guid>", "asset_report_token": "<assets-sandbox-guid>", "request_id": "<request_id>" }
Remove an Asset Report
$response = $this->client->assetReport()->remove($assetReportToken);
Remove Asset Report Response
{ "removed": true, "request_id": "<request_id>" }