[PM-31781] skip unpaid automations for exempt orgs#7480
[PM-31781] skip unpaid automations for exempt orgs#7480
Conversation
🤖 Bitwarden Claude Code ReviewOverall Assessment: APPROVE This PR adds exemption logic to Code Review DetailsNo findings. Behavior change worth noting (intentional and covered by tests): when the subscriber referenced by the Stripe event cannot be found in the local DB, the handler now exits early and |
|
Great job! No new security vulnerabilities introduced in this pull request |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## main #7480 +/- ##
==========================================
+ Coverage 59.50% 59.61% +0.10%
==========================================
Files 2089 2096 +7
Lines 92418 92584 +166
Branches 8214 8250 +36
==========================================
+ Hits 54994 55191 +197
+ Misses 35481 35439 -42
- Partials 1943 1954 +11 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
…paid with that billing reason
amorask-bitwarden
left a comment
There was a problem hiding this comment.
Looks great - nice work and thanks for updating those magic strings.
|
|
@amorask-bitwarden Added the db existence guard we discussed and also refactored to not have duplicate db lookups in the latest push. |




🎟️ Tracking
https://bitwarden.atlassian.net/browse/PM-31781
📔 Objective
Added exemption logic to
SubscriptionUpdatedHandlerthat skips unpaid billing automations (disable + cancellation) for organizations withExemptFromBillingAutomation = true. The flag is cleared after use so the exemption is single-use.Changes
SubscriptionUpdatedHandler.csSubscriptionWentUnpaidandSubscriptionWentIncompleteExpiredinto distinct branches. The exemption only applies tounpaid, notincomplete_expired.SkipUnpaidBillingAutomationsForExemptOrganizationAsync: checksEnabled && ExemptFromBillingAutomation, clears the flag, and logs. Returnsfalsefor user/provider subscribers.subscription_createbut it is impossible for a subscription to enterunpaidstatus with that billing reason, so I removed that check altogether fromSubscriptionWentUnpaid.subscription_updateandautomatic_pending_invoice_item_invoicebilling reasons, but no code was needed for these because they have always been excluded from theSubscriptionWentUnpaidcheck, so they never get processed as unpaid, and thus the acceptance criteria is already satisfied. (do not delete and do not remove the exempt flag)StripeConstants.csAutomaticPendingInvoiceItemInvoiceandSubscriptionUpdatebilling reason constants.InvoiceCreatedHandler.cs,PaymentFailedHandler.cs,StripeEventUtilityService.csStripeConstants.BillingReasonsconstants. No behavioral change.SubscriptionUpdatedHandlerTests.cssubscription_cycle→ skip disable, clear flagsubscription_update→ no action, flag preservedautomatic_pending_invoice_item_invoice→ no action, flag preserved