Stripe Webhooks and AWS-S3 function call issue

The stripe issue seems to be fixed now as the following is working for me

exports = async function(req, response) {
    const stripe = require('stripe')(context.values.get('STRIPE_API_KEY'));
    const { headers, body} = req;
    const endpointSecret = context.values.get('STRIPE_WEBHOOK_SECRET')

        // Get the signature sent by Stripe
        const signature = headers['Stripe-Signature'][0]

        try {
            event = stripe.webhooks.constructEvent(
                body.text(),
                signature,
                endpointSecret
            );
            console.log('body-text worked')
        } catch (err) {
            console.log(`️body-text  Webhook signature verification failed.`, err.message);
            console.error(err)

            response.setStatusCode(400);
            return response
        }
    
    response.setStatusCode(200);
    return response;
};

3 Likes