cal/packages/features/bookings/lib/getWebhookPayloadForBooking.ts
Hariom Balhara 20898e1505
fix: Handle payment flow webhooks in case of event requiring confirmation (#11458)
Co-authored-by: alannnc <alannnc@gmail.com>
2023-09-30 10:22:32 +05:30

38 lines
958 B
TypeScript

import type { EventTypeInfo } from "@calcom/features/webhooks/lib/sendPayload";
import type { CalendarEvent } from "@calcom/types/Calendar";
export const getWebhookPayloadForBooking = ({
booking,
evt,
}: {
booking: {
eventType: {
title: string;
description: string | null;
requiresConfirmation: boolean;
price: number;
currency: string;
length: number;
id: number;
} | null;
id: number;
eventTypeId: number | null;
userId: number | null;
};
evt: CalendarEvent;
}) => {
const eventTypeInfo: EventTypeInfo = {
eventTitle: booking.eventType?.title,
eventDescription: booking.eventType?.description,
requiresConfirmation: booking.eventType?.requiresConfirmation || null,
price: booking.eventType?.price,
currency: booking.eventType?.currency,
length: booking.eventType?.length,
};
return {
...evt,
...eventTypeInfo,
bookingId: booking.id,
};
};