Class: Storefront::AffirmController

Inherits:
ApplicationController
  • Object
show all
Includes:
CurrentCheckout
Defined in:
app/controllers/workarea/affirm_controller.rb

Instance Method Summary collapse

Instance Method Details

#completeObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/workarea/affirm_controller.rb', line 7

def complete
  check_inventory || return
  current_order.user_id = current_user.try(:id)

  Workarea::Affirm::Update.new(
    current_checkout,
    params[:checkout_token]
  ).apply

  Pricing.perform(current_order, current_shipping)
  current_checkout.payment.adjust_tender_amounts(current_order.total_price)

  if current_checkout.place_order && current_checkout.payment.affirm.details['total'] == current_checkout.payment.affirm.amount.cents
    completed_place_order
  else
    incomplete_place_order
  end
end