Sha256: 97ef983113155b7f6f8b04d74bb17c9fe549e1e491a82e40c8c488dd21aa90a4
Contents?: true
Size: 1.31 KB
Versions: 14
Compression:
Stored size: 1.31 KB
Contents
module Effective module Providers module Cheque extend ActiveSupport::Concern def pay_by_cheque @order ||= Order.find(params[:id]) @page_title = 'Payment Required' EffectiveOrders.authorize!(self, :update, @order) @order.purchase_state = EffectiveOrders::PENDING @order.payment_provider = 'cheque' begin @order.save! @order.send_pending_order_invoice_to_buyer! Effective::Cart.where(user_id: @order.user_id).destroy_all message = "Successfully indicated order will be payed by cheque. A pending order invoice has been sent to #{@order.user.email}" # When posted from admin form, there will be a redirect url if params[:purchased_url].present? flash[:success] = message redirect_to params[:purchased_url].gsub(':id', @order.to_param.to_s) else # Otherwise this is the user flow flash.now[:success] = message render 'effective/orders/cheque/pay_by_cheque' end rescue => e flash[:danger] = "Unable to save your order: #{@order.errors.full_messages.to_sentence}. Please try again." redirect_to params[:declined_url].presence || effective_orders.order_path(@order) end end end end end
Version data entries
14 entries across 14 versions & 1 rubygems