From 468cd2a3af3b811e9fcd87d6bd47b97753d76de8 Mon Sep 17 00:00:00 2001 From: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Date: Fri, 28 Feb 2025 15:34:08 +0530 Subject: [PATCH] fix: hubSpot doesn't work for paid team events (#19609) --- packages/features/ee/payments/api/webhook.ts | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/packages/features/ee/payments/api/webhook.ts b/packages/features/ee/payments/api/webhook.ts index 02910c013e..2be55d0fe8 100644 --- a/packages/features/ee/payments/api/webhook.ts +++ b/packages/features/ee/payments/api/webhook.ts @@ -7,6 +7,7 @@ import stripe from "@calcom/app-store/stripepayment/lib/server"; import EventManager from "@calcom/core/EventManager"; import { sendAttendeeRequestEmailAndSMS, sendOrganizerRequestEmail } from "@calcom/emails"; import { doesBookingRequireConfirmation } from "@calcom/features/bookings/lib/doesBookingRequireConfirmation"; +import { getAllCredentials } from "@calcom/features/bookings/lib/getAllCredentialsForUsersOnEvent/getAllCredentials"; import { handleConfirmation } from "@calcom/features/bookings/lib/handleConfirmation"; import { IS_PRODUCTION } from "@calcom/lib/constants"; import { getErrorFromUnknown } from "@calcom/lib/errors"; @@ -72,9 +73,15 @@ const handleSetupSuccess = async (event: Stripe.Event) => { eventType, }, }); + + const metadata = eventTypeMetaDataSchemaWithTypedApps.parse(eventType?.metadata); + const allCredentials = await getAllCredentials(user, { + ...eventType, + metadata, + }); + if (!requiresConfirmation) { - const metadata = eventTypeMetaDataSchemaWithTypedApps.parse(eventType?.metadata); - const eventManager = new EventManager(user, metadata?.apps); + const eventManager = new EventManager({ ...user, credentials: allCredentials }, metadata?.apps); const scheduleResult = await eventManager.create(evt); bookingData.references = { create: scheduleResult.referencesToCreate }; bookingData.status = BookingStatus.ACCEPTED; @@ -101,7 +108,7 @@ const handleSetupSuccess = async (event: Stripe.Event) => { if (!requiresConfirmation) { await handleConfirmation({ - user, + user: { ...user, credentials: allCredentials }, evt, prisma, bookingId: booking.id,