import { Router } from "express";
import transaction from "../controllers/transaction.controller";
import authorize from "../middlewares/authorization.middleware";
import validateData from "../middlewares/validation.middleware";
import {
  AddTransactionSchema,
  GenerateOrderIdSchema,
  GenerateChargesSchema,
} from "../schemas/transaction.schema";

const router = Router();

router.get("/list/tenant", authorize, transaction.ListForTenant);
router.get("/list/client", authorize, transaction.ListForClient);
router.get("/list/client/new", authorize, transaction.ListForClientX);
router.get("/list/web", authorize, transaction.ListForWeb);
router.get("/list/client/:tenantId", authorize, transaction.ListTenantTrans);
router.post(
  "/orderId/generate",
  authorize,
  validateData(GenerateOrderIdSchema),
  transaction.GenerateOrderId
);
router.post(
  "/charges/get",
  authorize,
  validateData(GenerateChargesSchema),
  transaction.TransactionCharge
);
router.post(
  "/add",
  authorize,
  validateData(AddTransactionSchema),
  transaction.Add
);

router.post(
  "/add/moveOut",
  authorize,
  validateData(AddTransactionSchema),
  transaction.AddMoveOut
);

router.post("/callback", transaction.PaymentLinkCallBack);
router.post("/easebuzz-callback", transaction.EaseBuzzCallback);
router.post("/cashfree-callback", transaction.CashfreeCallback);

router.post("/restore", authorize, transaction.Restore);
router.get("/get/refund/records", authorize, transaction.RefundList);

//router.get("/test/split", transaction.SettlePayment);
/**
 * Record unprocessed payments
*/
router.post("/record-payment", transaction.RecordOnlineTransactionManually);
router.post("/easebuzz-record-payment", transaction.RecordOnlineEaseBuzzTransManually);
router.post("/cashfree-record-payment", transaction.RecordOnlineCashfreeTransManually);

router.get("/stats", authorize, transaction.ListPaymentStats);

router.post("/update/dueDate", authorize, transaction.UpdateDueDate);

router.post("/init/payment", authorize, transaction.InitiatePayment);

//router.post("/payment/verify/payu/test", transaction.ValidatePayUCallback);
export default router;
