diff --git a/app/public/index.php b/app/public/index.php index cea8aff..3d761f8 100644 --- a/app/public/index.php +++ b/app/public/index.php @@ -20,4 +20,5 @@ register_shutdown_function(function() { if ($error !== null and in_array($error['type'], $fatal_errors, true)) { error_log(json_encode($error).PHP_EOL,3, '/logs/fatal.log'); } + error_clear_last(); }); diff --git a/app/src/Controller/API/Ventas/MediosPago/Toku.php b/app/src/Controller/API/Ventas/MediosPago/Toku.php index aea8228..78a190a 100644 --- a/app/src/Controller/API/Ventas/MediosPago/Toku.php +++ b/app/src/Controller/API/Ventas/MediosPago/Toku.php @@ -47,15 +47,20 @@ class Toku extends Controller ResponseFactoryInterface $responseFactory, Service\Venta\MediosPago\Toku $tokuService): ResponseInterface { - $body = $request->getBody(); - $input = json_decode($body->getContents(), true); + $body = $request->getBody()->getContents(); + $input = json_decode($body, true); try { if ($tokuService->successEvent($input)) { return $responseFactory->createResponse(200); } + $this->logger->warning("Could not update payment", ['input' => $input]); return $responseFactory->createResponse(409, 'Payment could not be updated'); } catch (InvalidResult $exception) { - $this->logger->warning($exception); + $this->logger->warning($exception, [ + 'uri' => $request->getUri()->getPath(), + 'body' => $body, + 'input' => $input + ]); if (str_contains($exception->getMessage(), 'Customer')) { $message = 'Customer not found'; } elseif (str_contains($exception->getMessage(), 'Invoice')) { diff --git a/app/src/Service/Venta/MediosPago/AbstractEndPoint.php b/app/src/Service/Venta/MediosPago/AbstractEndPoint.php index 16cc98c..595560a 100644 --- a/app/src/Service/Venta/MediosPago/AbstractEndPoint.php +++ b/app/src/Service/Venta/MediosPago/AbstractEndPoint.php @@ -30,11 +30,23 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint if (in_array($status, $invalidStatus)) { $contents = $response->getBody()->getContents(); + $this->logger->warning('Invalid Status', [ + 'uri' => $request_uri, + 'code' => $status, + 'reason' => $reason, + 'contents' => $contents + ]); $exception = new HttpException("{$reason}\n{$contents}", $status); throw new EmptyResponse($request_uri, $exception); } if (!in_array($status, $validStatus)) { $contents = $response->getBody()->getContents(); + $this->logger->warning('Not Valid Status', [ + 'uri' => $request_uri, + 'code' => $status, + 'reason' => $reason, + 'contents' => $contents + ]); $exception = new HttpException("{$reason}\n{$contents}", $status); throw new EmptyResponse($request_uri, $exception); } @@ -80,6 +92,13 @@ abstract class AbstractEndPoint extends LoggerEnabled implements EndPoint $contents = $response->getBody()->getContents(); if (trim($contents) === '') { + $this->logger->warning("Empty contents", [ + 'uri' => $request_uri, + 'data' => $data, + 'code' => $response->getStatusCode(), + 'reason' => $response->getReasonPhrase(), + 'contents' => $contents + ]); throw new EmptyResponse($request_uri); } $json = json_decode($contents, true);