email reminders
This commit is contained in:
@@ -14,6 +14,7 @@
|
||||
import type { PrismaClient } from "@/generated/prisma/client";
|
||||
import { stripe } from "@/lib/stripe";
|
||||
import { sendBookingConfirmation } from "@/lib/email";
|
||||
import { scheduleReminderForBooking } from "@/lib/reminders";
|
||||
|
||||
/**
|
||||
* Create a Stripe PaymentIntent for the booking's deposit and persist its id.
|
||||
@@ -177,10 +178,19 @@ export async function recordPaymentFailed(
|
||||
return { bookingId: booking.id };
|
||||
}
|
||||
|
||||
/** Convenience used by the webhook to send the confirmation email after payment. */
|
||||
/** Convenience used by the webhook after a payment succeeds and the booking
|
||||
* transitions to CONFIRMED — sends the confirmation email and schedules the
|
||||
* 24h reminder.
|
||||
*/
|
||||
export async function confirmAfterPayment(
|
||||
db: PrismaClient,
|
||||
bookingId: string,
|
||||
): Promise<void> {
|
||||
const booking = await db.booking.findUnique({
|
||||
where: { id: bookingId },
|
||||
select: { startsAt: true },
|
||||
});
|
||||
if (!booking) return;
|
||||
await sendBookingConfirmation({ db, bookingId });
|
||||
await scheduleReminderForBooking(bookingId, booking.startsAt);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user