Skip to content

Commit

Permalink
Merge branch 'main' into refactor_allow_managed_event_tests_parallel_…
Browse files Browse the repository at this point in the history
…runs
  • Loading branch information
zomars authored Aug 15, 2024
2 parents 61889ab + 5df14c3 commit 55b0b90
Showing 1 changed file with 12 additions and 20 deletions.
32 changes: 12 additions & 20 deletions packages/trpc/server/routers/viewer/payments.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,9 @@ import { z } from "zod";
import appStore from "@calcom/app-store";
import dayjs from "@calcom/dayjs";
import { sendNoShowFeeChargedEmail } from "@calcom/emails";
import getWebhooks from "@calcom/features/webhooks/lib/getWebhooks";
import { WebhookService } from "@calcom/features/webhooks/lib/WebhookService";
import getOrgIdFromMemberOrTeamId from "@calcom/lib/getOrgIdFromMemberOrTeamId";
import { getTranslation } from "@calcom/lib/server/i18n";
import sendPayload from "@calcom/lib/server/webhooks/sendPayload";
import { WebhookTriggerEvents } from "@calcom/prisma/enums";
import type { EventTypeMetadata } from "@calcom/prisma/zod-utils";
import type { CalendarEvent } from "@calcom/types/Calendar";
Expand Down Expand Up @@ -128,27 +127,20 @@ export const paymentsRouter = router({

const userId = ctx.user.id || 0;
const orgId = await getOrgIdFromMemberOrTeamId({ memberId: userId });

const subscriberOptions = {
const eventTypeId = booking.eventTypeId || 0;
const webhooks = await new WebhookService({
userId,
eventTypeId: booking.eventTypeId || 0,
eventTypeId,
triggerEvent: WebhookTriggerEvents.BOOKING_PAID,
orgId,
};

const subscribers = await getWebhooks(subscriberOptions);

await Promise.all(
subscribers.map(async (subscriber) => {
sendPayload(subscriber.secret, WebhookTriggerEvents.BOOKING_PAID, {
...evt,
bookingId: booking.id,
paymentId: payment.id,
paymentData,
eventTypeId: subscriberOptions.eventTypeId,
});
})
);
});
await webhooks.sendPayload({
...evt,
bookingId: booking.id,
paymentId: payment.id,
paymentData,
eventTypeId,
});

await sendNoShowFeeChargedEmail(
attendeesListPromises[0],
Expand Down

0 comments on commit 55b0b90

Please sign in to comment.