updated Code add logger
This commit is contained in:
@@ -75,15 +75,16 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillFetch(FetchBillRequest fetchBillRequest) {
|
||||
LOGGER.info("Initiating bill fetch for request ID: {} and MID :{} and billerId:{} ", fetchBillRequest.getReqId(),
|
||||
fetchBillRequest.getMid(),fetchBillRequest.getBillerId());
|
||||
|
||||
String apiName = "InitiateBillFetch";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = fetchBillRequest.getReqId();
|
||||
String mid = fetchBillRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, requestId, mid,
|
||||
fetchBillRequest.getBillerId());
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_INTI;
|
||||
fetchBillRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -106,7 +107,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, requestId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
@@ -154,6 +155,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, requestId, generalResponse.getStatus());
|
||||
return fetchBillById(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
@@ -223,86 +225,89 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillById(BillFetchByBillIdRequest billFetchByBillIdRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
String apiName = "FetchBillById";
|
||||
String reqId = billFetchByBillIdRequest.getReqId();
|
||||
String billId = billFetchByBillIdRequest.getBillId();
|
||||
String mid = billFetchByBillIdRequest.getMid();
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, reqId, mid, billId);
|
||||
|
||||
// create inbound log (GET -> no request body)
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName,
|
||||
billFetchByBillIdRequest.getMid(), "GET", null);
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID + billFetchByBillIdRequest.getBillId();
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billFetchByBillIdRequest.getMid());
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// create inbound log (GET -> no request body)
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billFetchByBillIdRequest.getMid(),
|
||||
"GET", null);
|
||||
|
||||
// create outbound log
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("Calling external BBPS API for FetchBillById, URL={}", fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response received from BBPS for billId={} : {}", billId, responseData);
|
||||
try {
|
||||
LOGGER.debug("Merchant validated successfully for MID={}", billFetchByBillIdRequest.getMid());
|
||||
|
||||
// update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
// create outbound log
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
LOGGER.info("[{}] Calling BBPS FetchBillById API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] BBPS Response | billId={} | data={}", apiName, billId, responseData);
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
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")));
|
||||
}
|
||||
|
||||
// update outbound log with response
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// update inbound log success and persist bill data
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
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")));
|
||||
}
|
||||
|
||||
return responseModel;
|
||||
BillDataResponse responseWrapper = objectMapper.convertValue(dataMap, BillDataResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
// update inbound log success and persist bill data
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveOrUpdateBillData(responseWrapper, billFetchByBillIdRequest, txnId);
|
||||
LOGGER.info("Bill data saved successfully for billId={} | Status={}", billId, generalResp.getStatus());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON for billId={} : {}", billId, e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
LOGGER.info("Initiating bill Validate for request ID: {} and MID:{} and billerId:{}", fetchBillValidateRequest.getReqId(),
|
||||
fetchBillValidateRequest.getMid(),fetchBillValidateRequest.getBillerId());
|
||||
public ResponseModel initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
|
||||
String apiName = "InitiateBillValidate";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = fetchBillValidateRequest.getReqId();
|
||||
String mid = fetchBillValidateRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billerId={}", apiName, fetchBillValidateRequest, mid,
|
||||
fetchBillValidateRequest.getBillerId());
|
||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILLER_VALIDATE_URL;
|
||||
fetchBillValidateRequest.setClientReqId(txnId);
|
||||
helper.validateMerchant(fetchBillValidateRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -327,7 +332,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.debug("Outbound log created successfully for txnId: {} and reqId: {}", txnId, reqId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, forwardJson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
@@ -375,6 +380,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
LOGGER.warn("Thread interrupted during delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Calling internal method Fetching bill by ID: {}", billFetchByBillIdRequest.getBillId());
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResponse.getStatus());
|
||||
return BillvaidateByBillId(billFetchByBillIdRequest, inboundLog);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error: {}", e.getMessage(), e);
|
||||
@@ -452,13 +458,16 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel initiateBillValidateByBillId(BillFetchByBillIdRequest billRequest) {
|
||||
String apiName = "FetchBillById";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billRequest.getReqId();
|
||||
String billId = billRequest.getBillId();
|
||||
String mid = billRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | billId={}", apiName, billRequest, mid, billId);
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_ID_URL + billRequest.getBillId();
|
||||
|
||||
LOGGER.info("Initiating {} API for billId={} and reqId={}", apiName, billId, reqId);
|
||||
@@ -467,7 +476,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, billRequest.getMid(), "GET", null);
|
||||
|
||||
try {
|
||||
helper.validateMerchant(billRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -488,26 +496,29 @@ public class AgentServiceImpl implements AgentService {
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new com.fasterxml.jackson.core.type.TypeReference<Map<String, Object>>(){});
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new com.fasterxml.jackson.core.type.TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure received for billId={} | Response={}", billId, responseData);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")),
|
||||
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")));
|
||||
}
|
||||
|
||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap, FetchBillValidateResponse.class);
|
||||
FetchBillValidateResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
FetchBillValidateResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
// update inbound log and save validation data
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.saveBillValidation(responseWrapper, billRequest);
|
||||
LOGGER.info("Bill validation saved successfully for billId: {}", billId);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (com.fasterxml.jackson.core.JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing ValidateByBillId JSON: {}", e.getMessage(), e);
|
||||
@@ -515,19 +526,23 @@ public class AgentServiceImpl implements AgentService {
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
//================================== Bill fetch and Bill Validate by Client Req Id==================================//
|
||||
|
||||
|
||||
// ================================== Bill fetch and Bill Validate by Client Req
|
||||
// Id==================================//
|
||||
|
||||
@Override
|
||||
public ResponseModel fetchBillValidateByClientReqId(BillValidateByClientIdRequest billValidateByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillValidateByClientIdRequest";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billValidateByClientIdRequest.getReqId();
|
||||
String clientReqId = billValidateByClientIdRequest.getClientReqId();
|
||||
String mid = billValidateByClientIdRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
|
||||
billValidateByClientIdRequest.getClientReqId());
|
||||
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
throw new CustomException("No Bill Found for given Client Req Id");
|
||||
@@ -535,8 +550,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
helper.validateMerchant(billValidateByClientIdRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -553,7 +566,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillValidateByClientReqId, URL={}", fullUrl);
|
||||
LOGGER.info("[{}] Calling BBPS API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
@@ -575,7 +588,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -589,9 +602,14 @@ public class AgentServiceImpl implements AgentService {
|
||||
public ResponseModel fetchBillByClientReqId(BillFetchByClientIdRequest billFetchByClientIdRequest) {
|
||||
|
||||
String apiName = "FetchBillByClientIdRequest";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = billFetchByClientIdRequest.getReqId();
|
||||
String clientReqId = billFetchByClientIdRequest.getClientReqId();
|
||||
String mid = billFetchByClientIdRequest.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, reqId, mid,
|
||||
billFetchByClientIdRequest.getClientReqId());
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
|
||||
Optional<BillInitiate> billInitiate = billIntiateRepository.findByReqId(clientReqId);
|
||||
if (billInitiate.isEmpty()) {
|
||||
@@ -600,8 +618,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.BILL_VALIDATE_BY_CLIENT_REQ_ID + billInitiate.get().getTxnId();
|
||||
|
||||
helper.validateMerchant(billFetchByClientIdRequest.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -618,7 +634,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS API FetchBillByClientReqId, URL={}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
@@ -639,7 +655,7 @@ public class AgentServiceImpl implements AgentService {
|
||||
GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
LOGGER.info("[{}] END | reqId={} | status={}", apiName, reqId, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -649,7 +665,6 @@ public class AgentServiceImpl implements AgentService {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* @Override public ResponseModel
|
||||
* initiateBillValidate(FetchBillValidatestRequest fetchBillValidateRequest) {
|
||||
@@ -837,5 +852,4 @@ public class AgentServiceImpl implements AgentService {
|
||||
* }
|
||||
*/
|
||||
|
||||
|
||||
}
|
||||
|
||||
@@ -19,16 +19,14 @@ import com.billpaymentservice.bbps.dto.request.ComplaintRequestDTO;
|
||||
import com.billpaymentservice.bbps.dto.request.GetTicketLatestStausRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.TxnStatusRequest;
|
||||
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsTicketsRequest;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.request.ViewAllComplaintsRequest;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintHistoryStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ComplaintResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TicketCheckStatusResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.TxnStatusResponse;
|
||||
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsTicketsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewAllComplaintsResponse;
|
||||
import com.billpaymentservice.bbps.dto.response.ViewComplainByIdResponse;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchComplaintForwardRequest;
|
||||
import com.billpaymentservice.bbps.dto.sentRequest.FetchTicketLatestStatusRequest;
|
||||
import com.billpaymentservice.bbps.entites.BharatConnectMaster;
|
||||
import com.billpaymentservice.bbps.entites.ComplaintStatusOptionsMaster;
|
||||
import com.billpaymentservice.bbps.entites.InboundTraceLog;
|
||||
@@ -83,19 +81,16 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
@Override
|
||||
public ResponseModel addComplain(ComplaintRequestDTO complainRequestDTO) {
|
||||
|
||||
LOGGER.info("Initiating add Complain for request ID: {} and MID {}", complainRequestDTO.getReqId(),
|
||||
complainRequestDTO.getMid());
|
||||
|
||||
String apiName = "ADD_COMPLAIN";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = complainRequestDTO.getReqId();
|
||||
String mid = complainRequestDTO.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = complainDataUrl + BBPSConstant.ADD_COMPLAIN_ENDPOINT;
|
||||
|
||||
LOGGER.info("Full URL-: "+ fullUrl);
|
||||
|
||||
// Convert input DTO to JSON
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
|
||||
LOGGER.info("[{}] Full URL={}", apiName, fullUrl);
|
||||
// Fetch tenant & agent from DB
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
@@ -104,25 +99,33 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
// Convert input DTO to JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchComplaintForwardRequest forwardReq = helper.fetchComplaintForwardRequestMap(complainRequestDTO);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(complainRequestDTO);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, complainRequestDTO.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST", null);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, fullUrl, "POST",
|
||||
forwardJson);
|
||||
|
||||
try {
|
||||
// Inject tenantId + agentId into request JSON
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||
root.put("tenantId", headersData.getTenantId());
|
||||
root.put("agentId", headersData.getAgentId());
|
||||
|
||||
String finalJson = root.toString();
|
||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
||||
LOGGER.info("[{}] Final Request Sent to API | reqId={} | payload={}", apiName, requestId, finalJson);
|
||||
|
||||
// IMPORTANT: Send finalJson, not requestJson
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Fetched response: {}", responseData);
|
||||
LOGGER.debug("[{}] Response Received | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -133,7 +136,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
if (start != -1 && end != -1) {
|
||||
responseData = responseData.substring(start, end + 1);
|
||||
}
|
||||
LOGGER.info("Extracted pure JSON from error: {}", responseData);
|
||||
LOGGER.warn("[{}] Extracted JSON from error wrapper | data={}", apiName, responseData);
|
||||
}
|
||||
|
||||
// Parse JSON into Map
|
||||
@@ -145,6 +148,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
// Throw exception for non-200
|
||||
if (statusCode != 200) {
|
||||
LOGGER.warn("[{}] Failure Response | reqId={} | statusCode={}", apiName, requestId, statusCode);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
@@ -156,6 +160,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
LOGGER.info("[{}] SUCCESS | reqId={} | status={}", apiName, requestId, responseWrapper.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -171,13 +176,17 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Fetching Complaint Status for TicketId={} ReqId={}", request.getTicketId(), request.getReqId());
|
||||
|
||||
String apiName = "COMPLAINT_STATUS";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String complaintId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
String ticketId = request.getTicketId();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPALINT_STATUS;
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
LOGGER.info("FUll URL -: " + fullUrl);
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -187,27 +196,32 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// Convert request to JSON
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
FetchTicketLatestStatusRequest forwardReq = helper.fetchTicketLatestStatusRequestMap(request);
|
||||
|
||||
String forwardJson = helper.convertObjectToJson(forwardReq);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
|
||||
requestJson);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", complaintId);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "POST", forwardJson);
|
||||
|
||||
try {
|
||||
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(requestJson);
|
||||
ObjectNode root = (ObjectNode) objectMapper.readTree(forwardJson);
|
||||
root.put("tenantId", headersData.getTenantId());
|
||||
//root.put("agentId", headersData.getAgentId());
|
||||
// root.put("agentId", headersData.getAgentId());
|
||||
|
||||
String finalJson = root.toString();
|
||||
LOGGER.info("Final Request Sent to API: {}", finalJson);
|
||||
// LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Final API Payload | reqId={} | payload={}", apiName, reqId, finalJson);
|
||||
|
||||
Map<String, String> responseMap = httpService.postRequest(fullUrl, finalJson, headers);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
|
||||
LOGGER.info("Complaint Fetch Response: {}", responseData);
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
if (responseData.startsWith("HttpService Error")) {
|
||||
@@ -227,20 +241,21 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
int statusCode = Integer.parseInt(String.valueOf(dataMap.get("statusCode")));
|
||||
|
||||
if (statusCode != 200) {
|
||||
LOGGER.warn("[{}] Failure Response | reqId={} | statusCode={}", apiName, reqId, statusCode);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
statusCode, String.valueOf(dataMap.get("remarks")));
|
||||
}
|
||||
|
||||
TicketCheckStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TicketCheckStatusResponse.class);
|
||||
|
||||
LOGGER.info("Complaint Current Status: {}", responseWrapper.getStatus());
|
||||
LOGGER.info("[{}] Complaint Status | ticketId={} | status={}", apiName, ticketId,
|
||||
responseWrapper.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, responseWrapper.getStatus());
|
||||
|
||||
// Save in DB
|
||||
mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
|
||||
|
||||
String saveComplaintStatus = mapperHelper.saveComplaintStatus(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("[{}] Save Status | ticketId={} | status={}", apiName, ticketId, saveComplaintStatus);
|
||||
return new ResponseModel(responseWrapper.getMessage(), responseWrapper.getStatus(),
|
||||
Integer.parseInt(responseWrapper.getStatusCode()), responseWrapper);
|
||||
|
||||
@@ -255,16 +270,17 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
@Override
|
||||
public ResponseModel viewComplaintHistory(ComplainStatusRequest request) {
|
||||
LOGGER.info("Fetching View Complaint History Complaint by Complaint Id={}", request.getTicketId(),
|
||||
request.getReqId());
|
||||
|
||||
String apiName = "View_Complaint_History";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.COMPLAINT_HISTORY + request.getTicketId();
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
String txnId = helper.generateTxnId(15);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -279,13 +295,13 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", ticketId);
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
LOGGER.debug("[{}] Outbound log created | URL={}", apiName, fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={} | reqId={}", apiName, fullUrl, reqId);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, reqId, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -294,8 +310,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
});
|
||||
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
LOGGER.warn("[{}] Invalid response structure | reqId={} | data={}", apiName, reqId, responseData);
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid response structure for txnId: {}", txnId);
|
||||
throw new CustomException(String.valueOf(dataMap.get("message")), String.valueOf(dataMap.get("status")),
|
||||
Integer.parseInt(String.valueOf(dataMap.get("statusCode"))), String.valueOf(""));
|
||||
}
|
||||
@@ -309,8 +325,8 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
String saveComplaintHistory = mapperHelper.saveComplaintHistory(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaintHistory);
|
||||
|
||||
LOGGER.info("[{}] Complaint history saved | ticketId={} | entryId={}", apiName, ticketId,
|
||||
saveComplaintHistory);
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -322,15 +338,16 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
@Override
|
||||
public ResponseModel viewComplaintById(ComplainStatusRequest request) {
|
||||
|
||||
LOGGER.info("Fetching View Complaint Complaint by Complaint Id={}", request.getTicketId(), request.getReqId());
|
||||
String apiName = "View_Complaint_By_ID";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String ticketId = request.getTicketId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||
String mid = request.getMid();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | ticketId={}", apiName, reqId, mid, ticketId);
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.VIEW_COMPLAINT_BY_ID + request.getTicketId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -349,7 +366,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | reqId={} | URL={}", apiName, reqId, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Complaint History Complaint FetchById Response: {}", responseData);
|
||||
@@ -376,7 +393,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
String saveComplaint = mapperHelper.saveComplainStatusDetail(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||
LOGGER.info("[{}] Complaint details saved | ticketId={} | id={}", apiName, ticketId, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
@@ -391,15 +408,16 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
public ResponseModel getAllActiveStatuses(AllMasterOptionsRequest request) {
|
||||
|
||||
try {
|
||||
LOGGER.info("Fetch All Master Options - MID: {}", request.getMid());
|
||||
String apiName = "View All Options Fetch By Id";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String fullUrl = "Data Base Options";
|
||||
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
String mid = request.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, reqId, mid);
|
||||
// Validate merchant
|
||||
helper.validateMerchant(request.getMid());
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET", null);
|
||||
@@ -432,14 +450,16 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
}
|
||||
|
||||
public ResponseModel checkTxnStatus(TxnStatusRequest request) {
|
||||
LOGGER.info("Check Txn Status Request by Id={} and ReqId ={}", request.getId(), request.getReqId());
|
||||
String apiName = "CheckTxnStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String apiName = "Check_Txn_Status";
|
||||
String reqId = request.getReqId();
|
||||
String ID = request.getId();
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.CHECK_TRANSACTION_URL + request.getId();
|
||||
String mid = request.getMid();
|
||||
String transactionId = request.getId();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | txnId={}", apiName, reqId, mid, transactionId);
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = agentDtaUrl + BBPSConstant.CHECK_TRANSACTION_URL + request.getId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
@@ -458,7 +478,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external BBPS API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("checkTxnStatus: {}", responseData);
|
||||
@@ -483,6 +503,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
LOGGER.info("[{}] End Txn Status: {}", apiName, generalResp.getStatus());
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
} catch (JsonProcessingException e) {
|
||||
@@ -499,14 +520,18 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Fetching All Complaint for status Type={} and reqId={} ", request.getStatusType(),
|
||||
request.getReqId());
|
||||
String apiName = "View_All_Complaint_By_Status_Type";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String reqId = request.getReqId();
|
||||
String mid = request.getMid();
|
||||
String statusType = request.getStatusType();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | statusType={}", apiName, reqId, mid, statusType);
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String fullUrl = complainDataUrl + BBPSConstant.VIEW_ALL_COMPLAINTS_BASE + "?pageNo=" + request.getPageNo()
|
||||
+ "&pageSize=" + request.getPageSize() + "&statusType=" + request.getStatusType() + "&ticketType="
|
||||
+ request.getTicketType();
|
||||
|
||||
helper.validateMerchant(request.getMid());
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
@@ -518,17 +543,17 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
String requestJson = helper.convertObjectToJson(request);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "POST",
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(reqId, txnId, apiName, request.getMid(), "GET",
|
||||
requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, reqId, apiName, fullUrl, "GET",
|
||||
request.getStatusType());
|
||||
LOGGER.debug("Outbound log created successfully for Complaint : {}", fullUrl);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling external API: {}", fullUrl);
|
||||
LOGGER.info("[{}] Calling external API | URL={}", apiName, fullUrl);
|
||||
Map<String, String> responseMap = httpService.getRequest(fullUrl, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Response: {}", responseData);
|
||||
LOGGER.info("[{}] API Response received", apiName);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
@@ -551,7 +576,7 @@ public class ComplainServiceImpl implements ComplainService {
|
||||
LOGGER.info("Current Complaint ReOpen Status: {}", status);
|
||||
|
||||
String saveComplaint = mapperHelper.saveAllComplaints(responseWrapper, reqId, txnId);
|
||||
LOGGER.info("Complaint ReOpen data saved successfully for Count History: {}", saveComplaint);
|
||||
LOGGER.info("[{}] Complaint records saved into DB | count={}", apiName, saveComplaint);
|
||||
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
+202
-144
@@ -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());
|
||||
|
||||
@@ -79,445 +79,453 @@ public class PaymentServiceImpl implements PaymentService {
|
||||
|
||||
@Override
|
||||
public ResponseModel initiatePayment(BillPaymentRequest billPaymentRequest) {
|
||||
String apiName = "InitiatePayment";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||
String apiName = "InitiatePayment";
|
||||
String requestId = billPaymentRequest.getReqId();
|
||||
String mid = billPaymentRequest.getMid();
|
||||
LOGGER.info("[{}] START | reqId={} | mid={}", apiName, requestId, mid);
|
||||
helper.validateMerchant(mid);
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String url = paymentUrl + BBPSConstant.PAYMENT_URL;
|
||||
billPaymentRequest.setClientReqId(txnId);
|
||||
LOGGER.info("Initiating payment for reqId={} and txnId={}", requestId, txnId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
BillPaymentForwardRequest forwardReq =
|
||||
helper.billPaymentForwardRequest(billPaymentRequest);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
|
||||
BillPaymentForwardRequest forwardReq = helper.billPaymentForwardRequest(billPaymentRequest);
|
||||
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
String forwardjson = helper.convertObjectToJson(forwardReq);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
|
||||
String requestJson = helper.convertObjectToJson(billPaymentRequest);
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(),
|
||||
"POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST", forwardjson);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnId, apiName, billPaymentRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "POST",forwardjson);
|
||||
try {
|
||||
LOGGER.info("[{}] Calling BBPS Payment API | url={}", apiName, url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("[{}] Raw Payment API Response | reqId={}", apiName, requestId);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS payment URL: {}", url);
|
||||
Map<String, String> responseMap = httpService.postRequest(url, forwardjson, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Payment API Response: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
|
||||
if (responseData == null || responseData.isEmpty()) {
|
||||
helper.updateInboundLogFailure(inboundLog, "Empty response from BBPS", "FAILED");
|
||||
LOGGER.warn("Empty response received from BBPS for txnId={}", txnId);
|
||||
throw new CustomException("Empty response from BBPS server");
|
||||
}
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey("genericResponse")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_STRUCTURE");
|
||||
LOGGER.warn("Invalid response structure received for txnId={}", txnId);
|
||||
throw new CustomException("Invalid response structure from BBPS");
|
||||
}
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
|
||||
BillPaymentResponse billPaymentResponse = objectMapper.convertValue(dataMap, BillPaymentResponse.class);
|
||||
GeneralResp generalResponse = billPaymentResponse.getGenericResponse();
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
BillPayment entity = mapper.map(billPaymentResponse, BillPayment.class);
|
||||
paymentRepository.save(entity);
|
||||
LOGGER.info("BillPayment entity saved successfully for txnId={}", txnId);
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
paymentInitiate.setTxnId(txnId);
|
||||
paymentInitiate.setReqId(requestId);
|
||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
||||
paymentIntiateRepository.save(paymentInitiate);
|
||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResponse.getStatus());
|
||||
PaymentInitiate paymentInitiate = new PaymentInitiate();
|
||||
paymentInitiate.setTxnId(txnId);
|
||||
paymentInitiate.setReqId(requestId);
|
||||
paymentInitiate.setBankTxnId(billPaymentResponse.getTxnId());
|
||||
paymentInitiate.setStatus(billPaymentResponse.getStatus());
|
||||
paymentIntiateRepository.save(paymentInitiate);
|
||||
LOGGER.info("PaymentInitiate entry saved successfully for txnId={}", txnId);
|
||||
LOGGER.info("[{}] Checking Transaction Status for bankTxnId={}", apiName, billPaymentResponse.getTxnId());
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
TransactionStatusRequest transactionStatusRequest = new TransactionStatusRequest();
|
||||
transactionStatusRequest.setTxnId(billPaymentResponse.getTxnId());
|
||||
transactionStatusRequest.setReqId(requestId);
|
||||
|
||||
try {
|
||||
Thread.sleep(9000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
try {
|
||||
Thread.sleep(9000);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
LOGGER.warn("Thread interrupted during payment delay: {}", e.getMessage());
|
||||
}
|
||||
LOGGER.info("Checking transaction status for txnId={}", billPaymentResponse.getTxnId());
|
||||
return checkTrasactionStatus(transactionStatusRequest, inboundLog);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("JSON Parsing Error in initiatePayment: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest, InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest,
|
||||
InboundTraceLog inboundLog) {
|
||||
String apiName = "CheckTransactionStatus";
|
||||
String txnId = helper.generateTxnId(15);
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
LOGGER.info("Checking transaction status (internal) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId, apiName, url, "GET", null);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response: {}", responseData);
|
||||
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData, new TypeReference<Map<String, Object>>() {});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
||||
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.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
try {
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
LOGGER.warn("Invalid transaction status response for txnId={}", transactionStatusRequest.getTxnId());
|
||||
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")));
|
||||
}
|
||||
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(), TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
LOGGER.info("Transaction status received: {}", generalResp.getStatus());
|
||||
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(), AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||
ModelMapper mapper = new ModelMapper();
|
||||
mapper.getConfiguration().setMatchingStrategy(MatchingStrategies.STRICT);
|
||||
TransactionMaster transactionMaster = mapper.map(responseWrapper.getTransactionDAO(),
|
||||
TransactionMaster.class);
|
||||
transactionMaster.setTxnId(txnId);
|
||||
transactionMaster.setReqId(transactionStatusRequest.getReqId());
|
||||
EntityRelationshipUtil.linkTransactionMasterRelationships(transactionMaster);
|
||||
transactionMasterRepository.save(transactionMaster);
|
||||
LOGGER.info("TransactionMaster saved successfully for txnId={}", txnId);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
AgentFundTransfer agentFundTransfer = mapper.map(responseWrapper.getAgentFundTransfer(),
|
||||
AgentFundTransfer.class);
|
||||
agentFundTransfer.setTxnId(txnId);
|
||||
agentFundTransfer.setReqId(transactionStatusRequest.getReqId());
|
||||
agentFundTransfer.setTransactionMasterId(transactionMaster.getBankTxnId());
|
||||
agentFundTransferRepository.save(agentFundTransfer);
|
||||
LOGGER.info("AgentFundTransfer entry saved successfully for txnId={}", txnId);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatus(TransactionStatusRequest transactionStatusRequest) {
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "checkTrasactionStatus";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String mid = transactionStatusRequest.getMid();
|
||||
String bankTxnId = transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | bankTxnId={}", apiName, requestId, mid, bankTxnId);
|
||||
|
||||
helper.validateMerchant(mid);
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL + transactionStatusRequest.getTxnId();
|
||||
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}", transactionStatusRequest.getTxnId(), requestId);
|
||||
LOGGER.info("Checking transaction status (public) for txnId={} and reqId={}",
|
||||
transactionStatusRequest.getTxnId(), requestId);
|
||||
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response data: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction status response data: {}", 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")));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS", transactionStatusRequest.getTxnId());
|
||||
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"))
|
||||
);
|
||||
}
|
||||
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")));
|
||||
LOGGER.warn("Invalid transaction status response for txnId={} from BBPS",
|
||||
transactionStatusRequest.getTxnId());
|
||||
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")));
|
||||
}
|
||||
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
String status = generalResp.getStatus();
|
||||
LOGGER.info("Current transaction status: {}", status);
|
||||
|
||||
ResponseModel responseModel = new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
ResponseModel responseModel = new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
return responseModel;
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing responseData JSON: {}", e.getMessage(), e);
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
public ResponseModel checkTrasactionStatusByClientReqId(
|
||||
TrasactionStatusByClientReqIdRequest transactionStatusRequest) {
|
||||
String apiName = "checkTrasactionStatusbyClientReqId";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String mid = transactionStatusRequest.getMid();
|
||||
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
LOGGER.info("[{}] START | reqId={} | mid={} | clientReqId={}", apiName, requestId, mid, clientReqId);
|
||||
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String apiName = "checkTrasactionStatusbyClientReqId";
|
||||
String requestId = transactionStatusRequest.getReqId();
|
||||
String clientReqId = transactionStatusRequest.getClientReqId();
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
helper.validateMerchant(transactionStatusRequest.getMid());
|
||||
String txnID = helper.generateTxnId(15);
|
||||
String requestJson = helper.convertObjectToJson(transactionStatusRequest);
|
||||
|
||||
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||
LOGGER.info("Checking transaction status for clientReqId={} and reqId={}", clientReqId, requestId);
|
||||
|
||||
// Fetch Txn from DB
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException("No Transaction Found for given Client Req Id");
|
||||
}
|
||||
// Fetch Txn from DB
|
||||
Optional<PaymentInitiate> paymentInitiate = paymentIntiateRepository.findByReqId(clientReqId);
|
||||
if (paymentInitiate.isEmpty()) {
|
||||
throw new CustomException("No Transaction Found for given Client Req Id");
|
||||
}
|
||||
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL + paymentInitiate.get().getTxnId();
|
||||
String url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_BY_CLIENT_REQ_ID_URL
|
||||
+ paymentInitiate.get().getTxnId();
|
||||
|
||||
// Prepare headers
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
LOGGER.info("[{}] BBPS URL={}", apiName, url);
|
||||
// Prepare headers
|
||||
BharatConnectMaster headersData = beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
HttpHeaders headers = new HttpHeaders();
|
||||
headers.set("x-digiledge-key", headersData.getXDigiledgeKey());
|
||||
headers.set("agentId", headersData.getAgentId());
|
||||
headers.set("tenantId", headersData.getTenantId());
|
||||
headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
|
||||
// 🔵 Create Inbound + Outbound Logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(requestId, txnID, apiName,
|
||||
transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
|
||||
// 🔵 Create Inbound + Outbound Logs
|
||||
InboundTraceLog inboundLog = helper.createInboundLog(
|
||||
requestId, txnID, apiName, transactionStatusRequest.getMid(), "POST", requestJson);
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(txnID, requestId, apiName, url, "GET", null);
|
||||
|
||||
OutboundTraceLog outboundLog = helper.createOutboundLog(
|
||||
txnID, requestId, apiName, url, "GET", null);
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
|
||||
try {
|
||||
LOGGER.info("Calling BBPS Transaction Status API URL={}", url);
|
||||
Map<String, String> responseMap = httpService.getRequest(url, headers);
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.debug("[{}] Raw Response | reqId={} | data={}", apiName, requestId, responseData);
|
||||
|
||||
String responseData = responseMap.get("data");
|
||||
LOGGER.info("Transaction Status Response: {}", responseData);
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
|
||||
helper.updateOutboundLogResponse(outboundLog, responseData);
|
||||
// Parse response
|
||||
Map<String, Object> dataMap = objectMapper.readValue(responseData,
|
||||
new TypeReference<Map<String, Object>>() {
|
||||
});
|
||||
|
||||
// Parse response
|
||||
Map<String, Object> dataMap = objectMapper.readValue(
|
||||
responseData, new TypeReference<Map<String, Object>>() {});
|
||||
// Validate response
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
LOGGER.warn("[{}] INVALID RESPONSE | reqId={} | response={}", apiName, requestId, responseData);
|
||||
|
||||
// Validate response
|
||||
if (!dataMap.containsKey("generalResp")) {
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
helper.updateInboundLogFailure(inboundLog, responseData, "INVALID_RESPONSE");
|
||||
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}",
|
||||
clientReqId, responseData);
|
||||
LOGGER.warn("Invalid transaction status response for clientReqId={} | Response={}", clientReqId,
|
||||
responseData);
|
||||
|
||||
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"))
|
||||
);
|
||||
}
|
||||
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")));
|
||||
}
|
||||
|
||||
// Convert into proper DTO
|
||||
TransactionStatusResponse responseWrapper =
|
||||
objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
// Convert into proper DTO
|
||||
TransactionStatusResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
TransactionStatusResponse.class);
|
||||
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
|
||||
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
LOGGER.info("Transaction Status for clientReqId={} => {}", clientReqId, generalResp.getStatus());
|
||||
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
helper.updateInboundLogSuccess(inboundLog, responseData, generalResp.getStatus());
|
||||
|
||||
return new ResponseModel(
|
||||
generalResp.getMessage(),
|
||||
generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()),
|
||||
responseWrapper
|
||||
);
|
||||
return new ResponseModel(generalResp.getMessage(), generalResp.getStatus(),
|
||||
Integer.parseInt(generalResp.getStatusCode()), responseWrapper);
|
||||
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
} catch (JsonProcessingException e) {
|
||||
LOGGER.error("Error parsing JSON in transaction status API: {}", e.getMessage(), e);
|
||||
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
throw new CustomException("Invalid JSON received from API");
|
||||
}
|
||||
}
|
||||
}
|
||||
/* PollBack logic for the fetchTxnByTxnId API
|
||||
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest) {
|
||||
*
|
||||
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
||||
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
||||
* System.out.print(fullUrl);
|
||||
*
|
||||
* BeneficiaryDetails
|
||||
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
*
|
||||
* HttpHeaders headers = new HttpHeaders();
|
||||
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
||||
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
||||
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
||||
* responseData);
|
||||
*
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper();
|
||||
*
|
||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||
* TypeReference<Map<String, Object>>() { }); if
|
||||
* (!dataMap.containsKey("genericResponse")) { 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")) ); }
|
||||
*
|
||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
* BillDataResponse.class);
|
||||
*
|
||||
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
*
|
||||
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper);
|
||||
*
|
||||
* return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
||||
* new CustomException("Invalid JSON received from API"); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
/*
|
||||
* PollBack logic for the fetchTxnByTxnId API
|
||||
*
|
||||
* @Override public ResponseModel fetchTxnByTxnId(BillFetchByBillIdRequest
|
||||
* billFetchByBillIdRequest) {
|
||||
*
|
||||
* String billId = billFetchByBillIdRequest.getBillId(); String fullUrl =
|
||||
* agentDtaUrl + BBPSConstant.BILL_FETCH_BY_ID+billId;
|
||||
* System.out.print(fullUrl);
|
||||
*
|
||||
* BeneficiaryDetails
|
||||
* headersData=beneficiaryDetailsRepository.findByOrgId("ORG001");
|
||||
*
|
||||
* HttpHeaders headers = new HttpHeaders();
|
||||
* headers.set("x-digiledge-key",headersData.getXDigiledgeKey());
|
||||
* headers.set("agentId", headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON);
|
||||
*
|
||||
* Map<String, String> responseMap = httpService.getRequest(fullUrl,headers);
|
||||
* String responseData = responseMap.get("data"); log.info("data is :{}",
|
||||
* responseData);
|
||||
*
|
||||
*
|
||||
* ObjectMapper objectMapper = new ObjectMapper();
|
||||
*
|
||||
* try { Map<String, Object> dataMap = objectMapper.readValue(responseData, new
|
||||
* TypeReference<Map<String, Object>>() { }); if
|
||||
* (!dataMap.containsKey("genericResponse")) { 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")) ); }
|
||||
*
|
||||
* BillDataResponse responseWrapper = objectMapper.convertValue(dataMap,
|
||||
* BillDataResponse.class);
|
||||
*
|
||||
* GeneralResp generalResp = responseWrapper.getGenericResponse();
|
||||
*
|
||||
* ResponseModel responseModel=new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper);
|
||||
*
|
||||
* return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing responseData JSON: {}", e.getMessage()); throw
|
||||
* new CustomException("Invalid JSON received from API"); }
|
||||
*
|
||||
* }
|
||||
*/
|
||||
|
||||
/*
|
||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||
* transactionStatusRequest.getTxnId(); ;
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
||||
* = new ObjectMapper();
|
||||
*
|
||||
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
||||
* apiName, url, "GET", null);
|
||||
*
|
||||
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
||||
* intervalMs = 5000;
|
||||
*
|
||||
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
||||
* headers); String responseData = responseMap.get("data");
|
||||
* LOGGER.info("Transaction status response: {}", 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, "INVALID_RESPONSE");
|
||||
* 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")) ); }
|
||||
*
|
||||
* TransactionStatusResponse responseWrapper =
|
||||
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
*
|
||||
* String status = generalResp.getStatus();
|
||||
* LOGGER.info("Current transaction status: {}", status);
|
||||
*
|
||||
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
||||
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
||||
* "Timeout after 40 seconds", "FAILED"); throw new
|
||||
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
||||
* "Transaction still in progress"); }
|
||||
*
|
||||
* Thread.sleep(intervalMs); continue; }
|
||||
*
|
||||
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper );
|
||||
*
|
||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||
* generalResp.getStatus()); return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||
* throw new CustomException("Thread interrupted during transaction check"); } }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
/*
|
||||
* public ResponseModel checkTrasactionStatus(TransactionStatusRequest
|
||||
* transactionStatusRequest,InboundTraceLog inboundLog) { String apiName =
|
||||
* "CheckTransactionStatus"; String txnId = helper.generateTxnId(15); //our
|
||||
* genrated txnId String requestId = transactionStatusRequest.getReqId(); String
|
||||
* url = paymentUrl + BBPSConstant.CHECK_TRANSACTION_URL +
|
||||
* transactionStatusRequest.getTxnId(); ;
|
||||
*
|
||||
* BharatConnectMaster headersData =
|
||||
* beneficiaryDetailsRepository.findByOrgId("ORG001"); HttpHeaders headers = new
|
||||
* HttpHeaders(); headers.set("x-digiledge-key",
|
||||
* headersData.getXDigiledgeKey()); headers.set("agentId",
|
||||
* headersData.getAgentId()); headers.set("tenantId",
|
||||
* headersData.getTenantId());
|
||||
* headers.setContentType(MediaType.APPLICATION_JSON); ObjectMapper objectMapper
|
||||
* = new ObjectMapper();
|
||||
*
|
||||
* OutboundTraceLog outboundLog = helper.createOutboundLog(txnId, requestId,
|
||||
* apiName, url, "GET", null);
|
||||
*
|
||||
* long startTime = System.currentTimeMillis(); long maxWaitTimeMs = 40000; long
|
||||
* intervalMs = 5000;
|
||||
*
|
||||
* while (true) { Map<String, String> responseMap = httpService.getRequest(url,
|
||||
* headers); String responseData = responseMap.get("data");
|
||||
* LOGGER.info("Transaction status response: {}", 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, "INVALID_RESPONSE");
|
||||
* 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")) ); }
|
||||
*
|
||||
* TransactionStatusResponse responseWrapper =
|
||||
* objectMapper.convertValue(dataMap, TransactionStatusResponse.class);
|
||||
* GeneralResp generalResp = responseWrapper.getGeneralResp();
|
||||
*
|
||||
* String status = generalResp.getStatus();
|
||||
* LOGGER.info("Current transaction status: {}", status);
|
||||
*
|
||||
* if ("INPROGRESS".equalsIgnoreCase(status)) { if (System.currentTimeMillis() -
|
||||
* startTime > maxWaitTimeMs) { helper.updateInboundLogFailure(inboundLog,
|
||||
* "Timeout after 40 seconds", "FAILED"); throw new
|
||||
* CustomException("Timeout waiting for transaction completion", "FAILED", 408,
|
||||
* "Transaction still in progress"); }
|
||||
*
|
||||
* Thread.sleep(intervalMs); continue; }
|
||||
*
|
||||
* ResponseModel responseModel = new ResponseModel( generalResp.getMessage(),
|
||||
* generalResp.getStatus(), Integer.parseInt(generalResp.getStatusCode()),
|
||||
* responseWrapper );
|
||||
*
|
||||
* helper.updateInboundLogSuccess(inboundLog, responseData,
|
||||
* generalResp.getStatus()); return responseModel;
|
||||
*
|
||||
* } catch (JsonProcessingException e) {
|
||||
* LOGGER.error("Error parsing transaction status JSON: {}", e.getMessage());
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "JSON_ERROR");
|
||||
* throw new CustomException("Invalid JSON received from API"); } catch
|
||||
* (InterruptedException e) { Thread.currentThread().interrupt();
|
||||
* helper.updateInboundLogFailure(inboundLog, e.getMessage(), "INTERRUPTED");
|
||||
* throw new CustomException("Thread interrupted during transaction check"); } }
|
||||
* }
|
||||
*
|
||||
*
|
||||
*/
|
||||
Reference in New Issue
Block a user