Sha256: fff65b66f796aaeae44549a127f63396167aad8bd61e03abc1ec33dbaa913c25
Contents?: true
Size: 969 Bytes
Versions: 11
Compression:
Stored size: 969 Bytes
Contents
module Shoppe class PaymentsController < ApplicationController before_filter { @order = Shoppe::Order.find(params[:order_id]) } before_filter { params[:id] && @payment = @order.payments.find(params[:id]) } 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 def destroy @payment.destroy redirect_to @order, :notice => t('shoppe.payments.destroy_notice') end 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 end end
Version data entries
11 entries across 11 versions & 3 rubygems