Skip to content

Scheduling infrastructure for absolutely everyone.

feat: Add more metadata to Stripe transaction (#11221)

Kevin Crimi3a05ae6f74d5
diff --git a/packages/app-store/stripepayment/lib/PaymentService.ts b/packages/app-store/stripepayment/lib/PaymentService.ts
index de021a7bcb5..17731e19d76 100644
--- a/packages/app-store/stripepayment/lib/PaymentService.ts
+++ b/packages/app-store/stripepayment/lib/PaymentService.ts
@@ -49,9 +49,13 @@ export class PaymentService implements IAbstractPaymentService {
async create(
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
bookingId: Booking["id"],
+ userId: Booking["userId"],
+ username: string | null,
+ bookerName: string,
bookerEmail: string,
paymentOption: PaymentOption,
- eventTitle?: string
+ eventTitle?: string,
+ bookingTitle?: string
) {
try {
// Ensure that the payment service can support the passed payment option
@@ -82,8 +86,12 @@ export class PaymentService implements IAbstractPaymentService {
metadata: {
identifier: "cal.com",
bookingId,
+ calAccountId: userId,
+ calUsername: username,
+ bookerName,
bookerEmail,
- eventName: eventTitle || "",
+ eventTitle: eventTitle || "",
+ bookingTitle: bookingTitle || "",
},
};
diff --git a/packages/features/bookings/lib/handleNewBooking.ts b/packages/features/bookings/lib/handleNewBooking.ts
index f7ad9e8edea..4d3c48594ef 100644
--- a/packages/features/bookings/lib/handleNewBooking.ts
+++ b/packages/features/bookings/lib/handleNewBooking.ts
@@ -1722,6 +1722,7 @@ async function handler(
eventType,
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
booking,
+ fullName,
bookerEmail
);
@@ -1911,7 +1912,7 @@ async function handler(
const createBookingObj = {
include: {
user: {
- select: { email: true, name: true, timeZone: true },
+ select: { email: true, name: true, timeZone: true, username: true },
},
attendees: true,
payment: true,
@@ -2279,6 +2280,7 @@ async function handler(
eventType,
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
booking,
+ fullName,
bookerEmail
);
@@ -2466,6 +2468,7 @@ const findBookingQuery = async (bookingId: number) => {
name: true,
email: true,
timeZone: true,
+ username: true,
},
},
eventType: {
diff --git a/packages/lib/payment/handlePayment.ts b/packages/lib/payment/handlePayment.ts
index 90155a56bd9..9b3aa85be2c 100644
--- a/packages/lib/payment/handlePayment.ts
+++ b/packages/lib/payment/handlePayment.ts
@@ -8,7 +8,7 @@ import type { IAbstractPaymentService, PaymentApp } from "@calcom/types/PaymentS
const handlePayment = async (
evt: CalendarEvent,
- selectedEventType: Pick<Zod.infer<typeof EventTypeModel>, "metadata">,
+ selectedEventType: Pick<Zod.infer<typeof EventTypeModel>, "metadata" | "title">,
paymentAppCredentials: {
key: Prisma.JsonValue;
appId: EventTypeAppsList;
@@ -18,11 +18,13 @@ const handlePayment = async (
} | null;
},
booking: {
- user: { email: string | null; name: string | null; timeZone: string } | null;
+ user: { email: string | null; name: string | null; timeZone: string; username: string | null } | null;
id: number;
+ userId: number | null;
startTime: { toISOString: () => string };
uid: string;
},
+ bookerName: string,
bookerEmail: string
) => {
const paymentApp = (await appStore[
@@ -58,8 +60,12 @@ const handlePayment = async (
currency: selectedEventType?.metadata?.apps?.[paymentAppCredentials.appId].currency,
},
booking.id,
+ booking.userId,
+ booking.user?.username ?? null,
+ bookerName,
bookerEmail,
paymentOption,
+ selectedEventType.title,
evt.title
);
}
diff --git a/packages/types/PaymentService.d.ts b/packages/types/PaymentService.d.ts
index 43c4b296786..0e89669a476 100644
--- a/packages/types/PaymentService.d.ts
+++ b/packages/types/PaymentService.d.ts
@@ -13,9 +13,13 @@ export interface IAbstractPaymentService {
create(
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
bookingId: Booking["id"],
+ userId: Booking["userId"],
+ username: string | null,
+ bookerName: string | null,
bookerEmail: string,
paymentOption: PaymentOption,
- eventTitle?: string
+ eventTitle?: string,
+ bookingTitle?: string
): Promise<Payment>;
/* This method is to collect card details to charge at a later date ex. no-show fees */
collectCard(