A limited discount code looks like a counter: "first N people get it". Then someone opens checkout, sees the payment form, and closes the tab. Did they use the code?
If you count that as a use, a handful of people who never paid can burn through the whole allowance and real customers get "code used up". If you don't count it, two people can both be mid-checkout on the last slot and both pay.
I hit this while building a launch discount for Freveo , a workspace for freelancers. The fix was to stop thinking of a redemption as a counter and give it a lifecycle.
A redemption has three states
export const DISCOUNT_REDEMPTION_STATUS = [ "pending" , "confirmed" , "released" ] as const ; export const DISCOUNT_RELEASE_REASONS = [ "expired" , "failed" , "staff" ] as const ;
Enter fullscreen mode
Exit fullscreen mode
pending : a hold.…