Class: Store::CheckoutsController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/store/checkouts_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/store/checkouts_controller.rb', line 4

def create
  unless current_cart.unfinished?
    render :json => "This order is already finished!", :status => :unprocessable_entity and return
  end

  @payment = CreditCardPayment.new(params[:payment])
  @payment.user_agreement = params[:payment][:user_agreement]
  current_cart.special_instructions = special_instructions
  
  @checkout = Checkout.new(current_cart, @payment)
  
  if @checkout.valid? && @checkout.finish
    @order = @checkout.order
    render :thanks and return
  else      
    flash[:error] = @checkout.message
    redirect_to store_order_path(params[:payment][:customer])
  end
rescue Exception => e
  Exceptional.context(:params => filter(params))
  Exceptional.handle(e, "Checkout failed!")    
  Rails.logger.error(e.backtrace)
  Rails.logger.error(e.message)
  flash[:error]  = "We're sorry but we could not process the sale.  Please make sure all fields are filled out accurately"
  flash[:notice] = "We've processed your donation, however we could not process your tickets." if @fafs_success
  redirect_to store_order_path    
end

#dookObject



38
39
40
41
# File 'app/controllers/store/checkouts_controller.rb', line 38

def dook
  @order = Order.find(18975)
  render :thanks
end

#filter(params) ⇒ Object



32
33
34
35
36
# File 'app/controllers/store/checkouts_controller.rb', line 32

def filter(params)
  filters = Rails.application.config.filter_parameters
  f = ActionDispatch::Http::ParameterFilter.new filters
  f.filter params
end