Reuse StripeScaPaymentAuthorize in Admin::PaymentsController

This commit is contained in:
Matt-Yorkley
2021-12-16 20:28:43 +00:00
parent dbe4d61e57
commit 542e3ad1aa
2 changed files with 6 additions and 7 deletions

View File

@@ -174,15 +174,14 @@ module Spree
def authorize_stripe_sca_payment
return unless @payment.payment_method.instance_of?(Spree::Gateway::StripeSCA)
@payment.authorize!(full_order_path(@payment.order))
OrderManagement::Order::StripeScaPaymentAuthorize.
new(@order, payment: @payment, off_session: true).
call!(full_order_path(@order))
unless @payment.pending? || @payment.requires_authorization?
raise Spree::Core::GatewayError, I18n.t('authorization_failure')
end
raise Spree::Core::GatewayError, I18n.t('authorization_failure') if @order.errors.any?
return unless @payment.requires_authorization?
PaymentMailer.authorize_payment(@payment).deliver_later
raise Spree::Core::GatewayError, I18n.t('action_required')
end

View File

@@ -10,9 +10,9 @@ module OrderManagement
class StripeScaPaymentAuthorize
include FullUrlHelper
def initialize(order, off_session: false)
def initialize(order, payment: nil, off_session: false)
@order = order
@payment = OrderPaymentFinder.new(order).last_pending_payment
@payment = payment || OrderPaymentFinder.new(order).last_pending_payment
@off_session = off_session
end