Open Source Platform for DTC, B2B Commerce, Marketplaces & Omnichannel. REST APIs, TypeScript SDKs, and production-ready Next.js storefront. Self-host it. Own your data. No vendor lock-in. Zero platform fees.
Ruby b2b-commercee-commerceecommerceecommerce-apiecommerce-frameworkecommerce-platformheadlessheadless-commerceheadless-ecommercemarketplacemulti-tenantmulti-vendormulti-vendor-ecommerceopen-sourcespree-commerce
FIX void payment (#13413)
brozek57d572f465a4
diff --git a/core/app/models/spree/payment/processing.rb b/core/app/models/spree/payment/processing.rbindex 7870863c3b..9dd3680b59 100644--- a/core/app/models/spree/payment/processing.rb+++ b/core/app/models/spree/payment/processing.rb@@ -63,6 +63,7 @@ module Spreedef void_transaction!return true if void?+ return void if response_code.blank?protect_from_connection_error doif payment_method.payment_profiles_supported?diff --git a/core/spec/models/spree/payment_spec.rb b/core/spec/models/spree/payment_spec.rbindex decdf6d838..3bed924b9f 100644--- a/core/spec/models/spree/payment_spec.rb+++ b/core/spec/models/spree/payment_spec.rb@@ -694,6 +694,19 @@ describe Spree::Payment, type: :model dopayment.void_transaction!endend++ context 'if response_code is blank' do+ before do+ payment.response_code = nil+ payment.state = 'pending'+ end++ it 'voids the payment without calling the gateway' do+ expect(payment.payment_method).not_to receive(:void)+ payment.void_transaction!+ expect(payment.state).to eq('void')+ end+ endendend