Billing Stripe, link regia mobile e staff solo trasmissione.
Aggiunge fatturazione club, pagina regia condivisibile senza account, roster squadre e rimuove la modalità controller dall'app (v1.1.0). Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
29
backend/app/helpers/public/billing_helper.rb
Normal file
29
backend/app/helpers/public/billing_helper.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
module Public
|
||||
module BillingHelper
|
||||
def plan_billing_action(current_slug:, target_plan:, stripe_subscription_active:)
|
||||
return { kind: :current, label: "Piano attuale" } if current_slug == target_plan.slug
|
||||
|
||||
if target_plan.slug == "free"
|
||||
return { kind: :contact, label: "Contatta il supporto per downgrade." }
|
||||
end
|
||||
|
||||
unless MatchLiveTv.stripe_enabled?
|
||||
return { kind: :disabled, label: "Stripe non configurato" }
|
||||
end
|
||||
|
||||
if current_slug == "free" || !stripe_subscription_active
|
||||
return { kind: :checkout, label: "Attiva #{target_plan.name}" }
|
||||
end
|
||||
|
||||
if Plan.tier(target_plan.slug) > Plan.tier(current_slug)
|
||||
{ kind: :change, label: "Passa a #{target_plan.name}" }
|
||||
else
|
||||
{ kind: :change, label: "Passa a #{target_plan.name}" }
|
||||
end
|
||||
end
|
||||
|
||||
def stripe_subscription_active?(subscription)
|
||||
subscription&.stripe_subscription_id.present? && subscription.active?
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user