Class: SolidusBraintree::CheckoutsController

Inherits:
CheckoutsController
  • Object
show all
Defined in:
lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb

Constant Summary collapse

PERMITTED_PAYMENT_PARAMS =
[
  :payment_method_id,
  { source_attributes: [
    :nonce,
    :payment_type
  ] }
].freeze

Instance Method Summary collapse

Instance Method Details

#payment_paramsObject



23
24
25
26
27
28
29
# File 'lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb', line 23

def payment_params
  params.
    require(:order).
    require(:payments_attributes).
    first.
    permit(PERMITTED_PAYMENT_PARAMS)
end

#updateObject



13
14
15
16
17
18
19
20
21
# File 'lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb', line 13

def update
  @payment = ::Spree::PaymentCreate.new(@order, payment_params).build

  if @payment.save
    render plain: "ok"
  else
    render plain: "not-ok"
  end
end