fix(billing): unblock on payment success for overage retries#4121
fix(billing): unblock on payment success for overage retries#4121icecrasher321 merged 1 commit intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryMedium Risk Overview Adds targeted Vitest coverage verifying org member blocking on metadata-backed payment failures and unblocking on subsequent payment success. Reviewed by Cursor Bugbot for commit 5aea045. Configure here. |
Greptile SummaryThis PR fixes a bug where Confidence Score: 5/5Safe to merge — the logic fix is correct and all remaining findings are P2 style/coverage suggestions. The core bug fix is sound: resolveInvoiceSubscription correctly prefers the parent-subscription link and falls back to metadata for overage invoice types, making both handlers consistent. The only findings are a relative import in the test file (trivial style violation) and a missing test for the wasBlocked=true scenario. Neither affects runtime correctness. apps/sim/lib/billing/webhooks/invoices.test.ts — relative import and limited coverage of the wasBlocked=true branch. Important Files Changed
Flowchart%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[Stripe Invoice Event] --> B{invoice.metadata.type}
B -->|credit_purchase| C[handleCreditPurchaseSuccess]
B -->|other / overage types| D[resolveInvoiceSubscriptionContext]
D --> E{parent.subscription_details.subscription present?}
E -->|Yes| F[resolutionSource: parent link]
E -->|No| G{metadata.type in METADATA_SUBSCRIPTION_INVOICE_TYPES?}
G -->|Yes + metadata.subscriptionId set| H[resolutionSource: metadata]
G -->|No| I[resolutionSource: none → skip]
F --> J[DB lookup by stripeSubscriptionId]
H --> J
J -->|not found| K[log warn → skip]
J -->|found| L[ResolvedInvoiceSubscription]
L --> M{Event type}
M -->|payment_succeeded| N[Check wasBlocked / Unblock if shouldUnblock / Reset usage if wasBlocked]
M -->|payment_failed| O[Block org members or user / Send email on attempt 1]
Reviews (1): Last reviewed commit: "fix(billing): unblock on payment success" | Re-trigger Greptile |
Summary
Divergence in block path (which works correctly) and unblock on payment success in the way they resolve subscription id. Unblock did not work on overage invoice retries success.
Type of Change
Testing
Tested manually
Checklist