app/services/pro_membership_manager.rb
# Subscribe the user to the given plan using the given token. If they are a
# new subscriber, charge them immediately. If they are already pro and just
# switching plans then update their token, move them to the new plan and only
# charge them when their current subscription runs out, i.e. don't charge them
# right now.
Subscribe the user to the given plan using the given token. If they are a
new subscriber, charge them immediately. If they are already pro and just
switching plans then update their token, move them to the new plan and only
charge them when their current subscription runs out, i.e. don't charge them
right now.
Subscribe the user to the given plan using the given token . If they are a new subscriber charge them immediately . If they are already pro and just switching plans then update their token move them to the new plan and only charge them when their current subscription runs out i . e . don ' t charge them right now .
def subscribe!(plan, token)
    @user.update_attributes! pro_membership_plan_id: plan.id,
                             stripe_token: token
    unless @user.pro? && plan.recurring?
      charge_user! token, (plan.amount * 100).to_i
      give_pro! @user, plan.duration.months
    end
    ProMailer.delay.welcome_email(@user)
  end
def subscribe! ( plan , token ) @user . update_attributes! pro_membership_plan_id : plan . id , stripe_token : token unless @user . pro? && plan . recurring? charge_user! token , ( plan . amount * 100 ) . to_i give_pro! @user , plan . duration . months end ProMailer . delay . welcome_email ( @user ) end
Subscribe the user to the given plan using the given token.
Subscribe the user to the given plan using the given token .
plan
<not_specific>
token
<not_specific>