Logging
This commit is contained in:
@ -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();
|
||||
});
|
||||
|
@ -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')) {
|
||||
|
@ -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);
|
||||
|
Reference in New Issue
Block a user