🐛 Fixed complimentary subscription created when editing comped members#28954
Open
Aubaid12 wants to merge 1 commit into
Open
🐛 Fixed complimentary subscription created when editing comped members#28954Aubaid12 wants to merge 1 commit into
Aubaid12 wants to merge 1 commit into
Conversation
…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.
Contributor
Walkthrough
🚥 Pre-merge checks | ✅ 4✅ Passed checks (4 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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/statusout of the payload by hand.The fix
MemberBREADService.edit()now checks whether the member was already comped before theupdate, 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.