#ebenezer-owusu_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1341832849191469068
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hi ๐
What is the exact error you receive?
What code are you using to handle webhook requests?
Time Out Error.
event = stripe.webhooks.constructEvent(bodyBuffer, sig, process.env.STRIPE_WEBHOOK_SECRET);
Error on this line. The API runs without returning a response.
It returns a 200 response when commented
const sig = request.headers['stripe-signature'];
if (!sig) {
context.log.error('Missing Stripe signature header');
return { status: 400, body: 'Missing Stripe signature' };
}
let event;
const rawBody = await request.text(); // Read raw body from the request
const bodyBuffer = Buffer.from(rawBody, 'utf8');
try {
event = stripe.webhooks.constructEvent(bodyBuffer, sig, process.env.STRIPE_WEBHOOK_SECRET);
} catch (err) {
context.log.error(`Webhook Error: ${err.message}`);
return {
status: 400,
body: `Webhook Error: ${err.message}`,
};
}
// Process event in the background
processStripeEventAsync(event, context);
// Return 200 response to acknowledge receipt
return {
status: 200,
body: 'Webhook received successfully',
headers: { 'Content-Type': 'application/json' },
};
Hi, taking over as my teammate needs to step away. Let me catch up
okay
What does 'Error on this line. The API runs without returning a response.
It returns a 200 response when commented' mean?
When I comment this - event = stripe.webhooks.constructEvent(bodyBuffer, sig, process.env.STRIPE_WEBHOOK_SECRET);
I see this event, https://dashboard.stripe.com/events/evt_1Qu1zp2BmsN6YOnarCXa77sF for instance is timed out as you're not returning 200 right away. We document here, https://docs.stripe.com/webhooks#webhook-endpoint-def that you need to quickly return 200. Here is our recommended integration: https://docs.stripe.com/webhooks/quickstart