Class: Shoppe::PaymentsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/shoppe/payments_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



7
8
9
10
11
12
13
14
# File 'app/controllers/shoppe/payments_controller.rb', line 7

def create
  payment = @order.payments.build(params[:payment].permit(:amount, :method, :reference))
  if payment.save
    redirect_to @order, :notice => t('shoppe.payments.create_notice')
  else
    redirect_to @order, :alert => payment.errors.full_messages.to_sentence
  end
end

#destroyObject



16
17
18
19
# File 'app/controllers/shoppe/payments_controller.rb', line 16

def destroy
  @payment.destroy
  redirect_to @order, :notice => t('shoppe.payments.destroy_notice')
end

#refundObject



21
22
23
24
25
26
27
28
29
30
# File 'app/controllers/shoppe/payments_controller.rb', line 21

def refund
  if request.post?
    @payment.refund!(params[:amount])
    redirect_to @order, :notice => t('shoppe.payments.refund_notice')
  else
    render :layout => false
  end
rescue Shoppe::Errors::RefundFailed => e
  redirect_to @order, :alert => e.message
end