Menu

Stripe SaaS Webhooks Done Right: Why Client Redirects Are Not Payment Proof
📰

Stripe SaaS Webhooks Done Right: Why Client Redirects Are Not Payment Proof

DEV Community: typescript·AutoLab Systems·14 days ago
#yHYnOlqk
#devtotypescript#devto#dev#stripe#event
Reading 0:00
15s threshold

A classic SaaS bug is unlocking paid features when the user hits /checkout/success?session_id=... . Users can close the tab before redirecting—or replay parameters manually.

Always Fulfill Inside Verified Webhooks

Verify the cryptographic signature using the raw request buffer (not parsed JSON).

Store processed event.id values inside an atomic database transaction to prevent duplicate fulfillment when Stripe retries.

import Stripe from 'stripe'

const stripe = new Stripe ( process . env . STRIPE_SECRET_KEY ! )

export async function processWebhook ( rawBody : Buffer , sig : string ) { const event = stripe . webhooks . constructEvent ( rawBody , sig , process . env . STRIPE_WEBHOOK_SECRET ! ) // Check if event.id already exists in DB, then grant access atomically return { received : true , type : event .…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.