Sha256: 6793cf768846f100c411e0cb1ac450fd60d4006b0d344f9342c75e722511cf69

Contents?: true

Size: 989 Bytes

Versions: 18

Compression:

Stored size: 989 Bytes

Contents

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

  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

  private

  def send_email_confirmation?
    params[:send_email_confirmation] == "1"
  end

  def return_items?
    params[:return_to_inventory] == "1"
  end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
artfully_ose-1.3.0.pre4 app/controllers/refunds_controller.rb
artfully_ose-1.3.0.pre3 app/controllers/refunds_controller.rb
artfully_ose-1.3.0.pre2 app/controllers/refunds_controller.rb
artfully_ose-1.3.0.pre1 app/controllers/refunds_controller.rb
artfully_ose-1.2.0 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.beta.1 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.alpha.2 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.alpha.1 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.27 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.26 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.24 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.23 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.21 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.20 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.19 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.18 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.17 app/controllers/refunds_controller.rb
artfully_ose-1.2.0.pre.16 app/controllers/refunds_controller.rb