Sha256: 8d520ba540a2dda83d0b1ce9d425138d37b8d8adfe830eb3e4e312998266c5e2

Contents?: true

Size: 1.56 KB

Versions: 5

Compression:

Stored size: 1.56 KB

Contents

class Kaui::ChargebacksController < Kaui::EngineController
  def show
    @payment_id = params[:id]
    if @payment_id.present?
      data = Kaui::KillbillHelper::get_chargebacks_for_payment(@payment_id)
      if data.present?
        @chargeback = Kaui::Chargeback.new(data)
      else
        Rails.logger.warn("Did not get back chargebacks #{response_body}")
      end
    else
      flash[:notice] = "No id given"
    end
  end

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

    # @payment_attempt = Kaui::KillbillHelper::get_payment_attempt(@external_key, @invoice_id, @payment_id)
    @account = Kaui::KillbillHelper::get_account(@account_id)
    # TODO: get payment by payment id (no api at the moment)
    @payment = Kaui::KillbillHelper::get_payment(@invoice_id, @payment_id)
    @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id)
    @chargeback = Kaui::Chargeback.new("payment_id" => @payment_id,
                                       "chargeback_amount" => @payment.amount)
  end

  def create
    account_id = params[:account_id]
    chargeback = Kaui::Chargeback.new(params[:chargeback])
    if chargeback.present?
      success = Kaui::KillbillHelper::create_chargeback(chargeback, params[:reason], params[:comment])
      if success
        flash[:info] = "Chargeback created"
      else
        flash[:error] = "Could not process chargeback"
      end
    else
      flash[:error] = "No chargeback to process"
    end
    redirect_to account_timeline_path(:id => params[:account_id])
  end


end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
kaui-0.0.7 app/controllers/kaui/chargebacks_controller.rb
kaui-0.0.6 app/controllers/kaui/chargebacks_controller.rb
kaui-0.0.5 app/controllers/kaui/chargebacks_controller.rb
kaui-0.0.4 app/controllers/kaui/chargebacks_controller.rb
kaui-0.0.3 app/controllers/kaui/chargebacks_controller.rb