added constant in bbps constant

This commit is contained in:
Lincpay Tech
2025-11-24 17:48:54 +05:30
parent c9dfb6f9ba
commit 435ee0dacf
7 changed files with 368 additions and 351 deletions
@@ -10,10 +10,7 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Service;
import com.billpaymentservice.bbps.dto.ContactMaster;
import com.billpaymentservice.bbps.dto.CustomParamDTO;
import com.billpaymentservice.bbps.dto.CustomerParamGroupsDTO;
import com.billpaymentservice.bbps.dto.GeneralResp;
@@ -108,16 +105,16 @@ public class MasterDataServiceImpl implements MasterDataService {
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 apiName = BBPSConstant.API_GET_MASTER_DATA;
String requestId = masterRequest.getReqId();
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), BBPSConstant.HTTP_POST,
requestJson);
try {
// Merchant Validation
helper.validateMerchant(masterRequest.getMid());
// check Tenant Id is present DB
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
if (headersData == null) {
LOGGER.warn("header data not found for the orgID");
throw new CustomException("Something went wrong", "FAILED", 500, "");
@@ -125,21 +122,21 @@ public class MasterDataServiceImpl implements MasterDataService {
// 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);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
HttpHeaders headers = helper.buildHeaders(headersData);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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
String.valueOf(dataMap.get("remarks")) // remarks
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
);
}
@@ -155,8 +152,9 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -168,31 +166,31 @@ public class MasterDataServiceImpl implements MasterDataService {
helper.validateMerchant(billerDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetBillerByBillerId";
String apiName = BBPSConstant.API_GET_BILLER_BY_ID;
String requestId = billerDetailRequest.getReqId();
String billerId = billerDetailRequest.getBillerId();
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerId;
String requestJson = helper.convertObjectToJson(billerDetailRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, billerDetailRequest.getMid(),
"POST", requestJson);
BBPSConstant.HTTP_POST, requestJson);
System.out.println(billerDataRespository.findByBillerId(billerId));
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("fetched data from api is :{}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
GeneralResp generalResp = responseWrapper.getGeneralResp();
@@ -208,7 +206,7 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -220,21 +218,21 @@ public class MasterDataServiceImpl implements MasterDataService {
customerParamRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetCustomerParamByBillerId";
String apiName = BBPSConstant.API_GET_CUSTOMER_PARAM_BY_BILLER_ID;
String requestId = customerParamRequest.getReqId();
String requestJson = helper.convertObjectToJson(customerParamRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, customerParamRequest.getMid(),
"POST", requestJson);
BBPSConstant.HTTP_POST, 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);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("data is :{}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -242,12 +240,12 @@ public class MasterDataServiceImpl implements MasterDataService {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
CustomParamResp responseWrapper = objectMapper.convertValue(dataMap, CustomParamResp.class);
@@ -270,7 +268,7 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -280,23 +278,23 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Contact Master Request Data " + contactMasterRequest);
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
String requestId = contactMasterRequest.getReqId();
String requestJson = helper.convertObjectToJson(contactMasterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, contactMasterRequest.getMid(),
"POST", requestJson);
BBPSConstant.HTTP_POST, requestJson);
try {
helper.validateMerchant(contactMasterRequest.getMid());
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId(BBPSConstant.ORG_ID);
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);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
HttpHeaders headers = helper.buildHeaders(headersData);
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -305,12 +303,12 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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
String.valueOf(dataMap.get("remarks")) // remarks
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
);
}
@@ -329,7 +327,7 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -339,10 +337,10 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Master Data CategoryResponseList-wise " + masterRequest);
String txnID = helper.generateTxnId(15);
String apiName = "FetchMasterDataCategoryWise";
String apiName = BBPSConstant.API_FETCH_MASTER_DATA_CATEGORY_WISE;
String requestId = masterRequest.getReqId();
String requestJson = helper.convertObjectToJson(masterRequest);
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, masterRequest.getMid(), BBPSConstant.HTTP_POST,
requestJson);
try {
helper.validateMerchant(masterRequest.getMid());
@@ -351,10 +349,10 @@ public class MasterDataServiceImpl implements MasterDataService {
masterRequest.getPageNo(), masterRequest.getPageSize());
LOGGER.info("Calling external API: {}", fullUrl);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
// LOGGER.info("Response Data: {}", responseData);
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -363,12 +361,12 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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
String.valueOf(dataMap.get("remarks")) // remarks
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)) // remarks
);
}
@@ -386,7 +384,7 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -397,17 +395,17 @@ public class MasterDataServiceImpl implements MasterDataService {
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetDispositionDetails";
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
String requestId = dispositionDetailRequest.getReqId();
helper.validateMerchant(dispositionDetailRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
@@ -415,12 +413,12 @@ public class MasterDataServiceImpl implements MasterDataService {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
DispositionResponse responseWrapper = objectMapper.convertValue(dataMap, DispositionResponse.class);
@@ -447,7 +445,7 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -458,31 +456,31 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Customer Param Group for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchCustomerParamGroup";
String apiName = BBPSConstant.API_FETCH_CUSTOMER_PARAM_GROUP;
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
helper.convertObjectToJson(requestModel));
try {
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.CUSTOMER_PARAM_GROUP + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
String responseData = apiResponse.get("data").toString();
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
helper.updateOutboundLogResponse(outboundLog, responseData);
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
CustomerParamGroupsResponse responseWrapper = objectMapper.convertValue(dataMap,
@@ -501,7 +499,7 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -513,20 +511,20 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Master Data Amount List for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchAllMasterAmountOption";
String apiName = BBPSConstant.API_FETCH_ALL_MASTER_AMOUNT_OPTION;
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
helper.convertObjectToJson(requestModel));
try {
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.AMOUNT_OPTIONS + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
LOGGER.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -534,12 +532,12 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
AmountOptionsResponse responseWrapper = objectMapper.convertValue(dataMap, AmountOptionsResponse.class);
@@ -558,7 +556,7 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -568,20 +566,20 @@ public class MasterDataServiceImpl implements MasterDataService {
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 apiName = BBPSConstant.API_FETCH_PLAN_CATEGORIES;
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
helper.convertObjectToJson(requestModel));
try {
helper.validateMerchant(requestModel.getMid());
String fullUrl = masterRegisterUrl + BBPSConstant.PLAN_CATEGORIES + requestModel.getBillerId();
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> apiResponse = httpService.getRequest(fullUrl);
LOGGER.info("Response" + apiResponse);
String responseData = apiResponse.get("data").toString();
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -589,12 +587,12 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
PlaneCategoriesResponse responseWrapper = objectMapper.convertValue(dataMap, PlaneCategoriesResponse.class);
@@ -611,7 +609,7 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -622,9 +620,9 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Initiating Channel for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchInitiatingChannel";
String apiName = BBPSConstant.API_FETCH_INITIATING_CHANNEL;
String requestId = requestModel.getReqId();
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), "POST",
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, requestModel.getMid(), BBPSConstant.HTTP_POST,
helper.convertObjectToJson(requestModel));
try {
@@ -632,11 +630,11 @@ public class MasterDataServiceImpl implements MasterDataService {
String fullUrl = masterRegisterUrl + BBPSConstant.INITIATING_CHANNEL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_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();
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY).toString();
helper.updateOutboundLogResponse(outboundLog, responseData);
@@ -644,12 +642,12 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
ChannelsListResponse responseWrapper = objectMapper.convertValue(dataMap, ChannelsListResponse.class);
@@ -664,7 +662,7 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
@@ -675,7 +673,7 @@ public class MasterDataServiceImpl implements MasterDataService {
LOGGER.info("Fetching Plan By Categories for ReqId={} and MID={}", requestModel.getReqId(),
requestModel.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "FetchPlanByCategories";
String apiName = BBPSConstant.API_FETCH_PLAN_BY_CATEGORIES;
String requestId = requestModel.getReqId();
helper.validateMerchant(requestModel.getMid());
@@ -691,12 +689,12 @@ 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(), BBPSConstant.HTTP_POST,
requestJson);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, BBPSConstant.HTTP_GET, null);
try {
Map<String, String> apiResponse = httpService.getRequest(url);
String responseData = apiResponse.get("data");
String responseData = apiResponse.get(BBPSConstant.RESPONSE_DATA_KEY);
LOGGER.info("Response Data: {}", responseData);
// Update outbound log with response
@@ -706,12 +704,13 @@ public class MasterDataServiceImpl implements MasterDataService {
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
// Failure response
helper.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")));
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)),
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))),
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
// Success response
@@ -727,7 +726,7 @@ public class MasterDataServiceImpl implements MasterDataService {
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
@@ -738,17 +737,17 @@ public class MasterDataServiceImpl implements MasterDataService {
dispositionDetailRequest.getMid());
String txnID = helper.generateTxnId(15);
String apiName = "GetTicketDispositionDetails";
String apiName = BBPSConstant.API_GET_TICKET_DISPOSITIONS;
String requestId = dispositionDetailRequest.getReqId();
helper.validateMerchant(dispositionDetailRequest.getMid());
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
dispositionDetailRequest.getMid(), "GET", "N/A");
dispositionDetailRequest.getMid(), BBPSConstant.HTTP_GET, "N/A");
String fullUrl = masterRegisterUrl + BBPSConstant.TICKET_DISPOSTION_URL;
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, fullUrl, BBPSConstant.HTTP_GET, null);
LOGGER.info("Calling external API: {}", fullUrl);
Map<String, String> responseMap = httpService.getRequest(fullUrl);
String responseData = responseMap.get("data");
String responseData = responseMap.get(BBPSConstant.RESPONSE_DATA_KEY);
helper.updateOutboundLogResponse(outboundLog, responseData);
try {
@@ -756,12 +755,12 @@ public class MasterDataServiceImpl implements MasterDataService {
Map<String, Object> dataMap = objectMapper.readValue(responseData,
new TypeReference<Map<String, Object>>() {
});
if (!dataMap.containsKey("generalResp")) {
helper.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)
String.valueOf(dataMap.get("remarks")));
if (!dataMap.containsKey(BBPSConstant.RESPONSE_GENERAL_RESP)) {
helper.updateInboundLogFailure(inboundLog, responseData, String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)));
throw new CustomException(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_MESSAGE_KEY)), // message
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUS_KEY)), // status
Integer.parseInt(String.valueOf(dataMap.get(BBPSConstant.RESPONSE_STATUSCODE_KEY))), // statusCode (int)
String.valueOf(dataMap.get(BBPSConstant.RESPONSE_REMARKS_KEY)));
}
TicketDispositionResponse responseWrapper = objectMapper.convertValue(dataMap,
@@ -779,9 +778,9 @@ public class MasterDataServiceImpl implements MasterDataService {
return responseModel;
} catch (JsonProcessingException e) {
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage());
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
helper.updateInboundLogFailure(inboundLog, e.getMessage(), BBPSConstant.JSON_ERROR);
throw new CustomException("Invalid JSON received from API");
}
}
}
}