"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
const express_1 = require("express");
const payment_controller_1 = require("../controllers/payment.controller");
const auth_middleware_1 = require("../../../middleware/auth.middleware");
const rbac_middleware_1 = require("../../../middleware/rbac.middleware");
const validate_middleware_1 = require("../../../middleware/validate.middleware");
const payment_validator_1 = require("../validators/payment.validator");
const router = (0, express_1.Router)();
// ==========================================
// 1. PUBLIC / USER ENDPOINTS (AUTHENTICATED)
// ==========================================
router.post('/create', auth_middleware_1.authenticateJWT, (0, validate_middleware_1.validateRequest)(payment_validator_1.initiatePaymentSchema), payment_controller_1.createPayment);
router.post('/verify', auth_middleware_1.authenticateJWT, (0, validate_middleware_1.validateRequest)(payment_validator_1.verifyPaymentSchema), payment_controller_1.verifyPayment);
router.post('/retry', auth_middleware_1.authenticateJWT, payment_controller_1.retryPayment);
router.post('/cancel', auth_middleware_1.authenticateJWT, payment_controller_1.cancelPayment);
router.get('/history', auth_middleware_1.authenticateJWT, payment_controller_1.getPaymentHistory);
router.get('/status/:id', auth_middleware_1.authenticateJWT, payment_controller_1.getPaymentStatus);
router.get('/:id', auth_middleware_1.authenticateJWT, payment_controller_1.getPaymentById);
// ==========================================
// 2. ADMIN ONLY MANAGEMENT
// ==========================================
router.get('/', auth_middleware_1.authenticateJWT, (0, rbac_middleware_1.authorizeRoles)('ADMIN'), payment_controller_1.getPayments);
router.post('/refund', auth_middleware_1.authenticateJWT, (0, rbac_middleware_1.authorizeRoles)('ADMIN'), (0, validate_middleware_1.validateRequest)(payment_validator_1.refundPaymentSchema), payment_controller_1.refundPayment);
// ==========================================
// 3. TAX INVOICE DOWNLOAD
// ==========================================
router.get('/invoice/download/:invoiceNumber', payment_controller_1.downloadInvoice);
// ==========================================
// 4. UNIFIED GATEWAY CALLBACKS & WEBHOOKS
// ==========================================
router.all('/callback/:gateway', payment_controller_1.handleGatewayCallback);
router.post('/webhook/:gateway', payment_controller_1.handleGatewayWebhook);
exports.default = router;
//# sourceMappingURL=payment.routes.js.map