Enables require confirmation after payment its made (#5671)

This commit is contained in:
alannnc
2022-11-29 18:28:02 +00:00
committed by GitHub
parent d3e9adf382
commit 16fda5f599
3 changed files with 15 additions and 2 deletions
@@ -282,6 +282,11 @@ function BookingListItem(booking: BookingItemProps) {
{t("pending_payment")}
</Badge>
)}
{booking.paid && (
<Badge className="ltr:mr-2 rtl:ml-2" variant="green">
{t("paid")}
</Badge>
)}
{recurringDates !== undefined && (
<div className="mt-2 text-sm text-gray-400">
<RecurringBookingsTooltip booking={booking} recurringDates={recurringDates} />
+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,