diff --git a/backend/internal/http/handler/payment.go b/backend/internal/http/handler/payment.go index 273c17f..acefa48 100644 --- a/backend/internal/http/handler/payment.go +++ b/backend/internal/http/handler/payment.go @@ -59,7 +59,11 @@ func (h *PaymentHandler) Recharge(c *gin.Context) { c.JSON(http.StatusBadRequest, gin.H{"detail": "invalid request body"}) return } - order, err := h.pay.CreateOrder(c.Request.Context(), user, body.Amount, body.Method, requestBaseURL(c), clientIP(c)) + base := requestBaseURL(c) + if strings.HasPrefix(base, "http://") { + base = "https://" + strings.TrimPrefix(base, "http://") + } + order, err := h.pay.CreateOrder(c.Request.Context(), user, body.Amount, body.Method, base, clientIP(c)) if err != nil { h.writeErr(c, err) return @@ -107,7 +111,11 @@ func (h *PaymentHandler) ContinueOrder(c *gin.Context) { c.JSON(http.StatusUnauthorized, gin.H{"detail": "未登录或会话已过期"}) return } - order, err := h.pay.Continue(c.Request.Context(), user, c.Param("id"), requestBaseURL(c), clientIP(c)) + base := requestBaseURL(c) + if strings.HasPrefix(base, "http://") { + base = "https://" + strings.TrimPrefix(base, "http://") + } + order, err := h.pay.Continue(c.Request.Context(), user, c.Param("id"), base, clientIP(c)) if err != nil { h.writeErr(c, err) return