Skip to Content

The Stripe webhook now checks that requests come from Stripe

Shipped 2026-10-22

The Stripe webhook at /api/stripe-webhook trusted any request body. A made-up payment with no matching fee row passed the “already paid?” check and set the member in its metadata to Active. It also replied 200 before doing any work and never awaited it, so a database or Stripe error disappeared and Stripe counted the event as delivered.

What changed

  • Signatures. Every Stripe event must carry a valid stripe-signature, checked against STRIPE_WEBHOOK_SECRET over the raw request body. Anything else gets a 400. The checkout page’s confirmation call stays unsigned; it is safe because the API re-reads the payment intent from Stripe.
  • Event types. Only payment_intent.* and refund.created are processed. Everything else is logged and acknowledged.
  • Unknown payments. A payment intent with no fee row is skipped and logged, at error level when it succeeded.
  • One request does the follow-up. The fee row is claimed with a conditional UPDATE, so when the checkout page and Stripe report the same payment only one sends the receipt and counts the coupon. Succeeded and refunded rows are never re-applied, so a replayed success can’t reactivate a refunded member.
  • Failures are retried. The reply now waits for the work. A failure before the claim returns 500 and Stripe retries. The email, GA4 and Stripe description steps after the claim log stripe_webhook.step_failed instead.

Reconciliation

Before shipping, production fee rows from the last 12 months were compared with Stripe. No member had paid without being recorded, and no member was Active without a succeeded payment. One partial refund ($15 of $25) set the member Inactive, because a refund.created of any amount is treated as a full refund. That behaviour is unchanged here and has a follow-up.

  • Jira: TUN-902 
  • PR: [#?]
  • Author: @alexhobday
Last updated on