spree_paypal_express/app/controllers/admin/paypal_payments_controller.rb

44 lines
1.0 KiB
Ruby
Raw Normal View History

class Admin::PaypalPaymentsController < Admin::BaseController
resource_controller
belongs_to :order
ssl_required
2010-01-28 16:48:01 +00:00
# to allow capture (NB also included in checkout controller...)
include Spree::PaypalExpress
def capture
2010-01-28 16:48:01 +00:00
load_object
if !@order.paypal_payments.empty? && (payment = @order.paypal_payments.last).can_capture?
2010-01-28 16:48:01 +00:00
paypal_capture(payment.find_authorization)
flash[:notice] = t("paypal_capture_complete")
else
flash[:error] = t("unable_to_capture_paypal")
end
2010-01-28 16:48:01 +00:00
redirect_to edit_admin_order_payment_url(@order, @paypal_payment)
end
2010-01-28 16:48:01 +00:00
def refund
load_object
2010-01-28 16:48:01 +00:00
if params.has_key? :amount
2010-01-28 16:48:01 +00:00
if !@order.paypal_payments.empty?
payment = @order.paypal_payments.first
paypal_refund(payment.find_capture, params[:amount].to_f)
flash[:notice] = t("paypal_refund_complete")
else
flash[:error] = t("unable_to_refund_paypal")
end
redirect_to edit_admin_order_payment_url(@order, @paypal_payment)
end
end
2010-01-28 16:48:01 +00:00
end