Repository navigation
fix(stripe): report declined payments to bouncer - #8460
Conversation
Bouncer's card_testing rule counts charge.failed credit events. Stripe reports a declined card attempt as payment_intent.payment_failed, which the webhook ignored, so the rule never saw a failure. Report a declined attempt as one charge.failed event keyed on its charge id, so a second event for the same attempt counts once, and read the card fingerprint from that charge.
Code Review SummaryStatus: No Issues Found | Recommendation: Merge Executive SummaryThe incremental commit only extends the charge-authentication table test with the Assumptions: Files Reviewed (2 files)
Previous Review Summaries (3 snapshots, latest commit b6e0687)Current summary above is authoritative. Previous snapshots are kept for context only. Previous review (commit b6e0687)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe incremental change correctly closes the Assumptions: Overview
Issue Details (click to expand)SUGGESTION
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 71dd91d)Status: 1 Issue Found | Recommendation: Address before merge Executive SummaryThe new authentication-failure filter applies only to Assumptions: Overview
Issue Details (click to expand)WARNING
Files Reviewed (2 files)
Fix these issues in Kilo Cloud Previous review (commit 6858725)Status: 2 Issues Found | Recommendation: Address before merge Overview
Issue Details (click to expand)WARNING
SUGGESTION
Fix these issues in Kilo Cloud Files Reviewed (2 files)
Reviewed by deepseek-flash-latest · Input: 43.4K · Output: 4K · Cached: 420.2K Review guidance: REVIEW.md from base branch |
Skip a payment intent that failed authentication: a retried 3DS challenge is not a declined card, and counting it would reach bouncer's card-testing threshold for a paying customer. Read a missing fingerprint from the intent's charge, then its payment method. A charge.failed payload already is the charge, so it no longer re-reads itself.
A charge that failed an authentication challenge is the same attempt a payment intent reports. Checking the charge's failure code and outcome reason as well keeps a retried 3DS challenge out of bouncer's card-testing count on both paths.
Bouncer's
card_testingrule countscharge.failedcredit events. Stripe reports a declined card attempt to the webhook aspayment_intent.payment_failed, and the handler read neither that event nor the charge behind it, so the rule never saw a failure.Change
payment_intent.payment_failedand enqueue acharge.failedcredit event.payment_intent.payment_failedandcharge.failed.Verification
apps/web/src/lib/stripe/index.test.ts: a declined payment intent reports the payer and card, both events for one attempt produce one row, an attempt with no charge keeps its own key, and an unresolved payer enqueues nothing.