feat: Add more metadata to Stripe transaction (#11221)
* Add booker info, event type title, and organizer info into Stripe metadata * Add back bookingTitle in addition to eventTitle * Remove .tool-versions * Fix typo --------- Co-authored-by: alannnc <alannnc@gmail.com>
This commit is contained in:
parent
efcfd7bb9b
commit
3a05ae6f74
|
@ -49,9 +49,13 @@ export class PaymentService implements IAbstractPaymentService {
|
||||||
async create(
|
async create(
|
||||||
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
|
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
|
||||||
bookingId: Booking["id"],
|
bookingId: Booking["id"],
|
||||||
|
userId: Booking["userId"],
|
||||||
|
username: string | null,
|
||||||
|
bookerName: string,
|
||||||
bookerEmail: string,
|
bookerEmail: string,
|
||||||
paymentOption: PaymentOption,
|
paymentOption: PaymentOption,
|
||||||
eventTitle?: string
|
eventTitle?: string,
|
||||||
|
bookingTitle?: string
|
||||||
) {
|
) {
|
||||||
try {
|
try {
|
||||||
// Ensure that the payment service can support the passed payment option
|
// Ensure that the payment service can support the passed payment option
|
||||||
|
@ -82,8 +86,12 @@ export class PaymentService implements IAbstractPaymentService {
|
||||||
metadata: {
|
metadata: {
|
||||||
identifier: "cal.com",
|
identifier: "cal.com",
|
||||||
bookingId,
|
bookingId,
|
||||||
|
calAccountId: userId,
|
||||||
|
calUsername: username,
|
||||||
|
bookerName,
|
||||||
bookerEmail,
|
bookerEmail,
|
||||||
eventName: eventTitle || "",
|
eventTitle: eventTitle || "",
|
||||||
|
bookingTitle: bookingTitle || "",
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1722,6 +1722,7 @@ async function handler(
|
||||||
eventType,
|
eventType,
|
||||||
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
|
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
|
||||||
booking,
|
booking,
|
||||||
|
fullName,
|
||||||
bookerEmail
|
bookerEmail
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -1911,7 +1912,7 @@ async function handler(
|
||||||
const createBookingObj = {
|
const createBookingObj = {
|
||||||
include: {
|
include: {
|
||||||
user: {
|
user: {
|
||||||
select: { email: true, name: true, timeZone: true },
|
select: { email: true, name: true, timeZone: true, username: true },
|
||||||
},
|
},
|
||||||
attendees: true,
|
attendees: true,
|
||||||
payment: true,
|
payment: true,
|
||||||
|
@ -2279,6 +2280,7 @@ async function handler(
|
||||||
eventType,
|
eventType,
|
||||||
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
|
eventTypePaymentAppCredential as IEventTypePaymentCredentialType,
|
||||||
booking,
|
booking,
|
||||||
|
fullName,
|
||||||
bookerEmail
|
bookerEmail
|
||||||
);
|
);
|
||||||
|
|
||||||
|
@ -2466,6 +2468,7 @@ const findBookingQuery = async (bookingId: number) => {
|
||||||
name: true,
|
name: true,
|
||||||
email: true,
|
email: true,
|
||||||
timeZone: true,
|
timeZone: true,
|
||||||
|
username: true,
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
eventType: {
|
eventType: {
|
||||||
|
|
|
@ -8,7 +8,7 @@ import type { IAbstractPaymentService, PaymentApp } from "@calcom/types/PaymentS
|
||||||
|
|
||||||
const handlePayment = async (
|
const handlePayment = async (
|
||||||
evt: CalendarEvent,
|
evt: CalendarEvent,
|
||||||
selectedEventType: Pick<Zod.infer<typeof EventTypeModel>, "metadata">,
|
selectedEventType: Pick<Zod.infer<typeof EventTypeModel>, "metadata" | "title">,
|
||||||
paymentAppCredentials: {
|
paymentAppCredentials: {
|
||||||
key: Prisma.JsonValue;
|
key: Prisma.JsonValue;
|
||||||
appId: EventTypeAppsList;
|
appId: EventTypeAppsList;
|
||||||
|
@ -18,11 +18,13 @@ const handlePayment = async (
|
||||||
} | null;
|
} | null;
|
||||||
},
|
},
|
||||||
booking: {
|
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;
|
id: number;
|
||||||
|
userId: number | null;
|
||||||
startTime: { toISOString: () => string };
|
startTime: { toISOString: () => string };
|
||||||
uid: string;
|
uid: string;
|
||||||
},
|
},
|
||||||
|
bookerName: string,
|
||||||
bookerEmail: string
|
bookerEmail: string
|
||||||
) => {
|
) => {
|
||||||
const paymentApp = (await appStore[
|
const paymentApp = (await appStore[
|
||||||
|
@ -58,8 +60,12 @@ const handlePayment = async (
|
||||||
currency: selectedEventType?.metadata?.apps?.[paymentAppCredentials.appId].currency,
|
currency: selectedEventType?.metadata?.apps?.[paymentAppCredentials.appId].currency,
|
||||||
},
|
},
|
||||||
booking.id,
|
booking.id,
|
||||||
|
booking.userId,
|
||||||
|
booking.user?.username ?? null,
|
||||||
|
bookerName,
|
||||||
bookerEmail,
|
bookerEmail,
|
||||||
paymentOption,
|
paymentOption,
|
||||||
|
selectedEventType.title,
|
||||||
evt.title
|
evt.title
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,9 +13,13 @@ export interface IAbstractPaymentService {
|
||||||
create(
|
create(
|
||||||
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
|
payment: Pick<Prisma.PaymentUncheckedCreateInput, "amount" | "currency">,
|
||||||
bookingId: Booking["id"],
|
bookingId: Booking["id"],
|
||||||
|
userId: Booking["userId"],
|
||||||
|
username: string | null,
|
||||||
|
bookerName: string | null,
|
||||||
bookerEmail: string,
|
bookerEmail: string,
|
||||||
paymentOption: PaymentOption,
|
paymentOption: PaymentOption,
|
||||||
eventTitle?: string
|
eventTitle?: string,
|
||||||
|
bookingTitle?: string
|
||||||
): Promise<Payment>;
|
): Promise<Payment>;
|
||||||
/* This method is to collect card details to charge at a later date ex. no-show fees */
|
/* This method is to collect card details to charge at a later date ex. no-show fees */
|
||||||
collectCard(
|
collectCard(
|
||||||
|
|
Loading…
Reference in New Issue
Block a user