Files
zeekay 1943f1c093 Hanzo Commerce
Multi-tenant commerce and billing: orders, subscriptions, invoices, plans,
usage metering and a credit ledger. One Go binary. MIT OR Apache-2.0.

Claude-Session: https://claude.ai/code/session_01SAtaDFm8VDiWrhYHNNtxMw
2026-09-23 21:52:16 -07:00

20 lines
505 B
Go

package mercury
import (
"crypto/hmac"
"crypto/sha256"
"encoding/hex"
)
// VerifySignature verifies a Mercury webhook signature.
// Mercury signs payloads with HMAC-SHA256 using the webhook secret.
func VerifySignature(payload []byte, signature string, secret string) bool {
if signature == "" || secret == "" {
return false
}
mac := hmac.New(sha256.New, []byte(secret))
mac.Write(payload)
expected := hex.EncodeToString(mac.Sum(nil))
return hmac.Equal([]byte(expected), []byte(signature))
}