Sha256: 610740f953e43a2106626df98694066697ccc6e8480767aee0dfda71ba5f7385

Contents?: true

Size: 681 Bytes

Versions: 1

Compression:

Stored size: 681 Bytes

Contents

require_dependency "tang/application_controller"

module Tang
  class Account::CardsController < Account::ApplicationController
    before_action :set_card, only: [:show]
    
    def show
    end

    def new
      @card = Card.new(
        customer: current_customer
      )
    end

    def create
      @card = SaveCard.call(
        current_customer, 
        params[:stripe_token]
      )

      if @card.errors.blank?
        redirect_to account_card_path, notice: 'Card was successfully created.'
      else
        render :new
      end
    end

    private

    def set_card
      @card = current_customer.card
    end

    def card_params
      params
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tang-0.0.1 app/controllers/tang/account/cards_controller.rb