updated Code add logger

This commit is contained in:
Mohd-Arham
2025-11-24 17:40:49 +05:30
parent f85aa7ec06
commit 89cb17b108
10 changed files with 1004 additions and 856 deletions
@@ -43,6 +43,7 @@ import com.billpaymentservice.bbps.entites.CustomParam;
import com.billpaymentservice.bbps.entites.DispositionDetails;
import com.billpaymentservice.bbps.entites.InboundTraceLog;
import com.billpaymentservice.bbps.entites.OutboundTraceLog;
import com.billpaymentservice.bbps.entites.PlanResponses;
import com.billpaymentservice.bbps.exception.CustomException;
import com.billpaymentservice.bbps.repository.BharatConnectMasterRepository;
import com.billpaymentservice.bbps.repository.BillerDataRepository;
@@ -102,30 +103,36 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getMasterData(MasterRequest masterRequest) {
LOGGER.info("Fetching Master Data for ReqId={} and MID={}", masterRequest.getReqId(), masterRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetMasterData";
String requestId = masterRequest.getReqId();
String mid = masterRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
// Merchant Validation
helper.validateMerchant(mid);
// check Tender Id is present DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
if (headersData == null) {
LOGGER.warn("header data not found for the orgID");
throw new CustomException("Something went wrong", "FAILED", 500, "");
}
// get full url
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
String txnID = helper.generateTxnId(15);
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
try {
// Merchant Validation
helper.validateMerchant(masterRequest.getMid());
// check Tender Id is present DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
if (headersData == null) {
LOGGER.warn("header data not found for the orgID");
throw new CustomException("Something went wrong", "FAILED", 500, "");
}
// get full url
String fullUrl = masterRegisterUrl + BBPSConstant.MASTER_CATEGORY_URL + headersData.getTenantId();
LOGGER.info("Calling external API: {}", fullUrl);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
// LOGGER.info("Response Data: {}", responseData);
LOGGER.debug("[{}] API Response | reqId={}", apiName, requestId);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
@@ -146,7 +153,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -159,28 +166,31 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
LOGGER.info("Fetching Biller Detail By Biller Id for ReqId={} and MID={}", billerDetailRequest.getReqId(),
billerDetailRequest.getMid());
helper.validateMerchant(billerDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetBillerByBillerId";
String apiName = "Get_Biller_By_BillerId";
String requestId = billerDetailRequest.getReqId();
String billerId = billerDetailRequest.getBillerId();
String mid = billerDetailRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid, billerId);
// 1. Validation
helper.validateMerchant(billerDetailRequest.getMid());
// 2. Transaction Id
String txnID = helper.generateTxnId(15);
// 3. Prepare URL
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
// 4. Prepare Logs
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
"POST", requestJson);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, fullUrl, "GET", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
System.out.println(billerDataRespository.findByBillerId(billerId));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.info("fetched data from api is :{}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
// Convert response
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
@@ -190,6 +200,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))),
String.valueOf(dataMap.get("remarks")));
}
// Mapping to Model
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
@@ -201,6 +212,7 @@ public class MasterDataServiceImpl implements MasterDataService {
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
@@ -212,27 +224,26 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getCustomerParamByBillerId(CustomParamRequest customerParamRequest) {
LOGGER.info("Fetching Customer Param By Biller Id for ReqId={} and MID={}", customerParamRequest.getReqId(),
customerParamRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetCustomerParamByBillerId";
String requestId = customerParamRequest.getReqId();
String mid = customerParamRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
customerParamRequest.getBillerId());
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String billerId = customerParamRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
String requestJson = helper.convertObjectToJson(customerParamRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
"POST", requestJson);
"GET", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
try {
helper.validateMerchant(customerParamRequest.getMid());
String billerId = customerParamRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMPARAM_URL + billerId;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.info("data is :{}", responseData);
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
@@ -258,11 +269,12 @@ public class MasterDataServiceImpl implements MasterDataService {
.collect(Collectors.toList());
// Save all to DB
customParamReposiotory.saveAll(entities);
LOGGER.info("[{}] Saved {} custom param records to DB", apiName, entities.size());
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
@@ -273,26 +285,28 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String apiName = "Fetch_Master_Data_Category_Wise";
String requestId = contactMasterRequest.getReqId();
LOGGER.info("[{}] START | reqId={} | mid={} | category={}", apiName, requestId, contactMasterRequest.getMid(),
contactMasterRequest.getCategory());
// Validated
helper.validateMerchant(contactMasterRequest.getMid());
String txnID = helper.generateTxnId(15);
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL, headersData.getTenantId(),
contactMasterRequest.getCategory());
String requestJson = helper.convertObjectToJson(contactMasterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
"POST", requestJson);
"GET", requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
try {
helper.validateMerchant(contactMasterRequest.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
String fullUrl = masterRegisterUrl + String.format(BBPSConstant.CONTACT_MASTER_URL,
headersData.getTenantId(), contactMasterRequest.getCategory());
LOGGER.info("Contact Master Full URL-:" + fullUrl);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.info("Response Data: {}", responseData);
LOGGER.debug("[{}] External API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -313,7 +327,7 @@ public class MasterDataServiceImpl implements MasterDataService {
String result = mapperHelper.saveContactMasterData(responseWrapper.getContactMasterList(), requestId,
txnID);
LOGGER.info("Result Master Contact Data -:" + result);
LOGGER.info("[{}] DB Save Result | reqId={} | result={}", apiName, requestId, result);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
@@ -321,6 +335,7 @@ public class MasterDataServiceImpl implements MasterDataService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
@@ -331,26 +346,33 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchMasterDataCategoryWise(MasterCategoryRequest masterRequest) {
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String requestId = masterRequest.getReqId();
String mid = masterRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerName={} | category={}", apiName, requestId, mid,
masterRequest.getBillerName(), masterRequest.getCategory());
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
masterRequest.getPageNo(), masterRequest.getPageSize());
LOGGER.info("Calling external API: {}", fullUrl);
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", requestJson);
try {
helper.validateMerchant(masterRequest.getMid());
String fullUrl = String.format("%s%s?billerName=%s&category=%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.BILLER_URL, masterRequest.getBillerName(), masterRequest.getCategory(),
masterRequest.getPageNo(), masterRequest.getPageSize());
LOGGER.info("Calling external API: {}", fullUrl);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
// LOGGER.info("Response Data: {}", responseData);
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -370,6 +392,7 @@ public class MasterDataServiceImpl implements MasterDataService {
BillerResponse responseWrapper = objectMapper.convertValue(dataMap, BillerResponse.class);
List<BillerCategoryWise> savedEntities = mapperHelper.mapAndSaveAll(responseWrapper.getBillerResp(),
requestId, txnID);
LOGGER.info("[{}] Saved {} records to DB | reqId={}", apiName, savedEntities.size(), requestId);
GeneralResp generalResp = responseWrapper.getGeneralResp();
@@ -377,7 +400,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
@@ -388,24 +411,26 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getDispositionDetails(DispositionRequest dispositionDetailRequest) {
LOGGER.info("Fetching Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetDispositionDetails";
String requestId = dispositionDetailRequest.getReqId();
helper.validateMerchant(dispositionDetailRequest.getMid());
String mid = dispositionDetailRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
// validate
helper.validateMerchant(mid);
// generate Txn Id
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
helper.updateOutboundLogResponse(outboundLog, responseData);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET",
dispositionDetailRequest.getMid());
try {
LOGGER.info("[{}] Calling external API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
helper.updateOutboundLogResponse(outboundLog, responseData);
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
ObjectMapper objectMapper = new ObjectMapper();
@@ -421,15 +446,13 @@ public class MasterDataServiceImpl implements MasterDataService {
}
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
System.out.println(responseWrapper);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
List<DispositionDetails> entities = responseWrapper.getDispositionsList().stream()
.map(dto -> mapper.map(dto, DispositionDetails.class)).collect(Collectors.toList());
System.out.println(entities);
LOGGER.info("[{}] Dispositions Received: {}", apiName, entities.size());
if (entities != null) {
dispositionRepository.saveAll(entities);
} else {
@@ -441,6 +464,7 @@ public class MasterDataServiceImpl implements MasterDataService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
@@ -452,22 +476,27 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchCustomerParamGroup(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchCustomerParamGroup";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
requestModel.getBillerId());
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
helper.convertObjectToJson(requestModel));
try {
helper.validateMerchant(requestModel.getMid());
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
try {
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
String responseData = apiResponse.get("data").toString();
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
@@ -489,10 +518,13 @@ public class MasterDataServiceImpl implements MasterDataService {
CustomerParamGroupsDTO responseDTO = mapperHelper
.saveCustomerParamGroups(responseWrapper.getCustomerParamGroupResp(), requestId, txnID);
LOGGER.info("[{}] Saved {} Customer Param Group records | reqId={}", apiName, responseDTO.toString(),
requestId);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
@@ -507,24 +539,29 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchAllMasterAmountOption(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchAllMasterAmountOption";
String requestId = requestModel.getReqId();
String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
requestModel.getBillerId());
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
helper.convertObjectToJson(requestModel));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
try {
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
LOGGER.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
@@ -543,6 +580,7 @@ public class MasterDataServiceImpl implements MasterDataService {
String saveAmountOptionsResponse = mapperHelper.saveAmountOptionsResponse(responseWrapper, requestId,
txnID);
LOGGER.info("[{}] Save Result | reqId={} | result={}", apiName, requestId, saveAmountOptionsResponse);
GeneralResp generalResp = responseWrapper.getGeneralResp();
@@ -551,6 +589,7 @@ public class MasterDataServiceImpl implements MasterDataService {
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -563,19 +602,21 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchPlanCategorie(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Plan Categories for ReqId={} and MID={}", requestModel.getReqId(), requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanCategorie";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
requestModel.getBillerId());
helper.validateMerchant(requestModel.getMid());
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
helper.convertObjectToJson(requestModel));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
try {
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
LOGGER.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
@@ -596,14 +637,17 @@ public class MasterDataServiceImpl implements MasterDataService {
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId, txnID);
String saveCategoryItems = mapperHelper.saveCategoryItems(responseWrapper.getCategoryRespList(), requestId,
txnID);
LOGGER.info("[{}] Saved category items | reqId={} | count={}", apiName, requestId, saveCategoryItems);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -616,24 +660,27 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel fetchInitiatingChannel(BillerDetailRequest requestModel) {
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchInitiatingChannel";
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
String mid = requestModel.getMid();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
helper.convertObjectToJson(requestModel));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", mid);
try {
helper.validateMerchant(requestModel.getMid());
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, fullUrl);
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling Master API: {}", fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
LOGGER.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -656,6 +703,7 @@ public class MasterDataServiceImpl implements MasterDataService {
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
@@ -669,13 +717,14 @@ public class MasterDataServiceImpl implements MasterDataService {
public ResponseModel fetchPlanByCategories(PlanRequest requestModel) {
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanByCategories";
String requestId = requestModel.getReqId();
String mid = requestModel.getMid();
helper.validateMerchant(requestModel.getMid());
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
requestModel.getBillerId());
helper.validateMerchant(mid);
String txnID = helper.generateTxnId(15);
String url = String.format("%s%s?billerId=%s%s%s%s&page=%d&pagesize=%d", masterRegisterUrl,
BBPSConstant.PLANS_URL, requestModel.getBillerId(),
@@ -688,13 +737,14 @@ public class MasterDataServiceImpl implements MasterDataService {
// Convert request to JSON and create inbound & outbound logs
String requestJson = helper.convertObjectToJson(requestModel);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "GET",
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
try {
LOGGER.info("[{}] Calling Master API | URL={} | Method=GET", apiName, url);
Map<String, String> apiResponse = httpService.getRequest(url);
String responseData = apiResponse.get("data");
LOGGER.info("Response Data: {}", responseData);
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
// Update outbound log with response
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -715,11 +765,14 @@ public class MasterDataServiceImpl implements MasterDataService {
PlanResponse responseWrapper = objectMapper.convertValue(dataMap, PlanResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
PlanResponses savePlanResponse = mapperHelper.savePlanResponse(responseWrapper, requestId, txnID);
LOGGER.info("[{}] Saved Plans | reqId={} | count={}", apiName, requestId, savePlanResponse);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
@@ -731,24 +784,27 @@ public class MasterDataServiceImpl implements MasterDataService {
@Override
public ResponseModel getTicketDispositions(DispositionRequest dispositionDetailRequest) {
LOGGER.info("Fetching Ticket Disposition Details for ReqId={} and MID={}", dispositionDetailRequest.getReqId(),
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetTicketDispositionDetails";
String requestId = dispositionDetailRequest.getReqId();
String mid = dispositionDetailRequest.getMid();
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
helper.validateMerchant(dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET",
dispositionDetailRequest.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
LOGGER.info("[{}] Calling External API | URL={} | Method=GET", apiName, fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
LOGGER.debug("[{}] API Response | reqId={} | data={}", apiName, requestId, responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
ObjectMapper objectMapper = new ObjectMapper();
@@ -765,16 +821,18 @@ public class MasterDataServiceImpl implements MasterDataService {
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
TicketDispositionResponse.class);
System.out.println(responseWrapper);
GeneralResp generalResp = responseWrapper.getGeneralResp();
ModelMapper mapper = new ModelMapper();
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
mapperHelper.saveTicketDisoptionDetails(responseWrapper.getDispositionsList(), requestId, txnID);
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResp.getStatus());
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());