Zomars/cal 748 paid bookings are failing (#1335)

* E2E video adjustments

* Adds test to add Stripe integration

* Type fix

* WIP: Payment troubleshooting

* Paid bookings shouldn't be confirmed by default

* Runs stripe test only if installed

* BookingListItem Adjustments

* Pending paid bookings should be unconfirmed

* Attempt to fix paid bookings

* Type fixes

* Type fixes

* Tests fixes

* Adds paid booking to seeder

* Moves stripe tests to own file

* Matches app locale to Stripe's

* Fixes minimun price for testing

* Stripe test fixes

* Fixes stripe frame test

* Added some Stripe TODOs
This commit is contained in:
Omar López authored and GitHub committed 2021-12-17 16:58:23 +00:00
1 parent ca405743fb
commit 21103580f7
19 files changed
+201 -51

No files matched your search

+13 -6
View File
@@ -5,8 +5,15 @@ import { getSession } from "@lib/auth";
import prisma from "@lib/prisma";
import { WorkingHours } from "@lib/types/schedule";
function handlePeriodType(periodType: string): PeriodType {
return PeriodType[periodType.toUpperCase()];
function isPeriodType(keyInput: string): keyInput is PeriodType {
return Object.keys(PeriodType).includes(keyInput);
}
function handlePeriodType(periodType: string): PeriodType | undefined {
if (typeof periodType !== "string") return undefined;
const passedPeriodType = periodType.toUpperCase();
if (!isPeriodType(passedPeriodType)) return undefined;
return PeriodType[passedPeriodType];
}
function handleCustomInputs(customInputs: EventTypeCustomInput[], eventTypeId: number) {
@@ -104,7 +111,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
}
if (req.method == "PATCH" || req.method == "POST") {
if (req.method === "PATCH" || req.method === "POST") {
const data: Prisma.EventTypeCreateInput | Prisma.EventTypeUpdateInput = {
title: req.body.title,
slug: req.body.slug.trim(),
@@ -116,7 +123,7 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
locations: req.body.locations,
eventName: req.body.eventName,
customInputs: handleCustomInputs(req.body.customInputs as EventTypeCustomInput[], req.body.id),
periodType: req.body.periodType ? handlePeriodType(req.body.periodType) : undefined,
periodType: handlePeriodType(req.body.periodType),
periodDays: req.body.periodDays,
periodStartDate: req.body.periodStartDate,
periodEndDate: req.body.periodEndDate,
@@ -179,8 +186,8 @@ export default async function handler(req: NextApiRequest, res: NextApiResponse)
}
const availabilityToCreate = openingHours.map((openingHour) => ({
startTime: openingHour.startTime,
endTime: openingHour.endTime,
startTime: new Date(openingHour.startTime),
endTime: new Date(openingHour.endTime),
days: openingHour.days,
}));