Class: Spree::Admin::PaymentPaywayCheckersController

Inherits:
PaymentPaywayBaseController show all
Includes:
Backend::Callbacks
Defined in:
app/controllers/spree/admin/payment_payway_checkers_controller.rb

Instance Method Summary collapse

Methods inherited from PaymentPaywayBaseController

#load_payment, #model_class, #validate_order

Instance Method Details

#payment_request_update_serviceObject



25
26
27
28
29
30
31
# File 'app/controllers/spree/admin/payment_payway_checkers_controller.rb', line 25

def payment_request_update_service
  if @payment.payment_method.type_payway_v2?
    Vpago::PaywayV2::PaymentRequestUpdater
  elsif @payment.payment_method.type_payway?
    Vpago::Payway::PaymentRequestUpdater
  end
end

#updateObject



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
# File 'app/controllers/spree/admin/payment_payway_checkers_controller.rb', line 6

def update
  options = {
    updated_by_user_id: try_spree_current_user.id,
    updated_reason: Spree.t('vpago.payments.checker_updated_by_description')
  }
  spree_updater = payment_request_update_service.new(@payment, options)
  spree_updater.call

  @payment.reload

  if @payment.order.completed?
    flash[:success] = Spree.t(:successfully_updated, resource: Spree.t(:payments))
  else
    flash[:error] = Spree.t(:unsuccessfully_updated, resource: Spree.t(:payments))
  end

  redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
end