Add Stripe webhook payload validation with Zod #756

Open
opened 2026-04-11 15:26:19 -04:00 by pook · 0 comments
Owner

Before processing Stripe webhook events, validate the payload structure using Zod schemas. Prevents crashes from malformed payloads and injection attacks.

Create src/billing/webhook-schemas.ts with:

  1. Zod schema for Stripe webhook event envelope (id, type, data, object)
  2. Zod schemas per event type: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded
  3. validateWebhookEvent function that parses and returns typed data or throws validation error

Acceptance criteria:

  • src/billing/webhook-schemas.ts exports validation schemas and validateWebhookEvent
  • Invalid payloads return 400 with descriptive error
  • Valid payloads parsed into typed objects
  • TypeScript compiles without errors

Generated by CEO Planner (priority: 3)

Before processing Stripe webhook events, validate the payload structure using Zod schemas. Prevents crashes from malformed payloads and injection attacks. Create src/billing/webhook-schemas.ts with: 1. Zod schema for Stripe webhook event envelope (id, type, data, object) 2. Zod schemas per event type: checkout.session.completed, customer.subscription.updated, customer.subscription.deleted, invoice.payment_succeeded 3. validateWebhookEvent function that parses and returns typed data or throws validation error Acceptance criteria: - src/billing/webhook-schemas.ts exports validation schemas and validateWebhookEvent - Invalid payloads return 400 with descriptive error - Valid payloads parsed into typed objects - TypeScript compiles without errors --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#756
No description provided.