Class: Spree::Admin::PaymentPaywayMarkersController
Instance Method Summary
collapse
#load_payment, #model_class, #validate_order
Instance Method Details
#status_marker_service ⇒ Object
35
36
37
38
39
40
41
|
# File 'app/controllers/spree/admin/payment_payway_markers_controller.rb', line 35
def status_marker_service
if @payment.payment_method.type_payway_v2?
Vpago::PaymentStatusMarker
elsif @payment.payment_method.type_payway?
Vpago::Payway::PaymentStatusMarker
end
end
|
#update ⇒ Object
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'app/controllers/spree/admin/payment_payway_markers_controller.rb', line 6
def update
reason = params[:updated_reason]&.strip
if reason.blank?
flash[:error] = Spree.t('vpago.payments.failed_require_updated_reason')
return redirect_to admin_order_payment_path(order_id: @payment.order.number, id: @payment.number)
end
options = {
updated_by_user_id: try_spree_current_user.id,
updated_reason: reason,
status: true,
description: 'vpago.payments.mark_with_reason'
}
spree_updater = status_marker_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
|