Hello,
When i have been building my application everything worked fine and no problems with stripe passing through webhooks to redwood API. Once Built to Vercel, the webhooks no longer work, and it's critical they do work!
if (event.httpMethod !== 'POST') {
return { statusCode: 404 }
}
// Check signing signature
const sig = event.headers['stripe-signature']
let stripeEvent
try {
stripeEvent = stripe.webhooks.constructEvent(event.body, sig, webhookSecret)
} catch (err) {
// On error, log and return the error message
// console.log(`Webhook Error message: ${err.message}`)
return {
statusCode: 400,
body: `Event Error: ${err.message}`,
}
}
stripe.webhooks.constructEvent wants event.body to be passed into it unparsed, (works fine on dev) but when pushed to production on Vercel. It seems some kind of processing is happening to the event.body meaning that stripe will not accept it.
to what I understand is that stripe wants rawJSON but something is parsing that JSON.
this would be the solution if bodyParser was used with express
app.use(bodyParser.json({
// Because Stripe needs the raw body, we compute it but only when hitting the Stripe callback URL.
verify: function(req,res,buf) {
var url = req.originalUrl;
if (url.startsWith('/stripe-webhooks')) {
req.rawBody = buf.toString()
}
}}));
Hello,
When i have been building my application everything worked fine and no problems with stripe passing through webhooks to redwood API. Once Built to Vercel, the webhooks no longer work, and it's critical they do work!
stripe.webhooks.constructEvent wants event.body to be passed into it unparsed, (works fine on dev) but when pushed to production on Vercel. It seems some kind of processing is happening to the event.body meaning that stripe will not accept it.
to what I understand is that stripe wants rawJSON but something is parsing that JSON.
this would be the solution if bodyParser was used with express