Sha256: fe02281c40846f00d4a4015df233789ac48bf80c59d08a80d76717b840355382

Contents?: true

Size: 562 Bytes

Versions: 3

Compression:

Stored size: 562 Bytes

Contents

module SolidusPaypalBraintree
  class ClientTokensController < Spree::Api::BaseController
    skip_before_action :authenticate_user

    before_action :load_gateway

    def create
      render json: { client_token: @gateway.generate_token, payment_method_id: @gateway.id }
    end

    private

    def load_gateway
      if params[:payment_method_id]
        @gateway = ::SolidusPaypalBraintree::Gateway.find_by!(id: params[:payment_method_id])
      else
        @gateway = ::SolidusPaypalBraintree::Gateway.find_by!(active: true)
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
solidus_paypal_braintree-0.3.0 app/controllers/solidus_paypal_braintree/client_tokens_controller.rb
solidus_paypal_braintree-0.2.0 app/controllers/solidus_paypal_braintree/client_tokens_controller.rb
solidus_paypal_braintree-0.1.0 app/controllers/solidus_paypal_braintree/client_tokens_controller.rb