dpods/plaid-api-php-client

This package is abandoned and no longer maintained. No replacement package was suggested.

PHP API Client for Plaid.com

0.5.0 2019-04-16 03:24 UTC

This package is not auto-updated.

Last update: 2020-02-12 06:33:32 UTC


README

GitHub release GitHub license

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.

  1. Create the report
  2. Filter unwanted accounts out of report
  3. Retrieve the report as JSON or PDF
  4. Refresh a previously created or filtered report
  5. 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>"
}

License

MIT