diff --git a/app/helpers/full_url_helper.rb b/app/helpers/full_url_helper.rb new file mode 100644 index 0000000000..e3bd833346 --- /dev/null +++ b/app/helpers/full_url_helper.rb @@ -0,0 +1,17 @@ +# frozen_string_literal: true + +module FullUrlHelper + def url_helpers + # This is how we can get the helpers with a usable root_url outside the controllers + Rails.application.routes.default_url_options = ActionMailer::Base.default_url_options + Rails.application.routes.url_helpers + end + + 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 diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index 351adf019d..a2fcc94717 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -10,6 +10,8 @@ require 'active_merchant/billing/gateways/stripe_decorator' module Spree class Gateway class StripeSCA < Gateway + include FullUrlHelper + preference :enterprise_id, :integer validate :ensure_enterprise_selected @@ -145,16 +147,6 @@ module Spree errors.add(:stripe_account_owner, I18n.t(:error_required)) end - - def full_checkout_path - URI.join(url_helpers.root_url, url_helpers.checkout_path).to_s - end - - def url_helpers - # This is how we can get the helpers with a usable root_url outside the controllers - Rails.application.routes.default_url_options = ActionMailer::Base.default_url_options - Rails.application.routes.url_helpers - end end end end