Method: Reji::ManagesSubscriptions#subscribed_to_plan

Defined in:
lib/reji/concerns/manages_subscriptions.rb

#subscribed_to_plan(plans, name = 'default') ⇒ Object

Determine if the Stripe model is actively subscribed to one of the given plans.



57
58
59
60
61
62
63
64
65
66
67
68
69
# File 'lib/reji/concerns/manages_subscriptions.rb', line 57

def subscribed_to_plan(plans, name = 'default')
  subscription = self.subscription(name)

  return false unless subscription&.valid?

  plans = [plans] unless plans.instance_of? Array

  plans.each do |plan|
    return true if subscription.plan?(plan)
  end

  false
end