From 2749965e73ac5b2fded95dc5541394996636fef6 Mon Sep 17 00:00:00 2001 From: Maikel Linke Date: Tue, 3 Feb 2026 11:28:15 +1100 Subject: [PATCH] Remove useless branch calling #void StripeSCA is the only method with a different method signature for `#void` but the additional parameter wasn't used. So this special case can just be removed. --- app/models/spree/gateway/stripe_sca.rb | 2 +- app/models/spree/payment/processing.rb | 11 +---------- spec/models/spree/gateway/stripe_sca_spec.rb | 4 ++-- spec/models/spree/payment_spec.rb | 5 ++--- 4 files changed, 6 insertions(+), 16 deletions(-) diff --git a/app/models/spree/gateway/stripe_sca.rb b/app/models/spree/gateway/stripe_sca.rb index 78e658ab9c..feea5eda54 100644 --- a/app/models/spree/gateway/stripe_sca.rb +++ b/app/models/spree/gateway/stripe_sca.rb @@ -84,7 +84,7 @@ module Spree end # NOTE: this method is required by Spree::Payment::Processing - def void(payment_intent_id, _creditcard, gateway_options) + def void(payment_intent_id, gateway_options) payment_intent_response = Stripe::PaymentIntent.retrieve( payment_intent_id, stripe_account: stripe_account_id ) diff --git a/app/models/spree/payment/processing.rb b/app/models/spree/payment/processing.rb index 599a562097..dccc339cac 100644 --- a/app/models/spree/payment/processing.rb +++ b/app/models/spree/payment/processing.rb @@ -58,16 +58,7 @@ module Spree protect_from_connection_error do check_environment - response = if payment_method.payment_profiles_supported? - # Gateways supporting payment profiles will need access to credit - # card object because this stores the payment profile information - # so supply the authorization itself as well as the credit card, - # rather than just the authorization code - payment_method.void(response_code, source, gateway_options) - else - # Standard ActiveMerchant void usage - payment_method.void(response_code, gateway_options) - end + response = payment_method.void(response_code, gateway_options) record_response(response) diff --git a/spec/models/spree/gateway/stripe_sca_spec.rb b/spec/models/spree/gateway/stripe_sca_spec.rb index 495c33aa6b..5379434c2e 100644 --- a/spec/models/spree/gateway/stripe_sca_spec.rb +++ b/spec/models/spree/gateway/stripe_sca_spec.rb @@ -109,7 +109,7 @@ RSpec.describe Spree::Gateway::StripeSCA, :vcr, :stripe_version do end it "refunds the payment" do - response = subject.void(payment_intent.id, nil, {}) + response = subject.void(payment_intent.id, {}) expect(response.success?).to eq true end @@ -131,7 +131,7 @@ RSpec.describe Spree::Gateway::StripeSCA, :vcr, :stripe_version do end it "void the payment" do - response = subject.void(payment_intent.id, nil, {}) + response = subject.void(payment_intent.id, {}) expect(response.success?).to eq true end diff --git a/spec/models/spree/payment_spec.rb b/spec/models/spree/payment_spec.rb index 360ad11318..a1209ed022 100644 --- a/spec/models/spree/payment_spec.rb +++ b/spec/models/spree/payment_spec.rb @@ -347,8 +347,7 @@ RSpec.describe Spree::Payment do context "when profiles are supported" do it "should call payment_enterprise.void with the payment's response_code" do - allow(payment_method).to receive(:payment_profiles_supported) { true } - expect(payment_method).to receive(:void).with('123', card, + expect(payment_method).to receive(:void).with('123', anything).and_return(success_response) payment.void_transaction! end @@ -357,7 +356,7 @@ RSpec.describe Spree::Payment do context "when profiles are not supported" do it "should call payment_gateway.void with the payment's response_code" do allow(payment_method).to receive(:payment_profiles_supported) { false } - expect(payment_method).to receive(:void).with('123', card, + expect(payment_method).to receive(:void).with('123', anything).and_return(success_response) payment.void_transaction! end