Module: EffectiveSubscriptionsHelper

Defined in:
app/helpers/effective_subscriptions_helper.rb

Instance Method Summary collapse

Instance Method Details

#customer_form_with(customer) ⇒ Object



25
26
27
28
29
30
31
32
# File 'app/helpers/effective_subscriptions_helper.rb', line 25

def customer_form_with(customer)
  raise 'form object must be an Effective::Customer object' unless customer.kind_of?(Effective::Customer)
  raise 'expected customer user to match current user' if customer.user != current_user

  subscripter = Effective::Subscripter.new(customer: customer, user: customer.user)

  render('effective/customers/form', subscripter: subscripter)
end

#subscribable_form_with(subscribable) ⇒ Object



16
17
18
19
20
21
22
23
# File 'app/helpers/effective_subscriptions_helper.rb', line 16

def subscribable_form_with(subscribable)
  raise 'form object must be an acts_as_subscribable object' unless subscribable.respond_to?(:subscripter)

  subscripter = subscribable.subscripter
  # raise 'subscribable.subscribable_buyer must match current_user' unless subscripter.user == current_user

  render('effective/subscripter/form', subscripter: subscripter)
end

#subscripter_stripe_data(subscripter) ⇒ Object



3
4
5
6
7
8
9
10
# File 'app/helpers/effective_subscriptions_helper.rb', line 3

def subscripter_stripe_data(subscripter)
  {
    email: current_user.email,
    image: stripe_site_image_url,
    key: EffectiveOrders.stripe[:publishable_key],
    name: EffectiveOrders.stripe[:site_title],
  }
end

#subscripter_stripe_plans(subscripter) ⇒ Object



12
13
14
# File 'app/helpers/effective_subscriptions_helper.rb', line 12

def subscripter_stripe_plans(subscripter)
  EffectiveOrders.stripe_plans
end