Sha256: 693b3d21e4a5c173106a8ceaa689f69776721fec65f566ea3e4c5016ca9df594

Contents?: true

Size: 885 Bytes

Versions: 4

Compression:

Stored size: 885 Bytes

Contents

module Effective
  module Providers
    module Free
      extend ActiveSupport::Concern

      def free
        raise('free provider is not available') unless EffectiveOrders.free?

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

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

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

        order_purchased(
          payment: 'free order. no payment required.',
          provider: 'free',
          card: 'none',
          purchased_url: free_params[:purchased_url],
          declined_url: free_params[:declined_url],
          email: false
        )
      end

      def free_params
        params.require(:free).permit(:purchased_url, :declined_url)
      end

    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
effective_orders-5.0.2 app/controllers/effective/providers/free.rb
effective_orders-5.0.1 app/controllers/effective/providers/free.rb
effective_orders-4.6.1 app/controllers/effective/providers/free.rb
effective_orders-5.0.0 app/controllers/effective/providers/free.rb