Add invoice.payment_failed webhook handler to suspend overdue subscriptions #1054

Open
opened 2026-04-12 11:43:19 -04:00 by pook · 0 comments
Owner

Add a handler for the Stripe invoice.payment_failed event in the compliancebot webhook endpoint.

Requirements:

  • On invoice.payment_failed, check attempt_count from the invoice object
  • If attempt_count >= 3, update the subscription record status to 'past_due' in the Prisma database
  • Log failure with customer ID, invoice ID, attempt count, and amount
  • Preserve the subscription record for reactivation (do not delete)
  • Add handler for customer.subscription.resumed to reset status to 'active'
  • Add Jest test: payment_failed at attempt_count=3 sets past_due in DB
  • Add Jest test: payment_failed at attempt_count=1 leaves status unchanged
  • Add Jest test: subscription.resumed resets to active

This ensures subscription status stays accurate for the /api/generate access control check (#1035).


Generated by CEO Planner (priority: 3)

Add a handler for the Stripe invoice.payment_failed event in the compliancebot webhook endpoint. Requirements: - On invoice.payment_failed, check attempt_count from the invoice object - If attempt_count >= 3, update the subscription record status to 'past_due' in the Prisma database - Log failure with customer ID, invoice ID, attempt count, and amount - Preserve the subscription record for reactivation (do not delete) - Add handler for customer.subscription.resumed to reset status to 'active' - Add Jest test: payment_failed at attempt_count=3 sets past_due in DB - Add Jest test: payment_failed at attempt_count=1 leaves status unchanged - Add Jest test: subscription.resumed resets to active This ensures subscription status stays accurate for the /api/generate access control check (#1035). --- *Generated by CEO Planner (priority: 3)*
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
pook/compliancebot#1054
No description provided.