mirror of
https://github.com/QuantumNous/new-api.git
synced 2026-04-30 12:51:46 +00:00
fix: redirect subscription payment return to user-accessible page
This commit is contained in:
@@ -172,7 +172,7 @@ func SubscriptionEpayReturn(c *gin.Context) {
|
|||||||
if c.Request.Method == "POST" {
|
if c.Request.Method == "POST" {
|
||||||
// POST 请求:从 POST body 解析参数
|
// POST 请求:从 POST body 解析参数
|
||||||
if err := c.Request.ParseForm(); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
params = lo.Reduce(lo.Keys(c.Request.PostForm), func(r map[string]string, t string, i int) map[string]string {
|
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 {
|
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
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
client := GetEpayClient()
|
client := GetEpayClient()
|
||||||
if client == nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
verifyInfo, err := client.Verify(params)
|
verifyInfo, err := client.Verify(params)
|
||||||
if err != nil || !verifyInfo.VerifyStatus {
|
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
|
return
|
||||||
}
|
}
|
||||||
if verifyInfo.TradeStatus == epay.StatusTradeSuccess {
|
if verifyInfo.TradeStatus == epay.StatusTradeSuccess {
|
||||||
LockOrder(verifyInfo.ServiceTradeNo)
|
LockOrder(verifyInfo.ServiceTradeNo)
|
||||||
defer UnlockOrder(verifyInfo.ServiceTradeNo)
|
defer UnlockOrder(verifyInfo.ServiceTradeNo)
|
||||||
if err := model.CompleteSubscriptionOrder(verifyInfo.ServiceTradeNo, common.GetJsonString(verifyInfo)); err != nil {
|
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
|
return
|
||||||
}
|
}
|
||||||
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=success")
|
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=success")
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/subscription?pay=pending")
|
c.Redirect(http.StatusFound, system_setting.ServerAddress+"/console/topup?pay=pending")
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user