import { publicProcedure, router } from '../trpc';
import {
  createCheckout,
  retrieveCheckoutSession,
} from '@crafted/services';
import { createCheckoutInput, getSessionInput } from '@crafted/validators';

export const paymentRouter = router({
  createCheckout: publicProcedure
    .input(createCheckoutInput)
    .mutation(async ({ input }) => {
      return await createCheckout(input);
    }),

  getSession: publicProcedure
    .input(getSessionInput)
    .query(async ({ input }) => {
      return await retrieveCheckoutSession(input.sessionId);
    }),
});
