Module: Effective::Providers::MarkAsPaid

Extended by:
ActiveSupport::Concern
Included in:
OrdersController
Defined in:
app/controllers/effective/providers/mark_as_paid.rb

Instance Method Summary collapse

Instance Method Details

#mark_as_paidObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/effective/providers/mark_as_paid.rb', line 6

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

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

  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),
    current_user: nil # Admin action, we don't want to assign current_user to the order
  )
end

#mark_as_paid_paramsObject



27
28
29
30
31
32
# File 'app/controllers/effective/providers/mark_as_paid.rb', line 27

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