Sha256: ec703d93e2baab231d2e92c08bf0a697eaeb8e898ef9b74e8190b92b3e6873d9
Contents?: true
Size: 1.13 KB
Versions: 38
Compression:
Stored size: 1.13 KB
Contents
require_dependency "wbase/application_controller" module Wbase class SubscriptionsController < ApplicationController before_action :require_login! layout 'wbase/auth' def new if current_user.trial? redirect_to '/' return end if params[:plan] current_user.selected_plan = params[:plan] current_user.save end end def create # Does the user have a subscription? # - if so see if it matches the planid that was passed service = StartSubscription.new(current_user, subscription_params) service.call if service.valid? login(service.user) AdminMailer.new_subscription(service.user).deliver_later ActivateDripSubscriberJob.perform_later(service.user) redirect_to '/subscribed' else flash.now[:errors] = service.errors render :new end end private def subscription_params params .require(:subscription) .permit( :plan_id, :stripe_id, :credit_card_token, :card_type, :last_four ) end end end
Version data entries
38 entries across 38 versions & 1 rubygems