Skip to content

fix(billing): public plans listing only returns products tagged with metadata.planId - #4124

Merged
PierreBrisorgueil merged 3 commits into
masterfrom
fix/plans-planid-only-4113
Sep 25, 2026
Merged

PierreBrisorgueil merged 3 commits into
masterfrom
fix/plans-planid-only-4113

Conversation

@PierreBrisorgueil

Copy link
Copy Markdown
Contributor

Summary

GET /api/billing/plans is public and returned every active Stripe product as a plan: a product without metadata.planId fell back to its raw Stripe id, so one-time packs (and anything else active in the account) showed up as plans with monthlyPrice: 0 and a null price id.

  • fetchPlansFromStripe now keeps only products tagged with metadata.planId; the raw-id fallback is gone.
  • createCheckout validates priceId against the same listing, so self-serve checkout also accepts only prices of tagged plans.
  • Active products but no tagged plan → a [billing.plans] warning instead of a silent empty listing.
  • Unchanged on purpose: plan resolution for existing subscriptions (billing.planResolver.js, webhook, admin sync) — a recurring product sold outside the catalogue (e.g. a Payment Link) keeps working, it just is not listed.

Verification

  • lint + test:coverage: 235 suites / 3158 tests pass, thresholds unchanged; the plans unit suite adds a mixed-catalogue case and the untagged-catalogue warning cases.
  • Pre-push review: OK with nits (both applied).

Closes #4113

https://claude.ai/code/session_01ARSKGeyDyVFv3UzGH1LBn6

…w id fallback

fetchPlansFromStripe fell back to the raw Stripe product id when
metadata.planId was missing, so any active Stripe product (a one-time
pack, a recurring product sold outside the plans catalogue via a
Payment Link) advertised itself as a public plan on GET
/api/billing/plans, often with a null price id.

Now only products carrying metadata.planId are returned. Subscription
and webhook plan resolution (billing.planResolver.js,
billing.webhook.service.js, billing.admin.service.js) are untouched:
a recurring product sold outside the plans catalogue still resolves
and works, it just no longer appears in the public listing.

Fixes #4113

Claude-Session: https://claude.ai/code/session_01ARSKGeyDyVFv3UzGH1LBn6
The two tests covering "no metadata" and "metadata without planId key"
exercised the identical guard clause and assertion; one test with both
product shapes gives the same coverage with less duplication.

Claude-Session: https://claude.ai/code/session_01ARSKGeyDyVFv3UzGH1LBn6
@coderabbitai

coderabbitai Bot commented Sep 25, 2026

Copy link
Copy Markdown

Warning

Review limit reached

Next included review available in 54 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository: pierreb-devkit/Node/.coderabbit.yaml

Review profile: ASSERTIVE

Plan: Advanced

Run ID: 6c094edf-c47e-4eb7-a7bc-3f6a7e1238dc

📥 Commits

Reviewing files that changed from the base of the PR and between 06ce893 and 2161d8c.

📒 Files selected for processing (4)
  • ERRORS.md
  • MIGRATIONS.md
  • modules/billing/services/billing.plans.service.js
  • modules/billing/tests/billing.plans.unit.tests.js

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.

@codecov

codecov Bot commented Sep 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.36%. Comparing base (06ce893) to head (2161d8c).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4124   +/-   ##
=======================================
  Coverage   94.36%   94.36%           
=======================================
  Files         173      173           
  Lines        6012     6016    +4     
  Branches     1936     1937    +1     
=======================================
+ Hits         5673     5677    +4     
  Misses        276      276           
  Partials       63       63           
Flag Coverage Δ
integration 63.97% <0.00%> (-0.05%) ⬇️
unit 79.20% <100.00%> (+0.01%) ⬆️

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


Continue to review full report in Codecov by Harness.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 06ce893...2161d8c. Read the comment docs.

🚀 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.

@PierreBrisorgueil
PierreBrisorgueil merged commit e408163 into master Sep 25, 2026
8 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/plans-planid-only-4113 branch September 25, 2026 08:35
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.

🐛 GET /api/billing/plans returns every active Stripe product as a plan

1 participant