PHP code example of eliosfund / plaid-php-sdk

1. Go to this page and download the library: Download eliosfund/plaid-php-sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

eliosfund / plaid-php-sdk example snippets




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');



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();



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
}



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();
shell
composer