3 Commits

Author SHA1 Message Date
e9b2fe9963 FIX: monto enviado en UF 2025-05-15 10:12:34 -04:00
2f481ef8a9 FIX: mapeo de datos al actualizar pago 2025-05-15 10:06:35 -04:00
386fe452af Catch error 2025-05-15 10:06:00 -04:00
3 changed files with 13 additions and 4 deletions

View File

@ -161,7 +161,7 @@ class Toku extends Ideal\Service
$customer = $this->customer->getByExternalId($request['customer']);
$invoice = $this->invoice->getByExternalId($request['invoice']);
return $this->invoice->update($invoice['id'], $request);
return $this->invoice->update($invoice['toku_id'], $request);
}
protected function successTransaction(array $input): bool
{
@ -253,6 +253,9 @@ class Toku extends Ideal\Service
protected function mapPaymentEventData(array $input): array
{
$data = $input['payment'];
if (!array_key_exists('amount', $data) and array_key_exists('payment_amount', $data)) {
$data['amount'] = $data['payment_amount'];
}
$data['status'] = 'AUTHORIZED';
$data['date'] = $data['payment_date'];
return $data;

View File

@ -76,9 +76,15 @@ class Invoice extends AbstractEndPoint
if ($uf === 0.0) {
throw new InvalidResult("No hay UF para la fecha: {$dateString}", 422);
}
$valor = $data['amount'] / $uf;
$valor = $data['amount'];
if ($valor > 1000) {
$valor = $data['amount'] / $uf;
}
if (abs($valor - $invoice->cuota->pago->valor()) >= 0.0001) {
throw new InvalidResult("Valor en UF no coincide: {$data['amount']}", 422);
throw new InvalidResult("Valor en UF no coincide: {$data['amount']}, {$valor} <=> {$invoice->cuota->pago->valor()}", 422);
}
if ($invoice->cuota->pago->isPagado()) {
return true;
}
return $this->pagoService->depositar($invoice->cuota->pago, $date);
}

View File

@ -37,7 +37,7 @@ class Pago
$pago = $this->process($this->pagoRepository->fetchById($pago->id));
$this->getUF($pago);
return true;
} catch (PDOException) {
} catch (PDOException | EmptyResult) {
return false;
}
}