Skip to content

Latest commit

 

History

History
221 lines (152 loc) · 8.06 KB

README.md

File metadata and controls

221 lines (152 loc) · 8.06 KB

Plaid SDK

Latest Stable Version Build Status Code Coverage License

Plaid PHP SDK supporting:

  • Link tokens
  • Auth
  • Items
  • Accounts
  • Institutions
  • Webhooks
  • Identity
  • Income
  • Assets
  • Balance
  • Liabilities
  • Investments
  • Payment Initiation (UK only)
  • Processors (Stripe & Dwolla)

Official Plaid API docs

For full description of request and response payloads and properties, please see the official Plaid API docs.

Requirements

  • PHP 7.2+
  • ext-curl
  • ext-json

Installation

composer require tomorrow-ideas/plaid-sdk-php

Configuration

Instantiate the Plaid client class with your credentials.

$client = new \TomorrowIdeas\Plaid\Plaid("your-client-id", "your-secret", "your-public-key");

Environments

The Plaid client by default uses the production Plaid API hostname for all API calls. You can change the environment by using the setEnvironment method.

Possible environments:

  • production
  • development
  • sandbox
$client->setEnvironment("sandbox");

API Versions

The Plaid client by default uses API version 2019-05-29. You can change the version by calling the setVersion method.

Possible API versions:

  • 2019-05-29
  • 2018-05-22
  • 2017-03-08
$client->setVersion("2019-05-29");

Options

Many methods allow the passing of options to the Plaid endpoint. These options should be an associative array of key/value pairs. The exact options supported are dependent on the endpoint being called. Please refer to the official Plaid documentation for more information.

$options = [
	"foo" => "bar",
	"baz" => "bat"
];

Example

use TomorrowIdeas\Plaid\Plaid;

require __DIR__ . "/vendor/autoload.php";

$plaid = new Plaid(
	\getenv("PLAID_CLIENT_ID"),
	\getenv("PLAID_CLIENT_SECRET"),
	\getevv("PLAID_PUBLIC_KEY")
);

$plaid->setEnvironment(
	\getenv("PLAID_ENVIRONMENT")
);

$item = $plaid->getItem("itm_1234");

Methods

For a full description of the response payload, please see the official Plaid API docs.

Link Tokens

createLinkToken(
	string $client_name,
	string $language,
	array $country_codes,
	string $client_user_id,
	array $products = [],
	?string $webhook = null,
	?string $link_customization_name = null,
	?AccountFilters $account_filters = null,
	?string $access_token = null,
	?string $redirect_url = null,
	?string $android_package_name = null,
	?string $payment_id = null): object

Auth

  • getAuth(string $access_token, array $options = []): object [?]

Liabilities

  • getLiabilities(string $access_token, array $options = []): object [?]

Items

  • getItem(string $access_token): object [?]
  • removeItem(string $access_token): object [?]
  • createPublicToken(string $access_token): object [?]
  • exchangeToken(string $public_token): object [?]
  • rotateAccessToken(string $access_token): object [?]

Webhooks

  • getWebhookVerificationKey(string $key_id): object [?]
  • updateWebhook(string $access_token, string $webhook): object [?]

Accounts

  • getAccounts(string $access_token): object [?]

Institutions

  • getInstitution(string $institution_id, array $options = []): object [?]
  • getInstitutions(int $count, int $offset, array $options = []): object [?]
  • findInstitution(string $query, array $products, array $options = []): object [?]

Transactions

  • getTransactions(string $access_token, DateTime $start_date, DateTime $end_date, array $options = []): object [?]

Balance

  • getBalance(string $access_token, array $options = []): object [?]

Identity

  • getIdentity(string $access_token): object [?]

Income

  • getIncome(string $access_token): object [?]

Assets

  • createAssetReport(array $access_tokens, int $days_requested, array $options = []): object [?]
  • refreshAssetReport(string $asset_report_token, int $days_requested, array $options = []): object [?]
  • filterAssetReport(string $asset_report_token, array $exclude_accounts): object [?]
  • getAssetReport(string $asset_report_token, bool $include_insights = false): object [?]
  • getAssetReportPdf(string $asset_report_token): ResponseInterface [?] Note: Because this endpoint returns PDF content in the repsponse body, this method returns an instance of a PSR-7 ResponseInterface. You may leverage the Response object to stream the PDF back to the requesting client and access response headers. See official Plaid API docs for more information.
  • removeAssetReport(string $asset_report_token): object [?]
  • createAssetReportAuditCopy(string $asset_report_token, string $auditor_id): object [?]
  • removeAssetReportAuditCopy(string $audit_copy_token): object [?]

Investments

  • getInvestmentHoldings(string $access_token, array $options = []): object [?]
  • getInvestmentTransactions(string $access_token, DateTime $start_date, DateTime $end_date, array $options = []): object [?]

Payment Initiation (UK only)

  • createRecipient(string $name, string $iban, RecipientAddress $address): object [?] Note: See the Entities section for details about the RecipientAddress entity needed for this method.
  • getRecipient(string $recipient_id): object [?]
  • listRecipients(): object [?]
  • createPayment(string $recipient_id, string $reference, float $amount, string $currency): object [?]
  • createPaymentToken(string $payment_id): object [?]
  • getPayment(string $payment_id): object [?]
  • listPayments(array $options = []): object [?]

Processors

  • createStripeToken(string $access_token, string $account_id): object [?]
  • createDwollaToken(string $access_token, string $account_id): object [?]

Entities

RecipientAddress

The TomorrowIdeas\Plaid\Entities\RecipientAddress entity is used to represent an address object for the recipient of a payment request.

Example:

$address = new TomorrowIdeas\Plaid\Entities\RecipientAddress("123 Elm St.", "Apt 1", "Anytown", "ABC 123", "GB");

Errors

All unsuccessfull (non 2xx) responses will throw a PlaidRequestException. The full response object is available via the getResponse() method.