implemented customerParam Api

This commit is contained in:
himanshu
2025-10-27 18:02:52 +05:30
parent 01394580f3
commit 4d501f7b4a
11 changed files with 238 additions and 48 deletions
@@ -0,0 +1,51 @@
package com.billpaymentservice.bbps.util;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import com.billpaymentservice.bbps.dto.request.MerchantRequestModel;
import com.billpaymentservice.bbps.entites.BBPSMerchantValidation;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.MerchantRepository;
@Component
public class Helper {
private static final Logger LOGGER = LoggerFactory.getLogger(Helper.class);
@Autowired
private MerchantRepository merchantRegisterRepo;
/**
* Validates whether the merchant exists and is active.
*
* @param requestModel MerchantRequestModel containing merchant details
* @return true if merchant exists and is active
* @throws CustomException if merchant is invalid or inactive
*/
public boolean isMerchantValidAndActive(MerchantRequestModel requestModel) {
if (requestModel == null || requestModel.getMid() == null) {
LOGGER.warn("MerchantRequestModel or MID is null");
throw new CustomException("Invalid request: MID is required");
}
// Fetch merchant details
BBPSMerchantValidation merchantValidation = merchantRegisterRepo.findByMid(requestModel.getMid());
if (merchantValidation == null) {
LOGGER.warn("Merchant not found for MID: {}", requestModel.getMid());
throw new CustomException("Merchant not found");
}
if (!Boolean.TRUE.equals(merchantValidation.isActive())) {
LOGGER.warn("Merchant inactive for MID: {}", requestModel.getMid());
throw new CustomException("Merchant inactive");
}
LOGGER.info("Merchant is valid and active for MID: {}", requestModel.getMid());
return true;
}
}