Skip to content

feat(billing): subscription cancelAt + cancelAtPeriodEnd lifecycle fields #3740

Description

@PierreBrisorgueil

Context

The upcoming `customer.subscription.updated` Stripe webhook handler (Task C.2 of the trawl-devkit alignment plan) needs to write pending-cancellation state to the Subscription document. Currently the model has no fields for this — without them C.2 cannot land.

What this tracks

Add two fields to the Subscription Mongoose model and Zod schema:

  • `cancelAtPeriodEnd` (Boolean, default null) — mirrors Stripe's `cancel_at_period_end` flag. Set to `true` when a subscription is scheduled to cancel at period end. Does NOT change `plan` — the sub stays on the current plan until `cancel_at`.
  • `cancelAt` (Date, default null) — the exact timestamp when cancellation will occur, converted from Stripe's Unix-seconds `cancel_at` field.

Both fields default to `null` (honest semantics: null = not yet synced from Stripe, distinct from false = explicitly not cancelling).

Gate for C.2

This is a strict prerequisite for the webhook handler task. C.2 lands the handler logic; C.1 lands the data model first.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions