Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def signup_unlimited_create
- @user = User.new(params[:user])
- @user.account_type = "Unlimited"
- @user.login = @user.email
- @number = params[:card_number]
- @month = params[:card_expiration_month]
- @year = params[:card_expiration_year]
- @type = params[:card_type]
- gateway = ActiveMerchant::Billing::BraintreeGateway.new({
- :login => 'demo',
- :password => 'demo'
- })
- if @user.errors.empty?
- if @number != "" and @month and "" and @year != "" and @type != ""
- @card = ActiveMerchant::Billing::CreditCard.new(:first_name => @user.first_name,
- :last_name => @user.last_name,
- :number => params[:card_number],
- :month => params[:card_expiration_month],
- :year => params[:card_expiration_year],
- :type => params[:card_type])
- @options = { :store => true, :order_id => "1212451" }
- response = gateway.authorize(1099.95, @card, @options)
- if @card.id != nil
- self.current_user = @user
- @user.credit_card_id = response.params["customer_vault_id"]
- end
- if @user.credit_card_id == nil
- flash[:notice] = "Please verify your credit card information below."
- render :action => 'signup_unlimited'
- end
- if @user.credit_card_id != nil
- @user.save
- @invoice = Invoice.new(params[:invoice])
- @invoice.amount = "9.95"
- @invoice.due_date = Date.today + 30
- @invoice.generated_date = Date.today
- @invoice.status = "Due"
- @invoice.user_id = @user.id
- @invoice.save
- self.current_user = @user
- flash[:notice] = "Thanks for signing up"
- redirect_to :action => 'index'
- end
- else
- flash[:notice] = "please fill out all credit card fields"
- render :action => 'signup_unlimited'
- end
- else
- flash[:notice] = "problem creating your account"
- render :action => 'signup_unlimited'
- end
- end
Add Comment
Please, Sign In to add comment