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

Version Path
shoppe-1.1.2 app/controllers/shoppe/payments_controller.rb
shoppe-1.1.1 app/controllers/shoppe/payments_controller.rb
shoppe-1.1.0 app/controllers/shoppe/payments_controller.rb
shoppe-1.0.9 app/controllers/shoppe/payments_controller.rb
shoppe-1.0.8 app/controllers/shoppe/payments_controller.rb
kylekthompson-shoppe-1.0.7 app/controllers/shoppe/payments_controller.rb
shoppe-1.0.7 app/controllers/shoppe/payments_controller.rb
shoppe-1.0.6 app/controllers/shoppe/payments_controller.rb
shoppe-paypal-1.1.0 vendor/bundle/ruby/2.1.0/gems/shoppe-1.0.5/app/controllers/shoppe/payments_controller.rb
shoppe-1.0.5 app/controllers/shoppe/payments_controller.rb
shoppe-1.0.3 app/controllers/shoppe/payments_controller.rb