Files
MatchLiveTv/backend/app/services/billing/stripe/plan_change_kind.rb
Emiliano Frascaro 566104aff4 Billing upgrade/downgrade, inviti in app e diretta YouTube da mobile.
Upgrade Stripe con addebito immediato; downgrade programmato a fine periodo.
UX billing più sobria con box info; icone piani. API inviti e OAuth YouTube
per staff trasmissione; deep link join; scelta partita programmata o nuova.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-06-02 22:15:27 +02:00

34 lines
834 B
Ruby

module Billing
module Stripe
module PlanChangeKind
module_function
def classify(from_plan_slug:, from_interval:, to_plan_slug:, to_interval:)
from_tier = Plan.tier(from_plan_slug)
to_tier = Plan.tier(to_plan_slug)
from_interval = PriceCatalog.normalize_interval(from_interval)
to_interval = PriceCatalog.normalize_interval(to_interval)
return :upgrade if to_tier > from_tier
return :downgrade if to_tier < from_tier
if from_interval == to_interval
:same
elsif to_interval == "yearly"
:upgrade
else
:downgrade
end
end
def upgrade?(**kwargs)
classify(**kwargs) == :upgrade
end
def downgrade?(**kwargs)
classify(**kwargs) == :downgrade
end
end
end
end