Fix attendees on a booking with seats and payments, navigate to the payment page. (#5788)

* Payment booking logic to seats

* Pass email to success page from payment page

* Fix type error

Co-authored-by: Alan <[email protected]>
This commit is contained in:
Joe Au-YeungandAlan authored and GitHub committed 2022-12-02 00:12:06 +00:00
1 parent 78aa4aecef
commit 19d00e691c
3 files changed
+31 -18

No files matched your search

@@ -519,16 +519,9 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) {
id: true,
attendees: true,
userId: true,
references: {
select: {
type: true,
uid: true,
meetingId: true,
meetingPassword: true,
meetingUrl: true,
externalCalendarId: true,
},
},
references: true,
startTime: true,
user: true,
},
});
if (!booking) {
@@ -579,6 +572,20 @@ async function handler(req: NextApiRequest & { userId?: number | undefined }) {
const eventManager = new EventManager({ ...organizerUser, credentials });
await eventManager.updateCalendarAttendees(evt, booking);
if (!Number.isNaN(stripeAppData.price) && stripeAppData.price > 0 && !!booking) {
const [firstStripeCredential] = organizerUser.credentials.filter(
(cred) => cred.type == "stripe_payment"
);
if (!firstStripeCredential)
throw new HttpError({ statusCode: 400, message: "Missing payment credentials" });
const payment = await handlePayment(evt, eventType, firstStripeCredential, booking);
req.statusCode = 201;
return { ...booking, message: "Payment required", paymentUid: payment.uid };
}
req.statusCode = 201;
return booking;
}
@@ -66,7 +66,7 @@ export default function PaymentComponent(props: Props) {
const handleSubmit = async (ev: SyntheticEvent) => {
ev.preventDefault();
if (!stripe || !elements) return;
if (!stripe || !elements || !router.isReady) return;
const card = elements.getElement(CardElement);
if (!card) return;
setState({ status: "processing" });
@@ -81,7 +81,10 @@ export default function PaymentComponent(props: Props) {
error: new Error(`Payment failed: ${payload.error.message}`),
});
} else {
const params: { [k: string]: any } = {};
const params: { [k: string]: any } = {
uid: props.bookingUid,
email: router.query.email,
};
if (props.location) {
if (props.location.includes("integration")) {