Sha256: 56e060c2c4b5010b137ca7417b0ff3f3eb67a867666218e1f25c0b394bb7d7cc

Contents?: true

Size: 1.25 KB

Versions: 1

Compression:

Stored size: 1.25 KB

Contents

class Kaui::RefundsController < ApplicationController
	def show
    @payment_id = params[:id]
    if @payment_id.present?
      data = Kaui::KillbillHelper::get_refunds_for_payment(@payment_id)
      if data.present?
        @refund = Kaui::Refund.new(data)
      else
        Rails.logger.warn("Did not get back refunds for the payment id #{response_body}")
      end
    else
      flash[:notice] = "No payment id given"
    end
  end

  def new
    @payment_id = params[:payment_id]
    @invoice_id = params[:invoice_id]
    @account_id = params[:account_id]

    @refund = Kaui::Refund.new('adjusted' => true)

    @account = Kaui::KillbillHelper::get_account(@account_id)
    @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
    @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
  end

  def create
    payment_id = params[:payment_id]
    account_id = params[:account_id]

    refund = Kaui::Refund.new(params[:refund])
    refund.adjusted = (refund.adjusted == "1")
    if refund.present?
      Kaui::KillbillHelper::create_refund(params[:payment_id], refund, params[:reason], params[:comment])
      redirect_to account_timeline_path(:id => params[:account_id])
    else
      flash[:error] = "No refund given to process"
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
kaui-0.0.2 app/controllers/kaui/refunds_controller.rb