const express = require('express');
const router = express.Router();
const OrderController = require('../controllers/order');
const { authenticate } = require('../middleware/auth');

// Order routes
router.post('/', authenticate, OrderController.createOrder);
router.get('/user', authenticate, OrderController.getUserOrders);
router.post('/create-and-pay', authenticate, OrderController.createOrderAndPay);
router.get('/:orderId', authenticate, OrderController.getOrderDetails);
router.put('/:orderId/cancel', authenticate, OrderController.cancelOrder);
router.put('/:orderId/reject', authenticate, OrderController.rejectOrder);
router.put('/:orderId/accept', authenticate, OrderController.acceptOrder);
router.put('/:orderId/ship', authenticate, OrderController.shipOrder);
router.put('/:orderId/complete', authenticate, OrderController.completeOrder);
router.post('/:orderId/pay', authenticate, OrderController.payForOrder);
router.get('/verify/:orderId', OrderController.verifyPayment);
router.post(
  '/:orderId/installments/:installmentNumber/pay',
  authenticate,
  OrderController.processInstallmentPayment
);
router.get(
  '/verify-installment/:orderId/:installmentNumber',
  OrderController.verifyInstallmentPayment
);



module.exports = router;
