diff --git a/src/Traits/PayPalHttpClient.php b/src/Traits/PayPalHttpClient.php index 3547ec58..93d3466c 100644 --- a/src/Traits/PayPalHttpClient.php +++ b/src/Traits/PayPalHttpClient.php @@ -5,6 +5,7 @@ use GuzzleHttp\Client as HttpClient; use GuzzleHttp\Exception\ClientException as HttpClientException; use GuzzleHttp\Utils; +use Illuminate\Support\Str; use Psr\Http\Message\StreamInterface; use RuntimeException; @@ -211,7 +212,7 @@ private function doPayPalRequest(bool $decode = true) return ($decode === false) ? $response->getContents() : Utils::jsonDecode($response, true); } catch (RuntimeException $t) { - $error = ($decode === false) ? $t->getMessage() : Utils::jsonDecode($t->getMessage(), true); + $error = ($decode === false) || (Str::isJson($t->getMessage()) === false) ? $t->getMessage() : Utils::jsonDecode($t->getMessage(), true); return ['error' => $error]; }