Skip to content

armgit / spree

Public Imported from GitHub
0

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.

Fix: Seller onboarding refused by Stripe for every connected account

Łukasz Adamczyk82ec292821f9
diff --git a/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb b/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb
index 3edf30488a..24c1b31162 100644
--- a/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb
+++ b/spree/providers/stripe/app/models/spree_stripe/gateway/connect.rb
@@ -138,7 +138,13 @@ module SpreeStripe
losses: { payments: 'application' },
stripe_dashboard: { type: 'express' }
},
- capabilities: { transfers: { requested: true } },
+ # `card_payments` is never exercised — the marketplace charges on its
+ # own account and only transfers onwards — but Stripe will not grant
+ # `transfers` alone outside the recipient agreement, and refuses
+ # that agreement for a seller in the platform's own country. Abroad
+ # it would be allowed, and is still wrong: a recipient account
+ # cannot receive the cross-border payouts this gem then makes.
+ capabilities: { transfers: { requested: true }, card_payments: { requested: true } },
# Spree decides when a seller is settled, so Stripe must not also be
# paying their balance out on a schedule of its own — two clocks on
# one relationship, and the seller's own setting would be the one
diff --git a/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb b/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb
index c817078ebe..b19c308409 100644
--- a/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb
+++ b/spree/providers/stripe/spec/models/spree_stripe/gateway/connect_spec.rb
@@ -323,9 +323,33 @@ RSpec.describe SpreeStripe::Gateway::Connect do
onboard
end
- # Which service agreement a seller abroad needs depends on which payouts
- # product the marketplace is on, which a country code cannot tell us — so
- # core sends none and lets Stripe apply its own default.
+ # Stripe grants `transfers` alone only under the recipient agreement, and
+ # refuses that agreement for a seller in the platform's own country — so
+ # the capability is asked for wherever the seller trades, even though the
+ # marketplace charges on its own account and never uses it.
+ it 'asks for card payments alongside transfers' do
+ expect(Stripe::Account).to receive(:create) do |params, _options|
+ expect(params[:capabilities]).to eq(transfers: { requested: true }, card_payments: { requested: true })
+ Stripe::StripeObject.construct_from(id: 'acct_new')
+ end
+
+ onboard
+ end
+
+ it 'asks for it for a seller abroad too' do
+ new_seller.update!(billing_address: create(:address, country_code: 'FR', state_code: nil))
+
+ expect(Stripe::Account).to receive(:create) do |params, _options|
+ expect(params[:capabilities]).to eq(transfers: { requested: true }, card_payments: { requested: true })
+ Stripe::StripeObject.construct_from(id: 'acct_new')
+ end
+
+ onboard
+ end
+
+ # Requesting `card_payments` settles it: that capability exists only under
+ # the full agreement, which is also the only one that can receive the
+ # cross-border payouts this gem makes. Naming it would add nothing.
it 'states no service agreement' do
new_seller.update!(billing_address: create(:address, country_code: 'FR', state_code: nil))