Production SaaS Billing Out-of-Order Webhook State Machine, Idempotency Lock & 31-Decline-Code Smart Dunning Engine Kit (Node.js + n8n + CSV/JSON)
When Stripe, Paddle, or Polar.sh sends customer.subscription.updated 4 seconds BEFORE customer.subscription.created over HTTP, a naive switch(event.type) webhook handler overwrites the customer's active upgrade with stale incomplete state—or triggers $15 Visa/Mastercard network penalties by auto-retrying hard-declined fraudulent, stolen_card, or expired_card renewals.
Included in this production codebase, n8n workflow, and dataset kit: