Sha256: efb69dec84809b5e763e1a74faefcc1008a6278ac5ca81ebd1c457d9ac327d65

Contents?: true

Size: 631 Bytes

Versions: 4

Compression:

Stored size: 631 Bytes

Contents

# frozen_string_literal: true

module SolidusBraintree
  class CheckoutsController < CheckoutsController
    PERMITTED_PAYMENT_PARAMS = [
      :payment_method_id,
      { source_attributes: [
        :nonce,
        :payment_type
      ] }
    ].freeze

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

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

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

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
solidus_braintree-3.2.0 lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb
solidus_braintree-3.1.0 lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb
solidus_braintree-3.0.1 lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb
solidus_braintree-3.0.0 lib/generators/solidus_braintree/install/templates/app/controllers/solidus_braintree/checkouts_controller.rb