fix-with-ai · STRIPE-WEBHOOK-001
Copy prompt<!-- pulselight prompt v2 --> Goal: Verify Stripe webhook signatures before processing events. The `/api/stripe/webhook` route currently parses the body and trusts event.type without calling stripe.webhooks.constructEvent(). Affected files: - app/api/stripe/webhook/route.ts (line 22) Working rules (enforced): - Read raw body, NOT request.json(), so the signature can be verified against the literal bytes Stripe signed. - Use STRIPE_WEBHOOK_SECRET from env. Do not hardcode. - Reject with 400 on signature failure; do NOT log the body. Do NOT: - Migrate Stripe SDK versions. - Touch other route handlers. - Change the response shape. Validation steps: - Run: pnpm test apps/api -t webhook - Confirm: invalid-signature request returns 400, not 200. - Confirm: valid event still flips subscription_status. Output a unified diff. Summarise what changed in 3 bullets.