import { Router } from 'express';
import {
  createCheckoutSession,
  confirmCheckout,
  myPurchases,
  getConfig,
  devGrant,
  adminFinance,
} from '../controllers/payment.controller.js';
import { authenticate, requireSuperAdmin } from '../middleware/auth.middleware.js';

const router = Router();

router.get('/config', getConfig);
router.post('/checkout', authenticate, createCheckoutSession);
router.post('/confirm', authenticate, confirmCheckout);
router.post('/dev-grant', authenticate, devGrant);
router.get('/my', authenticate, myPurchases);

// Finance is restricted to the super admin only.
router.get('/admin/finance', authenticate, requireSuperAdmin, adminFinance);

export default router;
