#IsmailSarikaya-webhook signature
1 messages ยท Page 1 of 1 (latest)
sure
Did you see something wrong? I actually got this code structure directly from Stripe's web site.
I'm taking a look
Great, thanks.
so basically I saw something but I'm not sure whether it's related or not
you're using Request.Headers["Stripe-Signature"] instead of HttpContext.Request.Headers["Stripe-Signature"]
I didn't write these parts on my own. Is this the correct one? HttpContext.Request.Headers["Stripe-Signature"]
I'm not sure
I don't have a full look at your code base
I don't know if Request is something that is exposed in your BaseController or what exactly
Take a look at this:
https://stripe.com/docs/webhooks
There:
var stripeEvent = EventUtility.ParseEvent(json);
yes
just take a look at this https://stripe.com/docs/webhooks/quickstart
and try to make it as much the same as possible
that's my best guess for you
Yes, I agree with you. But I am trying to understand if 'Stripe-Signature' must be used?
Because in the example that I mentioned, there is no header, they parsed directly from json but in you example they used signature.
And in my example, they didn't use endpointSecret. I am confused.
in that code they are not verifying the signature
it's important to verify the signature so that you can't be attacked since you're exposing your API on the internet
You say it's for the security? So at my own risk, does it work if I don't use it?
yes
Then I will try without it until the final product release.
oh wait
you're missing this var stripeEvent = EventUtility.ParseEvent(json); from your code
you need those three lines
var stripeEvent = EventUtility.ParseEvent(json);
var signatureHeader = Request.Headers["Stripe-Signature"];
stripeEvent = EventUtility.ConstructEvent(json,
signatureHeader, endpointSecret);```
in your code your only using var stripeEvent = EventUtility.ConstructEvent(json, Request.Headers["Stripe-Signature"], endpointSecret); which passes the json without parsing it first
Ok I will try this and let you know. Thanks.