Sha256: 45f254738692cdb29c240e68a1a5410bfd99378f6edea0c3d3eb7299a2cd7b83

Contents?: true

Size: 639 Bytes

Versions: 1

Compression:

Stored size: 639 Bytes

Contents

# frozen_string_literal: true

module SolidusBraintree
  class CheckoutsController < ::Spree::CheckoutController
    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

1 entries across 1 versions & 1 rubygems

Version Path
solidus_braintree-2.0.0 lib/controllers/frontend/solidus_braintree/checkouts_controller.rb