up
This commit is contained in:
@@ -63,15 +63,34 @@ func PagoExitosoPage(c *fiber.Ctx) error {
|
||||
|
||||
// Bold confirmó el pago directamente en la URL de retorno
|
||||
if boldTxStatus == "approved" {
|
||||
// IP real (detrás de nginx)
|
||||
ip := c.Get("X-Real-IP")
|
||||
if ip == "" {
|
||||
ip = c.Get("X-Forwarded-For")
|
||||
}
|
||||
if ip == "" {
|
||||
ip = c.IP()
|
||||
}
|
||||
_ = models.SaveBoldCallbackLog(models.BoldCallbackLog{
|
||||
Referencia: ref, PaymentLink: paymentLink, Params: paramsJSON,
|
||||
Estado: "pagado", IP: c.IP(), UserAgent: string(c.Request().Header.UserAgent()),
|
||||
Estado: "pagado", IP: ip, UserAgent: string(c.Request().Header.UserAgent()),
|
||||
})
|
||||
// Marcar contrato si aún no está confirmado
|
||||
var contratoID uint
|
||||
if _, err := fmt.Sscanf(ref, "contrato-%d", &contratoID); err == nil && contratoID > 0 {
|
||||
_ = models.MarcarContratoPagado(contratoID)
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "bold")
|
||||
// Intentar enriquecer con datos del webhook log si ya llegó
|
||||
go func() {
|
||||
if wLogs, err := models.GetBoldWebhookLogsByRef(ref); err == nil {
|
||||
for _, wl := range wLogs {
|
||||
if wl.PayerEmail != "" || wl.Monto > 0 {
|
||||
models.EnrichBoldCallbackLog(ref, wl.PayerEmail, wl.Monto)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
estado, fechaPago := verificarPago(ref)
|
||||
return c.Render("pago_exitoso", fiber.Map{
|
||||
@@ -81,12 +100,19 @@ func PagoExitosoPage(c *fiber.Ctx) error {
|
||||
|
||||
// Registrar el intento de pago en la tabla de callbacks
|
||||
if ref != "" || paymentLink != "" {
|
||||
ip := c.Get("X-Real-IP")
|
||||
if ip == "" {
|
||||
ip = c.Get("X-Forwarded-For")
|
||||
}
|
||||
if ip == "" {
|
||||
ip = c.IP()
|
||||
}
|
||||
entry := models.BoldCallbackLog{
|
||||
Referencia: ref,
|
||||
PaymentLink: paymentLink,
|
||||
Params: paramsJSON,
|
||||
Estado: "pendiente",
|
||||
IP: c.IP(),
|
||||
IP: ip,
|
||||
UserAgent: string(c.Request().Header.UserAgent()),
|
||||
}
|
||||
_ = models.SaveBoldCallbackLog(entry)
|
||||
|
||||
Reference in New Issue
Block a user