#Sumit - Webhooks
1 messages · Page 1 of 1 (latest)
Hello! That error usually indicates you haven't passed the headers to the ConstructEvent function properly. Can you share the code that calls that function?
sure thing. 1 sec
var strStripeRequest = OperationContext.Current.RequestContext.RequestMessage.GetBody<Stream>();
var json = await new StreamReader(strStripeRequest).ReadToEndAsync();
try
{
var stripeEvent = EventUtility.ConstructEvent(json, System.Web.HttpContext.Current.Request.Headers["Stripe-Signature"], ConfigurationManager.AppSettings["ClientSecret"].ToString());
}
catch(Exception e)
{
}
If you log the value of System.Web.HttpContext.Current.Request.Headers["Stripe-Signature"] is it what you expect (the signature)?
Also, how are you testing the code? Which event are you triggering?
I do.
This is one of the examples:
t=1637684898,v1=220cc3175c9511b1a1abca8488b4cc69a13d88a1ac56ca2695327b719b022c75,v0=fd11682662d95115d76fcd9520909c26c5288a89c71a960e71863e895f178a4e
The selected event for the webhook is invoice.paid
That certainly looks correct. How are you triggering the invoice.paid event?
For now, I am"Resending" a past invoice.paid event to see if it is able to do any validations
but the it throws the missing signature exception
my hunch is the Request body is not in an expected format
But I don't see any other way I could fetch the request object
Usually body issues will raise a different error, but it's a possibility...
Hang on, let me check the .NET SDK code to see when that error is raised...
Thank you sir
So the code in the SDK that throws the error is here: https://github.com/stripe/stripe-dotnet/blob/7b62c461d7c0cf2c9e06dce5e564b374a9d232e0/src/Stripe.net/Services/Events/EventUtility.cs#L155
That error is only thrown if the v1 signature is not present, but it is present in the value you shared above.
🤔
interesting
I'll check this.
Can you tell me what's the best way to fetch the stripe request body in a REST endpoint, which is an WCF "Operation Contract" ?
I'm not sure what 'WCF "Operation Contract"' means, is that a .NET specific thing?
Maybe this? https://stackoverflow.com/questions/1287802/access-request-body-in-a-wcf-restful-service
umm, I seem to be using that right. This is like never ending research for me. haha. Thank you though. I might reach out later again if I make any progress ahead of this error