Logging
This commit is contained in:
@ -156,6 +156,7 @@ class Toku extends Ideal\Service
|
||||
$validEvents = ['payment_intent.succeeded', 'payment.succeeded', 'transaction.success',
|
||||
'transaction.bulk_success', 'payment_intent.succeeded_batch'];
|
||||
if (!in_array($input['event_type'], $validEvents)) {
|
||||
$this->logger->warning("{$input['event_type']} is not a valid event");
|
||||
throw new InvalidResult("{$input['event_type']} is not a valid event", 422);
|
||||
}
|
||||
switch ($input['event_type']) {
|
||||
|
@ -74,19 +74,23 @@ class Invoice extends AbstractEndPoint
|
||||
try {
|
||||
$invoice = $this->invoiceRepository->fetchByTokuId($invoice_toku_id);
|
||||
} catch (EmptyResult $exception) {
|
||||
$this->logger->warning($exception, ['invoice_toku_id' => $invoice_toku_id, 'data' => $data]);
|
||||
throw new InvalidResult("No existe Invoice para toku_id {$invoice_toku_id}", 404, $exception);
|
||||
}
|
||||
if ($data['status'] !== 'AUTHORIZED') {
|
||||
$this->logger->warning("Pago no autorizado", ['invoice_toku_id' => $invoice_toku_id, 'data' => $data]);
|
||||
throw new InvalidResult("Pago no autorizado", 422);
|
||||
}
|
||||
$dateString = $data['date'];
|
||||
try {
|
||||
$date = new DateTimeImmutable($dateString);
|
||||
} catch (DateMalformedStringException $exception) {
|
||||
$this->logger->warning($exception, ['invoice_toku_id' => $invoice_toku_id, 'data' => $data]);
|
||||
throw new InvalidResult("Fecha no válida: {$dateString}", 422, $exception);
|
||||
}
|
||||
$uf = $this->ufService->get($date);
|
||||
if ($uf === 0.0) {
|
||||
$this->logger->warning("No hay UF para la fecha: {$dateString}", ['invoice_toku_id' => $invoice_toku_id, 'data' => $data]);
|
||||
throw new InvalidResult("No hay UF para la fecha: {$dateString}", 422);
|
||||
}
|
||||
$valor = $data['amount'];
|
||||
@ -94,6 +98,7 @@ class Invoice extends AbstractEndPoint
|
||||
$valor = $data['amount'] / $uf;
|
||||
}
|
||||
if (abs($valor - $invoice->cuota->pago->valor()) >= 0.0001) {
|
||||
$this->logger->warning("Valor en UF no coincide: {$data['amount']}, {$valor} <=> {$invoice->cuota->pago->valor()}", ['invoice_toku_id' => $invoice_toku_id, 'data' => $data]);
|
||||
throw new InvalidResult("Valor en UF no coincide: {$data['amount']}, {$valor} <=> {$invoice->cuota->pago->valor()}", 422);
|
||||
}
|
||||
if ($invoice->cuota->pago->isPagado()) {
|
||||
|
Reference in New Issue
Block a user