diff --git a/composer.json b/composer.json index dd34949..74cc507 100644 --- a/composer.json +++ b/composer.json @@ -22,6 +22,7 @@ "upmind/enhance-sdk": "^10", "giggsey/libphonenumber-for-php-lite": "^8", "ext-curl": "*", + "ext-json": "*", "ext-soap": "*" }, "require-dev": { diff --git a/src/Webuzo/Api.php b/src/Webuzo/Api.php index ec4fcdd..df90852 100644 --- a/src/Webuzo/Api.php +++ b/src/Webuzo/Api.php @@ -74,7 +74,14 @@ public function makeRequest( */ private function parseResponseData(string $response): array { - $parsedResult = json_decode($response, true); + try { + $parsedResult = json_decode($response, true, 512, JSON_THROW_ON_ERROR); + } catch (JsonException $e) { + throw ProvisionFunctionError::create('Failed to parse response data', $e) + ->withData([ + 'response' => $response, + ]); + } if ($error = $this->getResponseErrorMessage($parsedResult)) { throw ProvisionFunctionError::create($error)