import { Router } from "express";
import { authMiddleware } from "../../common/middlewares/auth.middleware";
import { tenantMiddleware } from "../../common/middlewares/tenant.middleware";
import * as paymentController from "./payment.controller";
import "./payment.openapi";

const router = Router();

// Stripe webhook — public, no auth
router.post("/webhook", paymentController.stripeWebhook);

router.use(authMiddleware, tenantMiddleware);

router.post(
  "/stripe/checkout/:invoiceId",
  paymentController.createCheckoutSession
);
router.get("/client/invoices/:invoiceId", paymentController.getClientInvoice);
router.get("/client/transactions", paymentController.getClientTransactions);
router.get("/admin/invoices/:invoiceId", paymentController.getAdminInvoice);
router.get("/admin/transactions", paymentController.getAdminTransactions);

export default router;
