Class: RefundsController

Inherits:
ArtfullyOseController show all
Defined in:
app/controllers/refunds_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/refunds_controller.rb', line 7

def create
  @order = Order.find(params[:order_id])
  @items = params[:items].collect { |item_id| Item.find(item_id) }

  @refund = Refund.new(@order, @items)
  @refund.submit(:and_return => return_items?, :send_email_confirmation => send_email_confirmation?)

  if @refund.successful?
    flash[:notice] = "Successfully refunded #{@refund.items.size} items."
  else
    if @refund.message.nil?
      flash[:error] = "Unable to refund items.  Please contact support and we'll try to help!"
    else
      flash[:error] = "Unable to refund items: " + @refund.message
    end
  end

  redirect_to order_url(@order)
end

#newObject



2
3
4
5
# File 'app/controllers/refunds_controller.rb', line 2

def new
  @order = Order.find(params[:order_id])
  @items = params[:items].collect { |item_id| Item.find(item_id) }
end