|
|
|
@@ -1,22 +1,23 @@
|
|
|
|
|
// java
|
|
|
|
|
package com.billpaymentservice.bbps.serviceImpl;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Map;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
|
|
|
|
import org.modelmapper.ModelMapper;
|
|
|
|
|
import org.modelmapper.convention.MatchingStrategies;
|
|
|
|
|
import org.slf4j.Logger;
|
|
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
|
|
import com.billpaymentservice.bbps.dto.GeneralResp;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.MasterApiResponse;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.ResponseModel;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.BillerDetailRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.ContactMasterRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.CustomParamRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.DispositionRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.MasterCategoryRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.MasterRequest;
|
|
|
|
|
import com.billpaymentservice.bbps.dto.request.PlanRequest;
|
|
|
|
@@ -32,11 +33,15 @@ import com.billpaymentservice.bbps.dto.response.PlaneCategoriesResponse;
|
|
|
|
|
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
|
|
|
|
import com.billpaymentservice.bbps.entites.BillerDetails;
|
|
|
|
|
import com.billpaymentservice.bbps.entites.DispositionDetails;
|
|
|
|
|
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
|
|
|
|
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
|
|
|
|
|
import com.billpaymentservice.bbps.exception.CustomException;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.BillerDataRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.DispositionRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.InboundTraceLogRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.MerchantRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.repository.OutboundTraceLogRepository;
|
|
|
|
|
import com.billpaymentservice.bbps.service.MasterDataService;
|
|
|
|
|
import com.billpaymentservice.bbps.util.BBPSConstant;
|
|
|
|
|
import com.billpaymentservice.bbps.util.EntityRelationshipUtil;
|
|
|
|
@@ -62,10 +67,14 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(MasterDataServiceImpl.class);
|
|
|
|
|
private final HttpService httpService;
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
private final InboundTraceLogRepository inboundTraceLogRepository;
|
|
|
|
|
private final OutboundTraceLogRepository outboundTraceLogRepository;
|
|
|
|
|
|
|
|
|
|
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
|
|
|
|
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
|
|
|
|
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository) {
|
|
|
|
|
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository,
|
|
|
|
|
InboundTraceLogRepository inboundTraceLogRepository,
|
|
|
|
|
OutboundTraceLogRepository outboundTraceLogRepository) {
|
|
|
|
|
this.merchantRegisterRepo = merchantRegisterRepo;
|
|
|
|
|
this.httpService = httpService;
|
|
|
|
|
this.httpClientApi = httpClientApi;
|
|
|
|
@@ -73,13 +82,70 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
this.billerDataRespository = billerDataRespository;
|
|
|
|
|
this.dispositionRepository = dispositionRepository;
|
|
|
|
|
this.beneficiaryDetailsRepository = beneficiaryDetailsRepository;
|
|
|
|
|
this.inboundTraceLogRepository = inboundTraceLogRepository;
|
|
|
|
|
this.outboundTraceLogRepository = outboundTraceLogRepository;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------- Trace helper methods ---------- */
|
|
|
|
|
private InboundTraceLog createInboundLog(String requestId, String txnId, String apiName, String mid,
|
|
|
|
|
String httpMethod, String requestPayload) {
|
|
|
|
|
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnId, apiName, mid == null ? "N/A" : mid,
|
|
|
|
|
"BBPS_ORG", httpMethod, requestPayload == null ? "N/A" : requestPayload);
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
return inboundLog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateInboundLogSuccess(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
|
|
|
|
if (inboundLog == null)
|
|
|
|
|
return;
|
|
|
|
|
inboundLog.setResponsePayload(responsePayload);
|
|
|
|
|
inboundLog.setResponseCode(responseCode);
|
|
|
|
|
inboundLog.setStatus("SUCCESS");
|
|
|
|
|
inboundLog.setResponseTime(LocalDateTime.now());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateInboundLogFailure(InboundTraceLog inboundLog, String responsePayload, String responseCode) {
|
|
|
|
|
if (inboundLog == null)
|
|
|
|
|
return;
|
|
|
|
|
inboundLog.setResponsePayload(responsePayload);
|
|
|
|
|
inboundLog.setResponseCode(responseCode);
|
|
|
|
|
inboundLog.setStatus("FAILED");
|
|
|
|
|
inboundLog.setResponseTime(LocalDateTime.now());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private OutboundTraceLog createOutboundLog(String txnId, String requestId, String apiName, String url,
|
|
|
|
|
String httpMethod, String requestPayload) {
|
|
|
|
|
OutboundTraceLog outboundLog = new OutboundTraceLog(txnId, requestId, apiName, url, httpMethod,
|
|
|
|
|
requestPayload == null ? "N/A" : requestPayload);
|
|
|
|
|
outboundTraceLogRepository.save(outboundLog);
|
|
|
|
|
return outboundLog;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void updateOutboundLogResponse(OutboundTraceLog outboundLog, String responsePayload) {
|
|
|
|
|
if (outboundLog == null)
|
|
|
|
|
return;
|
|
|
|
|
outboundLog.setResponsePayload(responsePayload);
|
|
|
|
|
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
|
|
|
|
outboundTraceLogRepository.save(outboundLog);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/* ---------- End helpers ---------- */
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getMasterData(MasterRequest masterRequest) {
|
|
|
|
|
LOGGER.info("Request DTO: {}", masterRequest);
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "GetMasterData";
|
|
|
|
|
String requestId = masterRequest.getReqId();
|
|
|
|
|
String requestJson = helper.convertObjectToJson(masterRequest);
|
|
|
|
|
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
|
|
|
|
|
requestJson);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
// Merchant Validation
|
|
|
|
|
helper.validateMerchant(masterRequest.getMid());
|
|
|
|
@@ -93,26 +159,28 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
|
|
|
|
log.info("Response -: " + headersData);
|
|
|
|
|
if (headersData == null) {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel("Tenant Id Is Null", "Not Found",
|
|
|
|
|
BBPSConstant.BADREQUEST, headersData);
|
|
|
|
|
return responseModel;
|
|
|
|
|
updateInboundLogFailure(inboundLog, "Tenant Id Is Null", "NOT_FOUND");
|
|
|
|
|
return new ResponseModel("Tenant Id Is Null", "Not Found", BBPSConstant.BADREQUEST, headersData);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// get full url
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
|
|
|
|
|
LOGGER.info("Calling external API: {}", fullUrl);
|
|
|
|
|
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
LOGGER.info("Response Data: {}", responseData);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ✅ Same check as in getBillerByBillerId()
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
|
|
|
@@ -126,10 +194,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
@@ -140,56 +211,69 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
|
|
|
|
|
|
|
|
|
helper.validateMerchant(billerDetailRequest.getMid());
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "GetBillerByBillerId";
|
|
|
|
|
String requestId = billerDetailRequest.getReqId();
|
|
|
|
|
String billerId = billerDetailRequest.getBillerId();
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
|
|
|
|
|
|
|
|
|
String requestJson = helper.convertObjectToJson(billerDetailRequest);
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(), "POST",
|
|
|
|
|
requestJson);
|
|
|
|
|
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
log.info("data is :{}", responseData);
|
|
|
|
|
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
|
|
helper.validateMerchant(billerDetailRequest.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String billerId = billerDetailRequest.getBillerId();
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
|
|
|
|
|
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
log.info("data is :{}", responseData);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
|
|
|
|
|
String.valueOf(dataMap.get("remarks")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
|
|
|
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
|
|
|
|
|
|
|
|
ModelMapper mapper = new ModelMapper();
|
|
|
|
|
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
|
|
|
|
BillerDetails entity = mapper.map(responseWrapper.getBillerDAO(), BillerDetails.class);
|
|
|
|
|
EntityRelationshipUtil.linkBillerRelationships(entity);
|
|
|
|
|
// billerDataRespository.save(entity);
|
|
|
|
|
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
|
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "GetCustomerParamByBillerId";
|
|
|
|
|
String requestId = customerParamRequest.getReqId();
|
|
|
|
|
String requestJson = helper.convertObjectToJson(customerParamRequest);
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(), "POST",
|
|
|
|
|
requestJson);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(customerParamRequest.getMid());
|
|
|
|
|
|
|
|
|
@@ -201,16 +285,19 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
String billerId = customerParamRequest.getBillerId();
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
|
|
|
|
|
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
log.info("data is :{}", responseData);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -223,9 +310,12 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
@@ -237,37 +327,41 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
|
|
|
|
|
|
|
|
|
// yeh krna hai
|
|
|
|
|
return new ResponseModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
|
|
|
|
|
LOGGER.info("Fetching Master Data Category-wise " + masterRequest);
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "FetchMasterDataCategoryWise";
|
|
|
|
|
String requestId = masterRequest.getReqId();
|
|
|
|
|
String requestJson = helper.convertObjectToJson(masterRequest);
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
|
|
|
|
|
requestJson);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(masterRequest.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
|
|
|
|
|
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
|
|
|
|
|
masterRequest.getPageStart(), masterRequest.getPageEnd());
|
|
|
|
|
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
LOGGER.info("Response Data: {}", responseData);
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// ✅ Same check as in getBillerByBillerId()
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode
|
|
|
|
@@ -281,24 +375,35 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
|
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getDispositionDetails() {
|
|
|
|
|
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "GetDispositionDetails";
|
|
|
|
|
String requestId = dispositionDetailRequest.getReqId();
|
|
|
|
|
;
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, dispositionDetailRequest.getMid(),
|
|
|
|
|
"GET", "N/A");
|
|
|
|
|
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
try {
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
@@ -306,6 +411,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -331,39 +437,45 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
|
return ex.getResponseModel(); // Directly return ResponseModel from exception
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
|
|
|
|
|
LOGGER.info("Fetching Master Data Category-wise for MID={}", requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "FetchCustomerParamGroup";
|
|
|
|
|
String requestId = requestModel.getReqId();
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
|
|
|
|
helper.convertObjectToJson(requestModel));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
|
|
|
|
|
// LOGGER.info("Calling Master API: {}", fullUrl);
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = apiResponse.get("data").toString();
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -377,10 +489,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException ex) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", ex.getMessage());
|
|
|
|
@@ -392,26 +507,31 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
|
|
|
|
|
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "FetchAllMasterAmountOption";
|
|
|
|
|
String requestId = requestModel.getReqId();
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
|
|
|
|
helper.convertObjectToJson(requestModel));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
|
|
|
|
|
// LOGGER.info("Calling Master API: {}", fullUrl);
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
|
|
|
|
log.info("Response" + apiResponse);
|
|
|
|
|
String responseData = apiResponse.get("data").toString();
|
|
|
|
|
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -424,10 +544,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException e) {
|
|
|
|
|
LOGGER.error("Custom Exception: {}", e.getMessage());
|
|
|
|
@@ -439,26 +562,31 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
|
|
|
|
|
LOGGER.info("Fetching Master Data Amount List for MID={}", requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "FetchPlanCategorie";
|
|
|
|
|
String requestId = requestModel.getReqId();
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
|
|
|
|
helper.convertObjectToJson(requestModel));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
|
|
|
|
|
// LOGGER.info("Calling Master API: {}", fullUrl);
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
|
|
|
|
log.info("Response" + apiResponse);
|
|
|
|
|
String responseData = apiResponse.get("data").toString();
|
|
|
|
|
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -471,10 +599,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException e) {
|
|
|
|
|
LOGGER.error("Custom Exception: {}", e.getMessage());
|
|
|
|
@@ -485,26 +616,33 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
|
|
|
|
|
LOGGER.info("Fetching Initiating Channel List for MID={}", requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "FetchInitiatingChannel";
|
|
|
|
|
String requestId = requestModel.getReqId();
|
|
|
|
|
InboundTraceLog inboundLog = createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
|
|
|
|
|
helper.convertObjectToJson(requestModel));
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
helper.validateMerchant(requestModel.getMid());
|
|
|
|
|
|
|
|
|
|
// if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
// LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
// return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
|
|
|
|
|
LOGGER.info("Calling Master API: {}", fullUrl);
|
|
|
|
|
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
|
|
|
|
|
log.info("Response" + apiResponse);
|
|
|
|
|
String responseData = apiResponse.get("data").toString();
|
|
|
|
|
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
|
|
|
|
new TypeReference<Map<String, Object>>() {
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get("status")));
|
|
|
|
|
throw new CustomException(String.valueOf(dataMap.get("message")), // message
|
|
|
|
|
String.valueOf(dataMap.get("status")), // status
|
|
|
|
|
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), // statusCode (int)
|
|
|
|
@@ -517,10 +655,13 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
|
|
|
|
|
|
|
|
|
updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
|
|
|
|
|
|
|
|
|
return responseModel;
|
|
|
|
|
|
|
|
|
|
} catch (JsonProcessingException e) {
|
|
|
|
|
log.error("Error parsing responseData JSON: {}", e.getMessage());
|
|
|
|
|
updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
|
|
|
|
throw new CustomException("Invalid JSON received from API");
|
|
|
|
|
} catch (CustomException e) {
|
|
|
|
|
LOGGER.error("Custom Exception: {}", e.getMessage());
|
|
|
|
@@ -547,7 +688,7 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
requestModel.getCircle() != null ? "&circle=" + requestModel.getCircle() : "",
|
|
|
|
|
requestModel.getPage(), requestModel.getPagesize());
|
|
|
|
|
|
|
|
|
|
//String fullUrl = masterRegisterUrl + BBPSConstant.PLANS_URL + url;
|
|
|
|
|
// String fullUrl = masterRegisterUrl + BBPSConstant.PLANS_URL + url;
|
|
|
|
|
LOGGER.info("Calling Master API: {}", url);
|
|
|
|
|
|
|
|
|
|
Map<String, String> apiResponse = httpService.getRequest(url);
|
|
|
|
|