Class: Kaui::ChargebacksController
- Inherits:
-
EngineController
- Object
- ApplicationController
- EngineController
- Kaui::ChargebacksController
- Defined in:
- app/controllers/kaui/chargebacks_controller.rb
Instance Method Summary collapse
Methods inherited from EngineController
Methods included from ErrorHelper
Instance Method Details
#create ⇒ Object
40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'app/controllers/kaui/chargebacks_controller.rb', line 40 def create account_id = params[:account_id] chargeback = Kaui::Chargeback.new(params[:chargeback]) if chargeback.present? begin Kaui::KillbillHelper::create_chargeback(chargeback, params[:reason], params[:comment]) flash[:info] = "Chargeback created" rescue => e flash[:error] = "Error while creating a new chargeback: #{as_string(e)}" end else flash[:error] = "No chargeback to process" end redirect_to kaui_engine.account_timeline_path(:id => params[:account_id]) end |
#new ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'app/controllers/kaui/chargebacks_controller.rb', line 21 def new @payment_id = params[:payment_id] @account_id = params[:account_id] @invoice_id = params[:invoice_id] begin @account = Kaui::KillbillHelper::get_account(@account_id) @payment = Kaui::KillbillHelper::get_payment(@payment_id) @invoice = Kaui::KillbillHelper::get_invoice(@invoice_id) @payment_method = Kaui::KillbillHelper::get_payment_method(@payment.payment_method_id) rescue => e flash[:error] = "Error while starting a new chargeback: #{as_string(e)}" redirect_to kaui_engine.account_timeline_path(:id => params[:account_id]) end @chargeback = Kaui::Chargeback.new("paymentId" => @payment_id, "chargebackAmount" => @payment.amount) end |
#show ⇒ Object
3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
# File 'app/controllers/kaui/chargebacks_controller.rb', line 3 def show @payment_id = params[:id] if @payment_id.present? begin data = Kaui::KillbillHelper::get_chargebacks_for_payment(@payment_id) rescue => e flash[:error] = "Error while getting chargeback information: #{as_string(e)}" end 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 |