|
|
|
@@ -1,3 +1,4 @@
|
|
|
|
|
// java
|
|
|
|
|
package com.billpaymentservice.bbps.serviceImpl;
|
|
|
|
|
|
|
|
|
|
import java.time.LocalDateTime;
|
|
|
|
@@ -16,6 +17,7 @@ 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.response.AmountOptionsResponse;
|
|
|
|
@@ -62,16 +64,16 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
private final BillerDataRepository billerDataRespository;
|
|
|
|
|
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;
|
|
|
|
|
private final ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public MasterDataServiceImpl(MerchantRepository merchantRegisterRepo, HttpService httpService,
|
|
|
|
|
HttpClientApi httpClientApi, Helper helper, BillerDataRepository billerDataRespository,
|
|
|
|
|
DispositionRepository dispositionRepository, BharatConnectMasterRepository beneficiaryDetailsRepository,
|
|
|
|
|
InboundTraceLogRepository inboundTraceLogRepository,
|
|
|
|
|
OutboundTraceLogRepository outboundTraceLogRepository) {
|
|
|
|
|
InboundTraceLogRepository inboundTraceLogRepository,
|
|
|
|
|
OutboundTraceLogRepository outboundTraceLogRepository) {
|
|
|
|
|
this.merchantRegisterRepo = merchantRegisterRepo;
|
|
|
|
|
this.httpService = httpService;
|
|
|
|
|
this.httpClientApi = httpClientApi;
|
|
|
|
@@ -82,35 +84,84 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
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 {
|
|
|
|
|
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
|
|
|
|
log.info("ResPONSE" + headersData);
|
|
|
|
|
if (headersData == null) {
|
|
|
|
|
ResponseModel responseModel = new ResponseModel("Tenant Id Is Null", "Not Found",
|
|
|
|
|
updateInboundLogFailure(inboundLog, "Tenant Id Is Null", "NOT_FOUND");
|
|
|
|
|
return new ResponseModel("Tenant Id Is Null", "Not Found",
|
|
|
|
|
BBPSConstant.BADREQUEST, headersData);
|
|
|
|
|
return responseModel;
|
|
|
|
|
}
|
|
|
|
|
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
|
|
|
|
@@ -124,105 +175,102 @@ 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");
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getBillerByBillerId(BillerDetailRequest billerDetailRequest) {
|
|
|
|
|
|
|
|
|
|
String txnID = helper.generateTxnId(15);
|
|
|
|
|
String apiName = "GetBillerByBillerId";
|
|
|
|
|
String requestId = billerDetailRequest.getReqId();
|
|
|
|
|
String fullUrl = masterRegisterUrl + BBPSConstant.BILLER_DATA_FETCH_URL + billerDetailRequest.getBillerId();
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
// 🔹 Inbound Log (request received)
|
|
|
|
|
InboundTraceLog inboundLog = new InboundTraceLog(requestId, txnID, apiName, billerDetailRequest.toString());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
OutboundTraceLog outboundLog = createOutboundLog(txnID, requestId, apiName, fullUrl, "GET", null);
|
|
|
|
|
|
|
|
|
|
// 🔹 Outbound Log (before sending external API request)
|
|
|
|
|
OutboundTraceLog outboundLog = new OutboundTraceLog(txnID, apiName, fullUrl, "N/A");
|
|
|
|
|
outboundTraceLogRepository.save(outboundLog);
|
|
|
|
|
|
|
|
|
|
// 🔹 Send request
|
|
|
|
|
Map<String, String> responseMap = httpService.getRequest(fullUrl);
|
|
|
|
|
String responseData = responseMap.get("data");
|
|
|
|
|
log.info("data is :{}", responseData);
|
|
|
|
|
|
|
|
|
|
outboundLog.setResponsePayload(responseData);
|
|
|
|
|
outboundLog.setResponseReceiveTime(LocalDateTime.now());
|
|
|
|
|
outboundTraceLogRepository.save(outboundLog);
|
|
|
|
|
|
|
|
|
|
// 🔹 Parse the response
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
Map<String, Object> dataMap;
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
// 🟥 Invalid JSON case — update inbound log before throwing
|
|
|
|
|
inboundLog.setResponsePayload("Invalid JSON: " + e.getMessage());
|
|
|
|
|
inboundLog.setResponseCode("FAILED");
|
|
|
|
|
inboundLog.setResponseTime(LocalDateTime.now());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
throw new CustomException("Invalid JSON received from upstream", "FAILED", 400, e.getMessage());
|
|
|
|
|
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")),
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
|
|
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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 🔹 If generalResp is missing — API returned error response
|
|
|
|
|
if (!dataMap.containsKey("generalResp")) {
|
|
|
|
|
// 🟥 Update inbound log before throwing
|
|
|
|
|
inboundLog.setResponsePayload(responseData);
|
|
|
|
|
inboundLog.setResponseCode(String.valueOf(dataMap.get("status")));
|
|
|
|
|
inboundLog.setResponseTime(LocalDateTime.now());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
|
|
|
|
|
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"))
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 🔹 Otherwise, success flow
|
|
|
|
|
BillerDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillerDataResponse.class);
|
|
|
|
|
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
|
|
|
|
|
|
|
|
|
inboundLog.setResponsePayload(responseData);
|
|
|
|
|
inboundLog.setResponseCode(generalResp.getStatus());
|
|
|
|
|
inboundLog.setResponseTime(LocalDateTime.now());
|
|
|
|
|
inboundTraceLogRepository.save(inboundLog);
|
|
|
|
|
|
|
|
|
|
return new ResponseModel(
|
|
|
|
|
generalResp.getMessage(),
|
|
|
|
|
generalResp.getStatus(),
|
|
|
|
|
Integer.parseInt(generalResp.getStatusCode()),
|
|
|
|
|
responseWrapper
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
|
|
|
|
|
|
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)
|
|
|
|
@@ -235,9 +283,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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -245,7 +296,17 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
public ResponseModel getContactMaster(ContactMasterRequest contactMasterRequest) {
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
* String txnID = helper.generateTxnId(15); String apiName = "GetContactMaster";
|
|
|
|
|
* String requestId = contactMasterRequest != null ?
|
|
|
|
|
* contactMasterRequest.getReqId() : "N/A"; String requestJson =
|
|
|
|
|
* helper.convertObjectToJson(contactMasterRequest); InboundTraceLog inboundLog
|
|
|
|
|
* = createInboundLog(requestId, txnID, apiName, contactMasterRequest != null ?
|
|
|
|
|
* contactMasterRequest.getMid() : "N/A", "POST", requestJson);
|
|
|
|
|
*
|
|
|
|
|
* // Implementation not present previously - create inbound log and return
|
|
|
|
|
* empty response updateInboundLogSuccess(inboundLog, "N/A", "SUCCESS");
|
|
|
|
|
*/
|
|
|
|
|
return new ResponseModel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -253,12 +314,19 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
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 {
|
|
|
|
|
|
|
|
|
|
String validateMerchant = helper.validateMerchant(masterRequest);
|
|
|
|
|
|
|
|
|
|
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
|
|
|
|
|
return new ResponseModel("Merchant validation failed", validateMerchant, BBPSConstant.BADREQUEST, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -266,18 +334,20 @@ public class MasterDataServiceImpl implements MasterDataService {
|
|
|
|
|
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
|
|
|
|
@@ -291,27 +361,36 @@ 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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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");
|
|
|
|
|
|
|
|
|
|
ObjectMapper objectMapper = new ObjectMapper();
|
|
|
|
|
updateOutboundLogResponse(outboundLog, responseData);
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
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)
|
|
|
|
@@ -337,37 +416,48 @@ 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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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 {
|
|
|
|
|
|
|
|
|
|
String validateMerchant = helper.validateMerchant(requestModel);
|
|
|
|
|
|
|
|
|
|
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
|
|
|
|
|
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)
|
|
|
|
@@ -381,10 +471,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");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -393,26 +486,36 @@ 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 {
|
|
|
|
|
String validateMerchant = helper.validateMerchant(requestModel);
|
|
|
|
|
|
|
|
|
|
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
|
|
|
|
|
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)
|
|
|
|
@@ -425,10 +528,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 +545,36 @@ 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 {
|
|
|
|
|
String validateMerchant = helper.validateMerchant(requestModel);
|
|
|
|
|
|
|
|
|
|
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
|
|
|
|
|
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 +587,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 +604,38 @@ 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 {
|
|
|
|
|
String validateMerchant = helper.validateMerchant(requestModel);
|
|
|
|
|
|
|
|
|
|
if (!"Valid".equalsIgnoreCase(validateMerchant)) {
|
|
|
|
|
LOGGER.warn("Merchant validation failed: {}", validateMerchant);
|
|
|
|
|
updateInboundLogFailure(inboundLog, validateMerchant, "INVALID_MERCHANT");
|
|
|
|
|
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 +648,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());
|
|
|
|
|