Class: Spree::Admin::PaymentWingSdkCheckersController

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

Instance Method Summary collapse

Methods inherited from PaymentWingSdkBaseController

#load_payment, #validate_order

Instance Method Details

#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_wing_sdk_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 = Vpago::WingSdk::PaymentRequestUpdater.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