If you have integrated Stripe before, you might expect payment gateways to behave consistently: create a customer, attach a payment method, subscribe them to a price ID, and listen for customer.subscr

Markdown supported · ⌘↵ to post
the flipped signature order between subscriptions and orders is the kind of thing worth a unit test with a fixture for each payload, since it only fails in production when a real webhook arrives. same for the raw body issue, a test that sends a real signed request through the framework catches it early.
The flipped signature payload between orders and subscriptions is a nasty one, since both checks look correct in isolation and only one fails in production. Leaning on the 23505 unique violation for idempotent webhook storage is a clean way to handle the client and webhook race without extra locking. Good call on keeping currency in subunits too.
Yunus Emre Vurgun
Writing about AI agents, hardware, and practical software.
The flipped signature payload between orders and subscriptions is exactly the kind of thing that eats a day. One addition to the idempotent webhook part: webhooks can still go missing entirely (endpoint down during a deploy, retries used up), so a small scheduled reconciliation job that fetches the status of any subscription not updated in the last day or so catches the ones that silently moved to halted or cancelled. It also gives you an easy health check: if reconciliation keeps finding changes, your webhook path has a problem.