Sha256: 668794c0ebcbb61acabb66990a1c9a046ed69ac9cebb497285aa0d884d4c174d

Contents?: true

Size: 645 Bytes

Versions: 5

Compression:

Stored size: 645 Bytes

Contents

# frozen_string_literal: true

module SolidusPaypalBraintree
  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

5 entries across 5 versions & 1 rubygems

Version Path
solidus_paypal_braintree-1.2.0 lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb
solidus_paypal_braintree-1.1.2 lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb
solidus_paypal_braintree-1.1.1 lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb
solidus_paypal_braintree-1.1.0 lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb
solidus_paypal_braintree-1.0.0 lib/controllers/frontend/solidus_paypal_braintree/checkouts_controller.rb