fix(purchase): update notification URL construction for gateway mode support
This commit is contained in:
parent
338d962618
commit
5d632608ab
@ -7,6 +7,7 @@ import (
|
|||||||
"time"
|
"time"
|
||||||
|
|
||||||
"github.com/perfect-panel/server/internal/model/log"
|
"github.com/perfect-panel/server/internal/model/log"
|
||||||
|
"github.com/perfect-panel/server/internal/report"
|
||||||
"github.com/perfect-panel/server/pkg/constant"
|
"github.com/perfect-panel/server/pkg/constant"
|
||||||
|
|
||||||
paymentPlatform "github.com/perfect-panel/server/pkg/payment"
|
paymentPlatform "github.com/perfect-panel/server/pkg/payment"
|
||||||
@ -275,16 +276,29 @@ func (l *PurchaseCheckoutLogic) epayPayment(config *payment.Payment, info *order
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gateway mod
|
||||||
|
|
||||||
|
isGatewayMod := report.IsGatewayMode()
|
||||||
|
|
||||||
// Build notification URL for payment status callbacks
|
// Build notification URL for payment status callbacks
|
||||||
notifyUrl := ""
|
notifyUrl := ""
|
||||||
if config.Domain != "" {
|
if config.Domain != "" {
|
||||||
notifyUrl = config.Domain + "/v1/notify/" + config.Platform + "/" + config.Token
|
notifyUrl = config.Domain
|
||||||
|
if isGatewayMod {
|
||||||
|
notifyUrl += "/api/"
|
||||||
|
}
|
||||||
|
notifyUrl = notifyUrl + "/v1/notify/" + config.Platform + "/" + config.Token
|
||||||
} else {
|
} else {
|
||||||
host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string)
|
host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
host = l.svcCtx.Config.Host
|
host = l.svcCtx.Config.Host
|
||||||
}
|
}
|
||||||
notifyUrl = "https://" + host + "/v1/notify/" + config.Platform + "/" + config.Token
|
|
||||||
|
notifyUrl = "https://" + host
|
||||||
|
if isGatewayMod {
|
||||||
|
notifyUrl += "/api"
|
||||||
|
}
|
||||||
|
notifyUrl = notifyUrl + "/v1/notify/" + config.Platform + "/" + config.Token
|
||||||
}
|
}
|
||||||
|
|
||||||
// Create payment URL for user redirection
|
// Create payment URL for user redirection
|
||||||
@ -317,18 +331,29 @@ func (l *PurchaseCheckoutLogic) CryptoSaaSPayment(config *payment.Payment, info
|
|||||||
return "", err
|
return "", err
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// gateway mod
|
||||||
|
isGatewayMod := report.IsGatewayMode()
|
||||||
|
|
||||||
// Build notification URL for payment status callbacks
|
// Build notification URL for payment status callbacks
|
||||||
notifyUrl := ""
|
notifyUrl := ""
|
||||||
if config.Domain != "" {
|
if config.Domain != "" {
|
||||||
notifyUrl = config.Domain + "/v1/notify/" + config.Platform + "/" + config.Token
|
notifyUrl = config.Domain
|
||||||
|
if isGatewayMod {
|
||||||
|
notifyUrl += "/api/"
|
||||||
|
}
|
||||||
|
notifyUrl = notifyUrl + "/v1/notify/" + config.Platform + "/" + config.Token
|
||||||
} else {
|
} else {
|
||||||
host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string)
|
host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string)
|
||||||
if !ok {
|
if !ok {
|
||||||
host = l.svcCtx.Config.Host
|
host = l.svcCtx.Config.Host
|
||||||
}
|
}
|
||||||
notifyUrl = "https://" + host + "/v1/notify/" + config.Platform + "/" + config.Token
|
|
||||||
}
|
|
||||||
|
|
||||||
|
notifyUrl = "https://" + host
|
||||||
|
if isGatewayMod {
|
||||||
|
notifyUrl += "/api"
|
||||||
|
}
|
||||||
|
notifyUrl = notifyUrl + "/v1/notify/" + config.Platform + "/" + config.Token
|
||||||
|
}
|
||||||
// Create payment URL for user redirection
|
// Create payment URL for user redirection
|
||||||
url := client.CreatePayUrl(epay.Order{
|
url := client.CreatePayUrl(epay.Order{
|
||||||
Name: l.svcCtx.Config.Site.SiteName,
|
Name: l.svcCtx.Config.Site.SiteName,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user