import { z } from "zod/v4";
import {
	adminProcedure,
	createTRPCRouter,
	protectedApiProcedure,
} from "~/server/api/trpc";
import {
	stripeHealthCheck,
	whIntentCreatedHandler,
	whIntentFailedHandler,
	whIntentSucceededHandler,
} from "~/server/controllers/stripe.controller";
import { zOrdineId } from "~/server/utils/zod_types";

export const stripeRouter = createTRPCRouter({
	health: adminProcedure.query(async () => {
		return await stripeHealthCheck();
	}),

	whIntentCreated: protectedApiProcedure
		.input(
			z.object({
				ordineId: zOrdineId,
				pIntentId: z.string(),
			}),
		)
		.mutation(async ({ input }) => {
			return await whIntentCreatedHandler({
				ordineId: input.ordineId,
				pIntentId: input.pIntentId,
			});
		}),
	whIntentFailed: protectedApiProcedure
		.input(z.object({ pIntentId: z.string() }))
		.mutation(async ({ input }) => {
			return await whIntentFailedHandler({
				pIntentId: input.pIntentId,
			});
		}),

	whIntentSucceeded: protectedApiProcedure
		.input(
			z.object({
				ordineId: zOrdineId,
				pIntentId: z.string(),
				pm_id: z.string(),
			}),
		)
		.mutation(async ({ input }) => {
			return await whIntentSucceededHandler({
				ordineId: input.ordineId,
				pIntentId: input.pIntentId,
				pm_id: input.pm_id,
			});
		}),
});

/*
Credit Card integration guide
https://docs.stripe.com/payments/cards

Google Pay integration guide
https://docs.stripe.com/google-pay

SEPA Direct Debit integration guide
https://docs.stripe.com/payments/sepa-debit/accept-a-payment

Bank Transfers integration guide
https://docs.stripe.com/payments/bank-transfers

Satispay integration guide
https://docs.stripe.com/payments/satispay
*/
