* app initialization * btcpay-calcom payment * include logo and images * resolve comments * include USD and webhook cleaning * currency display * fix type error * payment service create error * type error fix * icon update * bot feedback update * Remove console * Remove currency suffix in price * fix coderRabbit comment * resolve extra comments * Use repositories and declarative installation ocode for app * use PrismaBookingPaymentRepository as well as fix UI view * Avoid fetching booking just for title which is already passed to create fn in handlePayment * fix type issues * return 200 if payment is already processed --------- Co-authored-by: Anik Dhabal Babu <81948346+anikdhabal@users.noreply.github.com> Co-authored-by: Hariom Balhara <hariombalhara@gmail.com> Co-authored-by: Omar López <zomars@me.com>
37 lines
1.2 KiB
TypeScript
37 lines
1.2 KiB
TypeScript
import type { GetServerSidePropsContext } from "next";
|
|
|
|
import { getServerSession } from "@calcom/features/auth/lib/getServerSession";
|
|
import { CredentialRepository } from "@calcom/lib/server/repository/credential";
|
|
|
|
import { btcpayCredentialKeysSchema } from "../../lib/btcpayCredentialKeysSchema";
|
|
import type { IBTCPaySetupProps } from "./index";
|
|
|
|
export const getServerSideProps = async (ctx: GetServerSidePropsContext) => {
|
|
try {
|
|
const notFound = { notFound: true } as const;
|
|
if (typeof ctx.params?.slug !== "string") return notFound;
|
|
|
|
const { req } = ctx;
|
|
const session = await getServerSession({ req });
|
|
if (!session?.user?.id) return { redirect: { permanent: false, destination: "/auth/login" } };
|
|
|
|
const credential = await CredentialRepository.findFirstByUserIdAndType({
|
|
userId: session.user.id,
|
|
type: "btcpayserver_payment",
|
|
});
|
|
|
|
let props: IBTCPaySetupProps | undefined;
|
|
if (credential?.key) {
|
|
const keyParsing = btcpayCredentialKeysSchema.safeParse(credential.key);
|
|
if (keyParsing.success) {
|
|
props = keyParsing.data;
|
|
}
|
|
}
|
|
return { props: props ?? {} };
|
|
} catch (error) {
|
|
return {
|
|
props: {},
|
|
};
|
|
}
|
|
};
|