Browse/Stripe/Webhook Signature Verification
Webhook Signature Verification
Stripe
Free sample
Verify incoming webhook events and parse the payload safely.
webhook-handler.ts
import Stripe from "stripe";
export async function POST(req: Request) {
const sig = req.headers.get("stripe-signature")!;
const body = await req.text();
const event = stripe.webhooks.constructEvent(
body, sig, process.env.STRIPE_WEBHOOK_SECRET!
);
switch (event.type) {
case "checkout.session.completed":
await fulfillOrder(event.data.object);
break;
}
return new Response("ok", { status: 200 });
}
Webhook Signature Verification — Stripe Example (TypeScript, Node, Python, Go, PHP, Ruby) | apiexamples