ip
This commit is contained in:
@@ -78,8 +78,9 @@ func PagoExitosoPage(c *fiber.Ctx) error {
|
||||
// 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")
|
||||
if ok, _ := models.MarcarContratoPagado(contratoID); ok {
|
||||
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 {
|
||||
@@ -161,8 +162,9 @@ func verificarPago(ref string) (confirmado bool, fechaPago string) {
|
||||
for _, l := range dlocalLogs {
|
||||
if l.Estado == "PAID" || l.Estado == "AUTHORIZED" {
|
||||
log.Printf("[PAGO-ESTADO] Contrato %d confirmado via dlocal_payment_log (id=%d)", contratoID, l.ID)
|
||||
_ = models.MarcarContratoPagado(contratoID)
|
||||
if ok, _ := models.MarcarContratoPagado(contratoID); ok {
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "dlocal")
|
||||
}
|
||||
return true, l.CreatedAt.Format("02/01/2006 15:04")
|
||||
}
|
||||
}
|
||||
@@ -177,8 +179,9 @@ func verificarPago(ref string) (confirmado bool, fechaPago string) {
|
||||
log.Printf("[PAGO-ESTADO] Bold API error para link %s: %v", contrato.EnlacePagoLinkID, boldApiErr)
|
||||
} else if paid {
|
||||
log.Printf("[PAGO-ESTADO] Contrato %d confirmado via Bold API (payment_id=%s)", contratoID, paymentID)
|
||||
_ = models.MarcarContratoPagado(contratoID)
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "bold")
|
||||
if ok, _ := models.MarcarContratoPagado(contratoID); ok {
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "bold")
|
||||
}
|
||||
if paymentID != "" && !models.IsBoldNotificationDuplicate("api-check-"+paymentID) {
|
||||
_ = models.SaveBoldWebhookLog(models.BoldWebhookLog{
|
||||
NotificationID: "api-check-" + paymentID,
|
||||
@@ -203,8 +206,9 @@ func verificarPago(ref string) (confirmado bool, fechaPago string) {
|
||||
log.Printf("[PAGO-ESTADO] dLocal API error para order_id %s: %v", ref, dlocalApiErr)
|
||||
} else if paid {
|
||||
log.Printf("[PAGO-ESTADO] Contrato %d confirmado via dLocal API (payment_id=%s)", contratoID, paymentID)
|
||||
_ = models.MarcarContratoPagado(contratoID)
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "dlocal")
|
||||
if ok, _ := models.MarcarContratoPagado(contratoID); ok {
|
||||
go services.EnviarCorreoConfirmacionPago(contratoID, "dlocal")
|
||||
}
|
||||
notifID := "api-check-" + ref
|
||||
if !models.IsDlocalNotificationDuplicate(notifID) {
|
||||
_ = models.SaveDlocalPaymentLog(models.DlocalPaymentLog{
|
||||
|
||||
Reference in New Issue
Block a user