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>
This commit is contained in:
33
backend/app/services/billing/stripe/plan_change_kind.rb
Normal file
33
backend/app/services/billing/stripe/plan_change_kind.rb
Normal file
@@ -0,0 +1,33 @@
|
||||
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
|
||||
Reference in New Issue
Block a user