const Joi = require("joi");

const { Validate } = require("./Validate");
const { PaymentTypes } = require("../utils/Enum");

const RazorPayValidation = async (req, res, next) => {
  const schema = Joi.object().keys({
    paymentType: Joi.string()
      .required()
      .valid(
        PaymentTypes.PAYONACCESS,
        PaymentTypes.FEATURED,
        PaymentTypes.USERPLAN
      )
      .messages({
        "any:required": "PaymentType field is required",
      }),
    planId: Joi.number().integer().optional().allow(null, 0).messages({
      "any:required": "PlanId field is required",
    }),
    propertyId: Joi.number().integer().optional().allow(null, 0).messages({
      "any:required": "PropertyId field is required",
    }),
    description: Joi.string().required().messages({
      "any:required": "Description field is required",
    }),
    amount: Joi.number().integer().required().messages({
      "any:required": "Amount field is required",
    }),
  });
  await Validate(req, res, next, schema);
};

module.exports = {
  RazorPayValidation,
};
