Sha256: ea69d08fa25fe01be1367d574fc025866e89303c925c09cec37e8318ee74289b

Contents?: true

Size: 1.1 KB

Versions: 21

Compression:

Stored size: 1.1 KB

Contents

module EffectiveSubscriptionsHelper

  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

  def subscripter_stripe_plans(subscripter)
    EffectiveOrders.stripe_plans
  end

  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

  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

end

Version data entries

21 entries across 21 versions & 1 rubygems

Version Path
effective_orders-4.4.2 app/helpers/effective_subscriptions_helper.rb