Skip to content

🐛 Fixed Stripe checkout failing for accounts with Managed Payments enabled - #29715

Merged
sagzy merged 3 commits into
mainfrom
stripe-checkout-managed-payments-e05196
Aug 3, 2026
Merged

🐛 Fixed Stripe checkout failing for accounts with Managed Payments enabled#29715
sagzy merged 3 commits into
mainfrom
stripe-checkout-managed-payments-e05196

Conversation

@sagzy

@sagzy sagzy commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

ref https://linear.app/ghost/issue/ONC-1928
ref https://ghost.slack.com/archives/CJBJ3MZFD/p1785434550639309
ref https://forum.ghost.org/t/stripe-checkout-session-fails-with-managed-payments-cannot-be-used-with-connect-on-self-hosted-ghost-6-52-1/63449/1
ref https://forum.ghost.org/t/paid-checkout-fails-for-both-the-monthly-and-annual-options/63465

Problem

Since late July 2026, Stripe has been provisioning some new accounts with Managed Payments (their merchant-of-record product) enabled by default for all Checkout Sessions. Managed Payments does not support Connect, so on those accounts every checkout attempt fails with a 400 from Stripe:

You specified a Stripe-Account header, but Managed Payments cannot be used with Connect.

Members cannot start any paid subscription on affected sites. Affected site owners can't always opt out themselves: on default-on accounts the Stripe dashboard states Managed Payments "can only be disabled for individual sessions" and offers no account-level toggle.

Solution

Stripe checkout session creation now explicitly disables Managed Payments per session (managed_payments: {enabled: false}) on all four Checkout Session types: subscription, donation, gift, and setup.

Verified empirically against the live Stripe API using Connect-obtained test keys:

  • managed_payments[enabled]=false is accepted under Ghost's pinned 2020-08-27 API version, on subscription-shaped (legacy subscription_data.items), payment-mode, and setup-mode session creation — so no API version bump or retry fallback is needed.
  • stripe-node 8.222.0 (Ghost's pinned version) serializes the parameter correctly and sessions create successfully.
  • The inverse (enabled=true) on the same Connect key reproduces the reported error verbatim, confirming the failure mechanism.

…abled

Since late July 2026, Stripe has been provisioning some new accounts with
Managed Payments (their merchant-of-record product) enabled by default for
all Checkout Sessions. Managed Payments does not support Connect, so on
those accounts every checkout attempt fails with "You specified a
Stripe-Account header, but Managed Payments cannot be used with Connect"
— members cannot subscribe at all, and the account-level default cannot
always be disabled from the Stripe dashboard.

Ghost never wants Managed Payments — it handles its own invoicing and
connects via Stripe Connect — so we now explicitly disable it per session
on every Checkout Session type (subscription, donation, gift, and setup).
Verified against the live Stripe API that the parameter is accepted under
the pinned 2020-08-27 API version and stripe-node 8.x, and that enabling
it reproduces the reported failure exactly.
@coderabbitai

coderabbitai Bot commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

Added a shared MANAGED_PAYMENTS_DISABLED configuration with enabled: false. Applied it to Stripe Checkout and Setup Session creation for subscription, donation, gift subscription, and setup flows. Added unit tests that verify the parameter in each flow.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the Stripe checkout failure fix for accounts with Managed Payments enabled.
Description check ✅ Passed The description directly explains the Managed Payments incompatibility and the session-level Stripe fix.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch stripe-checkout-managed-payments-e05196

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nx-cloud

nx-cloud Bot commented Aug 3, 2026

Copy link
Copy Markdown

🤖 Nx Cloud AI Fix

Ensure the fix-ci command is configured to always run in your CI pipeline to get automatic fixes in future runs. For more information, please see https://nx.dev/ci/features/self-healing-ci


View your CI Pipeline Execution ↗ for commit 69c2bfe

Command Status Duration Result
nx run ghost:test:ci:integration ✅ Succeeded 2m 47s View ↗
nx run ghost:test:integration ✅ Succeeded 3m 22s View ↗
nx run ghost:test:legacy ✅ Succeeded 2m 17s View ↗
nx run ghost:test:e2e ✅ Succeeded 2m 47s View ↗
nx run-many -t test:unit -p ghost ✅ Succeeded 28s View ↗
nx run ghost-monorepo:lint:boundaries ✅ Succeeded 17s View ↗
nx run-many -t lint -p ghost,ghost-monorepo ✅ Succeeded 16s View ↗
nx run-many --target=build --projects=tag:publi... ✅ Succeeded <1s View ↗
nx run @tryghost/admin:build ✅ Succeeded 3s View ↗

💡 Verify your cache is correct by running tasks in a sandbox. Read docs ↗


☁️ Nx Cloud last updated this comment at 2026-08-03 09:13:30 UTC

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@ghost/core/test/unit/server/services/stripe/stripe-api.test.js`:
- Around line 238-243: Update both Stripe session tests to use valid production
method arguments: in createCheckoutSetupSession, pass a customer object
containing id and email as the first argument; in createDonationCheckoutSession,
pass a single options object such as {priceId: 'priceId'}. Apply these changes
at ghost/core/test/unit/server/services/stripe/stripe-api.test.js lines 238-243
and 572-577.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 4915ed75-edd4-48cf-990e-3dd00e25c882

📥 Commits

Reviewing files that changed from the base of the PR and between ee55297 and 69c2bfe.

📒 Files selected for processing (2)
  • ghost/core/core/server/services/stripe/stripe-api.js
  • ghost/core/test/unit/server/services/stripe/stripe-api.test.js

Comment thread ghost/core/test/unit/server/services/stripe/stripe-api.test.js
sagzy added 2 commits August 3, 2026 10:58
no ref

The setup-session test now passes a customer object and the donation
test a single options object, matching the production method
signatures instead of the loose shapes copied from neighbouring
legacy tests.
@sagzy
sagzy enabled auto-merge (squash) August 3, 2026 09:13
@sagzy
sagzy disabled auto-merge August 3, 2026 09:14
@codecov

codecov Bot commented Aug 3, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 90.00000% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 75.38%. Comparing base (d4f794a) to head (885ecab).
⚠️ Report is 2 commits behind head on main.

Files with missing lines Patch % Lines
...ost/core/core/server/services/stripe/stripe-api.js 90.00% 1 Missing ⚠️
Additional details and impacted files
@@           Coverage Diff           @@
##             main   #29715   +/-   ##
=======================================
  Coverage   75.38%   75.38%           
=======================================
  Files        1607     1607           
  Lines      141658   141668   +10     
  Branches    17495    17496    +1     
=======================================
+ Hits       106784   106797   +13     
+ Misses      33806    33803    -3     
  Partials     1068     1068           
Flag Coverage Δ
e2e-tests 77.53% <90.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@sagzy
sagzy enabled auto-merge (squash) August 3, 2026 09:23
@sagzy
sagzy merged commit 2be8d9f into main Aug 3, 2026
49 checks passed
@sagzy
sagzy deleted the stripe-checkout-managed-payments-e05196 branch August 3, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant