From 081a26c1649d859189e05e4ab406425cb65f3eb4 Mon Sep 17 00:00:00 2001 From: admin Date: Wed, 27 May 2026 13:08:07 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20BepUsdt=E7=AD=BE=E5=90=8D=E6=94=B9?= =?UTF-8?q?=E7=94=A8fmt.Sprint=E6=A0=BC=E5=BC=8F=E5=8C=96amount(=E4=B8=8E?= =?UTF-8?q?=E5=AE=98=E6=96=B9=E4=B8=80=E8=87=B4)=EF=BC=8C=E6=B7=BB?= =?UTF-8?q?=E5=8A=A0=E8=B0=83=E8=AF=95=E6=97=A5=E5=BF=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/internal/api/handlers/payment.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/backend/internal/api/handlers/payment.go b/backend/internal/api/handlers/payment.go index 01981b0..3eb1f4e 100644 --- a/backend/internal/api/handlers/payment.go +++ b/backend/internal/api/handlers/payment.go @@ -78,9 +78,11 @@ func (h *PaymentHandler) CreatePayment(c *gin.Context) { redirectURL := fmt.Sprintf("%s/orders/%d", baseURL, order.ID) timestamp := time.Now().Unix() + amountStr := fmt.Sprint(order.TotalAmount) + params := map[string]string{ "order_id": strconv.Itoa(int(order.ID)), - "amount": strconv.FormatFloat(order.TotalAmount, 'f', -1, 64), + "amount": amountStr, "notify_url": notifyURL, "redirect_url": redirectURL, "timestamp": strconv.FormatInt(timestamp, 10), @@ -91,6 +93,9 @@ func (h *PaymentHandler) CreatePayment(c *gin.Context) { signature := signBepUsdt(params, apiToken) + fmt.Printf("[BepUsdt] signature params: %v\n", params) + fmt.Printf("[BepUsdt] signature: %s, token: %s\n", signature, apiToken) + reqBody := BepUsdtCreateRequest{ TradeType: tradeType, OrderID: strconv.Itoa(int(order.ID)), @@ -102,6 +107,7 @@ func (h *PaymentHandler) CreatePayment(c *gin.Context) { } body, _ := json.Marshal(reqBody) + fmt.Printf("[BepUsdt] request body: %s\n", string(body)) resp, err := http.Post(apiURL+"/api/v1/order/create-transaction", "application/json", strings.NewReader(string(body))) if err != nil { c.JSON(http.StatusInternalServerError, gin.H{"error": "Failed to connect payment gateway"}) @@ -111,6 +117,8 @@ func (h *PaymentHandler) CreatePayment(c *gin.Context) { respBody, _ := io.ReadAll(resp.Body) + fmt.Printf("[BepUsdt] response: %s\n", string(respBody)) + var result map[string]interface{} json.Unmarshal(respBody, &result)