TomorrowIdeas / plaid-sdk-php

PHP bindings for the Plaid API
MIT License
111 stars 42 forks source link

TomorrowIdeas \ Plaid \ PlaidRequestException (400) Bad Request #35

Closed gigalabs18 closed 3 years ago

gigalabs18 commented 3 years ago

I am using this package(0.14.0) wrapper in php framework (laravel) as below.

use TomorrowIdeas\Plaid\Plaid;

$plaid = new Plaid(
            $clientId,
            $secretKey,
            'development'
        );

        $item = $plaid->createLinkToken('name of user', 'es', ['US'],'unique_user_id',["auth"]);

        return $this->sendSuccessResponse('role', $item, 'role stored successfully!');

it return me an error as TomorrowIdeas \ Plaid \ PlaidRequestException (400) Bad Request don't why although clientId, secret is correct.

brentscheffler commented 3 years ago

What Plaid API version are you using? Can you add a try... catch around the the createLinkToken call and send the contents of: \dd($exception->getResponse())?

For example:

try {
    $item = $plaid->createLinkToken('name of user', 'es', ['US'],'unique_user_id',[]);
} catch ( PlaidRequestException $exception) {
   \dd($exception->getResponse());
}
gigalabs18 commented 3 years ago

What Plaid API version are you using? Can you add a try... catch around the the createLinkToken call and send the contents of: \dd($exception->getResponse())?

For example:

try {
    $item = $plaid->createLinkToken('name of user', 'es', ['US'],'unique_user_id',[]);
} catch ( PlaidRequestException $exception) {
   \dd($exception->getResponse());
}

i am using 0.14.0 version and it generate an error now bad request error image : https://ibb.co/4RjDYnm by default it install 0.14.0 version by "composer require tomorrow-ideas/plaid-sdk-php" and should i update version?

brentscheffler commented 3 years ago

Sounds like you are on PHP 7.2 and are locked into the 0.14 release. Can you send the contents of:

try {
    $item = $plaid->createLinkToken('name of user', 'es', ['US'],'unique_user_id',[]);
} catch ( PlaidRequestException $exception) {
   \dd($exception->getResponse());
}

To know exactly what the issue is, I need to see the error being returned by Plaid.

gigalabs18 commented 3 years ago

Sounds like you are on PHP 7.2 and are locked into the 0.14 release. Can you send the contents of:

try {
    $item = $plaid->createLinkToken('name of user', 'es', ['US'],'unique_user_id',[]);
} catch ( PlaidRequestException $exception) {
   \dd($exception->getResponse());
}

To know exactly what the issue is, I need to see the error being returned by Plaid.

<?php

namespace App\Http\Controllers\API;

use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use App\Http\Controllers\API\BaseController as BaseController;
use TomorrowIdeas\Plaid\Plaid;

class PlaidController extends BaseController
{
    public function auth() {
        $clientId  = "***********************";
        $secretKey = "**************************";
        $env = "development";
        $plaid = new Plaid(
            $clientId,
            $secretKey,
            $env
        );
      try {
        $item = $plaid->createLinkToken('hassan shafique', 'es', ['US'],'1',["auth"]);
      } catch ( PlaidRequestException $exception) {

         return dd($exception->getResponse());
      }
        return $this->sendSuccessResponse('item', $item, 'item created successfully!');
    }
}

error : https://ibb.co/4RjDYnm error Log:

local.ERROR: Bad Request {"userId":1,"email":"admin@gmail.com","exception":"[object] (TomorrowIdeas\\Plaid\\PlaidRequestException(code: 400): Bad Request at /var/www/html/plaid/vendor/tomorrow-ideas/plaid-sdk-php/src/Plaid.php:205
)
brentscheffler commented 3 years ago

The issue is you are referencing the current master documentation which is drastically different than the version you are on (version 0.14). Your constructor parameters are incorrect. For version 0.14, you need to either include your public key or set it to null in the constructor. For example:

$plaid = new Plaid(
    $client_id,
    $client_secret,
    null,
    "development"
);

Or you can upgrade your PHP version to at least 7.3 and update the SDK to the 1.x version.

gigalabs18 commented 3 years ago

Yes i upgrade php and package version now it is running perfectly.