Class: Kaui::TransactionsController

Inherits:
EngineController show all
Defined in:
app/controllers/kaui/transactions_controller.rb

Instance Method Summary collapse

Methods inherited from EngineController

#current_ability, #current_user, #options_for_klient

Instance Method Details

#createObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'app/controllers/kaui/transactions_controller.rb', line 12

def create
  @account_id        = params[:account_id]
  @payment_method_id = params[:payment_method_id]
  @transaction       = Kaui::Transaction.new(params[:transaction].delete_if { |key, value| value.blank? })

  begin
    payment = @transaction.create(@account_id, @payment_method_id, current_user.kb_username, params[:reason], params[:comment], options_for_klient)
    redirect_to kaui_engine.(:id => payment.), :notice => 'Transaction successfully created'
  rescue => e
    flash.now[:error] = "Error while creating a new transaction: #{as_string(e)}"
    render :action => :new
  end
end

#newObject



3
4
5
6
7
8
9
10
# File 'app/controllers/kaui/transactions_controller.rb', line 3

def new
  @account_id        = params[:account_id]
  @payment_method_id = params[:payment_method_id]
  @transaction       = Kaui::Transaction.new(:payment_id       => params[:payment_id],
                                             :amount           => params[:amount],
                                             :currency         => params[:currency],
                                             :transaction_type => params[:transaction_type])
end