c# - Stripe .net "The signature for the webhook is not present in the Stripe-Signature header."

标签 c# asp.net stripe-payments webhooks

我正在使用 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 页面获取:

Web Hooks Signing Secret

关于c# - Stripe .net "The signature for the webhook is not present in the Stripe-Signature header.",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46451508/

相关文章:

c# - MediaPlayer 在 Visual Studio 中导致 AppCrash

ruby - Stripe 访问 token 和 API SK key 有什么区别?

c# - 在 while 语句中使用返回值赋值

c# - 如何在 Windows 8 的后台更新我的磁贴?

c# - 如何建模独占行为并使其可配置

javascript - 时间选择器控件

asp.net - IE 10 不显示文本框宽度和高度

c# - ListItems 列表中的 DataBinding asp.net DropDownList 导致 System.ArgumentOutOfRangeException 错误

ssl - 处理付款和搭载 ssl

node.js - Stripe - 创建或更新订阅时 PaymentIntent 为空