stripe webhooks integration

#http-functions #stripe
If anyone is facing the following error when implementing stripe webhooks
Stripe webhook delivery issues for ‘your.domain.xyz’
The solution is:

export a ‘POST’ function from your http-functions.js. This is your webhook.
eg:- https://your.domain.xyz /_functions/name_of_your_function

Ensure you return status 200 as soon as your hook is called :
return response ({ status :200})
Failure to do so, will result in multiple retries from Stripe. You may receive email warnings like the one below:


We’ve attempted to send event notifications to this endpoint 182 times since the first failure on June 11, 2021 at 3:39:01 AM UTC. If this endpoint is important to your application, please try and fix the issue. If you do not need this webhook endpoint, you can remove it from your Stripe webhook settings . We will stop sending event notifications to this webhook endpoint by June 20, 2021 at 3:39:01 AM UTC.

Here is the summary of errors we received while attempting to send webhook events
182 requests returned HTTP 500, indicating a server error on your end.


export function post_stripehook ( request ) {

const signature = request . headers [ ‘stripe-signature’ ];
var event ;

return request . body . text (). then (( rawBody ) => {
try {
event = stripe . webhooks . constructEvent ( rawBody , signature , stripeConfigs . STRIPE_WEBHOOK_SECRET );
handleStripeHook ( event );

return response ( {
status : 200 });

} catch ( err ) {

        console . log ( "Error constructing event :" ,  err ); 
        console . log ( "Request  :" ,  request ); 

return serverError ({
status : 500 ,

});
}

})

}