2025-08-07 14:50:40 +02:00
|
|
|
import { z } from "zod/v4";
|
2025-08-04 17:45:44 +02:00
|
|
|
import {
|
|
|
|
|
createTRPCRouter,
|
|
|
|
|
protectedProcedure,
|
|
|
|
|
publicProcedure,
|
|
|
|
|
} from "~/server/api/trpc";
|
|
|
|
|
import {
|
|
|
|
|
createIntentHandler,
|
|
|
|
|
whIntentCreatedHandler,
|
|
|
|
|
whIntentFailedHandler,
|
|
|
|
|
whIntentSucceededHandler,
|
|
|
|
|
} from "~/server/controllers/stripe.controller";
|
|
|
|
|
import { zPagamentoId } from "~/server/utils/zod_types";
|
|
|
|
|
|
|
|
|
|
export const stripeRouter = createTRPCRouter({
|
|
|
|
|
createIntent: protectedProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
paymentId: zPagamentoId,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.mutation(async ({ input }) => {
|
|
|
|
|
return await createIntentHandler({
|
|
|
|
|
paymentId: input.paymentId,
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
whIntentCreated: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
pIntentId: z.string(),
|
|
|
|
|
paymentId: zPagamentoId,
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await whIntentCreatedHandler({
|
|
|
|
|
pIntentId: input.pIntentId,
|
|
|
|
|
paymentId: input.paymentId,
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
|
|
|
|
|
whIntentSucceeded: publicProcedure
|
|
|
|
|
.input(
|
|
|
|
|
z.object({
|
|
|
|
|
pIntentId: z.string(),
|
|
|
|
|
paymentId: zPagamentoId,
|
|
|
|
|
pm_id: z.string(),
|
|
|
|
|
}),
|
|
|
|
|
)
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await whIntentSucceededHandler({
|
|
|
|
|
pIntentId: input.pIntentId,
|
|
|
|
|
paymentId: input.paymentId,
|
|
|
|
|
pm_id: input.pm_id,
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
whIntentFailed: publicProcedure
|
|
|
|
|
.input(z.object({ pIntentId: z.string() }))
|
|
|
|
|
.query(async ({ input }) => {
|
|
|
|
|
return await whIntentFailedHandler({
|
|
|
|
|
pIntentId: input.pIntentId,
|
|
|
|
|
});
|
|
|
|
|
}),
|
|
|
|
|
});
|