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
Follow the capture-method rename through the payment session flow
Damian Legawiecfeeff25ac80f
diff --git a/spree/core/spec/models/spree/payment_spec.rb b/spree/core/spec/models/spree/payment_spec.rbindex d571f0567b..e12daa516e 100644--- a/spree/core/spec/models/spree/payment_spec.rb+++ b/spree/core/spec/models/spree/payment_spec.rb@@ -540,10 +540,10 @@ describe Spree::Payment, type: :model doendend- # The caller reporting actual gateway state overrides the auto_capture- # guess in both directions.+ # The caller reporting actual gateway state overrides the method's+ # capture timing in both directions.context 'when the funds are captured on a manual-capture method' do- let(:auto_capture) { false }+ let(:capture_method) { 'manual' }it 'completes the payment with a capture event' dopayment.confirm!(captured: true)@@ -553,8 +553,8 @@ describe Spree::Payment, type: :model doendend- context 'when the funds are not captured on an auto-capture method' do- let(:auto_capture) { true }+ context 'when the funds are not captured on a checkout-capture method' do+ let(:capture_method) { 'checkout' }it 'pends the payment' dopayment.confirm!(captured: false)diff --git a/spree/core/spec/workflows/spree/payment_sessions/complete_spec.rb b/spree/core/spec/workflows/spree/payment_sessions/complete_spec.rbindex a0ab5827ee..7f2f27a132 100644--- a/spree/core/spec/workflows/spree/payment_sessions/complete_spec.rb+++ b/spree/core/spec/workflows/spree/payment_sessions/complete_spec.rb@@ -52,7 +52,7 @@ RSpec.describe Spree::PaymentSessions::Complete doresult = described_class.call(payment_session: payment_session)expect(result).to be_failure- expect(result.error.value).to eq('on fraud hold')+ expect(result.error.to_s).to eq('on fraud hold')expect(payment_session.reload.status).to eq('pending')enddiff --git a/spree/core/spec/workflows/spree/payments/void_spec.rb b/spree/core/spec/workflows/spree/payments/void_spec.rbindex 55714e4171..8868dbba39 100644--- a/spree/core/spec/workflows/spree/payments/void_spec.rb+++ b/spree/core/spec/workflows/spree/payments/void_spec.rb@@ -48,7 +48,7 @@ RSpec.describe Spree::Payments::Void doresult = described_class.call(payment: payment)expect(result).to be_failure- expect(result.error.value).to eq('under review')+ expect(result.error.to_s).to eq('under review')endit 'runs after_void once the gateway call succeeds' dodiff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rbindex 0d072a5967..2ee3182321 100644--- a/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rb+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/payment_sessions.rb@@ -178,7 +178,9 @@ module SpreeStripecurrency: order.currency,customer: customer_profile_id,payment_method: payment_method_id,- capture_method: (MANUAL_CAPTURE_METHOD unless auto_capture?),+ # Stripe knows only "charge now" or "authorize now, capture later",+ # so both on_dispatch and manual map to its manual capture.+ capture_method: (MANUAL_CAPTURE_METHOD unless capture_at_checkout?),statement_descriptor_suffix: statement_descriptor_suffix_for(order),automatic_payment_methods: { enabled: true },transfer_group: order.number,diff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rbindex 7f5ac39fe3..e2f6b9dc21 100644--- a/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway_spec.rb@@ -289,8 +289,8 @@ RSpec.describe SpreeStripe::Gateway doendend- context 'when auto_capture is false on the gateway' do- before { gateway.update!(auto_capture: false) }+ context 'when the gateway captures manually' do+ before { gateway.update!(capture_method: 'manual') }it 'asks Stripe for manual capture' doVCR.use_cassette('create_payment_intent_manual_capture') do@@ -301,8 +301,8 @@ RSpec.describe SpreeStripe::Gateway doendend- context 'when auto_capture is true on the gateway' do- before { gateway.update!(auto_capture: true) }+ context 'when the gateway captures at checkout' do+ before { gateway.update!(capture_method: 'checkout') }it 'leaves the capture method to Stripe' doVCR.use_cassette('create_payment_intent') do