-
Notifications
You must be signed in to change notification settings - Fork 650
Apply discounts to existing subscriptions #8780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
server/migrations/versions/2026-01-06-1200_add_discount_applied_at_to_subscriptions.py
Show resolved
Hide resolved
frankie567
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great, makes a lot of sense :) Good to go!!
The discount expiration logic was using subscription.started_at as the reference point, which caused discounts applied mid-subscription to expire immediately (since started_at could be months in the past). This commit: - Adds discount_applied_at field to track when a discount was first applied to a billing cycle - Updates is_repetition_expired() to use discount_applied_at instead of subscription.started_at - Sets discount_applied_at at checkout for non-trial subscriptions - Sets discount_applied_at on first cycle() for mid-subscription discount applications - Updates subscription.amount immediately when discount is assigned (already handled by existing event listener)
Verifies that when a discount is applied at checkout with a trial period: - discount_applied_at remains null during the trial - discount_applied_at is set on the first billing cycle after trial ends - The discount duration is counted from the first billing cycle, not trial start
Populates discount_applied_at for existing subscriptions by finding the first order that used each subscription's current discount.
a9dc25a to
77b3c29
Compare
|
Issue #8714.
Replaced #8776.
Original PR description: