#arti-villa_error
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/1349025573137023018
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
app.post("/", async (c) => {
const signature = c.req.header("stripe-signature");
if (!signature) {
return c.json({ error: "Missing stripe-signature header" }, 400);
}
try {
const rawBody = await c.req.raw.clone().text();
const event = stripe.webhooks.constructEvent(
rawBody,
signature,
process.env.STRIPE_WEBHOOK_SECRET!
);
console.log('Received webhook event:', {
type: event.type,
id: event.id
});
/** types of events: https://docs.stripe.com/api/events/types */
switch (event.type) {
case 'checkout.session.completed':
await checkoutHandler.handleCompleted(event.data.object as Stripe.Checkout.Session);
break;
default:
console.log('Unhandled event type:', event.type);
}
return c.json({ received: true });
} catch (err) {
console.error('Webhook error:', err);
return c.json(
{ error: 'Webhook handler failed' },
err instanceof stripe.errors.StripeSignatureVerificationError ? 400 : 500
);
}
});
export default app;
nvm think i got it. it needs to be constructEventAsync and awaited. thanks.
Nice! Glad you could figure it out
the docs likely need to be updated.