Spec the subscription webhook that grants plan access

Vibe codingMedium25 minStripe style

Your task

Your app sells monthly plans through Stripe Billing. Today a nightly script updates each account's access, so a customer who pays at 9 am waits until midnight. You want a webhook to keep every account's plan in step with Stripe, and a coding agent will build it.

Write the spec you would hand the agent.

What you know:

  • Python 3.12, FastAPI, Postgres and the official stripe package
  • each Stripe customer carries metadata.account_id, which matches accounts.id
  • accounts has plan, access_until and stripe_subscription_id columns, and the app grants the paid plan while access_until is in the future
  • a failed renewal keeps access for a 7-day grace period, then the account drops to the free plan

Then, in a few sentences: what would "update the account when a subscription webhook arrives" get wrong?