Sha256: 9d870aefdc5b7b37b0c61a754bd23f51715e038db04fdf6fd7433b22a70cda43

Contents?: true

Size: 1.16 KB

Versions: 1

Compression:

Stored size: 1.16 KB

Contents

class Kaui::PaymentsController < Kaui::EngineController

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

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

  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], options_for_klient)
        flash[:notice] = "Payment created"
      rescue => e
        flash[:error] = "Error while creating a new payment: #{as_string(e)}"
      end
    end
    redirect_to kaui_engine.account_timeline_path(:id => payment.account_id)
  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaui-0.3.0 app/controllers/kaui/payments_controller.rb