mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
[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:
@@ -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(
|
||||
{},
|
||||
|
||||
Reference in New Issue
Block a user