= javascript_include_tag 'https://checkout.stripe.com/checkout.js'
- stripe = subscripter_stripe_data(subscripter)
- plans = subscripter_stripe_plans(subscripter)
- subscripter.quantity ||= subscripter.subscribable.subscribable_quantity_used
- subscripter.stripe_plan_id ||= Hash(plans.first)[:id]
= effective_form_with(model: subscripter, url: effective_orders.subscripter_path, remote: true, data: { stripe: stripe, plans: plans }) do |f|
= f.hidden_field :subscribable_global_id
= f.hidden_field :stripe_token, value: nil
= f.hidden_field :stripe_plan_id
= f.error :stripe_token
- if f.object.subscribable.subscribed?
- quantity_used = f.object.subscribable.subscribable_quantity_used.to_i
- quantity_purchased = f.object.subscribable.subscription.quantity
.text-center
%p
You currently have #{pluralize(quantity_used, 'member')} in your team
and have space for #{pluralize(quantity_purchased, 'member')}.
- if quantity_purchased > quantity_used
%p You can add #{pluralize(quantity_purchased - quantity_used, 'more member')} without updating your plan.
- else
%p To add more members you will need to update your plan.
%p To pay for less than #{pluralize(quantity_used, 'member')}, remove some team members first.
- else
.text-center
%p
You are not currently subscribed to any plan.
%br
For full access, upgrade to a paid plan below.
%br
To upgrade with fewer people, remove some team members first.
.card.mb-4
.card-body.card-subscripter
%h5.card-title.subscripter-title Billing Cycle
= f.radios :stripe_plan_id, plans.map { |plan| [plan[:name], plan[:id]] }, label: false, buttons: true
%hr.mt-4.mb-4
- plans.each do |plan|
= f.show_if(:stripe_plan_id, plan[:id]) do
= render 'effective/subscripter/plan', plan: plan, f: f
= f.submit(border: false, center: true) do
= f.save('Continue to Billing', class: ('effective-orders-stripe-token-required' if f.object.token_required?))