app/controllers/sales_controller.rb in artfully_ose-1.2.0.pre.23 vs app/controllers/sales_controller.rb in artfully_ose-1.2.0.pre.24

- old
+ new

@@ -28,25 +28,25 @@ flash[:error] = @sale.error Ticket.unlock(@sale.tickets, @sale.cart) render :js => "window.location = '#{new_event_show_sales_path(@event, @show)}'" return end - + render :json => @sale.as_json .merge(:total => @sale.cart.total) .merge(:tickets_remaining => tickets_remaining) - .merge(:door_list_rows => door_list_rows), + .merge(:door_list_rows => door_list_rows), :status => 200 end def checking_out? !params[:commit].blank? end - + def door_list_rows door_list_rows = [] - + @sale.tickets.each_with_index do |ticket, i| ticket.reload if ticket.sold? || ticket.comped? door_list_rows[i] = {} door_list_rows[i]['first_name'] = @sale.buyer.first_name @@ -69,11 +69,11 @@ @sale.ticket_types.each do |ticket_type| remaining[ticket_type.id] = ticket_type.available("box_office") end remaining end - + def setup_defaults params[:anonymous] = true params[:cash] = true params[:credit_card] = {} end @@ -106,52 +106,52 @@ def person return @person unless @person.nil? #if there's a person_id, use find @person = Person.find(params[:person][:id]) unless params[:person][:id].blank? - + if user_entered_nothing? @person = @dummy else @person = Person.first_or_create(person_attributes) end - + @person end def person_attributes { :id => params[:person][:id], :first_name => params[:person][:first_name], :last_name => params[:person][:last_name], :email => params[:person][:email], - :organization => current_organization + :organization => current_organization } end def user_entered_nothing? params[:person][:id].blank? && params[:person][:first_name].blank? && params[:person][:last_name].blank? && params[:person][:email].blank? end - def payment + def payment if Swiper.can_parse? params[:credit_card][:number] swiped_data = Swiper.parse(params[:credit_card][:number]) params[:credit_card][:name] = swiped_data.track1.cardholder_name params[:credit_card][:number] = swiped_data.track1.primary_account_number params[:credit_card][:month] = swiped_data.track1.expiration_month params[:credit_card][:year] = swiped_data.track1.expiration_year end - + params[:benefactor] = current_user - + payment = Payment.create(params[:payment_method], params) payment.customer = person payment end - + def has_card_info? params[:credit_card].present? and params[:credit_card][:card_number].present? end end