mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Simplify StripeScaPaymentAuthorize and clarify both return URL types (checkout and off-session)
This commit is contained in:
@@ -175,8 +175,7 @@ module Spree
|
||||
return unless @payment.payment_method.instance_of?(Spree::Gateway::StripeSCA)
|
||||
|
||||
OrderManagement::Order::StripeScaPaymentAuthorize.
|
||||
new(@order, payment: @payment, off_session: true).
|
||||
call!(full_order_path(@order))
|
||||
new(@order, payment: @payment, off_session: true).call!
|
||||
|
||||
raise Spree::Core::GatewayError, I18n.t('authorization_failure') if @order.errors.any?
|
||||
|
||||
|
||||
@@ -10,8 +10,4 @@ module FullUrlHelper
|
||||
def full_checkout_path
|
||||
URI.join(url_helpers.root_url, url_helpers.checkout_path).to_s
|
||||
end
|
||||
|
||||
def full_order_path(order)
|
||||
URI.join(url_helpers.root_url, url_helpers.order_path(order)).to_s
|
||||
end
|
||||
end
|
||||
|
||||
@@ -14,7 +14,7 @@ module Checkout
|
||||
def path
|
||||
return unless stripe_payment_method?
|
||||
|
||||
payment = payment_authorizer.call!(return_url)
|
||||
payment = payment_authorizer.call!(checkout_return_url)
|
||||
|
||||
return if order.errors.any?
|
||||
|
||||
@@ -33,7 +33,7 @@ module Checkout
|
||||
OrderManagement::Order::StripeScaPaymentAuthorize.new(order)
|
||||
end
|
||||
|
||||
def return_url
|
||||
def checkout_return_url
|
||||
payment_gateways_confirm_stripe_url
|
||||
end
|
||||
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
module OrderManagement
|
||||
module Order
|
||||
class StripeScaPaymentAuthorize
|
||||
include FullUrlHelper
|
||||
include Rails.application.routes.url_helpers
|
||||
|
||||
def initialize(order, payment: nil, off_session: false, notify_hub: false)
|
||||
@order = order
|
||||
@@ -17,10 +17,10 @@ module OrderManagement
|
||||
@notify_hub = notify_hub
|
||||
end
|
||||
|
||||
def call!(redirect_url = full_order_path(order))
|
||||
def call!(return_url = off_session_return_url)
|
||||
return unless payment&.checkout?
|
||||
|
||||
payment.authorize!(redirect_url)
|
||||
payment.authorize!(return_url)
|
||||
|
||||
order.errors.add(:base, I18n.t('authorization_failure')) unless successfully_processed?
|
||||
send_auth_emails if requires_authorization_emails?
|
||||
@@ -44,6 +44,10 @@ module OrderManagement
|
||||
PaymentMailer.authorize_payment(payment).deliver_now
|
||||
PaymentMailer.authorization_required(payment).deliver_now if notify_hub
|
||||
end
|
||||
|
||||
def off_session_return_url
|
||||
order_url(order)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user