Sha256: 0abb07e44d54977f3f9cf737d4a1f39d4abf4f9599e06f7871cd4d16df7d630e

Contents?: true

Size: 1.2 KB

Versions: 16

Compression:

Stored size: 1.2 KB

Contents

module Workarea
  module Api
    module Storefront
      class SavedCreditCardsController < Api::Storefront::ApplicationController
        before_action :set_payment_profile

        def index
          @credit_cards = @payment_profile.credit_cards
        end

        def show
          @credit_card = @payment_profile.credit_cards.find(params[:id])
        end

        def create
          @credit_card = @payment_profile.credit_cards.create!(card_params)
          render :show
        end

        def update
          @credit_card = @payment_profile.credit_cards.find(params[:id])

          @credit_card.update_attributes!(card_params)
          render :show
        end

        def destroy
          @payment_profile.credit_cards.find(params[:id]).destroy
          head :no_content
        end

        private

        def set_payment_profile
          @payment_profile ||= Payment::Profile.lookup(
            PaymentReference.new(current_user)
          )
        end

        def card_params
          params.permit(
            :first_name,
            :last_name,
            :number,
            :month,
            :year,
            :cvv,
            :default
          )
        end
      end
    end
  end
end

Version data entries

16 entries across 16 versions & 2 rubygems

Version Path
workarea-api-4.5.6 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.6 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.5.5 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.5 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.5.4 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.4 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.5.3 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.3 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.5.2 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.2 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.5.0 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.5.0 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.4.7 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.4.7 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-4.4.6 storefront/app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb
workarea-api-storefront-4.4.6 app/controllers/workarea/api/storefront/saved_credit_cards_controller.rb