debug: log webhook raw body and sign comparison

This commit is contained in:
erio
2026-04-10 14:17:39 +08:00
parent 7ea6cafadb
commit 72f7677815
2 changed files with 4 additions and 2 deletions
@@ -95,8 +95,7 @@ func (h *PaymentWebhookHandler) handleNotify(c *gin.Context, providerKey string)
if len(truncatedBody) > webhookLogTruncateLen {
truncatedBody = truncatedBody[:webhookLogTruncateLen] + "...(truncated)"
}
slog.Error("[Payment Webhook] verify failed", "provider", providerKey, "error", err, "method", c.Request.Method, "bodyLen", len(rawBody))
slog.Debug("[Payment Webhook] verify failed body", "provider", providerKey, "rawBody", truncatedBody)
slog.Error("[Payment Webhook] verify failed", "provider", providerKey, "error", err, "method", c.Request.Method, "bodyLen", len(rawBody), "rawBody", truncatedBody)
c.String(http.StatusBadRequest, "verify failed")
return
}
@@ -9,6 +9,7 @@ import (
"encoding/json"
"fmt"
"io"
"log/slog"
"net/http"
"net/url"
"sort"
@@ -186,6 +187,8 @@ func (e *EasyPay) VerifyNotification(_ context.Context, rawBody string, _ map[st
return nil, fmt.Errorf("missing sign")
}
if !easyPayVerifySign(params, e.config["pkey"], sign) {
expected := easyPaySign(params, e.config["pkey"])
slog.Error("[EasyPay] sign mismatch", "expected", expected, "got", sign, "pkeyLen", len(e.config["pkey"]), "instanceID", e.instanceID, "paramCount", len(params))
return nil, fmt.Errorf("invalid signature")
}
status := payment.ProviderStatusFailed