#sow - webhook signature

1 messages · Page 1 of 1 (latest)

harsh niche
quiet radish
#

my webhook ID : we_1KFta4CHSKMd2K1khxPRAUT3

harsh niche
#

Well my first caveat is that you need to be absolutely certain you pass in the raw body of the request, not any transformed version

#

Personally I'm skeptical of the json parameter you are showing.

quiet radish
#

string json = await new StreamReader(req.Body).ReadToEndAsync();

#

since the body was posted by stripe I dont have any control ?

#

Little more info of the api,

#

public async Task<IActionResult> Run(
[HttpTrigger(AuthorizationLevel.Function, "post", Route = "stripe/webhook")] HttpRequest req, ExecutionContext executionContext
)
{
_logger.LogInformation("Processing Stripe Events");

        try
        {
            int responseCode;

            string json = await new StreamReader(req.Body).ReadToEndAsync();

            var stripeEvent = EventUtility.ConstructEvent(json, req.Headers["Stripe-Signature"], _apiSettings.Stripe.StripeWebHookTopic.DirectEndpointSecret);

            _logger.LogInformation("Retrieved the stripe event")
#

currently I am testing from the stripe dasbhoard by sending a test event

#

and it is failing with 400 error and error on the webhook listener is the one I have posted : "The signature for the webhook is not present in the Stripe-Signature header"

#

is it because req.Headers["Stripe-Signature"] is not there ?

harsh niche
#

Can you try logging the value in reqHeaders["Stripe-SIgnature"]? That would help

quiet radish
#

sure let me test it

quiet radish
#

i just started logging and all of suddently it started working too :), no other code changes. Not sure the root cause though 🙂