Class: Kaui::TransactionsController

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

Constant Summary

Constants included from EngineControllerUtil

EngineControllerUtil::SIMPLE_PAGINATION_THRESHOLD

Instance Method Summary collapse

Methods inherited from EngineController

#check_for_redirect_to_tenant_screen, #current_ability, #current_user, #options_for_klient, #populate_account_details, #retrieve_allowed_users_for_current_user, #retrieve_tenants_for_current_user

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/kaui/transactions_controller.rb', line 24

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

  plugin_properties = params[:plugin_properties].values.select{ |item| !(item['value'].blank? || item['key'].blank?) } unless params[:plugin_properties].blank?
  plugin_properties.map! do |property|
    KillBillClient::Model::PluginPropertyAttributes.new(property)
  end unless plugin_properties.blank?

  options = plugin_properties.blank? ? options_for_klient : ({:pluginProperty => plugin_properties}).merge(options_for_klient)

  control_plugin_names = params[:control_plugin_names].select{ |item| !item.blank? } unless params[:control_plugin_names].blank?
  options.merge!({:controlPluginNames => control_plugin_names}) unless control_plugin_names.blank?

  payment = transaction.create(params.require(:account_id), params[:payment_method_id], current_user.kb_username, params[:reason], params[:comment], options)
  redirect_to kaui_engine.(payment., payment.payment_id), :notice => 'Transaction successfully created'
end

#fix_transaction_stateObject



41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/kaui/transactions_controller.rb', line 41

def fix_transaction_state
  transaction = Kaui::Transaction.new(params[:transaction].delete_if { |key, value| value.blank? })
  payment_id = transaction.payment_id
  transaction_id = transaction.transaction_id
  transaction_status = transaction.status

  Kaui::Admin.fix_transaction_state(payment_id, transaction_id, transaction_status, current_user.kb_username, params[:reason], params[:comment], options_for_klient)

  redirect_to kaui_engine.(params.require(:account_id), payment_id), :notice => "Transaction successfully transitioned to #{transaction_status}"
end

#newObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# File 'app/controllers/kaui/transactions_controller.rb', line 8

def new
  @account_id = params[:account_id]
  @payment_method_id = params[:payment_method_id]

  transaction_id = params[:transaction_id].presence
  if transaction_id.nil?
    @transaction = Kaui::Transaction.new(:payment_id => params[:payment_id],
                                         :amount => params[:amount],
                                         :currency => params[:currency],
                                         :transaction_type => params[:transaction_type])
  else
    payment = Kaui::Payment.find_by_transaction_id(transaction_id, false, false, options_for_klient)
    @transaction = Kaui::Transaction.build_from_raw_transaction(payment.transactions.find { |tx| tx.transaction_id == transaction_id })
  end
end

#restful_showObject



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

def restful_show
  payment = Kaui::Payment.find_by_transaction_id(params.require(:id), false, true, options_for_klient)
  redirect_to (payment., payment.payment_id)
end