From f9617b81561ed1ca28d306d6415f24da1ff5ae87 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 3 Feb 2026 12:51:02 +1100 Subject: [PATCH] Remove broken dead code branch The StripeSCA method is forwarding all missing methods to the provider gateway. The ActiveMerchant gateway used to be decorated by our code and that's how this code may have worked one day. But we removed the decorator years ago: - 549610bc355c2ad7b757e9f1013e125e0a4a9e90 A bit later we found that refunds are broken with Stripe: - https://github.com/openfoodfoundation/openfoodnetwork/issues/12843 This commit could potentiall fix that, I guess? I haven't tested that. It's a rare use case and not the aim of this work. --- app/models/spree/gateway/stripe_sca.rb | 6 ++++++ app/models/spree/payment/processing.rb | 19 +++++-------------- 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index 10253377bd..fc9768e670 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -106,6 +106,12 @@ module Spree provider.refund(money, payment_intent_id, gateway_options) end + # NOTE: this method is required by Spree::Payment::Processing + def refund(money, payment_intent_id, gateway_options) + gateway_options[:stripe_account] = stripe_account_id + provider.refund(money, payment_intent_id, gateway_options) + end + def create_profile(payment) return unless payment.source.gateway_customer_profile_id.nil? diff --git a/app/models/spree/payment/processing.rb b/app/models/spree/payment/processing.rb index 4a78e9f727..46a1e784fd 100644 --- a/app/models/spree/payment/processing.rb +++ b/app/models/spree/payment/processing.rb @@ -107,20 +107,11 @@ module Spree refund_amount = calculate_refund_amount(refund_amount) - response = if payment_method.payment_profiles_supported? - payment_method.refund( - (refund_amount * 100).round, - source, - response_code, - gateway_options - ) - else - payment_method.refund( - (refund_amount * 100).round, - response_code, - gateway_options - ) - end + response = payment_method.refund( + (refund_amount * 100).round, + response_code, + gateway_options + ) record_response(response)