From 2ad5566c654f0fce6981fbb645cdef24ecf8075f Mon Sep 17 00:00:00 2001 From: Kyle Anderson Date: Mon, 2 Oct 2023 15:55:41 -0400 Subject: [PATCH] only set access token when it exists --- src/Models/Paypal.php | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/Models/Paypal.php b/src/Models/Paypal.php index 2f9f7fa..e9626e9 100644 --- a/src/Models/Paypal.php +++ b/src/Models/Paypal.php @@ -18,7 +18,10 @@ public function __construct() { $this->client = new PayPalClient(); $this->client->setApiCredentials(config('paypal')); - $this->client->setAccessToken($this->cacheAccessToken()); + + if (array_keys($this->cacheAccessToken()['access_token'])) { + $this->client->setAccessToken($this->cacheAccessToken()); + } $mode = config('paypal.mode'); $this->clientId = config("paypal.{$mode}.client_id");