Skip to content

fix(billing): block a payer on every failed invoice payment - #10579

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/block-on-first-payment-failure
Dec 1, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/block-on-first-payment-failure

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • handleInvoicePaymentFailed only blocked the payer from attempt_count >= 1. A charge Stripe makes outside its retry schedule, such as the one when a trial whose card already had a trial is ended at once, fails with attempt_count: 0, so the payer was never blocked and kept the plan's full allowance while past due
  • Block the payer (or the org's members) on every failed invoice payment; a later paid invoice still lifts the block as before
  • Send the payment-failed email on attempt 0 or 1, and keep skipping it on retries

Type of Change

  • Bug fix

Testing

  • lib/billing/webhooks/invoices.integration.ts (real Postgres): a failed invoice blocks its personal payer on attempt 1 and on attempt 0. The attempt-0 case fails on the pre-fix handler and passes with the fix; 5/5 green
  • lib/billing/webhooks/invoices.test.ts 2/2; biome on the changed files; type-check, audits and the full suite in CI

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

A charge made outside Stripe's retry schedule, such as the one that ends an
ineligible trial at once, fails with attempt_count 0. The handler only blocked
from attempt 1, so the payer kept the plan's full allowance while past due.
Block on any failure, and send the failure email on attempt 0 or 1.
@vercel

vercel Bot commented Dec 1, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Dec 1, 2026 5:26pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no blocking issues remain.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no blocking issues remain.

Summary

Blocks personal payers and organization members on every failed invoice payment, including attempt_count: 0.

  • Every failed invoice blocks its payer, even with no attempts counted.
  • An attempted open invoice keeps the payer blocked until it is resolved.

Reviews (2) · Last reviewed commit: "fix(billing): hold a payment block while..." · Reviewed by Greptile

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

All reported issues were addressed across 2 files

This PR changes payment, billing, or quota logic. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit f54e29d into staging Dec 1, 2026
69 of 77 checks passed
@waleedlatif1
waleedlatif1 deleted the fix/block-on-first-payment-failure branch December 1, 2026 17:31

This branch was previously deployed

1 inactive deployment
Preview — 44bb9c11 Deployed Dec 1, 2026 by vercel[bot]
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.

1 participant