Skip to content

Commit

Permalink
fix access token
Browse files Browse the repository at this point in the history
  • Loading branch information
Kyle Anderson committed Oct 2, 2023
1 parent 092357b commit 8d7088a
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions src/Models/Paypal.php
Original file line number Diff line number Diff line change
Expand Up @@ -18,24 +18,16 @@ public function __construct()
{
$this->client = new PayPalClient();
$this->client->setApiCredentials(config('paypal'));
$this->client->setAccessToken($this->getAccessToken());
$this->client->setAccessToken($this->cacheAccessToken());

$mode = config('paypal.mode');
$this->clientId = config("paypal.{$mode}.client_id");
}

public function getAccessToken()
public function cacheAccessToken()
{
return Cache::remember('paypal.access_token', 60 * 60 * 4, function () {
$token = $this->client->getAccessToken();
if (is_array($token)) {
return [
'access_token' => '',
'token_type' => '',
];
}

return json_decode($token, true);
return $this->client->getAccessToken();
});
}

Expand Down

0 comments on commit 8d7088a

Please sign in to comment.