();
const price = getAppData("price");
@@ -32,6 +37,9 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
const paymentOption = getAppData("paymentOption");
const paymentOptionSelectValue = paymentOptions.find((option) => paymentOption === option.value);
const [requirePayment, setRequirePayment] = useState(getAppData("enabled"));
+ const otherPaymentAppEnabled = checkForMultiplePaymentApps(eventTypeFormMetadata);
+
+ const shouldDisableSwitch = !requirePayment && otherPaymentAppEnabled;
const { t } = useLocale();
const recurringEventDefined = eventType.recurringEvent?.count !== undefined;
@@ -66,7 +74,9 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
switchOnClick={(enabled) => {
setRequirePayment(enabled);
}}
- teamId={eventType.team?.id || undefined}>
+ teamId={eventType.team?.id || undefined}
+ disableSwitch={shouldDisableSwitch}
+ switchTooltip={shouldDisableSwitch ? t("other_payment_app_enabled") : undefined}>
<>
{recurringEventDefined && (
@@ -75,7 +85,7 @@ const EventTypeAppCard: EventTypeAppCardComponent = function EventTypeAppCard({
<>
;
};
export type EventTypeAppCardComponent = React.FC;
diff --git a/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts b/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts
index 1f5fb9e13b..96bf895607 100644
--- a/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts
+++ b/packages/trpc/server/routers/viewer/eventTypes/update.handler.ts
@@ -1,6 +1,7 @@
import { Prisma } from "@prisma/client";
import type { NextApiResponse, GetServerSidePropsContext } from "next";
+import type { appDataSchemas } from "@calcom/app-store/apps.schemas.generated";
import updateChildrenEventTypes from "@calcom/features/ee/managed-event-types/lib/handleChildrenEventTypes";
import { validateIntervalLimitOrder } from "@calcom/lib";
import logger from "@calcom/lib/logger";
@@ -240,31 +241,14 @@ export const updateHandler = async ({ ctx, input }: UpdateOptions) => {
}
}
- /**
- * Since you can have multiple payment apps we will honor the first one to save in eventType
- * but the real detail will be inside app metadata, so with this you can have different prices in different apps
- * So the price and currency inside eventType will be deprecated soon or just keep as reference.
- */
- if (
- input.metadata?.apps?.alby?.price ||
- input?.metadata?.apps?.paypal?.price ||
- input?.metadata?.apps?.stripe?.price
- ) {
- data.price =
- input.metadata?.apps?.alby?.price ||
- input.metadata.apps.paypal?.price ||
- input.metadata.apps.stripe?.price;
- }
-
- if (
- input.metadata?.apps?.alby?.currency ||
- input?.metadata?.apps?.paypal?.currency ||
- input?.metadata?.apps?.stripe?.currency
- ) {
- data.currency =
- input.metadata?.apps?.alby?.currency ||
- input.metadata.apps.paypal?.currency ||
- input.metadata.apps.stripe?.currency;
+ for (const appKey in input.metadata?.apps) {
+ const app = input.metadata?.apps[appKey as keyof typeof appDataSchemas];
+ // There should only be one enabled payment app in the metadata
+ if (app.enabled && app.price && app.currency) {
+ data.price = app.price;
+ data.currency = app.currency;
+ break;
+ }
}
const connectedLink = await ctx.prisma.hashedLink.findFirst({