app/controllers/shop_controller.rb
# called when address is ok and order already saved
# includes possible charge with previous credit card if the checkbox was clicked
called when address is ok and order already saved
includes possible charge with previous credit card if the checkbox was clicked
called when address is ok and order already saved includes possible charge with previous credit card if the checkbox was clicked
def process_order
    new_basket
    OrderMailer.confirm(@order).deliver_now
    session[:order] = @order.id
    notice = t(:thanks)
    unless(params[:use_card].blank?)
      charge = has_charge(current_clerk)
      begin
        charge_customer charge.customer , @order
        notice += "<br/>" + t(:paid)
      rescue Stripe::StripeError => e 
        notice += "<br/>" + e.message
      end
    end
    redirect_to shop_order_path, :notice => notice
  end
def process_order new_basket OrderMailer . confirm ( @order ) . deliver_now session [ :order ] = @order . id notice = t ( :thanks ) unless ( params [ :use_card ] . blank? ) charge = has_charge ( current_clerk ) begin charge_customer charge . customer , @order notice += "<br/>" + t ( :paid ) rescue Stripe :: StripeError => e notice += "<br/>" + e . message end end redirect_to shop_order_path , :notice => notice end
called when address is ok and order already saved
includes possible charge with previous credit card if the checkbox was clicked
called when address is ok and order already saved includes possible charge with previous credit card if the checkbox was clicked
# nothing must escape, CardError is just a subset