feat(billing): config-gate allow_promotion_codes on subscription Checkout (#3793)#3794
Conversation
…kout (#3793) Mirror the automaticTax pattern: set checkoutParams.allow_promotion_codes = true only when config.stripe.allowPromotionCodes === true (strict, default off). Existing downstreams (comes/montaine/pierreb/ism) are unaffected. Extras-pack Checkout left unchanged (one-time payment, no coupon use-case). Fix false claim in STRIPE_SETUP.md (doc/code drift). Add 4 unit tests: absent/false/truthy-non-strict → absent; true → present.
|
Warning Review limit reached
More reviews will be available in 5 minutes and 48 seconds. Learn how PR review limits work. Your organization has run out of usage credits. Purchase more in the billing tab. ⌛ How to resolve this issue?After more reviews become available, a review can be triggered using the We recommend that you space out your commits to avoid hitting the rate limit. 🚦 How do rate limits work?CodeRabbit enforces hourly rate limits for each developer per organization. Our paid plans include higher PR review limits than trial, open-source, and free plans. In all cases, reviews become available again over time. During sustained high-volume PR review activity, CodeRabbit may temporarily slow when the next review becomes available. Please see our Fair Usage Limits Policy for further information. ℹ️ Review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (3)
✨ 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 |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in, strict config gate for Stripe Checkout promo codes on subscription checkouts, aligning behavior with the existing automaticTax pattern and correcting documentation drift.
Changes:
- Add
checkoutParams.allow_promotion_codes = truewhenconfig?.stripe?.allowPromotionCodes === trueincreateCheckout. - Add unit coverage for the new config gate (absent/false/truthy-non-true/true).
- Update
modules/billing/STRIPE_SETUP.mdto reflect that promo codes are config-gated (not unconditional).
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| modules/billing/services/billing.service.js | Config-gates allow_promotion_codes for subscription Checkout sessions with a strict === true guard. |
| modules/billing/tests/billing.checkout.unit.tests.js | Adds unit tests validating the allowPromotionCodes gate behavior across key config values. |
| modules/billing/STRIPE_SETUP.md | Fixes doc/code drift by documenting the config-gated nature of promo codes on hosted Checkout. |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #3794 +/- ##
==========================================
+ Coverage 90.19% 90.23% +0.03%
==========================================
Files 152 152
Lines 5020 5028 +8
Branches 1598 1600 +2
==========================================
+ Hits 4528 4537 +9
+ Misses 387 386 -1
Partials 105 105
Flags with carried forward coverage won't be shown. Click here to find out more. Continue to review full report in Codecov by Harness.
🚀 New features to boost your workflow:
|
Summary
allow_promotion_codesto the subscription Checkout session, gated onconfig.stripe.allowPromotionCodes === true(strict, default OFF)automaticTaxpattern exactly (placement, style, config access path)createExtrasCheckout) left unchanged — one-time payment, no promo-code use-caseSTRIPE_SETUP.md: removes false claim that the flag was already passed unconditionallyBehavior
allowPromotionCodesabsentallow_promotion_codesnot sent to Stripe (default)allowPromotionCodes: falseallowPromotionCodes: 1(truthy non-strict)=== trueguardallowPromotionCodes: trueallow_promotion_codes: truepassed to Stripe CheckoutDownstreams opt in via
config.stripe.allowPromotionCodes: truein theirdefaults/<project>.config.js. Existing comes/montaine/pierreb/ism are unaffected.Test plan
billing.checkout.unit.tests.js: absent → undefined, false → undefined, truthy-non-strict (1) → undefined, true → presentCloses #3793