Module: Effective::Providers::Cheque

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

Instance Method Summary collapse

Instance Method Details

#pay_by_chequeObject



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

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

  @order.purchase_state = EffectiveOrders::PENDING
  @order.payment_provider = 'cheque'

  EffectiveOrders.authorized?(self, :update, @order)

  @page_title = 'Payment Required'

  if @order.save
    @order.send_pending_order_invoice_to_buyer!
    current_cart.try(:destroy)
    flash.now[:success] = 'Successfully indicated order will be payed by cheque.'
  else
    flash[:danger] = "Unable to save your order: #{@order.errors.full_messages.to_sentence}. Please try again."
    redirect_to effective_orders.order_path(@order)
    return
  end

  render 'effective/orders/cheque/pay_by_cheque'
end