Repository navigation
fix(billing): block a failed payer only while the invoice is still owed - #10601
Conversation
Read the invoice back from Stripe before blocking, so a failure event that arrives after the invoice was paid or voided blocks nobody. A failure Stripe counted no attempt for blocks only once the plan is past due, so an active plan keeps access while the customer completes an authentication-required charge. Answer a charge too large for the card with a different-card message logged as an error, and correct the overage-invoice log that claimed Stripe retries it.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Confidence Score: 5/5
[Medium impact] The latest change appears safe to merge; no new actionable issue was found. SummaryThe latest change keeps failed invoices marked
Reviews (3) · Last reviewed commit: "fix(billing): keep blocking on an invoic..." · Reviewed by Greptile |
There was a problem hiding this comment.
All reported issues were addressed across 6 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
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
There was a problem hiding this comment.
All reported issues were addressed across 6 files
Requires human review: Auto-approval blocked because this review re-detected 1 unresolved issue already reported by Cubic.
Turn on auto-fix | Re-trigger cubic
|
@cubic-dev-ai review this PR |
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
Summary
Follow-ups from an audit of #10530 and #10579:
handleInvoicePaymentFailedreads the invoice back from Stripe before blocking. Webhooks can land late or be redelivered, so a failure that arrives after the invoice was paid or voided no longer blocks a payer nothing will unblockamount_too_largeis permanent for that card, so it now asks for a different card and logs at error (it can signal a pricing misconfiguration); rate limits keep the "try again later" messageauto_advance: false)Type of Change
Testing
lib/billing/webhooks/invoices.integration.ts(real Postgres): no block when the invoice is already paid or voided; no block for an uncounted failure on an active plan; a never-attempted open invoice doesn't hold the block.lib/billing/free-plan.integration.ts: a too-large charge asks for a different card. The four new guard tests fail on staging and pass here; 33/33 greenlib/billing/webhooks/unit tests 18/18; biome on the changed files; type-check, audits and the full suite in CIChecklist
test-auditauthoring gate)