Skip to content

feat(payments): subscription lifecycle, renewal invoices and plan-based write access #908

Closed

Description

@Priyanshubhartistm

Is your feature request related to a problem? Please describe.
With the subscription data model in place, nothing creates or extends a subscription, issues renewal invoices, or ends access when a period lapses. Write access still depends only on the permanent is_admitted flag.

Describe the solution you'd like

  • A SubscriptionService for subscribe, renew and status transitions (active → renewal_pending → past_due → expired).
  • PaymentsService.confirmInvoice extends the subscription period (same transaction as the invoice confirmation). All five confirmation paths (maintenance poll and the Zebedee/LNbits/OpenNode/Nodeless callbacks) already go through it, so the invoice carries its plan_id instead of each callback learning about plans.
  • POST /invoices accepts a plan id; existing admission behaviour is unchanged when no plans are configured.
  • A periodic sweep (maintenance worker) that issues renewal invoices before period end and moves overdue subscriptions through grace to expired.
  • isUserAdmitted checks for an active subscription, reusing the existing admission cache so there is no extra database read per event.
  • Tests for each transition, the confirm path, and the cache behaviour.

Additional context

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

enhancementNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions