From e87965bda02434d2976b2308ba1b4d91f5701813 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 3 Feb 2026 11:23:38 +1100 Subject: [PATCH] Simplify storing of payment profiles StripeSCA is the only payment method storing profiles following this logic. This is the first step to remove indirection and let the payment method handle this instead of the payment decided for the payment method. --- app/models/spree/payment.rb | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/app/models/spree/payment.rb b/app/models/spree/payment.rb index da38a29665..5df898136b 100644 --- a/app/models/spree/payment.rb +++ b/app/models/spree/payment.rb @@ -34,7 +34,7 @@ module Spree # invalidate previously entered payments after_create :invalidate_old_payments - after_save :create_payment_profile, if: :profiles_supported? + after_save :create_payment_profile # update the order totals, etc. after_save :ensure_correct_adjustment, :update_order @@ -217,18 +217,13 @@ module Spree errors.blank? end - def profiles_supported? - payment_method.respond_to?(:payment_profiles_supported?) && - payment_method.payment_profiles_supported? - end - def create_payment_profile return unless source.is_a?(CreditCard) return unless source.try(:save_requested_by_customer?) return unless source.number || source.gateway_payment_profile_id return unless source.gateway_customer_profile_id.nil? - payment_method.create_profile(self) + payment_method.try(:create_profile, self) rescue ActiveMerchant::ConnectionError => e gateway_error e end