Class: Trade::Admin::RefundsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/trade/admin/refunds_controller.rb

Instance Method Summary collapse

Instance Method Details

#confirmObject



34
35
36
37
# File 'app/controllers/trade/admin/refunds_controller.rb', line 34

def confirm
  @refund.do_refund(operator_id: current_user.id, operator_type: current_user.class.name)
  redirect_to admin_refunds_url(order_id: @refund.order_id)
end

#createObject



18
19
20
21
22
23
24
# File 'app/controllers/trade/admin/refunds_controller.rb', line 18

def create
  @refund = Refund.new(refund_params)

  unless @refund.save
    render :new, locals: { model: @refund }, status: :unprocessable_entity
  end
end

#denyObject



39
40
41
42
# File 'app/controllers/trade/admin/refunds_controller.rb', line 39

def deny
  @refund.deny_refund(operator_id: current_user.id, operator_type: current_user.class.name)
  redirect_to admin_refunds_url(order_id: @refund.order_id)
end

#destroyObject



44
45
46
# File 'app/controllers/trade/admin/refunds_controller.rb', line 44

def destroy
  @refund.destroy
end

#editObject



15
16
# File 'app/controllers/trade/admin/refunds_controller.rb', line 15

def edit
end

#indexObject



4
5
6
# File 'app/controllers/trade/admin/refunds_controller.rb', line 4

def index
  @refunds = Refund.includes(:order, :payment).default_where(params.permit(:order_id, :payment_id)).page(params[:page])
end

#newObject



11
12
13
# File 'app/controllers/trade/admin/refunds_controller.rb', line 11

def new
  @refund = @payment.refunds.build
end

#showObject



8
9
# File 'app/controllers/trade/admin/refunds_controller.rb', line 8

def show
end

#updateObject



26
27
28
29
30
31
32
# File 'app/controllers/trade/admin/refunds_controller.rb', line 26

def update
  @refund.assign_attributes(refund_params)

  unless @refund.save
    render :new, locals: { model: @refund }, status: :unprocessable_entity
  end
end