class TbCommerce::CheckoutController < ApplicationController before_action :require_cart_not_empty before_action :load_current_order, :only => [:billing] def new @order = TbCommerce::Order.new() if current_user @order.email = current_user.email end render 'new' end def billing if tb_commerce_current_cart.order.blank? redirect_to tb_commerce_checkout_path and return end @credit_card = TbCommerce::CreditCard.new() if !Rails.env.production? # These values will work against the Stripe sandbox environment @credit_card.card_number = 4242424242424242 @credit_card.card_ccv = 123 @credit_card.card_expiration = Date.today.next_year end render 'billing' end private def require_cart_not_empty if tb_commerce_current_cart.cart_is_empty? flash[:notice] = 'You cannot check out with an empty cart' redirect_to tb_commerce_cart_path return false end end def load_current_order @order = TbCommerce::Order.find_by!(:cart => tb_commerce_current_cart) end end