From 5d632608ab5ccbca8dc831825b088c58b91b5086 Mon Sep 17 00:00:00 2001 From: Tension Date: Mon, 8 Dec 2025 15:47:45 +0800 Subject: [PATCH] fix(purchase): update notification URL construction for gateway mode support --- .../public/portal/purchaseCheckoutLogic.go | 35 ++++++++++++++++--- 1 file changed, 30 insertions(+), 5 deletions(-) diff --git a/internal/logic/public/portal/purchaseCheckoutLogic.go b/internal/logic/public/portal/purchaseCheckoutLogic.go index f016a49..ff7faf2 100644 --- a/internal/logic/public/portal/purchaseCheckoutLogic.go +++ b/internal/logic/public/portal/purchaseCheckoutLogic.go @@ -7,6 +7,7 @@ import ( "time" "github.com/perfect-panel/server/internal/model/log" + "github.com/perfect-panel/server/internal/report" "github.com/perfect-panel/server/pkg/constant" paymentPlatform "github.com/perfect-panel/server/pkg/payment" @@ -275,16 +276,29 @@ func (l *PurchaseCheckoutLogic) epayPayment(config *payment.Payment, info *order return "", err } + // gateway mod + + isGatewayMod := report.IsGatewayMode() + // Build notification URL for payment status callbacks notifyUrl := "" 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 { host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string) if !ok { 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 @@ -317,18 +331,29 @@ func (l *PurchaseCheckoutLogic) CryptoSaaSPayment(config *payment.Payment, info return "", err } + // gateway mod + isGatewayMod := report.IsGatewayMode() + // Build notification URL for payment status callbacks notifyUrl := "" 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 { host, ok := l.ctx.Value(constant.CtxKeyRequestHost).(string) if !ok { 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 url := client.CreatePayUrl(epay.Order{ Name: l.svcCtx.Config.Site.SiteName,