Enables require confirmation after payment its made (#5671)

This commit is contained in:
alannnc authored and GitHub committed 2022-11-29 18:28:02 +00:00
1 parent d3e9adf382
commit 16fda5f599
3 files changed
+15 -2

No files matched your search

+8 -1
View File
@@ -65,7 +65,10 @@ async function handlePaymentSuccess(event: Stripe.Event) {
if (!booking) throw new HttpCode({ statusCode: 204, message: "No booking found" });
const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({ recurringEvent: true });
const eventTypeSelect = Prisma.validator<Prisma.EventTypeSelect>()({
recurringEvent: true,
requiresConfirmation: true,
});
const eventTypeData = Prisma.validator<Prisma.EventTypeArgs>()({ select: eventTypeSelect });
type EventTypeRaw = Prisma.EventTypeGetPayload<typeof eventTypeData>;
let eventTypeRaw: EventTypeRaw | null = null;
@@ -130,6 +133,10 @@ async function handlePaymentSuccess(event: Stripe.Event) {
bookingData.references = { create: scheduleResult.referencesToCreate };
}
if (eventTypeRaw?.requiresConfirmation) {
delete bookingData.status;
}
const paymentUpdate = prisma.payment.update({
where: {
id: payment.id,
@@ -504,7 +504,8 @@ export const eventTypesRouter = router({
};
}
if (input?.price) {
if (input?.price || input.metadata?.apps?.stripe?.price) {
data.price = input.price || input.metadata?.apps?.stripe?.price;
const paymentCredential = await ctx.prisma.credential.findFirst({
where: {
userId: ctx.user.id,