fix(billing): eliminate pack-token overwrite by collapsing to single mutateBillingDb per webhook
The old pattern called mutateBillingDb twice per webhook event — once to apply the business change (e.g. add pack tokens) and once to mark the event as processed. With eventual consistency, the second load could return the pre-write state and save it back, silently zeroing out pack token balances that had just been credited.
Subscription events survived because Stripe fires follow-up events (customer.subscription.updated) that re-apply the tier; one-time pack payments have no follow-up, so their balance stayed at 0.
Fix: separate async preparation (Stripe API calls, token resolution) from synchronous blob mutation. Each webhook now performs exactly one mutateBillingDb call that atomically applies the business change AND marks the event processed in the same read-modify-write cycle.
0 comments
muse hub commit comment sha256:84e61e3868d56741f0944bd54cc564e53d5bb3a5d2ce6d7bd8ed4bd033d5c0f2 --body "your comment"
No comments yet. Be the first to start the discussion.