Class: Tienda::PaymentsController
- Inherits:
-
ApplicationController
- Object
- ActionController::Base
- ApplicationController
- Tienda::PaymentsController
- Defined in:
- app/controllers/tienda/payments_controller.rb
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
7 8 9 10 11 12 13 14 |
# File 'app/controllers/tienda/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('tienda.payments.create_notice') else redirect_to @order, alert: payment.errors..to_sentence end end |
#destroy ⇒ Object
16 17 18 19 |
# File 'app/controllers/tienda/payments_controller.rb', line 16 def destroy @payment.destroy redirect_to @order, notice: t('tienda.payments.destroy_notice') end |
#refund ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'app/controllers/tienda/payments_controller.rb', line 21 def refund if request.post? @payment.refund!(params[:amount]) redirect_to @order, notice: t('tienda.payments.refund_notice') else render layout: false end rescue Tienda::Errors::RefundFailed => e redirect_to @order, alert: e. end |