Sha256: 3df5d71d607af50e36d87144160b8ad629c942dcad05f10952c1580ed1c08aae

Contents?: true

Size: 1.17 KB

Versions: 16

Compression:

Stored size: 1.17 KB

Contents

module Effective
  module Providers
    module MarkAsPaid
      extend ActiveSupport::Concern

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

        @order ||= Order.deep.find(params[:id])
        @order.current_user = nil # Admin action, we don't want to assign current_user to the order

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

        @order.assign_attributes(mark_as_paid_params.except(:payment_provider, :payment_card))

        order_purchased(
          payment: 'mark as paid',
          provider: mark_as_paid_params[:payment_provider],
          card: mark_as_paid_params[:payment_card],
          email: @order.send_mark_as_paid_email_to_buyer?,
          skip_buyer_validations: true,
          purchased_url: effective_orders.admin_order_path(@order)
        )
      end

      def mark_as_paid_params
        params.require(:effective_order).permit(
          :purchased_at, :payment_provider, :payment_card,
          :note_to_buyer, :note_internal, :send_mark_as_paid_email_to_buyer
        )
      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/mark_as_paid.rb
effective_orders-6.19.0 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.18.4 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.18.3 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.18.2 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.18.1 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.18.0 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.17.2 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.17.1 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.17.0 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.16.4 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.16.3 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.16.2 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.16.1 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.16.0 app/controllers/effective/providers/mark_as_paid.rb
effective_orders-6.15.0 app/controllers/effective/providers/mark_as_paid.rb