Sha256: 51a2d6c4b5735b4584232c888f6d43a409a2308d36a0f1131eb73bdaf4479a1f

Contents?: true

Size: 1.26 KB

Versions: 42

Compression:

Stored size: 1.26 KB

Contents

module Effective
  module Providers
    module Refund
      extend ActiveSupport::Concern

      def refund
        @order ||= Order.find(params[:id])

        EffectiveOrders.authorize!(self, :update, @order)
        EffectiveOrders.authorize!(self, :admin, :effective_orders)

        unless @order.refund?
          flash[:danger] = 'Unable to process refund with a non-negative total'
          redirect_to effective_orders.admin_order_path(@order)
          return
        end

        @order.assign_attributes(refund_params.except(:payment, :payment_provider, :payment_card))

        order_purchased(
          payment: refund_params[:payment],
          provider: refund_params[:payment_provider],
          card: refund_params[:payment_card],
          email: @order.send_mark_as_paid_email_to_buyer?,
          skip_buyer_validations: true,
          purchased_url: params[:purchased_url].presence || effective_orders.admin_order_path(@order),
          declined_url: params[:declined_url].presence || effective_orders.admin_order_path(@order)
        )
      end

      def refund_params
        params.require(:effective_order).permit(
          :payment, :payment_provider, :payment_card, :note_to_buyer, :send_mark_as_paid_email_to_buyer
        )
      end

    end
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
effective_orders-4.3.2 app/controllers/effective/providers/refund.rb
effective_orders-4.3.1 app/controllers/effective/providers/refund.rb
effective_orders-4.3.0 app/controllers/effective/providers/refund.rb
effective_orders-4.2.7 app/controllers/effective/providers/refund.rb
effective_orders-4.2.6 app/controllers/effective/providers/refund.rb
effective_orders-4.2.5 app/controllers/effective/providers/refund.rb
effective_orders-4.2.4 app/controllers/effective/providers/refund.rb
effective_orders-4.2.3 app/controllers/effective/providers/refund.rb
effective_orders-4.2.2 app/controllers/effective/providers/refund.rb
effective_orders-4.2.1 app/controllers/effective/providers/refund.rb
effective_orders-4.2.0 app/controllers/effective/providers/refund.rb
effective_orders-4.1.5 app/controllers/effective/providers/refund.rb
effective_orders-4.1.4 app/controllers/effective/providers/refund.rb
effective_orders-4.1.3 app/controllers/effective/providers/refund.rb
effective_orders-4.1.2 app/controllers/effective/providers/refund.rb
effective_orders-4.1.1 app/controllers/effective/providers/refund.rb
effective_orders-4.1.0 app/controllers/effective/providers/refund.rb
effective_orders-4.0.6 app/controllers/effective/providers/refund.rb
effective_orders-4.0.5 app/controllers/effective/providers/refund.rb
effective_orders-4.0.4 app/controllers/effective/providers/refund.rb