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)