#Akro-webhooks
1 messages ยท Page 1 of 1 (latest)
@honest spoke what do your server logs tell you about the error in your server that results in the 500 getting returned?
2021-10-28 11:03:26
[09:03:26 ERR] HTTP POST /stripeWebhook/webhook responded 500 in 134 ms
System.ArgumentNullException: String reference not set to an instance of a String. (Parameter 's')
what "bothers" me is that its working in localhost, so It could be that I havn't setup the webhook correctly in stripe dashboard
I really have no idea, since that error comes from your code(what is s and why is it null?)
I'd suggest adding more logging to the production app so you can track down why exactly it's failing and get a stack trace and so on. Off the top of my head there's no immediate idea I would be able to suggest, there's too many possibilities here
S would be:
var stripeEvent = EventUtility.ConstructEvent(json, Request.Headers["Stripe-Signature"], _stripeSettings.WebhookSecretKey);
My guess is the setup i've done locally, isn't being mimic'ed in production
i.e. the webhook in stripe is not the same as the one running locally with: stripe listen --forward-to https://localhost:5001/stripeWebhook/webhook
well the webhook secret will be different at least, the secret is the one you see on the dashboard when looking at the specific endpoint (https://dashboard.stripe.com/test/webhooks) not the one printed by stripe-cli, which is just for that
at Stripe.EventUtility.ConstructEvent(String json, String stripeSignatureHeader, String secret, Int64 tolerance, Boolean throwOnApiVersionMismatch)
at Tooltracker.Api.Controllers.StripeWebhookController.WebHook() in /home/runner/work/tooltracker/tooltracker/Tooltracker-2.0/Tooltracker.Api/Controllers/StripeWebhookController.cs:line 40
It looks like it is in the Stripe Request.Headers, from the snippet I printed above
could be other things, like maybe in production you have a proxy/something else which strips the Stripe-Signature header from the request. It really could be many things so the first step is detailed logs to debug things a little more
sounds to me like one of the arguments you passed to ConstuctEvent is null then
that could be too, yes
maybe your configuration setting/store doesn't exist in production in the same way. etc
Isn't the StripeSettings.WebhookSecretKey only set in local
?
or do I need to make one for production too?
omg... I think I have missed the Signing secret...
It worked, why didn't you just say that Karl! ๐ (just kidding)
some feedback from a newbie: if you make some kind of visible notifications when users add webhooks in your dashboard, where it states they need to use this new webhook key. I didn't seem to comprehend that a new key was created and I needed to use that in production ๐
great!
and yes people sometimes keep using the stripe-cli secret in production or don't copy the one from the dashboard, that page was redesigned recently but we can always make it clearer!