diff --git a/apps/web/ee/components/stripe/Payment.tsx b/apps/web/ee/components/stripe/Payment.tsx index e1ae9dd2bb..c6157114b2 100644 --- a/apps/web/ee/components/stripe/Payment.tsx +++ b/apps/web/ee/components/stripe/Payment.tsx @@ -35,6 +35,7 @@ type Props = { eventType: { id: number }; user: { username: string | null }; location?: string | null; + bookingId: number; }; type States = @@ -86,6 +87,7 @@ export default function PaymentComponent(props: Props) { type: props.eventType.id, user: props.user.username, name, + bookingId: props.bookingId, }; if (props.location) { diff --git a/apps/web/ee/components/stripe/PaymentPage.tsx b/apps/web/ee/components/stripe/PaymentPage.tsx index 08606bdd67..d1bfd3e835 100644 --- a/apps/web/ee/components/stripe/PaymentPage.tsx +++ b/apps/web/ee/components/stripe/PaymentPage.tsx @@ -137,6 +137,7 @@ const PaymentPage: FC = (props) => { eventType={props.eventType} user={props.user} location={props.booking.location} + bookingId={props.booking.id} /> )} diff --git a/apps/web/ee/pages/payment/[uid].tsx b/apps/web/ee/pages/payment/[uid].tsx index 23b44b9003..fd7021b9b8 100644 --- a/apps/web/ee/pages/payment/[uid].tsx +++ b/apps/web/ee/pages/payment/[uid].tsx @@ -21,6 +21,7 @@ export const getServerSideProps = async (context: GetServerSidePropsContext) => bookingId: true, booking: { select: { + id: true, description: true, title: true, startTime: true, diff --git a/apps/web/pages/api/book/event.ts b/apps/web/pages/api/book/event.ts index 05dcc2b58b..52bf93f912 100644 --- a/apps/web/pages/api/book/event.ts +++ b/apps/web/pages/api/book/event.ts @@ -769,6 +769,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse) try { const [firstStripeCredential] = user.credentials.filter((cred) => cred.type == "stripe_payment"); + if (!firstStripeCredential) return res.status(500).json({ message: "Missing payment credentials" }); + if (!booking.user) booking.user = user; const payment = await handlePayment(evt, eventType, firstStripeCredential, booking); diff --git a/apps/web/pages/success.tsx b/apps/web/pages/success.tsx index 52b0e715e5..45ef3ff8a0 100644 --- a/apps/web/pages/success.tsx +++ b/apps/web/pages/success.tsx @@ -636,7 +636,9 @@ export async function getServerSideProps(context: GetServerSidePropsContext) { const recurringEventIdQuery = asStringOrNull(context.query.recur); const typeSlug = asStringOrNull(context.query.eventSlug) ?? "15min"; const dynamicEventName = asStringOrNull(context.query.eventName) ?? ""; - const bookingId = parseInt(context.query.bookingId as string); + if (typeof context.query.bookingId !== "string") return { notFound: true } as const; + const bookingId = parseInt(context.query.bookingId); + //http://localhost:3000/success?date=2022-06-02T02%3A00%3A00-06%3A00&type=5&user=pro&name=Stripe%20Stripeson if (isNaN(typeId)) { return { diff --git a/apps/web/playwright/booking-pages.test.ts b/apps/web/playwright/booking-pages.test.ts index 1df5137ee7..59814f3688 100644 --- a/apps/web/playwright/booking-pages.test.ts +++ b/apps/web/playwright/booking-pages.test.ts @@ -85,7 +85,7 @@ test.describe("pro user", () => { test("pro user's page has at least 2 visible events", async ({ page }) => { // await page.pause(); - const $eventTypes = await page.locator("[data-testid=event-types] > *"); + const $eventTypes = page.locator("[data-testid=event-types] > *"); expect(await $eventTypes.count()).toBeGreaterThanOrEqual(2); }); @@ -102,7 +102,7 @@ test.describe("pro user", () => { await bookFirstEvent(page); await page.goto("/bookings/upcoming"); - await page.locator('[data-testid="reschedule"]').click(); + await page.locator('[data-testid="reschedule"]').nth(0).click(); await page.locator('[data-testid="edit"]').click(); await page.waitForNavigation({ url: (url) => { diff --git a/apps/web/playwright/dynamic-booking-pages.test.ts b/apps/web/playwright/dynamic-booking-pages.test.ts index fe0c257603..0f73b459ee 100644 --- a/apps/web/playwright/dynamic-booking-pages.test.ts +++ b/apps/web/playwright/dynamic-booking-pages.test.ts @@ -8,6 +8,8 @@ import { selectSecondAvailableTimeSlotNextMonth, } from "./lib/testUtils"; +test.describe.configure({ mode: "parallel" }); + test.describe("dynamic booking", () => { test.use({ storageState: "playwright/artifacts/proStorageState.json" }); @@ -17,7 +19,7 @@ test.describe("dynamic booking", () => { await page.goto("/pro+free"); }); - test.afterAll(async () => { + test.afterEach(async () => { // delete test bookings await deleteAllBookingsByEmail("pro@example.com"); await deleteAllBookingsByEmail("free@example.com"); @@ -36,7 +38,7 @@ test.describe("dynamic booking", () => { // Logged in await page.goto("/bookings/upcoming"); - await page.locator('[data-testid="reschedule"]').click(); + await page.locator('[data-testid="reschedule"]').nth(0).click(); await page.locator('[data-testid="edit"]').click(); await page.waitForNavigation({ url: (url) => { diff --git a/apps/web/playwright/reschedule.test.ts b/apps/web/playwright/reschedule.test.ts index d21cdbaae4..60459fae72 100644 --- a/apps/web/playwright/reschedule.test.ts +++ b/apps/web/playwright/reschedule.test.ts @@ -58,7 +58,7 @@ test.describe("Reschedule Tests", async () => { await page.goto("/bookings/upcoming"); - await page.locator('[data-testid="reschedule"]').click(); + await page.locator('[data-testid="reschedule"]').nth(0).click(); await page.locator('[data-testid="reschedule_request"]').click();