Giter Club home page Giter Club logo

plaid-api-php-client's Introduction

plaid-api-php-client

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' => '[email protected]'
  ]
];
$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

plaid-api-php-client's People

Contributors

tcshields avatar pepsikus avatar gborcherds avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.