up
This commit is contained in:
@@ -14,11 +14,16 @@ import (
|
||||
func PagoExitosoPage(c *fiber.Ctx) error {
|
||||
// Recolectar todos los parámetros posibles que Bold puede enviar
|
||||
params := map[string]string{}
|
||||
// Parámetros clave que Bold envía en la callback_url
|
||||
for _, k := range []string{"bold-order-id", "order_id", "payment_link", "reference", "id", "ref"} {
|
||||
if v := c.Query(k, ""); v != "" {
|
||||
params[k] = v
|
||||
}
|
||||
}
|
||||
// bold-tx-status: Bold envía el resultado directamente en la URL
|
||||
if v := c.Query("bold-tx-status", ""); v != "" {
|
||||
params["bold-tx-status"] = v
|
||||
}
|
||||
c.Request().URI().QueryArgs().VisitAll(func(k, v []byte) {
|
||||
params[string(k)] = string(v)
|
||||
})
|
||||
@@ -43,6 +48,19 @@ func PagoExitosoPage(c *fiber.Ctx) error {
|
||||
}
|
||||
paramsJSON += "}"
|
||||
|
||||
// Si Bold ya envía el resultado en la URL (bold-tx-status), usarlo directamente
|
||||
// antes de hacer cualquier llamada a la API externa.
|
||||
boldTxStatus := params["bold-tx-status"]
|
||||
if boldTxStatus == "rejected" || boldTxStatus == "cancelled" || boldTxStatus == "failed" {
|
||||
_ = models.SaveBoldCallbackLog(models.BoldCallbackLog{
|
||||
Referencia: ref, PaymentLink: paymentLink, Params: paramsJSON,
|
||||
Estado: "fallido", IP: c.IP(), UserAgent: string(c.Request().Header.UserAgent()),
|
||||
})
|
||||
return c.Render("pago_exitoso", fiber.Map{
|
||||
"Ref": ref, "Estado": "rechazado", "FechaPago": "",
|
||||
}, "layouts/landing")
|
||||
}
|
||||
|
||||
// Registrar el intento de pago en la tabla de callbacks
|
||||
if ref != "" || paymentLink != "" {
|
||||
entry := models.BoldCallbackLog{
|
||||
|
||||
Reference in New Issue
Block a user