Sha256: 45c4eda4de7b5674c5633c5db093da1a59d6ad1e5430a4a335ff350a248fcbff

Contents?: true

Size: 1.05 KB

Versions: 16

Compression:

Stored size: 1.05 KB

Contents

module Effective
  module Providers
    module Refund
      extend ActiveSupport::Concern

      def refund
        raise('refund provider is not available') unless EffectiveOrders.refund?
        raise('refund provider is not configured for buyer purchase') unless EffectiveOrders.buyer_purchases_refund?

        @order ||= Order.deep.find(params[:id])
        @order.current_user = current_user unless admin_checkout?(refund_params)

        EffectiveResources.authorize!(self, :update, @order)

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

        flash[:success] = EffectiveOrders.refund[:success].presence

        order_purchased(
          payment: 'refund. no payment required.',
          provider: 'refund',
          purchased_url: refund_params[:purchased_url]
        )
      end

      def refund_params
        params.require(:refund).permit(:purchased_url, :declined_url)
      end

    end
  end
end

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
effective_orders-6.19.1 app/controllers/effective/providers/refund.rb
effective_orders-6.19.0 app/controllers/effective/providers/refund.rb
effective_orders-6.18.4 app/controllers/effective/providers/refund.rb
effective_orders-6.18.3 app/controllers/effective/providers/refund.rb
effective_orders-6.18.2 app/controllers/effective/providers/refund.rb
effective_orders-6.18.1 app/controllers/effective/providers/refund.rb
effective_orders-6.18.0 app/controllers/effective/providers/refund.rb
effective_orders-6.17.2 app/controllers/effective/providers/refund.rb
effective_orders-6.17.1 app/controllers/effective/providers/refund.rb
effective_orders-6.17.0 app/controllers/effective/providers/refund.rb
effective_orders-6.16.4 app/controllers/effective/providers/refund.rb
effective_orders-6.16.3 app/controllers/effective/providers/refund.rb
effective_orders-6.16.2 app/controllers/effective/providers/refund.rb
effective_orders-6.16.1 app/controllers/effective/providers/refund.rb
effective_orders-6.16.0 app/controllers/effective/providers/refund.rb
effective_orders-6.15.0 app/controllers/effective/providers/refund.rb