Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Company::ProfileController < Company::BaseController
- def show
- end
- def update
- if !params[:company][:password].present? and !params[:company][:password_confirmation].present?
- params[:company].delete(:password)
- params[:company].delete(:password_confirmation)
- end
- # THIS IS A TERRIBLE SPOT FOR THIS LOGIC
- # BUT
- #REMOVED CODE TO ALLOW COUPONS and CARDS
- # if params[:stripeToken] || params[:stripe_coupon]
- # token = params[:stripeToken]
- # #must all be updated for company..
- # begin
- # #THIS NEEDS TO BE UPDATED TO HAVE THE USER CASE OF A PERSON WHO HAS USED A COUPON
- # # Company signs up for pro
- # customer = Stripe::Customer.create(
- # :card => token,
- # :plan => "sortboxpro",
- # :email => @company.email
- # )
- #start new coupon code
- if params[:stripeToken] || params[:stripe_coupon]
- stripe_params = {
- :plan => "sortboxpro",
- :email => @company.email
- }
- stripe_params[:card] = params[:stripeToken] if params[:stripeToken]
- stripe_params[:coupon] = params[:stripe_coupon] if params[:stripe_coupon].present?
- #must all be updated for company..
- begin
- # Company signs up for pro
- customer = Stripe::Customer.create(stripe_params)
- #end coupon code..
- @company.companypro = true
- @company.customerid = customer.id.to_s
- # abort if coupon doesn't exist
- rescue Stripe::InvalidRequestError => e
- @error = e
- flash[:alert] = "Your Coupon has Expired or is not Valid."
- rescue Stripe::CardError => e
- @error = e
- end
- end
- if @company.update_attributes(params[:company])
- flash[:notice] = "Updated successfuly"
- redirect_to company_profile_path
- else
- render :action => "show"
- end
- end
- #CORY this is where I have added the stripe info for subscription. I don't know if this is correct.
- def remove_subscription
- if @company.customerid
- cu = Stripe::Customer.retrieve(@company.customerid)
- if cu
- cu.cancel_subscription
- @company.customerid = nil
- @company.companypro = false
- @company.save
- end
- end
- redirect_to company_profile_path
- end
- #this is most likely dead code. SMELLY!!
- def submit
- if params[:stripeToken]
- token = params[:stripeToken]
- #must all be updated for company..
- begin
- # Company signs up for pro
- customer = Stripe::Customer.create(
- :card => token,
- :plan => "sortboxpro",
- :email => @company.email
- )
- @company.companypro = true
- @company.customerid = customer.id.to_s
- @company.save!
- rescue Stripe::CardError => e
- @error = e
- end
- end
- end
- end
- # class Company::ProfileController < Company::BaseController
- # def show
- # end
- #
- # def update
- # if !params[:company][:password].present? and !params[:company][:password_confirmation].present?
- # params[:company].delete(:password)
- # params[:company].delete(:password_confirmation)
- # end
- #
- # # THIS IS A TERRIBLE SPOT FOR THIS LOGIC
- # # BUT
- # #REMOVED CODE TO ALLOW COUPONS and CARDS
- # # if params[:stripeToken] || params[:stripe_coupon]
- # # token = params[:stripeToken]
- # # #must all be updated for company..
- # # begin
- # # #THIS NEEDS TO BE UPDATED TO HAVE THE USER CASE OF A PERSON WHO HAS USED A COUPON
- # # # Company signs up for pro
- # # customer = Stripe::Customer.create(
- # # :card => token,
- # # :plan => "sortboxpro",
- # # :email => @company.email
- # # )
- #
- # #start new coupon code
- # if params[:stripeToken] || params[:stripe_coupon]
- #
- # stripe_params = {
- # :plan => "sortboxpro",
- # :email => @company.email
- # }
- #
- # stripe_params[:card] = params[:stripeToken] if params[:stripeToken]
- # stripe_params[:coupon] = params[:stripe_coupon] if params[:stripe_coupon].present?
- #
- # #must all be updated for company..
- # begin
- # # Company signs up for pro
- # customer = Stripe::Customer.create(stripe_params)
- # #end coupon code..
- #
- #
- #
- #
- #
- #
- # @company.companypro = true
- # @company.customerid = customer.id.to_s
- #
- # rescue Stripe::CardError => e
- # @error = e
- # end
- # end
- #
- # if @company.update_attributes(params[:company])
- # #flash[:notice] = "Updated successfuly"
- # redirect_to company_profile_path
- # else
- # render :action => "show"
- # end
- # end
- # #CORY this is where I have added the stripe info for subscription. I don't know if this is correct.
- #
- # def remove_subscription
- # if @company.customerid
- # cu = Stripe::Customer.retrieve(@company.customerid)
- # if cu
- # cu.cancel_subscription
- # @company.customerid = nil
- # @company.companypro = false
- # @company.save
- # end
- # end
- # redirect_to company_profile_path
- # end
- #
- # #this is most likely dead code. SMELLY!!
- #
- # def submit
- # if params[:stripeToken]
- # token = params[:stripeToken]
- # #must all be updated for company..
- # begin
- #
- # # Company signs up for pro
- # customer = Stripe::Customer.create(
- # :card => token,
- # :plan => "sortboxpro",
- # :email => @company.email
- # )
- #
- # @company.companypro = true
- # @company.customerid = customer.id.to_s
- # @company.save!
- #
- # rescue Stripe::CardError => e
- # @error = e
- # end
- # end
- # end
- # end
Advertisement
Add Comment
Please, Sign In to add comment