Class: Spree::PaymentsController

Inherits:
StoreController
  • Object
show all
Defined in:
app/controllers/spree/payments_controller.rb

Instance Method Summary collapse

Instance Method Details

#find_paymentObject



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

def find_payment
  @payment = if spree_current_user
    spree_current_user.payments.find_by(number: params[:id])
  else
    Payment.joins(:order).find_by(number: params[:id], spree_orders: { user_id: nil })
  end

  unless @payment
    flash[:error] = Spree.t(:payment_not_found)
    redirect_back(fallback_location: root_path)
  end
end

#updateObject



7
8
9
10
11
12
13
14
15
# File 'app/controllers/spree/payments_controller.rb', line 7

def update
  payment_details = Payment::BankUpdater.new(@payment, payment_params)
  if payment_details.update
    flash[:notice] = Spree.t(:payment_successfully_updated)
  else
    flash[:error] = payment_details.errors.to_sentence
  end
  redirect_back(fallback_location: root_path)
end