mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Reuse StripeScaPaymentAuthorize in Admin::PaymentsController
This commit is contained in:
@@ -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
|
||||
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user