Class: Checkout::ConfirmController

Inherits:
CheckoutController
  • Object
show all
Defined in:
app/controllers/gemgento/checkout/confirm_controller.rb

Instance Method Summary collapse

Instance Method Details

#showObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/gemgento/checkout/confirm_controller.rb', line 7

def show
  @quote.payment.assign_attributes(session[:payment_data]) if @quote.payment && session[:payment_data]
  @shipping_method = get_magento_shipping_method

  respond_to do |format|
    format.html
    format.json { render json: { order: @quote, shipping_method: @shipping_method, totals: @quote.totals } }
  end
end

#updateObject



17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'app/controllers/gemgento/checkout/confirm_controller.rb', line 17

def update
  @quote.payment.update(session[:payment_data]) if @quote.payment && session[:payment_data]

  respond_to do |format|
    if @quote.convert(request.remote_ip)
      session[:order_increment_id] = @quote.order_increment_id
      session.delete :payment_data

      if !@quote.payment.is_redirecting_payment_method?('confirm_after')
        format.html { redirect_to checkout_thank_you_path }
        format.json { render json: { result: true, order: @quote.order } }

      else
        format.html { redirect_to confirm_after_redirect_url }
        format.json { render json: { result: true, payment_redirect_url: confirm_after_redirect_url } }
      end
    else
      @shipping_method = get_magento_shipping_method
      format.html { render 'show' }
      format.json { render json: { result: false, errors: @quote.errors }, status: 422 }
    end
  end

end