diff --git a/classes/Carrier/SendCloud/SendCloudApi.php b/classes/Carrier/SendCloud/SendCloudApi.php index 18f87bff..140f3984 100644 --- a/classes/Carrier/SendCloud/SendCloudApi.php +++ b/classes/Carrier/SendCloud/SendCloudApi.php @@ -77,9 +77,9 @@ class SendCloudApi $response = $this->sendRequest($uri, null, true, ['parcel' => $parcel->toApiRequest()], [200,400]); switch ($response['code']) { case 200: - if (isset($response->parcel)) + if (isset($response['body']->parcel)) try { - return ParcelResponse::fromApiResponse($response->parcel); + return ParcelResponse::fromApiResponse($response['body']->parcel); } catch (Exception $e) { throw new SendcloudApiException(previous: $e); } diff --git a/classes/Carrier/SendCloud/SendcloudApiException.php b/classes/Carrier/SendCloud/SendcloudApiException.php index 247fa9af..8062a1e8 100644 --- a/classes/Carrier/SendCloud/SendcloudApiException.php +++ b/classes/Carrier/SendCloud/SendcloudApiException.php @@ -8,11 +8,11 @@ class SendcloudApiException extends Exception { public static function fromResponse(array $response) : SendcloudApiException { if (!isset($response['body']) || !is_object($response['body'])) - return new SendcloudApiException(); + return new SendcloudApiException(print_r($response,true)); return new SendcloudApiException( - $response['body']->error->message ?? '', - $response['body']->error->code ?? 0 + print_r($response['body'],true), + $response['code'] ); } } \ No newline at end of file diff --git a/www/lib/class.versanddienstleister.php b/www/lib/class.versanddienstleister.php index a55cfe33..1e569c09 100644 --- a/www/lib/class.versanddienstleister.php +++ b/www/lib/class.versanddienstleister.php @@ -353,7 +353,7 @@ abstract class Versanddienstleister public function Paketmarke(string $target, string $docType, int $docId): void { $address = $this->GetAdressdaten($docId, $docType); - if (isset($_SERVER['HTTP_CONTENT_TYPE']) && ($_SERVER['HTTP_CONTENT_TYPE'] === 'application/json')) { + if (isset($_SERVER['CONTENT_TYPE']) && ($_SERVER['CONTENT_TYPE'] === 'application/json')) { $json = json_decode(file_get_contents('php://input')); $ret = []; if ($json->submit == 'print') { diff --git a/www/lib/versandarten/sendcloud.php b/www/lib/versandarten/sendcloud.php index 5a44e890..51204348 100644 --- a/www/lib/versandarten/sendcloud.php +++ b/www/lib/versandarten/sendcloud.php @@ -131,7 +131,7 @@ class Versandart_sendcloud extends Versanddienstleister $ret->Errors[] = $result; } } catch (SendcloudApiException $e) { - $ret->Errors[] = $e->getMessage(); + $ret->Errors[] = strval($e); } return $ret; }