#Sumit - Webhooks

1 messages · Page 1 of 1 (latest)

twilit geode
#

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?

warm path
#

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)
{
}

twilit geode
#

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?

warm path
#

I do.
This is one of the examples:
t=1637684898,v1=220cc3175c9511b1a1abca8488b4cc69a13d88a1ac56ca2695327b719b022c75,v0=fd11682662d95115d76fcd9520909c26c5288a89c71a960e71863e895f178a4e

#

The selected event for the webhook is invoice.paid

twilit geode
#

That certainly looks correct. How are you triggering the invoice.paid event?

warm path
#

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

twilit geode
#

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...

warm path
#

Thank you sir

twilit geode
#

🤔

warm path
#

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" ?

twilit geode
#

I'm not sure what 'WCF "Operation Contract"' means, is that a .NET specific thing?

warm path
#

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