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