[web] ensure Stripe & Recurly webhooks can handle a migrating subscription (#30787)

* return early from various event handlers if the subscription isn't controlled by the payment provider sending the event
* update `Subscription` type for webhook events

GitOrigin-RevId: f3fc345c37bbe134b7696ccde9d6d8c7608f8f12
This commit is contained in:
Kristina
2026-01-20 09:05:36 +00:00
committed by Copybot
parent 3786471135
commit 1228eac81e
5 changed files with 101 additions and 19 deletions
@@ -3,6 +3,7 @@ import AnalyticsManager from '../Analytics/AnalyticsManager.mjs'
import SubscriptionEmailHandler from './SubscriptionEmailHandler.mjs'
import { AI_ADD_ON_CODE } from './AiHelper.mjs'
import mongodb from 'mongodb-legacy'
import SubscriptionLocator from './SubscriptionLocator.mjs'
const { ObjectId } = mongodb
@@ -14,6 +15,17 @@ async function sendRecurlyAnalyticsEvent(event, eventData) {
return
}
const subscription =
await SubscriptionLocator.promises.getUsersSubscription(userId)
if (
subscription?.paymentProvider?.service &&
subscription.paymentProvider.service.includes('stripe')
) {
// do not send recurly events for subscriptions managed by stripe
return
}
const customerIoEnabled =
await SplitTestHandler.promises.hasUserBeenAssignedToVariant(
{},