Skip to content

fix(billing): surface live cancelAt through getSubscription - #4023

Merged
PierreBrisorgueil merged 1 commit into
masterfrom
fix/4022-cancel-at-live-value
Aug 5, 2026
Merged

fix(billing): surface live cancelAt through getSubscription#4023
PierreBrisorgueil merged 1 commit into
masterfrom
fix/4022-cancel-at-live-value

Conversation

@PierreBrisorgueil

@PierreBrisorgueil PierreBrisorgueil commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • What changed: fetchSubscriptionDetails now includes the already-computed cancelAt in the object it returns, so getSubscription's merge overrides the persisted (DB) value with the live Stripe value — the same freshness treatment cancelAtPeriodEnd and currentPeriodEnd already receive.
  • Why: getSubscription merges a live cancelAtPeriodEnd with a stale, DB-only cancelAt written by the last webhook. Stripe represents a portal cancellation as cancel_at + canceled_at + a cancellation reason, leaving cancel_at_period_end false — so a consumer reading cancelAt for "this subscription is ending" sees a value Stripe already cleared after a reactivation, until the next webhook lands (or indefinitely if it's dropped/out of order).
  • Related issues: Closes 🐛 fetchSubscriptionDetails drops the live cancelAt, so a reactivated subscription keeps a stale cancellation date #4022

Scope

  • Module(s) impacted: billing
  • Cross-module impact: none
  • Risk level: low

Validation

  • npm run lint
  • npm test
  • Manual checks done (if applicable)

Guardrails check

  • No secrets or credentials introduced (.env*, secrets/**, keys, tokens)
  • No risky rename/move of core stack paths
  • Changes remain merge-friendly for downstream projects
  • Tests added or updated when behavior changed

Notes for reviewers

  • Security considerations: none — read-path only, no new state or schema change.
  • Mergeability considerations: none — single field addition, no signature change.
  • Follow-up tasks (optional): none.

Summary by CodeRabbit

  • Bug Fixes
    • Subscription details now accurately reflect the cancellation date from the payment provider.
    • Reactivated subscriptions no longer display an outdated cancellation date.

fetchSubscriptionDetails computed cancelAt from the live Stripe object
but dropped it before returning, so getSubscription's merge kept the
stale, DB-only value written by the last webhook. On reactivation
(Stripe clears cancel_at, cancel_at_period_end stays false) a consumer
reading cancelAt would see a cancellation that no longer exists until
the webhook lands.

Include cancelAt in the returned object so the live value overrides
the persisted one, same treatment cancelAtPeriodEnd and
currentPeriodEnd already get.
@PierreBrisorgueil PierreBrisorgueil added the Fix A bug fix label Aug 5, 2026
@PierreBrisorgueil PierreBrisorgueil self-assigned this Aug 5, 2026
@PierreBrisorgueil
PierreBrisorgueil marked this pull request as ready for review August 5, 2026 19:24
@codecov

codecov Bot commented Aug 5, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 94.01%. Comparing base (36d37cc) to head (ece6956).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4023   +/-   ##
=======================================
  Coverage   94.01%   94.01%           
=======================================
  Files         170      170           
  Lines        5810     5810           
  Branches     1859     1860    +1     
=======================================
  Hits         5462     5462           
  Misses        285      285           
  Partials       63       63           
Flag Coverage Δ
integration 62.25% <ø> (ø)
unit 76.85% <ø> (ø)

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 36d37cc...ece6956. 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.

@coderabbitai

coderabbitai Bot commented Aug 5, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The billing service now returns Stripe’s live cancelAt value. A regression test verifies that a reactivated subscription returns null instead of a stale persisted cancellation date.

Changes

Billing cancellation state

Layer / File(s) Summary
Live cancellation state propagation
modules/billing/services/billing.service.js, modules/billing/tests/billing.checkout.unit.tests.js
fetchSubscriptionDetails includes the computed cancelAt value. The getSubscription test verifies that Stripe’s cancel_at: null overrides a stale local cancellation date.

Estimated code review effort: 2 (Simple) | ~10 minutes

Possibly related issues

  • pierreb-devkit/Vue#4549 — The backend now exposes live Stripe cancelAt data required for frontend cancellation-state rendering.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Linked Issues check ✅ Passed The implementation and regression test satisfy issue #4022 by returning live cancelAt and covering reactivation with Stripe cancel_at set to null.
Out of Scope Changes check ✅ Passed The changes are limited to the billing read path and its regression test, which matches the linked issue scope.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Title check ✅ Passed The title clearly and concisely describes exposing the live Stripe cancellation timestamp through getSubscription.
Description check ✅ Passed The description covers the change, rationale, scope, validation, guardrails, linked issue, and reviewer notes; the optional infrastructure section is not needed.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/4022-cancel-at-live-value

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.

@PierreBrisorgueil
PierreBrisorgueil merged commit 5f4b1d5 into master Aug 5, 2026
8 checks passed
@PierreBrisorgueil
PierreBrisorgueil deleted the fix/4022-cancel-at-live-value branch August 5, 2026 19:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Fix A bug fix

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐛 fetchSubscriptionDetails drops the live cancelAt, so a reactivated subscription keeps a stale cancellation date

1 participant