From 016fa3ee72efe39245b386fa87e3f3a87a04b926 Mon Sep 17 00:00:00 2001 From: jhc Date: Sat, 29 Mar 2025 10:53:46 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pkg/service/bundle/pay.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/pkg/service/bundle/pay.go b/pkg/service/bundle/pay.go index 734ff62..8856fec 100644 --- a/pkg/service/bundle/pay.go +++ b/pkg/service/bundle/pay.go @@ -12,6 +12,7 @@ import ( "fonchain-fiee/pkg/service/bundle/common" bundleModel "fonchain-fiee/pkg/service/bundle/model" "io" + "math" "net/http" "strconv" @@ -52,7 +53,9 @@ func CreateStripeCheckoutSession(c *gin.Context) { fmt.Println("req.ProductAllPrice :", req.ProductAllPrice) //金额校验 - if detail.OrderRecord.TotalAmount*100 != float32(req.ProductAllPrice) { + orderAmountInCents := int64(math.Round(float64(detail.OrderRecord.TotalAmount * 100))) + reqAmountInCents := int64(math.Round(float64(req.ProductAllPrice))) + if orderAmountInCents != reqAmountInCents { service.Error(c, errors.New(common.InvalidOrderAmount)) return }