Skip to content

feat: add pause resume billing adjustment - #1071

Open
eischideraa-unn wants to merge 1 commit into
Smartdevs17:mainfrom
eischideraa-unn:feature/subscription-pause-resume-billing-adjustment
Open

feat: add pause resume billing adjustment#1071
eischideraa-unn wants to merge 1 commit into
Smartdevs17:mainfrom
eischideraa-unn:feature/subscription-pause-resume-billing-adjustment

Conversation

@eischideraa-unn

Copy link
Copy Markdown
Contributor

Summary

This PR implements subscription pause/resume billing adjustment support for the app’s subscription lifecycle. It adds the missing billing behavior around paused subscriptions so users can pause an active subscription, receive a prorated billing credit, and resume without losing billing continuity. The fix ensures the subscription state, pause history, and next billing date behave consistently during pause and resume cycles.

Closes #932

Motivation

The codebase already had pause-related UI/state plumbing, but the billing adjustment flow was incomplete and inconsistent across the subscription store. Specifically, the app needed a clear and safe flow for:

  • pausing an active subscription
  • calculating prorated credit based on the pause duration
  • tracking the active pause state and credit remaining
  • resuming a subscription and shifting the next billing date appropriately
  • preserving pause history for auditing and UI display

This PR closes that gap in the key subscription logic implemented in subscriptionStore.ts and the pause model in pause.ts.


What Changed

1) Subscription pause logic

The store now properly creates a pause record when a subscription is paused:

  • marks the subscription as inactive
  • records the pause reason and note
  • calculates credit using the subscription price and pause duration
  • stores billing adjustment metadata and scheduled resume date
  • keeps pause history available for later lookup and UI display

Implemented in:

  • subscriptionStore.ts

2) Billing adjustment metadata

The pause record model now includes the fields needed to represent billing-adjustment behavior and resume lifecycle tracking, including:

  • credit amount
  • credit remaining
  • billing adjustment alias
  • planned resume date
  • resume status
  • pause lifecycle state

Updated in:

  • pause.ts

3) Resume flow with billing restart

When a subscription is resumed:

  • the active pause is located and resumed
  • the subscription is set back to active
  • the remaining credit is preserved as part of the resume record
  • the next billing date is shifted forward by the pause window to maintain billing continuity

This protects against billing drift when a subscription is paused and later resumed.

4) Regression coverage

Added targeted unit tests covering the critical pause/resume billing flow, including:

  • pause creates credit-bearing pause record
  • subscription is marked inactive while paused
  • resume reactivates the subscription
  • next billing date advances after resume

Test coverage added in:

  • subscriptionPauseResume.test.ts

5) Documentation alignment

The issue flow is consistent with the pause/resume billing documentation already present in:

  • PAUSE_RESUME.md

Edge Cases Considered

  • Prevents invalid pause creation when a subscription is already paused
  • Handles missing or malformed pause history safely
  • Uses existing store conventions and persisted state handling
  • Keeps billing state aligned with the UI’s pause/resume expectations
  • Preserves historical data for downstream analytics and review

Testing

Added focused unit coverage for the newly introduced behavior:

  • pause creates a structured pause record with prorated credit
  • resume marks the subscription active again
  • next billing date is adjusted after resume
  • pause history reflects resume lifecycle changes

Note: this PR is prepared with the implementation in place and unit tests added, but the full CI quality gates below remain to be validated in the project environment.


Pull Request Checklist

Quality Gates (All must pass before merge)

  • Lint: Code passes ESLint and Prettier checks
  • Type Check: TypeScript compilation succeeds
  • Tests: All tests pass
  • Build: Project builds successfully
  • Rust Format: Smart contract formatting is correct
  • Rust Clippy: Smart contract linting passes
  • Rust Tests: All smart contract tests pass
  • Rust Build: Smart contracts compile successfully

Additional Requirements

  • New code has appropriate TypeScript types
  • No hardcoded secrets or credentials
  • New features have corresponding tests
  • Documentation updated if needed

@drips-wave

drips-wave Bot commented Aug 28, 2026

Copy link
Copy Markdown

@eischideraa-unn Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits.

You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀

Learn more about application limits

@eischideraa-unn
eischideraa-unn deployed to security-review August 28, 2026 15:21 — with GitHub Actions Active
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.

Build subscription pause/resume with billing adjustment

1 participant