Skip to content

Add customer.subscription.deleted webhook handler for auto-deactivation #64

Description

@markgoho

Context

The new "Cancel Membership" feature (replacing "Deactivate Membership") schedules Stripe subscription cancellation at the end of the billing period via cancel_at_period_end: true. However, when the period actually ends and Stripe fires the customer.subscription.deleted event, we don't yet handle it.

What needs to happen

When customer.subscription.deleted fires (billing period has ended after cancellation):

  1. Deactivate member: Set membershipActive: false in Firestore
  2. Draft profile: Set the member's Hugo profile to draft so it's hidden from the directory
  3. Unsubscribe from newsletter: Remove from MailerLite subscriber list

Technical details

  • The webhook handler should be added to the existing Stripe webhook processing pipeline
  • Follow the same patterns as the existing charge.refunded handler
  • The handler should be idempotent (safe to retry)
  • Should send admin notification on failure

Related

  • Cancel membership implementation: the PR that introduces cancel_at_period_end behavior

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions