Class: Kaui::PaymentsController

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

Instance Method Summary collapse

Methods inherited from EngineController

#current_user

Methods included from ErrorHelper

#as_string

Instance Method Details

#createObject



17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'app/controllers/kaui/payments_controller.rb', line 17

def create
  payment = Kaui::Payment.new(params[:payment])
  if payment.present?
    payment.external = (payment.external == "1")
    begin
      Kaui::KillbillHelper::create_payment(payment, payment.external, current_user, params[:reason], params[:comment])
      flash[:info] = "Payment created"
    rescue => e
      flash[:error] = "Error while creating a new payment: #{as_string(e)}"
    end
  end
  redirect_to kaui_engine.(:id => payment.)
end

#newObject



3
4
5
6
7
8
9
10
11
12
13
14
15
# File 'app/controllers/kaui/payments_controller.rb', line 3

def new
  @account_id = params[:account_id]
  @invoice_id = params[:invoice_id]
  begin
    @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
    @account = Kaui::KillbillHelper::(@account_id)
  rescue => e
    flash[:error] = "Error while creating a new payment: #{as_string(e)}"
    redirect_to kaui_engine.(:id => payment.)
  end

  @payment = Kaui::Payment.new("accountId" => @account_id, "invoiceId" => @invoice_id, "amount" => @invoice.balance)
end