bug: failed payment consumes Early Bird offer without reverting it on failure
Summary
A user attempted to subscribe to the $8/mo Basic plan using the Early Bird discount. The payment failed, but when they retried, the Early Bird offer was no longer available — the failed payment attempt appears to have consumed/redeemed the offer without reverting it on failure.
Steps to Reproduce
- Go to tinyhumans.ai → Plans
- Select Basic plan with Early Bird offer applied (EARLYBIRDY code)
- Attempt payment — payment fails
- Retry checkout — Early Bird discount is no longer available / already consumed
Expected Behaviour
A failed payment should not consume a discount offer. If the payment does not complete successfully, any applied promo/early bird redemption should be fully reversed so the user can retry with the same offer.
Actual Behaviour
The Early Bird discount slot was consumed by the failed payment attempt. The user cannot retry with the discounted price and is now being asked to pay full price ($19.99/mo) instead of the early bird rate ($7.99/mo).
Impact
- User locked out of Early Bird pricing they were entitled to
- Potentially affects other early adopters who experienced payment failures during checkout
- Affected user details available internally via support team
Required Actions
- Manually restore Early Bird eligibility for the affected user so they can purchase at $7.99/mo (contact support team for user details)
- Fix the offer redemption logic — promo codes/early bird slots must only be marked as used after a payment successfully settles, not on initiation
- Audit other users who may have lost Early Bird eligibility due to failed payments
Root cause analysis
Confirmed this is a redemption-accounting bug, and the "offer no longer available on retry" symptom is global promotion-code exhaustion, not a per-user flag.
How the offer actually works today
EARLYBIRDY is not tracked in our own database — it's a native Stripe promotion code
with a max_redemptions cap. The backend only resolves the code and attaches it to the
Checkout Session at checkout time; Stripe owns the counter:
createSubscriptionCheckoutattachesdiscounts: [{ promotion_code }]to the session (backend-alphahuman/src/services/stripe/subscription.ts:73-79).resolvePromotionCodeIdjust lists active codes — it returnsnullwhen the code is unknown/expired/exhausted (subscription.ts:24-36).
Why the slot got consumed by a failed payment
Stripe increments times_redeemed when the subscription is created with the discount
applied (at checkout completion), not when the first charge settles. In this case the
first invoice failed afterwards — most likely a 3DS/SCA or async path where the
subscription is created incomplete, the slot is counted at that creation, and the
authenticated charge then fails. The backend's failure handler
(handleInvoicePaymentFailed, controllers/payment/stripe/handleWebhook.ts:786-826)
only demotes + cancels the subscription — it never reads metadata.couponCode and Stripe
exposes no API to decrement times_redeemed. So the slot stays burned.
Why retry showed full price
On retry, resolvePromotionCodeId("EARLYBIRDY") now finds the code at/over its
max_redemptions → returns empty → the discount is silently dropped and the session is
created at full price. (This silent fallback is documented behavior — see
routes/payment/stripe.ts:36-39.) So the failed attempt ate a global slot, and the next
genuine purchase — including this user's retry — sees it as gone.
To verify (read-only, in Stripe)
- Retrieve the EARLYBIRDY promotion code → compare
times_redeemedvsmax_redemptions. - List
[email protected]'s customer → subscriptions → expect anincomplete/incomplete_expired/canceled sub with the discount applied and no paid invoice; check the PaymentIntentlast_payment_errorto confirm the failure path.
Resolved — fixed by backend #1014 (merged dcd2e379 on 2026-06-24)
The triage premise on this ticket — "a failed payment consumed the Early Bird offer" — turned out to be incorrect. A read-only audit of the live database + Stripe showed EARLYBIRDY at 746 / 1000 redemptions, still active. The actual overcharging mechanism is different:
When a repeat payer (typically an accidental double click on subscribe) checks out again with a first-time-customer-only promotion code (EARLYBIRDY), Stripe rejects the code, the backend silently drops it and creates a second subscription at full price ($19.99/mo), and nothing stops duplicate concurrent subscriptions. One affected customer was holding 4 active $19.99 subs simultaneously for what should have been a single $8 plan.
Audit signal (51 most recent sign-ups)
| Got the $8 discount | Charged full $19.99 | |
|---|---|---|
| Repeat payer | 0 | 10 |
| Brand-new customer | 41 | 0 |
9 of the 10 full-price repeat-payer cases hold concurrent duplicate subscriptions today.
What #1014 changed
- New
ApiErrorCodesALREADY_SUBSCRIBEDandPROMO_CODE_INVALID. purchasePlanrefuses a second Checkout Session withALREADY_SUBSCRIBED(+ current plan/expiry) whenteam.subscription.hasActiveSubscription === true. Stops the duplicate-sub creation that was driving ~9 of every 10 overcharges.createSubscriptionCheckoutsurfacesPROMO_CODE_INVALIDwhen a suppliedcouponCodecannot be applied (confirmed-missing code OR Stripe rejects the discount mid-create on afirst-time customer onlyrestriction). The pre-#3899 silent full-price fallback is removed. Real Stripe outages propagate as 500s througherrorHandler/Sentry, not as user-facing 400s.- 6 new service tests + 2 new controller tests; Swagger updated.
Closing this — follow-ups tracked separately
The code side is done. The remaining work touches Stripe Dashboard config, billing ops, and adjacent code surfaces; each is filed as its own issue so it doesn't get lost in a closed ticket:
- Stripe config + refunds (ops/billing + leadership decisions): EARLYBIRDY first-time-only restriction, $8 first-month vs ongoing, Tier A ($159.92, 5 customers / 8 charges) + Tier B (up to $250.13 pending one verification) refunds + duplicate-sub cancellations. → see follow-up issue.
- Persist Stripe subscription invoices to our DB (RCA item #4 — almost no sub invoices currently land in the
Paymentcollection, which is why the duplicate-sub pattern went unnoticed for so long). → see follow-up issue. - Frontend handling of
ALREADY_SUBSCRIBED(route to portal) andPROMO_CODE_INVALID(inline error). Existing generic toast is an acceptable stopgap. - #3866 ($28 charged with no subscription + UNAUTHORIZED auth errors) is a different bug, already fixed by #1005 — staying open until the reporter is refunded and the prod deploy is verified.
The earlier "incomplete-sub burns the slot via 3DS/SCA" theory on this thread is inconsistent with what the live data shows (slot at 746/1000 — healthy — and every full-price victim is a repeat payer, not the 3DS-failure population). Different mechanism; #1014 addresses the actual one.
Closing.