我正在使用 NuGet 的 Stripe.net SDK。我总是得到
The signature for the webhook is not present in the Stripe-Signature header.
StripeEventUtility.ConstructEvent
方法的异常。
[HttpPost]
public void Test([FromBody] JObject incoming)
{
var stripeEvent = StripeEventUtility.ConstructEvent(incoming.ToString(), Request.Headers["Stripe-Signature"], Constants.STRIPE_LISTENER_KEY);
}
WebHook key 正确,请求 header 包含“Stripe-Signature” key 。
我正确地接收了来自 Webhook 测试器实用程序的传入数据(将 nGrok 与 Visual Studio 结合使用)。
secureCompare
方法似乎是罪魁祸首=> StripeEventUtility.cs
我试图操纵来自 Stripe 的传入数据(Jobject、字符串、序列化...)。有效负载签名可能会导致一些问题。
有人遇到同样的问题吗?
最佳答案
根据@Josh 的评论,我收到了同样的错误
The signature for the webhook is not present in the Stripe-Signature header.
这是因为我错误地使用了 API secret (以 sk_
开头)来验证 EventUtility.ConstructEvent
上的 HMAC。
相反,Stripe WebHook 有效载荷是带有 Web Hook Signing Secret(以 whsec_
开头)的标志 per the docs
Web Hook Signing Secret
可以从 Developers -> WebHooks
页面获取:
关于c# - Stripe .net "The signature for the webhook is not present in the Stripe-Signature header.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46451508/