"use client"; import { useEffect, useState } from "react"; import z from "zod"; import type { PaymentPageProps } from "@calcom/features/ee/payments/pages/payment"; import { useBookingSuccessRedirect } from "@calcom/lib/bookingSuccessRedirect"; import { useCompatSearchParams } from "@calcom/lib/hooks/useCompatSearchParams"; import { useCopy } from "@calcom/lib/hooks/useCopy"; import { useLocale } from "@calcom/lib/hooks/useLocale"; import { trpc } from "@calcom/trpc"; import { Button } from "@calcom/ui/components/button"; import { Spinner } from "@calcom/ui/components/icon"; import { showToast } from "@calcom/ui/components/toast"; interface IPaymentComponentProps { payment: { // Will be parsed on render data: unknown; }; paymentPageProps: PaymentPageProps; } // Create zod schema for data const PaymentBTCPayDataSchema = z.object({ invoice: z.object({ checkoutLink: z.string() }).required(), }); export const BtcpayPaymentComponent = (props: IPaymentComponentProps) => { const { payment } = props; const { data } = payment; const [iframeLoaded, setIframeLoaded] = useState(false); const { copyToClipboard, isCopied } = useCopy(); const wrongUrl = ( <>

Couldn't obtain payment URL

); const parsedData = PaymentBTCPayDataSchema.safeParse(data); if (!parsedData.success || !parsedData.data?.invoice?.checkoutLink) return wrongUrl; const checkoutUrl = parsedData.data.invoice.checkoutLink; const handleOpenInNewTab = () => { window.open(checkoutUrl, "_blank", "noopener,noreferrer"); }; return (
{!iframeLoaded && (

Loading payment page...

)}