Skip to content

🐛 Fixed complimentary subscription created when editing comped members#28954

Open
Aubaid12 wants to merge 1 commit into
TryGhost:mainfrom
Aubaid12:fix/25735-comped-member-stripe-subscription
Open

🐛 Fixed complimentary subscription created when editing comped members#28954
Aubaid12 wants to merge 1 commit into
TryGhost:mainfrom
Aubaid12:fix/25735-comped-member-stripe-subscription

Conversation

@Aubaid12

@Aubaid12 Aubaid12 commented Jun 28, 2026

Copy link
Copy Markdown

fixes #25735

@9larsons confirmed this on the issue and tagged it bug + help wanted.

The problem

A member can be comped without a Stripe subscription behind it (comped through the API
or an import, where the subscription id is blank). When you GET that member and PUT it
back with an unrelated change like a new label, the payload still carries comped: true.
The edit path sees that, finds no complimentary Stripe sub, and creates one. So a simple
label edit creates a zero-amount yearly Stripe subscription and bumps the period out a year.

Nothing ever bills, but it's confusing, and the only workaround was stripping
comped/status out of the payload by hand.

The fix

MemberBREADService.edit() now checks whether the member was already comped before the
update, and only creates a complimentary subscription when comp status actually changes.
The uncomp path is untouched. This matches what the Admin UI already does (it strips these
fields before saving), which is what @9larsons suggested.

Tests

6 unit cases in members-bread-service.test.js, one per path: free to comped (creates),
already-comped with no Stripe sub (the bug, now skipped), already-comped with a Stripe sub
(no duplicate), uncomp (removes), edit with no comped field (no work), and Stripe not connected.

  • I've read and followed the Contributor Guide
  • I've written an automated test to prove my change works

…members

fixes TryGhost#25735

A member comped without a backing Stripe subscription (e.g. comped via the API
or an import) re-sent `comped: true` on edit, so the edit path found no existing
complimentary subscription and created one on every unrelated change such as
adding a label. As suggested on the issue, the edit path now only creates a
complimentary subscription when comp status is actually changing, by checking
whether the member was already comped before the update — mirroring how the
Admin UI strips these fields before saving.
@coderabbitai

coderabbitai Bot commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Walkthrough

MemberBREADService.edit now fetches the existing member record when options.id is present and data.comped is a boolean with Stripe configured, storing the prior status as wasComped. The complimentary Stripe subscription creation path is tightened to also require !wasComped, preventing re-creation when an already-comped member is edited for unrelated fields. Accompanying unit tests add a createStripeEditService helper and cases covering all transition scenarios.

🚥 Pre-merge checks | ✅ 4
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly summarizes the main fix: preventing complimentary subscriptions from being created during edits to comped members.
Linked Issues check ✅ Passed The implementation addresses #25735 by avoiding Stripe subscription creation on unrelated edits to already-comped members and adds coverage for the bug.
Out of Scope Changes check ✅ Passed The added tests and service logic are directly in scope for the comped-member Stripe subscription fix.
Description check ✅ Passed The description directly matches the code changes, explaining the comped-member Stripe subscription bug, the edit-path fix, and added tests.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.

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.

Stripe subscription entity is created on comped accounts using Ghost API

1 participant