fix: redirect subscription payment return to user-accessible page

This commit is contained in:
Seefs
2026-02-28 15:14:08 +08:00
parent 75fa0398b3
commit 24b427170e

View File

@@ -172,7 +172,7 @@ func SubscriptionEpayReturn(c *gin.Context) {
if c.Request.Method == "POST" {
// POST 请求:从 POST body 解析参数
if err := c.Request.ParseForm(); err != nil {
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=fail")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=fail")
return
}
params = lo.Reduce(lo.Keys(c.Request.PostForm), func(r map[string]string, t string, i int) map[string]string {
@@ -188,29 +188,29 @@ func SubscriptionEpayReturn(c *gin.Context) {
}
if len(params) == 0 {
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=fail")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=fail")
return
}
client := GetEpayClient()
if client == nil {
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=fail")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=fail")
return
}
verifyInfo, err := client.Verify(params)
if err != nil || !verifyInfo.VerifyStatus {
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=fail")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=fail")
return
}
if verifyInfo.TradeStatus == epay.StatusTradeSuccess {
LockOrder(verifyInfo.ServiceTradeNo)
defer UnlockOrder(verifyInfo.ServiceTradeNo)
if err := model.CompleteSubscriptionOrder(verifyInfo.ServiceTradeNo, common.GetJsonString(verifyInfo)); err != nil {
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=fail")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=fail")
return
}
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=success")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=success")
return
}
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=pending")
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=pending")
}