Repository navigation
fix: include one-time coupons in billed amount preview - #830
Merged
Merged
Conversation
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes Reviewed the complete billing-preview change and regression tests, verified Stripe's documented preview semantics, and checked the consumer schema; all 27 focused billing tests passed.
- One-time coupon preview: Uses
preview_mode=nextso applicable one-time referral coupons affectBilledAmountPerPeriod, while preserving the plan price and existing subscription-line exclusions. - Regression coverage: Exercises once and forever coupons, restoration after coupon consumption, and independence from customer credit or debit balances, alongside the existing filtering and unavailable-preview cases.
Validation used mocked Stripe clients, not a live Stripe request.
gpt-6.1-sol | 𝕏
|
thomasluizon
added a commit
that referenced
this pull request
Oct 20, 2026
(cherry picked from commit 377eca5)
thomasluizon
added a commit
that referenced
this pull request
Oct 20, 2026
…e sub-habits and referral Pro days (#746) (#829) * fix: preserve yearly streak gap repairs through recalculation (#818) * fix: preserve yearly streak gap repairs through recalculation * fix: isolate yearly streak repair history window (cherry picked from commit 90c5320) * fix: expose discounted Stripe billed amount per period (#819) * fix: expose discounted Stripe billed amount per period * fix: isolate optional recurring Stripe billing preview (cherry picked from commit 0460a54) * Make sub-habits free across every creation path (ORB-231) (#824) * feat: make sub-habits available to every plan (ORB-231) * test: track free sub-habits in migration model expectations * fix: preserve Pro slip alerts when creating free sub-habits (cherry picked from commit c9d22a6) * Grant atomic referral Pro days (ORB-22) (#823) * feat: grant atomic referral Pro days (ORB-22) * fix: preserve referral transaction and billing context * fix: preserve bonus Pro access across provider changes (cherry picked from commit 7b4e9af) * test: retain combined migration assertions after main carry * fix: include one-time coupons in billed amount preview (#830) (cherry picked from commit 377eca5)
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 thomasluizon/orbit-tickets#1581
An unused 10% referral coupon now makes
billedAmountPerPeriod900 on a 1000-unit subscription. After consumption it returns to 1000, whileamountPerPeriodremains the plan price.src/Orbit.Infrastructure/Services/StripeBillingService.csrequestspreview_mode=nextso Stripe includes applicable one-time coupons. The existing filter still sums only non-prorated lines for the requested subscription, subtracts Stripe's line discounts, excludes one-time charges and customer balance, and returns null when a preview is unavailable or incomplete. The optional response field and its type are unchanged.tests/Orbit.Infrastructure.Tests/Services/StripeBillingDetailsTests.cscoversonceandforevercoupons using the referral percentage fromAppConstants, coupon consumption, no coupon, and customer credit and debit balances. Existing proration, one-time item, other-subscription, and unavailable-preview cases remain. The coupon fixture varies its response with preview mode, so it cannot give a one-time discount to a recurring preview.External interface evidence
Read Stripe.net source at commit
f4f1c8ce704825d7d7f00b4c9d848a2d028757eb, identified by the installed Stripe.net 52.4.2 package'sstripe.net.nuspecrepository entry. Reproduce by inspecting that package entry and opening these pinned source files:PreviewMode, acceptsnextandrecurring, and documents thenextdefault. Lines 58-67 confirm inherited discounts; lines 136-153 confirmSubscriptionandSubscriptionDetails.CurrencyandDiscountAmounts; lines 135-140 confirmParent; lines 207-213 defineSubtotalbefore discounts and taxes.SubscriptionItemDetails; InvoiceLineItemParentSubscriptionItemDetails.cs:18-37 confirmsProrationandSubscription.Amountin minor currency units. Invoice.cs:116-126 explains customer balance inAmountDue; lines 664-672 defineLines, and lines 837-844 defineStartingBalance. StripeList.cs:19-33 confirmsDataandHasMore.Duration = "once"inStripeCouponRewardService.cs:31-40and the 10% constant inAppConstants.cs:29.Test evidence
Before editing the test or implementation:
Exit 0, 1 passed with the defect present. The original forever-only fixture missed the defect.
After strengthening the tests, with the implementation still using recurring mode:
Exit 1, 3 failed and 24 passed.
Handle_ReferralDiscountChangesRecurringAmountWithoutChangingPlanPrice(duration: "once")andHandle_ConsumedReferralCouponRestoresNormalBilledAmountexpected 900 but received 1000. The forever case also rejected the recurring request mode. After changing the implementation to next mode, the same command exited 0 with all 27 passing.Verification after the commit:
dotnet build Orbit.slnx: exit 0, zero errors. Existing dependency and obsolete API warnings remain. OpenAPI regeneration produced no tracked changes.dotnet test tests/Orbit.Infrastructure.Tests --no-build --filter FullyQualifiedName~StripeBillingDetailsTests: exit 0, 27 passed.dotnet test tests/Orbit.Domain.Tests --no-build: exit 0, 789 passed.dotnet test tests/Orbit.Application.Tests --no-build: exit 0, 5313 passed.dotnet test tests/Orbit.Infrastructure.Tests --no-build: exit 0, 3853 passed.dotnet test Orbit.slnx --no-build: exit 0, all 9995 tests passed across the four test projects, including 40 analyzer tests.