module Billing
  class AssignPlan
    def self.call(club:, plan_slug:, status: "active", stripe_attrs: {})
      plan = Plan[plan_slug]
      sub = club.subscription || club.build_subscription
      attrs = { plan: plan, status: status }.merge(stripe_attrs.symbolize_keys)
      sub.assign_attributes(attrs)
      sub.save!
      sub
    end
  end
end
